Skip to content

test(branch-flow): stop racing the wait timeout - #2229

Merged
eric8810 merged 2 commits into
mainfrom
dim/2228-branch-wait
Nov 26, 2026
Merged

eric8810 merged 2 commits into
mainfrom
dim/2228-branch-wait

Conversation

@eric8810

Copy link
Copy Markdown
Collaborator

Summary

start_wait in branch_flow started tool:wait {"timeoutMs":3000}, then waited for the ToolUse event and asserted that no ToolResult had landed. Under load the 3 s timeout could fire before the event was observed, so the assertion failed with the wait is still waiting; this happened on PR #2223's Linux verify job.

The three callers end the wait from a branch idle/end/message notice:

  • an_idle_line_wakes_the_wait_of_the_main_that_opened_it
  • an_ended_line_wakes_the_wait_of_the_main_that_opened_it
  • a_steer_message_from_a_line_wakes_the_wait_of_the_main_that_opened_it

The wait now uses its default timeout. The tests no longer race a short tool timeout; the existing bounded until_events / soon waits still fail promptly if the notice never arrives.

Fixes #2228. Part of #2217.

Design rule checklist

  • Scope: n/a — test-only change; no part, state or lifecycle.
  • Commands and results: n/a — no module state changes.
  • Handover: n/a — no handover points.
  • Timeline before callbacks: n/a — no Timeline writes.
  • Infrastructure: n/a — Timeline, Dispatcher, assembly and facades unchanged.
  • Core mechanisms: n/a — no plugin-specific handling.
  • Batch: n/a — no facts are written.
  • Context: n/a — no context inputs.
  • No reading another plugin's internal state: n/a.
  • Cross-language faces: n/a — no service or face changes.
  • Business configuration: n/a — no loader rows.
  • Missing mechanism capabilities: n/a.
  • Timeline facts: n/a.

Documentation

  • No accepted ADR is modified or deleted.
  • No other module's design is changed.
  • No delivery status is added to an ADR, index or roadmap.

Verification

  • Each of the three tests run twice with --exact --test-threads=1: six passes.
  • cargo clippy --locked -p dim-agent-capabilities --test capabilities_flow -- -D warnings — passed.
  • cargo fmt --all -- --check — passed.

@eric8810

Copy link
Copy Markdown
Collaborator Author

Marked ready for review. The branch-flow tests this PR changes pass locally and in CI; the red verify is the unrelated app-server startup-timeout cluster. #2231 adds the test-only 30 s assembly budget for that cluster; after it merges I will rebase this PR and rerun.

@Simon-He95 Simon-He95 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at e18dc54a. Removing timeoutMs: 3000 lets Wait use its 300 s default; the three tests end it from an idle/end/steer notice, and the bounded until_events/soon waits still fail promptly if the notice never arrives. No production change.

Note on CI: the verify (linux) failure at this head is agents::sessions::tests::exists_answers_loaded_unloaded_closed_and_deleted hitting the 10 s startup budget (initialization timed out ... SqliteStorage Loading), which is unrelated to this diff and is the failure #2231 addresses. The code change itself is fine; rerun the failed job before merging.

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at e18dc54a62ee05cee556ec936b477b7a6552d738.

The test helper now uses the existing Wait default instead of racing a 3-second timer against notice observation. Its three callers retain bounded observation and still verify the intended wake and the delivered notice. All three passed in both Linux attempts on the tested merge. The same startup failure seen in attempt 2 also occurred before this patch, in a different test before its assertions. The underlying SQLite stall is unverified. This approves the test change only; ci-ok remains red and still gates merge.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 5a85674. No findings.

The net diff against origin/main 3a8113c is the same test-only change from e18dc54, +6/-8 in crates/dim-agent-capabilities/tests/branch_flow.rs; the merge left the file identical (git diff e18dc54a..5a85674c -- crates/dim-agent-capabilities/tests/branch_flow.rs is empty). start_wait submits tool:wait {} instead of tool:wait {"timeoutMs":3000}, so it uses Wait's 300 s default (crates/dim-agent-capabilities/src/wait.rs:37, :404-405) and no longer races a 3 s timeout against the observation of ToolUse.

Checks:

  • Each of the three callers still proves the notice wakes the wait: wait ended: steer (crates/dim-agent-capabilities/tests/branch_flow.rs:8147, :8180, :8210); a timeout returns wait ended: timeout (wait.rs:453).
  • The no-result assertion is retained (branch_flow.rs:8054-8059).
  • A missing notice still fails promptly: wait_ended is bounded by until_events, 600 iterations of 10 ms (branch_flow.rs:3594-3602), so it panics at about 6 s of sleeps plus page time, not at the 300 s default. soon (5 s) and patient (30 s) bound the surrounding steps (:41-51).
  • No other real Wait caller keeps a short timeout in this file; the {"millis":...} calls at :7426 and :7590 use MockTools' wait (crates/dim-agent-capabilities/src/adapters.rs:162-218).
  • No production change: only crates/dim-agent-capabilities/tests/branch_flow.rs differs from main, and merge-tree against 3a8113c is clean.

Verification: cargo fmt --all -- --check passed. With the pinned 1.100.0 toolchain and an isolated home, the three tests ran twice at this head with --test-threads=1 (3 passed each run, 0.16 s and 0.12 s). CI at 5a85674 (run 45802684729) has changes green; verify (linux) and macos-native were still running when this review was written. The red verify (linux) at e18dc54 was the app-server sessions startup timeout that #2231, now in main, fixes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(branch-flow): remove the 3s Wait timeout race in start_wait

4 participants