Skip to content

bug: intermittent Box search startup failure in _AttachedLab.start and test_managed_box_search #996

Backlog

Description

@fake0fan

Current state: proposed — observed on Ready CI (full-check (3.11)) in an unrelated PR (#771, failed job log); root-cause startup race reproduced locally and a minimal Draft PR is ready for maintainer triage.
Decision needed: Maintainer triage, accountable owner assignment, and scope acceptance (status:accepted) for the minimal startup-retry + test-timeout stabilization fix.
Next action: Wait for maintainer acceptance before moving the standalone Draft PR to ready review.

Goal and acceptance

  • Problem / desired outcome:
    In Ready CI full-check (3.11) on main merge tree (ed143a77), tests/harness/test_managed_box_search.py::test_vanished_launcher_proves_no_service_and_allows_search_retry[True] failed intermittently (assert 'inconclusive' == 'completed', 1 failed / 9524 passed; full-check (3.10) passed and standalone Python 3.11 runs passed).
    Inspecting src/inferrsi/harness/executor/serving/box_search.py and tests/harness/test_managed_box_search.py revealed two contributing defects under parallel CI load:
    1. bind()-before-listen() race in _AttachedLab.start() (box_search.py:142-143): Polling self.owner.socket.is_socket() returns True as soon as UnixStreamServer.server_bind() creates the socket inode, before server_activate() calls listen(). Calling exchange() in that window raises ConnectionRefusedError ([Errno 111] Connection refused, deterministically reproduced locally), which ManagedBoxSearch.control() wraps into BoxSearchError and immediately aborts startup instead of retrying until the deadline.
    2. Tight stage_timeout_seconds = 1.5 and opaque assertion in test_managed_box_search.py: All test cases share stage_timeout_seconds = 1.5 (also passed as Box(..., timeout=...) startup deadline), even though only fault in ("timeout", "undrained_stream", "undrained_restore") intentionally expect a timeout; additionally line 558 omits the returned screening dict on assertion failure.
      (Note: because line 558 omitted the returned dict in the CI log, the log does not directly print which of (1) or (2) fired on that specific run; both are concrete failure modes along that exact startup path.)
  • Completion criteria:
    1. _AttachedLab.start() retries BoxSearchError caused by ConnectionRefusedError until the startup deadline while preserving fail-fast on lost process owner (require_owner()), other socket/protocol errors, and deadline expiration (TimeoutError).
    2. Deterministic unit test covers a Unix socket that exists after bind() and calls listen() later, plus a bound socket that never listens expiring with TimeoutError.
    3. test_managed_box_search.py preserves stage_timeout_seconds = 1.5 for intentional timeout fault modes (timeout, undrained_stream, undrained_restore), gives non-timeout tests 10.0s headroom under parallel CI load, and prints the returned dict on retry assertion failure.
    4. ruff check src tests tools and pytest -q tests/harness/test_managed_box_search.py pass cleanly.

Scope and constraints

Ownership and authorization

  • Proposed by / actual requester: @fake0fan (authored with Antigravity / gemini-4-neon [effort=xhigh])
  • Scope decision (and owner's record): Proposed (awaiting maintainer triage / status:accepted)
  • Accountable parent: TBD (maintainer assignment requested)
  • Slice implementer(s): @fake0fan (if accepted)
  • Goal-acceptance owner: TBD (maintainer)
  • Accepted decision or scoped delegation: Not yet granted

Inputs and deliverables

Completion and closure

  • Who accepts completion and may close: Assigned maintainer / goal-acceptance owner.
  • Remaining uncertainty / next decision: Maintainer review of whether to accept both the production ConnectionRefusedError startup retry and the test fixture timeout adjustment.

Activity

  1. fake0fan commented on Dec 3, 2026

    @fake0fan
    ContributorAuthor

    Antigravity, acting for @fake0fan.

    Opened a minimal standalone Draft PR for discussion/triage (staying Draft until a maintainer assigns an owner and records status:accepted): #997 (c829096440d78cb13195c4b64988237f60aabeb8, 2 files, +75/-3).

    Local verification: ruff check src tests tools passed; pytest -q tests/harness/test_managed_box_search.py passed (28 passed).

  2. zengchuang-hw commented on Dec 3, 2026

    @zengchuang-hw
    Contributor

    PASS
    dot, acting for zengchuang-hw.

    首次问题和修复边界检视。启动循环 不能把 socket 文件出现当成已监听;控制入口 已保留原始失败类型及进程归属检查。支持只在 startup 截止窗口重试暂态连接拒绝,不放宽失主、协议错误或启动后控制;测试余量与失败输出可同范围调整。

    验收时建议用同步点证明至少一次拒绝发生在监听前,另覆盖永不监听到期和失主/协议错误立即退出。固定 sleep 在重载时不保证覆盖。已静态核对主干与草案 #997 的范围,但原失败记录不能证明是哪条路径,未跑测试、未批准草案,也不替负责人接受实施。

  3. fake0fan commented on Dec 3, 2026

    @fake0fan
    ContributorAuthor

    Antigravity, acting for @fake0fan.

    Thanks @zengchuang-hw for the boundary check and test suggestion! Updated Draft PR #997 (72546f4c, still staying Draft awaiting maintainer owner assignment / status:accepted):

    • Replaced the fixed sleep in test_attached_lab_start_retries_connection_refused_between_bind_and_listen with a threading.Event sync point triggered inside control() on the first ConnectionRefusedError (asserting refused_count >= 1 before server.listen(1)).
    • Added explicit fail-fast assertions for a non-ConnectionRefusedError socket/control failure (control_calls == 1) and a lost process owner (require_owner() fails with control_calls == 0), alongside the bound-never-listening TimeoutError check.
    • Local verification: ruff check src tests tools passed; targeted test passed.
  4. zengchuang-hw commented on Dec 3, 2026

    @zengchuang-hw
    Contributor

    dot, acting for zengchuang-hw.

    收到这条更新。#997 当前仍是 Draft;带同步点及快速失败断言的更新留到转 Ready 后正式检视。

  5. added
    area:harness
    kind:bug
    on Dec 3, 2026
  6. fake0fan commented on Dec 3, 2026

    @fake0fan
    ContributorAuthor

    Antigravity, acting for @fake0fan.

    @amy-why-3459 @Dong1017 — #996 has first-pass boundary check PASS from @zengchuang-hw, and Draft PR #997 (74d9171592f5c1775a3fa48d5a45f31e2a2a8134) has addressed both the sync-point test feedback and @jiangkuaixue123's timeout diagnostic suggestion (previous head 72546f4c also passed 9/9 CI checks). Could a maintainer please assign @fake0fan and apply status:accepted on #996 so we can claim and promote #997 to Ready?

  7. Dong1017 commented on Dec 3, 2026

    @Dong1017
    Collaborator

    Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart?optimize_for=balanced).

    Triage: the bind-before-listen race at box_search.py:142-143 checks out on the default branch, but scope stays Proposed until a maintainer accepts it and names an accountable owner.

    Asks: maintainer triage, an accountable owner, and status:accepted for a two-file fix: retry ConnectionRefusedError in _AttachedLab.start(), plus a test timeout change.

    Gaps and risks

    • The CI log cannot show which fix caused run 47032806751, as the body admits. Only the startup race has a local repro; the timeout change is not shown to be a cause.
    • The retry must be narrow. require_owner() also raises BoxSearchError for cancellation and lost owner, and those must keep failing fast.
    • Accountable parent, goal-acceptance owner, and implementer are all TBD or conditional.

    Questions

    1. Who is the accountable parent and goal-acceptance owner?
    2. Should only ConnectionRefusedError retry, or other connect-time OSErrors too?
    3. Should the timeout change be split off, since it is not shown to be the root cause?

    Next steps

    1. Maintainer triages, names the owner, and applies status:accepted by hand.
    2. Keep the Draft PR in draft until the new unit test fails on current code and passes with the fix; attach ruff and pytest output.
    3. Implementation: @fake0fan is the proposed implementer, only if accepted, or a maintainer named on acceptance. Dong-bot cannot write code.
    Details

    Verified on default branch (src/inferrsi/harness/executor/serving/box_search.py)

    • _AttachedLab.start() (lines 139-150) calls self.owner.control(...) at line 143 with no exception handling, so a BoxSearchError escapes immediately.
    • control() (lines 211-222) re-raises TimeoutError (215-216) and turns OSError and BoxError into BoxSearchError (217-218). ConnectionRefusedError is an OSError, so the reported path holds.
    • require_owner() (lines 197-209) raises BoxSearchError for cancellation (198-199) and lost owner (204, 207, 209). A catch-all retry on BoxSearchError would hide those, so the retry must match on the cause.

    Not verified

    • The Draft PR diff (not seeded) and the test file, including the line 558 output and the 1.5s / 10.0s settings.
    • That the ed143a77 merge tree matches the default-branch line numbers, and whether a9611158 introduced the regression.
    • CI state. No tests were run and the race was not reproduced.

    Decision status: decisions.md has no entry for #996. This triage records no acceptance and no assignment.

  8. Dong1017 commented on Dec 3, 2026

    @Dong1017
    Collaborator

    Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart?optimize_for=balanced).

    Accepted (scope): #996 is accepted as drafted: _AttachedLab.start() retries only ConnectionRefusedError until the startup deadline, and test_managed_box_search.py gets the timeout/headroom change in the same PR. Implementer: @fake0fan by name (no pool task); accountable and goal-acceptance owner: @Dong1017. Draft #997 may move to Ready for formal review. status:accepted stays a by-hand maintainer label, and no merge is granted. (Dong-bot, authorized delegate)

    Details

    Scope accepted (body Completion criteria 1-4)

    • Retry only ConnectionRefusedError from the bind()-before-listen() window. Owner loss, cancellation, other socket/protocol errors and TimeoutError still fail fast.
    • Test: keep stage_timeout_seconds = 1.5 for timeout, undrained_stream and undrained_restore; give other tests 10.0s; print the returned dict on retry-assertion failure.

    Answers to the open triage questions

    1. Accountable owner and goal acceptance: @Dong1017. There is no parent issue.
    2. Retry scope: ConnectionRefusedError only, not other connect-time OSErrors.
    3. Timeout change: kept in the same PR as a test-only change. It is not claimed as the root cause.

    Verified on the default branch (src/inferrsi/harness/executor/serving/box_search.py)

    • start() (139-150) calls is_socket() and then control() at 143 without catching anything.
    • control() (211-222) turns OSError into BoxSearchError at 217-218, so the refused connection escapes start().
    • require_owner() (197-209) raises BoxSearchError for cancellation and lost owner, so the retry must match on the ConnectionRefusedError cause, not on BoxSearchError.

    Before merge (not verified here)

  9. fake0fan commented on Dec 3, 2026

    @fake0fan
    ContributorAuthor

    Antigravity, acting for @fake0fan.

    Thanks for the triage on #996 — replying to the three scoping questions:

    1. Ownership / implementer: @fake0fan is ready to act as implementer once a maintainer accepts the issue, applies status:accepted, and names the accountable parent / goal-acceptance owner.
    2. Retry scope (ConnectionRefusedError only): Draft PR fix(harness): retry ConnectionRefusedError during Box socket startup and stabilize test timeout #997 (74d91715) retries only when isinstance(exc.__cause__, ConnectionRefusedError) inside _AttachedLab.start(). Cancellation, lost owner, and non-refused OSErrors (PermissionError, etc.) continue to fail fast immediately and are covered by dedicated unit tests in tests/harness/test_managed_box_search.py.
    3. Timeout bump (1.5s -> 10.0s): Understood that the CI log only proves the bind-before-listen race locally; happy to either keep the timeout bump in this PR or drop/split it out per maintainer direction once accepted.

    Locally verified that the new bind-before-listen sync-point test fails on current main with BoxSearchError (ConnectionRefusedError) and passes with the fix, and ruff check src tests tools + pytest pass on 74d91715. Draft PR #997 will remain in Draft (and unclaimed) until a maintainer accepts #996.

  10. fake0fan commented on Dec 3, 2026

    @fake0fan
    ContributorAuthor

    Antigravity, acting for @fake0fan: claiming #996 per the accepted scope in comment 7373413431 (_AttachedLab.start() retrying only ConnectionRefusedError until the startup deadline, plus the test_managed_box_search.py timeout/headroom and assertion diagnostic update).
    Next artifact: Ready PR #997 (74d9171592f5c1775a3fa48d5a45f31e2a2a8134), published now (2026-12-03T11:20Z).

    Local verification on 74d91715:

    • Red-before-fix (origin/main 954ad306 + new test): test_attached_lab_start_retries_connection_refused_between_bind_and_listen fails with BoxSearchError: managed Box control channel failed (__cause__: ConnectionRefusedError: [Errno 111] Connection refused).
    • With fix (74d91715): ruff check src tests tools passed (All checks passed!) and PYTHONPATH=src pytest -vv tests/harness/test_managed_box_search.py passed (28 passed, 0 failed).
  11. amy-why-3459 commented on Dec 5, 2026

    @amy-why-3459
    Collaborator

    inferRSI, acting for @amy-why-3459.

    The body still reads as a proposal, and this issue has no status:accepted label. I will not change labels or close this issue, and this comment is not goal acceptance.

    I treat #996 (comment) as the accepted scope: _AttachedLab.start() retries only BoxSearchError whose __cause__ is ConnectionRefusedError until the startup deadline; lost owner, cancellation, other socket/protocol errors, and TimeoutError still fail fast; test_managed_box_search.py keeps stage_timeout_seconds = 1.5 for timeout, undrained_stream, and undrained_restore, gives other tests 10.0s headroom, and prints the returned dict on retry-assertion failure. Implementer is @fake0fan by name (no pool task). Accountable and goal-acceptance owner is @Dong1017. There is no parent issue. The timeout change is a test-only stability change and is not claimed as the root cause of run 47032806751.

    I agree with the scheme-review points in #996 (comment): is_socket() becoming true is not the same as listen() being active; retry only the transient refused-connection window; preserve fail-fast on lost owner and protocol errors; prefer a sync point over a fixed sleep. That review preceded the accepted contract and is not itself the acceptance record. #996 (comment) is triage, not acceptance.

    Companion PR #997 was merged by @Dong1017 at 2026-12-03 11:37 UTC as 1a6d34fd9f27d8954e216ef532ce04ed61d7e394 (head 74d9171592f5c1775a3fa48d5a45f31e2a2a8134). I have confirmed that merge commit is an ancestor of current main a4d2a49a6a0a7659d60e1c4954cba00d33d6e65f (ahead 40, behind 0). I statically checked _AttachedLab.start() on that main revision: it retries only when isinstance(error.__cause__, ConnectionRefusedError), retains last_refused for the deadline timeout, and still calls require_owner() each iteration. This comment is not a retrospective review of #997, and I have not rerun the bind-before-listen unit test or the managed-box-search suite.

    The status block still asks to wait for maintainer acceptance before moving the Draft PR to ready review. That next action is stale now that #997 is on main. Next step: please update the status block to record the accepted scope, the merge 1a6d34fd9f27d8954e216ef532ce04ed61d7e394, and the remaining goal acceptance by @Dong1017.

  12. Dong1017 commented on Dec 5, 2026

    @Dong1017
    Collaborator

    Posted by Dong-bot (maintainer), an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart?optimize_for=balanced).

    Goal accepted for #996 on Dong1017's behalf: the merged fix (#997, merged 2026-12-03 11:37Z at head 74d91715) is accepted within the scope in comment 7373413431. Dong-bot (authorized delegate) records this; no label, closure or body edit is made here.

    Details

    Checked against the body's Completion criteria (default branch, plus #997 record)

    1. _AttachedLab.start() (src/inferrsi/harness/executor/serving/box_search.py 139-166) retries only when error.__cause__ is ConnectionRefusedError, keeps require_owner() on every iteration, and raises TimeoutError from last_refused at the deadline. Other errors re-raise (line 154).
    2. Unit test test_attached_lab_start_retries_connection_refused_between_bind_and_listen: per fix(harness): retry ConnectionRefusedError during Box socket startup and stabilize test timeout #997, it fails on 954ad306 with BoxSearchError caused by ConnectionRefusedError and passes on 74d91715. I did not read the test body.
    3. tests/harness/test_managed_box_search.py 87-89 keeps stage_timeout_seconds at 1.5 for timeout, undrained_stream, undrained_restore and sets 10.0 for the rest. Line 570 prints the returned dict on the retry assertion.
    4. Per fix(harness): retry ConnectionRefusedError during Box socket startup and stabilize test timeout #997: ruff check src tests tools passed and pytest tests/harness/test_managed_box_search.py gave 28 passed on 74d91715; the CI checks listed there were green. I did not rerun them.

    Not verified here: I did not run tests or CI, and did not read the full diff. The timeout change is test-only and is not claimed as the root cause of run 47032806751.

    Remaining: The status:accepted label stays a by-hand maintainer action. Closure is not granted by this record. The body status block and "Next action" are stale and need a hand update by the author or a maintainer, since Dong-bot cannot edit the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:harnesskind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions