Skip to content

tests: separate machine-sensitive wall-clock bounds from hang guards #2217

Done

Description

@eric8810

Context

Static audit of 5,331 Rust test functions in crates/, tests/ and xtask/ on 2026-11-26. The full per-test inventory is test-wait-audit.md (section C, rows marked M).

327 tests carry at least one machine-sensitive time constraint: a real wall-clock upper bound, a real lower bound, an explicit timeout <= 5s, or a direct sleep >= 500ms.

Shape

Marker Tests
real elapsed() upper bound 20
real elapsed() lower bound 11
explicit timeout <= 5s 280
direct sleep >= 500ms 22

The categories overlap; the total is 327. By area:

Area M tests
app-server 174
capabilities 51
integration 32
dimcode 13
goal 11
oauth 9
aimux 7
scheduler 7
cli-lib 6
acp 6
modality 3
runtime 3
session-title 2
event-hub 2
codemode 1

Tightest explicit timeouts: 10 ms (4 tests), 20 ms (2), 25 ms (2), 30 ms (4), 50 ms (several). The 20 upper bounds range from 1 s to 60 s; examples:

  • crates/dim-app-server/src/methods/tests.rs:432 — upper 1 s
  • crates/dim-agent-capabilities/tests/hooks_flow.rs:1661 — upper 1200 ms
  • crates/dim-agent-capabilities/tests/hooks_flow.rs:3345 — upper 4 s
  • crates/dim-agent-capabilities/tests/hooks_flow.rs:1402, 1815 — upper 5 s
  • crates/dim-agent-runtime/tests/lifecycle_review.rs:199 — upper 5 s
  • tests/integration/tests/named_parts.rs:593 — upper 5 s
  • crates/dim-agent-capabilities/tests/host_platform_flow.rs:891, 927 — upper 5 s
  • crates/dimcode/tests/cli_flow/daemon_startup_progress.rs:352, 439 — upper 60 s (debug-only)
  • crates/dimcode/tests/cli_flow/daemon_startup_progress.rs:648, 858 — upper 30 s (debug-only)

Prior individual fixes: #1593, #2193, #1728, #836, #291, #807, #1935.

Acceptance criteria

  • Classify each M row as semantic timing or a hang guard; do not use one bound for both.
  • Semantic timing uses start_paused, ManualClock or FixedClock where the delay is not the subject. The scheduler and settings tests already have these paths.
  • Only behavior whose subject is real time (process startup, network expiry, watchdog) remains wall-clock; it moves to a dedicated timing job with an explicit runner budget.
  • A hang guard is derived from the operation it guards and names the predicate; an arbitrary 1 s/5 s is replaced by a completion event where one exists.
  • Verify on a loaded runner: no test fails solely because the runner is slow, and a stalled test fails with what it waited for.
  • Keep the ignored measurement harnesses out of ordinary CI.

Out of scope: merely relabeling a test to #[ignore] without a replacement path or a dedicated job.

Batching plan

The M label mixes three different things. Split by what the time is doing, not by the flag:

One PR = one file or one helper. Split a file when it contains guard rows and semantic rows.

Batch Scope M rows Split
1 mcp_session_flow 19 8 pure 5 s guards; 10 poll loops to #2215
2 transport_flow/sessions 17 5 s guards and poll loops
3 mcp_http_flow 16 5 s guards and poll loops
4 session_typescript 12 5 s guards
5 transport_flow/approval 9 6 guards; 3 short semantic
6 transport_flow/reload 12 6 guards; 6 polls
7 dim_oauth_flow 9 semantic; paused clock
8 goal_parts_flow + goal_evaluator_flow 12 750 ms semantic; paused clock
9 branch_flow remaining 9 guards and short semantic
10 context_reads, context_flow, host_flows ~20 one file per PR
11 local_execution, tool_binding, prompt_lifecycle ~21 one file per PR
12 daemon_startup_progress 7 gated by #2218; lower priority

Start with batch 1 after the shared until_events work in #2215, because most of its poll rows disappear there.

Activity

  1. self-assigned this
    on Nov 26, 2026
  2. eric8810 commented on Nov 26, 2026

    @eric8810
    CollaboratorAuthor

    Parent tracking issue: #2219. Full audit inventory: https://gist.github.com/eric8810/d47cf3c4441230360546a448d7809818

  3. eric8810 commented on Nov 26, 2026

    @eric8810
    CollaboratorAuthor

    Evidence from PR #2224 (dim/2217-hooks-timing, run 45764743678): the Linux verify job failed on two App Server timeouts unrelated to the hook test in the patch:

    • managed_oauth_flow::the_managed_grok_route_takes_only_the_native_xai_image_formats — the device login did not complete after the token response: Elapsed(()) at the 3 s wait after the token response.
    • storage_flow::a_cold_read_failure_preserves_the_record_and_other_session_progress — the read failure remained local to the operation: Elapsed(()) from the test-level timeout.

    Both are in the M inventory. The hook test itself passed on the same runner. The failed job was rerun; the patch was not changed for these failures.

  4. eric8810 commented on Nov 26, 2026

    @eric8810
    CollaboratorAuthor

    Merged #2224 at 3edabc0b. The async PostToolUse test no longer uses a 1.2 s upper bound, a fixed 2 s sleep, or a 1.5 s fixture sleep: the async handler is gated, its marker is published by atomic rename, and the test waits for markers. The remaining M inventory stays open in this issue.

  5. eric8810 commented on Nov 26, 2026

    @eric8810
    CollaboratorAuthor

    PR #2223 Linux verify (job 139751447908) failed before the dedicated debug step on:

    branch_flow::an_ended_line_wakes_the_wait_of_the_main_that_opened_it — the wait is still waiting at crates/dim-agent-capabilities/tests/branch_flow.rs:8056.

    The test starts tool:wait {"timeoutMs":3000}, waits for the ToolUse event, then asserts no later ToolResult. Under load the 3 s wait can finish before that assertion, so the failure measures runner progress, not the test’s behavior. The PR changes only CI routing/docs/test gating; the job was rerun and the new verify attempt is in progress.

  6. eric8810 commented on Nov 26, 2026

    @eric8810
    CollaboratorAuthor

    PR #2229 Linux verify (job 139793876277) failed on unrelated startup/timeout tests after the branch-flow fix:

    • 8 transport_flow tests (mcp_import::*, product_protocol::mcp_*) panicked at transport_flow.rs:405 because launch_with hit the default 10 s startup_timeout while the assembly rows were still Pending.
    • managed_oauth_flow::the_managed_grok_route_takes_only_the_native_xai_image_formats hit the 3 s attempt-status wait again.

    The branch-flow tests this PR changes passed. The failed job was rerun.

  7. eric8810 commented on Nov 26, 2026

    @eric8810
    CollaboratorAuthor

    PR #2233 Linux verify (job 139860921466) failed on two unrelated tests after the managed-OAuth helper change:

    • storage_flow::a_cold_read_failure_preserves_the_record_and_other_session_progress — the read failure remained local to the operation: Elapsed(()) from the test-level timeout again.
    • model_startup::temporary_startup_rebinds_after_restart_and_preserves_parent_cut_connections — Framework(PluginFailed(Closed(...))) while waiting for the detached Session to unload.

    The managed-OAuth tests this PR changes passed; the failed job was rerun.

  8. added
    roadmap
    P2
    on Nov 27, 2026
  9. eric8810 commented on Nov 27, 2026

    @eric8810
    CollaboratorAuthor

    PR #2255 Linux verify (job 140307014640) failed on context_flow::product_summary::compaction_chunks_images_as_markers_and_legacy_screenshots_as_text at product_summary.rs:67: Storage("unknown session …") inside the 10 s compaction poll. The PR changes only the replacement-daemon accept wait; the failed job was rerun.

  10. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Closing after this session. Completed guard slices: #2224, #2233, #2314 and #2336. The remaining M file batches are not done; they are recorded in the audit gist. No active PR.

  11. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Reopening: the M batches are not done. Closing as not planned was premature; guard slices #2314/#2336 advanced it, but the file batches remain.

  12. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Batch analysis: 2217-A8 goal-parts/evaluator machine-sensitive time

    Verdict: split

    Current evidence

    • Nine 750ms bounds, all negative assertions. Gate-arrival class (6): goal_parts_flow.rs:1022 timeout(750ms, second.arrived()) where second is a second hold_stage(Stage::Decision, first.sequence) (:982); goal_parts_flow.rs:1127, :1228, :1339 timeout(750ms, again.arrived()) on hold_stage(Stage::Record, interrupt.sequence) — :1325 already states "The bound only keeps the case from waiting forever"; goal_parts_flow.rs:1600 and goal_evaluator_flow.rs:1040 timeout(750ms, pause.arrived()) on hold_stage(Stage::Append, ..). Write-absence class (3): goal_parts_flow.rs:792, goal_evaluator_flow.rs:692, :1313 run timeout(750ms, loop { env.settled/writes + sleep(10ms) }), a bespoke copy of Env::settled (tests/support/parts.rs:1614, stable 10×10ms).
    • Existing barriers that already end the same task: Env::dispatched (support/parts.rs:1170), Stage::Done fired unconditionally after do_turn_end_inner returns (src/branch.rs:1988-1999), Stage::Released at the end of every record_inner incl. failure (src/branch.rs:1534-1541), and the failure path itself — a failed change release_settlement()s and leaves the deferred interrupt "for a later settlement that succeeds" (src/branch.rs:744-756), so its RPC reply is terminal.
    • No paused clock fits. tokio dev-dependency has test-util (Cargo.toml), but every case is #[tokio::test(flavor = "multi_thread", worker_threads = 2)] (29 in parts, 18 in evaluator) and start_paused is current-thread only; more decisively, these waits bound absence, not a scheduled delay, so advancing time proves nothing.

    Proposed change

    1. src/testing.rs: add one accessor per hold type, pub fn taken(&mut self) -> Option<u64> backed by mpsc::UnboundedReceiver::try_recv, on HeldStage, HeldWrite, HeldFold (testing feature only, ~3 lines each).
    2. Gate-arrival sites: drop the timeout/.is_ok() pair and assert assert!(gate.taken().is_none(), msg) after the terminal signal the case already awaits — failure.await (:1022), pause's error reply from the existing tokio::join! (:1127, :1228, :1339), env.wait_for(kind="continuation") (:1600, evaluator:1040, which today samples the gate before that barrier). Each of those paths returns only after the held stage could have been reached, so absence becomes a property, not a 750ms sample. No new stage hooks.
    3. Leave the three write-absence sites to tests: convert in-process polling waits to event waits #2215: they need owner quiescence, not a duration. Interim: hold_stage(Stage::Done, <deciding fact>) before the Queue emit, await its arrival, release, then a single env.settled("main") absence assertion. The durable fix is a barrier over State::decision_tasks (src/branch.rs:412, TaskTracker), since a decision deferred to a later settlement is invisible to Stage::Done. goal_beta_flow.rs:26 (NEGATIVE) is the same class and should disappear with that barrier.

    Risks / exceptions

    • taken() is a single try_recv sample: sound only after a barrier that proves the producing task ended; keep the per-case 15s/WAIT timeout on that barrier so a broken barrier fails instead of hanging. Keep settled(), dispatched() as they are.
    • Stage::Done does not cover a record restated after a rebuild, which is why the poll-class sites stay with tests: convert in-process polling waits to event waits #2215 rather than being forced onto it.
    • Hook holds live in process-wide statics keyed by line; Drop already releases, so a converted case cannot leave a stale hold for a later case.
    • Conversion must not weaken the case: taken() after the barrier still fails when the second decision or the deferral take-up really happens.

    Suggested PR
    Files: crates/dim-goal/src/testing.rs, crates/dim-goal/tests/goal_parts_flow.rs, crates/dim-goal/tests/goal_evaluator_flow.rs. Split: this PR does the 6 gate-arrival sites plus taken(); the 3 write-absence sites go with the #2215 quiescence barrier (and goal_beta_flow.rs with them).
    Verify: cargo test --locked -p dim-goal (all cases live in the single goal_suite target; the dev-dependency enables testing), then cargo clippy --workspace --all-targets --locked -- -D warnings.

  13. 4 remaining items

  14. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Batch analysis: 2217-A9 branch_flow remaining machine-sensitive time

    Verdict: split

    Current evidence

    • Guard rows (5 s inline duplicates of soon, branch_flow.rs:41) around event-driven waits: a_stale_note_is_replaced_once 12205 (not in the audit's nine rows), a_move_that_stopped_between_its_fact_and_its_notes_is_completed_at_load 12531, a_restore_writes_the_owed_note_before_the_line_answers 12670, a_move_committed_before_its_writer_starts_still_owes_its_note 12811, a_close_waits_for_an_admitted_move_and_a_restore_reads_its_fact 13076/13100. Each wraps a loop over HeldWriters::arrived() (timeline_tree.rs:61, mpsc), so the number guards nothing but the runner.
    • data_creation_releases_its_cancellation_wait_when_the_caller_leaves 2936: timeout(1s, released.cancelled()). The token is cancelled by the drop_guard moved into the call-owned future, dropped at drop(waiting) 2934 — no clock involved.
    • 8 s at an_ancestors_end_closes_a_pending_end_whose_delivery_was_held 8985 and an inline 30 s at 6698 that duplicates patient (branch_flow.rs:47).
    • Semantic lower bounds — "has not answered while the store holds a batch": 3223 (50 ms on closing), 11111 (150 ms on ended), 12960 (150 ms on next), 13073/13097 (150 ms select windows). These are the assertion, not a guard.
    • Still polling, i.e. tests: convert in-process polling waits to event waits #2215 not tests: separate machine-sensitive wall-clock bounds from hang guards #2217: roster-load loop for _ in 0..500 { sleep(10ms) } 12381 and sleep(500ms) 12429; pre-arm sleep(50ms) 11087, 11143, 12895, 13121; loops 1942/2088/2313/2615/2690/7824; helpers until_branch 3742, settle_line 3753, wait_new_line 4466, quiet 4495, second_parent_block 6307, owed_notes 12735, answers_default 12752, records_end 12766, support::Committed::next (support/mod.rs:98). until_events 3603 is already event-driven (test(branch-flow): wait for committed events in until_events #2244).

    Proposed change
    PR 1 (guards + the one exact semantic site):

    • 2936: delete the timeout; after drop(waiting) assert released.is_cancelled().
    • Add one support helper held_writers(&mut HeldWriters, lines: &[&str]) that loops arrived() under soon, panicking "the writers of {lines:?} never stopped at the test seam"; call it at 12205, 12531, 12670, 12811.
    • 13076/13100 → soon(&mut closing); 8985 → patient(ender); 6698 → patient(...).
    • 3223 → assert!(futures_util::poll!(&mut closing).is_pending(), "close waits for the held dispatch"), the idiom already used at 13766/13826. StopInterrupt has committed and probe.child_builds == 0, so the future is provably at its blocking point; the clock adds nothing.
      PR 2 (tests: convert in-process polling waits to event waits #2215 hand-off): the poll rows above. No semantic row changes value.

    Risks / exceptions

    • 11111, 12960, 13073/13097 must stay real-time. The futures sit on held DB batches in #[tokio::test(flavor = "multi_thread")], where tokio::time::pause() is unavailable, so no paused clock exists. A single poll! there is weaker than a window: those futures have not been driven to their blocking point, and only a window catches an answer landing a few milliseconds early. Keep the numbers as they are.
    • 12429 is a negative window ("a second load writes neither a roster nor a retirement"); it needs a committed fence from tests: convert in-process polling waits to event waits #2215, not a shorter sleep.
    • 11087/11143/12895/13121 are real upper bounds on the line's turn landing: on a loaded runner the store can be armed before the roster writes land, and the held batch is then not the move's own. Replace with quiet(&session, &line) (4495).

    Suggested PR: one PR, crates/dim-agent-capabilities/tests/branch_flow.rs plus the helper in crates/dim-agent-capabilities/tests/support/mod.rs. The remaining poll rows are a separate #2215 PR, so the split is by issue, not by file. Verify with cargo test --locked -p dim-agent-capabilities --test branch_flow.

  15. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Batch analysis: 2217-A6 crates/dim-app-server/tests/transport_flow.rs

    Verdict: split — every 5 s / 10 s / 20 s / 30 s bound in this file is a hang guard (one helper); the startup, handshake and write bounds are the behavior under test; the three poll loops belong to #2216/#2215.

    Current evidence

    • Fifteen Duration::from_secs(5): :1342 timeout(5s, cleanup.entered.notified()); :1370, :1395, :2011 timeout(5s, server.join()) after server.shutdown(); :1664, :2127, :2327 child stdout unixPath line; :2150 outer bound over the fd-exhaustion loop (10 ms retry sleep :2161); :2248, :2261, :2286, :2373, :2393 wait_with_output() of a child that must exit; :2358 recovered.wait(); :2384 foreign.accept().
    • Other guards: :1199 timeout(10s, server.join()); :1401 timeout(1s, client.response(100)) after force; :1549 EOF read gated by hello_timeout :1527; :565 timeout(20s, session.closed()); :2875, :3014 hold.waiting.notified(); :332/:360 Client::read/response 30 s; :2412 30 s around the whole external-binary flow.
    • Behavior under test: startup_timeout 2 s at :694/:726/:754, 500 ms at :775, 1 s at :586, with launch_inner :446-451 widening only an untouched default (65c225a); hello_timeout 100 ms :1527; write_timeout 2 s :1758; note coalescing ASSEMBLY_REPORT_INTERVAL = 500 ms (src/storage/sqlite.rs:983) driving fixture sleeps :2814 (700 ms), :2936 (50 ms), :2941 (1500 ms), :3024 (700 ms) and the file's only elapsed assertion seen - reported <= 800 :3004.
    • Polls: :1803-1812 20 ms poll of daemon.ping.connections; no fact exists (protocol.rs:945 lists only daemon.ping/daemon.shutdown, ConnectionHub::count has no notification). :2856-2870 50 ms and :2988-3001 20 ms polls of the .startup note file.
    • Assertions, not waits: :1349 timeout(30ms, client.response(id)) is the "not premature" window; :3024 is the "no trailing write" window.

    Proposed change

    1. Guard PR: one helper in transport_flow.rs — const GUARD: Duration = Duration::from_secs(30) plus async fn guarded<T>(what: &str, work: impl Future<Output = T>) -> T that panics naming what — and use it at :1342, :1199, :1370, :1395, :1401, :1549, :2011, :2875, :3014, each call naming the event it waits for ("daemon shutdown after cleanup", "cleanup entered", …). Client's 30 s and unloaded's 20 s already name their wait and stay. No external bound moves here.
    2. Semantic PR: keep the startup, handshake and write bounds unchanged. Add pub fn assembly_report_interval() under feature = "testing" beside set_upgrade_report_delay (sqlite.rs:1234), and derive :2814, :2936, :2941, :3024 and :3004 from it instead of the literal 700/50/1500/800 ms; :3004 keeps one interval-derived bound, and the existing in_apply assertion carries "before the row finished".
    3. Polls: tests: replace external process/file polling waits with exit or output events #2216. The note is written in-process (AssemblyProgress::progress, sqlite.rs:1014), so the take_upgrade_steps shape (sqlite.rs:1284) — recorded counters plus a Notify — replaces both file polls and leaves one file read as the assertion. :1803 has no event source; leave it until tests: convert in-process polling waits to event waits #2215 gives connection count a fact, with the guard kept above write_timeout.
    4. :1349 and :3024 stay: both are the assertion, not a wait.

    Risks / exceptions

    • No paused clock here: real unix/ws sockets, child processes and blocking SQLite writes on a multi_thread runtime, so start_paused would auto-advance past hello_timeout/write_timeout and stop proving the flow. The two note tests are genuinely wall-clock and also belong in the timing job from ci: separate debug-only and measurement tests from ordinary workspace verification #2218 (ci.yml:986 is the pattern).
    • :1349 can only miss a bug, never false-fail.
    • The fd-exhaustion case needs the real ulimit -n 64; its 10 ms retry is the documented macOS ConnectionRefused workaround, not a poll.
    • Dropping :2814 below one interval would stop the counter from rising.

    Suggested PR

  16. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Batch analysis: 2217-A12 scattered machine-sensitive time

    Verdict: split

    Current evidence (current tree; audit line numbers drifted, tests located by name)

    • Guards over real events, keep a bound but derive it: crates/dim-app-server/tests/managed_oauth_flow.rs:567,578,798,803 — 3 s/1 s around f.started.notified(), f.release, and joining a cancelled complete_browser; every signal is a Notify. crates/dim-agent-runtime/tests/lifecycle_review.rs:85,89,99,151,157,161,171 — 2 s around the same three Notifys plus joins. crates/dim-app-server/tests/storage_flow.rs:5951 — 5 s on db.close(); :5597 30 s and :5548 5 s on a child daemon's stdout/stderr. crates/dim-modality/tests/modality_flow.rs:6477 — 5 s on wait_terminal. crates/dim-app-server/src/methods/tests.rs:293 is already G (whole-flow 10 s).
    • Polls dressed as bounds: managed_oauth_flow.rs:1023-1030,1404-1410,1775-1781 — 10 s timeout around while f.device_successes.load(..) == before { sleep(10ms) }, then wait_for_login (:316, 30 s, test(managed-oauth): give device login completion a load-tolerant budget #2233). storage_flow.rs:5846 — 1 ms reopen loop. crates/dim-agent-capabilities/tests/interrupt_flow.rs:721 — inline 5 ms while !chain_events(..) although the file already has until_events (:855).
    • Semantic, clock is the subject: managed_oauth_flow.rs:904-916 lower elapsed() >= 8 s for slow_down, :941 sleep(1100 ms) for expires_in:1; the poll interval comes from the fixture and no Clock is injectable in dim-oauth or the app-server OAuth plugin. modality_flow.rs:4343,4351 — 3 × sleep(6 s) lease holds and elapsed() >= 18 s startup recovery; start_in_with_clock fakes timestamps, not timers. modality_flow.rs:5109 — elapsed() < 20 s "the FIFO did not block" (macOS-only), redundant with wait_terminal. methods/tests.rs:540 — elapsed() < 1 s bounding synchronous rejection of four bad names including a 262 KB one: CPU-speed assertion, cannot hang.
    • Must-remain-pending samples, no predicate and no clock needed: lifecycle_review.rs:93 10 ms, interrupt_flow.rs:285 10 ms, interrupt_flow.rs:735 25 ms, storage_flow.rs:5993 10 ms. 58 such sites repo-wide.
    • Already handled / other batches: storage_flow.rs:6850 cold read (test(storage): use a flow guard in the cold-read failure test #2315), managed device-login budget (test(managed-oauth): give device login completion a load-tolerant budget #2233), hooks (test(hooks): wait for async hook markers instead of sleeping #2224). Section-C rows of mcp_session_flow, transport_flow/*, dim_oauth_flow, goal_*, branch_flow, context_*, local_execution/tool_binding/prompt_lifecycle and daemon_startup_progress belong to A1-A11/A13.

    Proposed change

    • Guards: reuse one file constant per file — SETTLED (storage_flow.rs:200) at :5951; add the same shape to lifecycle_review.rs and interrupt_flow.rs, which already has soon (:26). wait_for_login stays.
    • Pending samples: replace the timeout with a non-blocking check — assert!(!stop.is_finished()) at interrupt_flow.rs:285, !close.is_finished() at lifecycle_review.rs:93 (pattern already at methods/tests.rs:316), and poll_fn(.. is_pending()) at storage_flow.rs:5993, matching :5826 in the same file.
    • Polls: interrupt_flow.rs:721 → existing until_events; give Fixture a device_success: Arc<Notify> signalled next to device_successes.fetch_add (managed_oauth_flow.rs:147) and wait on it at the three sites.
    • Drop methods/tests.rs:540 and modality_flow.rs:5109; the result assertions stay.
    • Stays wall-clock: 8 s slow_down, 1100 ms expiry and the retention 6 s/18 s row, until the device flow and modality startup take an injectable clock.

    Risks / exceptions

    • No paused clock reachable: the OAuth service owns its sleeps and the modality server owns its runtime, so start_paused cannot apply; those rows need a timing route (ci: separate debug-only and measurement tests from ordinary workspace verification #2218 closed) or owner-side clock injection.
    • Platform: storage_flow.rs:5514,5885 unix-only; modality_flow.rs:5070 macOS-only.
    • is_finished() can pass before the task is polled; keep it paired with the terminal-error assertions so an early return still fails. Dropping elapsed() < 1 s loses the only check that huge names are rejected quickly.
    • The two device_successes tests reset f.polls before begin_device, so the notify must fire on the success branch only at :147.

    Suggested PR

    1. First and smallest: managed_oauth_flow.rs — fixture Notify + one token_response(&f) helper replacing :1023, :1404, :1775. One file, 3 rows. cargo test --locked -p dim-app-server --test managed_oauth_flow
    2. storage_flow.rs — :5951 → SETTLED, :5993 → poll-once. cargo test --locked -p dim-app-server --test storage_flow
    3. lifecycle_review.rs then interrupt_flow.rs — guard constant, pending samples, until_events. cargo test --locked -p dim-agent-runtime --test lifecycle_review, cargo test --locked -p dim-agent-capabilities --test interrupt_flow
    4. Semantic rows stay split out: modality_flow.rs needs a clock decision first; do not fold them into a guard PR.
  17. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Batch analysis: 2217-A2 transport_flow/sessions

    Verdict: split

    Current evidence (HEAD 7b78aac17; 32 Duration::from_secs(5) sites across 19 tests plus 2 test helpers):

    • 23 sites are pure hang guards whose wait already has a notification: published_after waits publication().watch() (sessions.rs:1362-1386, guard at 1365); gate.entered.notified() (1418, 1516, 1587, 2880, 3227); spawned-call joins (1198, 1243, 1458, 1548, 1615, 3265, 3279); held.recv() on DeferredInputs (2442, 2489, 2564, 2582, 2804); row-view watch to Unloading (2497, 2750); rules.held.notified() (2745); legacy.watch().wait_for (2668); socket EOF after shutdown (3062). None reads elapsed(); none asserts a lower bound.
    • 2 sites bound an operation that already owns a deadline: server.restart("Agents") (2568) and loader.restart("session-node") (2822). RunningServer::restart ends in wait_active(startup_timeout) (src/lib.rs:327-354), this binary raises that deadline to 30 s because "a whole-suite run can make assembly slower than the product's 10 s default" (transport_flow.rs:446-451), and Client::read is 30 s (transport_flow.rs:331-333). 5 s is stricter than the harness budget for the same operation.
    • 7 sites poll in-process state and belong to tests: convert in-process polling waits to event waits #2215: event_written's chain_events loop (1029-1042, called by every awaiting_approval test), write_published's 10 ms retry loop with no deadline at all (198-209), publication.has_pending() (1001, 3049), get::<PermissionState>().is_none() (1921 with a 10 ms sleep, 2367 with yield_now), agent.sessions() + attach (2043), the history probe until reloading (2449). Same class above 5 s: 2983, 3346, 3357.
    • Semantic absence windows (keep): 50 ms "has not returned" at 1020, 3245, 3260, 3273; 100 ms !is_finished at 1126, 1778, 1191, 2038, 2507, 2829.
    • 8 of the 32 sit in #[ignore] node tests (2367, 2442, 2489, 2497, 2745, 2750, 2804, 2822).

    Proposed change

    • Guards: one named guard in sessions.rs — const GUARD: Duration = Duration::from_secs(30); and async fn guarded<T>(what: &str, wait: impl Future<Output = T>) -> T that panics with deadline: {what} — used at the 23 guard sites and the two restart sites; each call names its predicate (e.g. 1458 "the withdraw replies while the close waits for its interrupt"). The existing named-predicate precedent is deletion::eventually (deletion.rs:131). What stays: every guard (a stalled test must fail; cargo test has no per-test deadline), all assertions, every 50/100 ms window.
    • Polls: separate batch under tests: convert in-process polling waits to event waits #2215 — delete 1001 (write.await already returns the commit and 1011 asserts it stays pending); rewrite event_written on publication().watch() like published_after; give write_published a bounded, named retry; dispatch_watch().wait_for(|d| d.sequence >= publication.sequence()) for 2983; consumed/approval event scans for 3346/3357.

    Risks / exceptions

    • 30 s is not new in this binary (Client, raised startup_timeout); the only cost is that a genuine stall reports 25 s later.
    • No event source exists for three waits, so they stay bounded polls: Session registration (Agent::sessions is a snapshot, 2043); a committed-but-unpublished append (1001, 3049); Permission's cell being re-provided after a reload (on() returns None while the part is unloaded, 1921/2367 — Session::on cannot observe re-provision). The HeldRules fixture (sessions.rs:261-296) can expose a "provided again" notify, which is the cheapest signal to add.
    • The 100 ms fences are race windows, not bounds: 1191/1194, 1838-1841 and 3041-3069 need the create/update write in flight before COMMIT or restart. A loaded runner can commit first, and the test then passes without covering the window. Fixing it needs a holding store through Setup::store (as DeferredInputs does, src/agents/sessions/tests/deferred_inputs.rs), not a larger number.
    • Paused clock is unavailable: real RunningServer, SQLite lock contention and index reloads on a multi-thread runtime; start_paused cannot replace these waits.
    • Timing is the subject only in input_replies_after_publication... (1020) and pending_waits_for_published_input_dispatch... (3245/3260/3273): they assert "still waiting" and stay wall clock.

    Suggested PR

    • PR 1: crates/dim-app-server/tests/transport_flow/sessions.rs only — add GUARD/guarded, convert the 25 guard sites, no test-logic change. Verify: cargo test --locked -p dim-app-server --test transport_flow -- sessions::
    • PR 2 (Refs #2215): the helper and poll conversions above; split if event_written / write_published exceed about 30 call sites.
  18. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Batch analysis: 2217-A10 context_flow, context_reads, host_flows

    Verdict: split

    Current evidence

    • None of these files has an elapsed() bound or a sleep >= 500ms; every M row is an explicit timeout <= 5s around a wait that is already event-driven.
    • context_flow.rs:1382,1634,1741,1752,1757,1803,1900 — timeout(3s, session.idle("main")). Branch::idle (crates/dim-agent-runtime/src/timeline_context.rs:1037) is the completion event; the 3 s only decides when a hang fails, and :1634 already names its predicate ("recovery stuck at {boundary}").
    • context_flow.rs:2139 timeout(3s, gate.entered.notified()), :2165 timeout(3s, stop) — same shape.
    • context_flow.rs:2145 and context_reads.rs:2167 — timeout(3s, loop { select! { dispatch.changed() => {}, sleep(10ms) => {} } }): the event exists; the 10 ms arm is only a spare tick.
    • context_reads.rs:1059,1481,2517,2522,2537,2552,2721,2728 (10s), :1572,1703,2367,2811,5914 (5s), :1528 (1s), :5537 (15s) — whole-test or whole-step guards; :1528 wraps a timeline_events read that must not need publication (the assertion timeline.sequence() == 0 carries that, not the 1 s).
    • context_reads.rs:1774 — let premature = timeout(25ms, &mut stop) asserting stop has not settled while the turn/end publication is held. Here the window is the assertion; the repo's idiom is assert!(!task.is_finished()) (branch_flow.rs:3227, transport_flow/sessions.rs:1021).
    • host_flows.rs:1214,2910,2999,3083,3263,3423,3834,4410 (5s), 1285,1366,1435,2594,3614,3862,3928,3992,4060,4123,4188,4235 (10s), 2195,2419 (15s) — whole-test guards around event waits. The file already holds the target state: #[tokio::test(start_paused)] + advance() for real-time subjects (:2635-2751, :2878), and :3545 documents why a timeout there is only a liveness guard; no wall-clock elapsed assertion is left outside a paused test.
    • Poll loops that are not bounds — context_reads.rs:2537 (10 ms tick), :2811 (yield_now spin on store.query_kinds), :5914 (5 ms tick on ToolSourcesView::get), :1450 (1 ms fixture hold): tests: convert in-process polling waits to event waits #2215. ToolSourcesView::subscribe() already exists (crates/dim-agent-capabilities/src/tool_registry.rs:214) and mcp_session_flow.rs:793 already waits that way.

    Proposed change

    • context_flow.rs (and through use super::* its context_flow/ submodules): add once, next to the builders,
    /// Bounds a flow step that has no deadline of its own; a real hang still
    /// fails instead of holding the test binary.
    const FLOW_GUARD: Duration = Duration::from_secs(60);

    then replace the duration argument of every tokio::time::timeout(...) with FLOW_GUARD — 16 sites in context_flow.rs, 19 in context_reads.rs (all but :1774). Keep each .unwrap()/.expect("…") message and every assertion; nothing else changes.

    • context_reads.rs:1774: delete the 25 ms window; before release.notify_one() add assert!(!stop.is_finished(), "stop settled before turn/end {end} publication"). assert!(returned >= end) stays.
    • host_flows.rs (separate binary): the same FLOW_GUARD, applied to all 24 timeout( sites, the paused tests included (there the value is irrelevant — the timer fires only when the flow is stuck).
    • Left alone: context_reads.rs:5430 startup_timeout(120s) is the fixture profile's own no-progress setting for paging 1,200 refreshes, not a test bound.

    Risks / exceptions

    • Raising a guard cannot mask a wrong assertion; it delays reporting a hang. A stalled flow still fails at 60 s with the same message.
    • is_finished() is sound here only because the spawned stop has been through many awaits since ends.recv(), reload.restart() and the generation loop, and cannot finish while the publication is held. Keep worker_threads = 2; on a single worker the check would be weak.
    • Do not convert the poll loops in this batch; tests: convert in-process polling waits to event waits #2215 owns them and 5914 should move to subscribe()/borrow_and_update() first.

    Suggested PR

    • PR 1 crates/dim-agent-capabilities/tests/context_flow.rs (const + 16 sites) — cargo test --locked -p dim-agent-capabilities --test context_flow
    • PR 2 crates/dim-agent-capabilities/tests/context_flow/context_reads.rs (19 sites + the is_finished assertion) — cargo test --locked -p dim-agent-capabilities --test context_flow
    • PR 3 crates/dim-agent-capabilities/tests/host_flows.rs (const + 24 sites) — cargo test --locked -p dim-agent-capabilities --test host_flows
    • Each Refs #2217.
  19. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Batch analysis: 2217-A4 transport_flow/approval

    Verdict: split

    Current evidence

    • 15 five-second guards, three kinds of target:
      • Test-owned event gates, already event waits: approval.rs:251, :334 (inside gate, :329-337), :386, :721, :942, :1075, :1500 wait on probe.entered/cancel_entered (Notify, notified by the probe's dispatcher handler at :150/:77); :817 waits on HeldPublication::arrived (mpsc, storage/timeline.rs:122), released by :831.
      • Real work reached through a facade: :871 session.closing() (sqlite trigger failure), :948/:1022 the spawned approval.admit, :1365 server.restart("Rpc"), :1421 probe.tools.restart().
      • In-process polling: :339 (wait_events :338-356, yield_now + chain_events) and :998-1004 (while !timeline.has_pending()).
    • RunningServer::restart bounds only activation, wait_active(startup_timeout) (crates/dim-app-server/src/lib.rs:351); view.restart() (rutis fiber.rs:2135) and loader.restart have no deadline. The module already raised startup_timeout to 30 s because "a whole-suite run can make assembly slower than the product's 10 s default" (transport_flow.rs:446-451), while Client::read uses 30 s — so 5 s is the outlier, not the norm.
    • Short bounds: :402 100 ms, :479 30 ms, :735 100 ms, :1012 100 ms. Two have exact observable substitutes: session.history blocks on dispatch.state.sequence < through (crates/dim-app-server/src/connection/tree.rs:289-320) and Approval::respond returns only when its registered oneshot is resolved by dispatch (crates/dim-agent-capabilities/src/approval.rs:379-403). Dispatcher::sequence() is public (crates/dim-agent-runtime/src/core/dispatcher.rs:266) and advances after handlers (:299-307), and Probe already stores the dispatcher (:1198 uses fail).

    Proposed change

    • Guards: one const SETTLE: Duration = Duration::from_secs(30) and one helper async fn reached(notify: &Notify, what: &str) (timeout(SETTLE, notify.notified()) + expect naming the missed event). Replace the seven probe.*_entered sites and use SETTLE for :817, :871, :948, :1022, :1365, :1421. Mechanism unchanged; only the deadline and the panic message change, so a hang says which event never arrived instead of Elapsed(()).
    • :402 → delete the 100 ms attempt; assert dispatcher.sequence() < head inline (that is the exact blocking condition in tree.rs) and keep the reply assertions at :414-421.
    • :479 → delete the 30 ms attempt; after wait_events(..., "approval/respond", 2) read the second respond event's sequence and assert dispatcher.sequence() < seq with the existing message.
    • :735 → delete the loop; keep one assert_eq!(calls…, 0, "a committed denial must block automatic admission before dispatch"). The post-release assert at :747 catches a start that happens after the read. Stays: the gate and everything after release.
    • :1012 → keep a no-progress window (shrink the name to a shared constant): it is the only check that admission does not finish while its terminal is uncommitted; the :1022 await passes either way.
    • Kept out of scope: wait_events and :998 stay polling here; they are tests: convert in-process polling waits to event waits #2215's conversion (Line::dispatch_watch route.rs:432, Line::publication route.rs:436, Timeline::watch core/timeline.rs:944, has_pending core/timeline.rs:590).

    Risks / exceptions

    • Notify holds one permit: if a gate fires twice between two waits, the guard is what reports it, so keep the guard and name the event.
    • No paused clock: these tests drive a real RunningServer over unix/ws sockets, a sqlite writer thread and rutis reloads; tokio::time::pause() would freeze those real waits. :1012 keeps wall clock for that reason.
    • The two deleted short bounds also removed a latent hazard: cancelling Client::response_with_timeout drops a partially read socket line (transport_flow.rs:335-375). Remaining shortened client.response calls keep it.
    • dispatcher.sequence() < seq states "not delivered yet", which is the tested property; it does not detect a reply produced before its append, which wait_events already covers.

    Suggested PR

    • crates/dim-app-server/tests/transport_flow/approval.rs only, no production change.
    • Split in two: (1) SETTLE/reached plus the real-work deadlines; (2) the dispatcher.sequence() conversions for :402 and :479. Leave the poll conversion to tests: convert in-process polling waits to event waits #2215.
    • Verify with cargo test --locked -p dim-app-server --test transport_flow approval::.
  20. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Batch analysis: 2217-A11 integration machine-sensitive time (local_execution, tool_binding, prompt_lifecycle)

    Verdict: split — 17 M rows: 13 guards, 2 semantic bounds, 4 "still pending" windows that assert no time at all; 3 poll loops belong to #2215/#2216.

    Current evidence

    • tests/integration/tests/local_execution.rs:473 — file-local until polls branch_events 1500×20 ms and panics naming what. It is already the file's hang guard, so the timeout(5s, until(...)) wrappers duplicate it: :754 (started marker), :791, :796, :2012, :2923.
    • local_execution.rs:781 wraps session.idle; :2706, :2770, :2808, :2829 wrap restart/join! completions; :771 (3 s) waits for done-{n} before releasing the blocked offload; :766 is the condvar self-release of that offload thread — a premature 5 s release silently drops the "drains before offload" premise. Harness::new walks every process row with wait_active(..., 5s) at :419.
    • tests/integration/tests/tool_binding.rs:285 (adopted), :471 (plugin_state) and per-test 5 s bounds :564, :590, :615, :698, :785, :862, :1017, :1026, :1381, :1400, :1519, :1543, :1554 all wrap a completion event (watch wait_for, Notify, idle, plugin state) and assert nothing about 5 s.
    • tool_binding.rs:1137 polls ToolSourcesView::get() every 5 ms although the same file already uses subscribe().wait_for(...) at :1519.
    • tool_binding.rs:1396, :1550 — 150 ms published.changed() / sources.changed() windows assert "nothing happened yet".
    • tests/integration/tests/prompt_lifecycle.rs:1158, :1207 — 50 ms windows on tasks held by hosts that block on a Notify released later; :1951, :2084 — 30 ms windows on creation while the host still holds release.
    • Semantic: prompt_lifecycle.rs:1505 20 s restore bound plus :1513 elapsed() > 1 s; the fixture sleeps (200 ms steps) sum to ≥1.4 s, so slowness cannot fail it. :1491 500 ms and :1897/:2033 300 ms startup_timeout are the subjects (inactivity deadline renewed by progress).
    • Pure guards in prompt_lifecycle.rs: :1216, :1562, :1927, :1946, :1961, :1982, :2071, :2092, :2098.

    Proposed change

    • Add to tests/integration/tests/local_support/mod.rs the app-server convention (crates/dim-app-server/tests/storage_flow.rs:203): pub const FLOW_GUARD: Duration = Duration::from_secs(60); and pub async fn settled<T>(what, fact).
    • local_execution.rs: delete the five timeout(5s, until(...)) wrappers — until already bounds and names its predicate; move :419, :766, :771, :781, :2706, :2770, :2808, :2829 to FLOW_GUARD.
    • tool_binding.rs: one FLOW_GUARD for adopted, plugin_state, follow and the listed test bounds; replace :1137 with session_service::<ToolSourcesView>().unwrap().subscribe().wait_for(...); replace :1396 with assert!(!published.has_changed().unwrap(), ...) after the registry shows v2; delete the refreshed window at :1550 — the existing assert_eq!(offered(&sources.borrow()), second) after close already detects a refresh; give it the message.
    • prompt_lifecycle.rs: FLOW_GUARD for the listed guards; replace :1158, :1207, :1951, :2084 with assert!(!handle.is_finished(), ...) (each release comes later, so the state read is exact); keep the 1 s lower bound and the 300/500 ms deadline subjects.
    • Stay with tests: convert in-process polling waits to event waits #2215/tests: replace external process/file polling waits with exit or output events #2216: external marker polls local_execution.rs:754, :771 (tests: replace external process/file polling waits with exit or output events #2216); output_page/output polls :2012, :2923 and prompt_lifecycle.rs:785 (tests: convert in-process polling waits to event waits #2215).

    Risks / exceptions

    • is_finished() is valid only where the blocker is a later Notify; never where the signal is a timer.
    • published.has_changed() assumes no unrelated publication while assembly is held (true today).
    • The integration crate lacks tokio test-util, so these tests cannot use start_paused; assembly.rs:185 is tokio time, so paused-clock conversion stays possible for the 300/500 ms deadlines later.
    • Harness::new's progress-based wait_active already names unmet rows; only its interval changes.

    Suggested PR: one PR per file plus the shared constant. Files: tests/integration/tests/local_support/mod.rs, local_execution.rs, tool_binding.rs, prompt_lifecycle.rs. Verify per module: cargo test --locked -p dim-agent-integration-tests --test integration_flow local_execution:: -- --test-threads=4 (repeat with tool_binding::, prompt_lifecycle::), then cargo clippy --locked -p dim-agent-integration-tests --tests -- -D warnings.

  21. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Batch analysis: 2217-A5 crates/dim-app-server/tests/transport_flow/reload.rs

    Verdict: split — 6 pure guards, 1 semantic, 8 polls (4 convertible now, 4 for #2215), 2 external.

    Current evidence

    • 15 × tokio::time::timeout(Duration::from_secs(5), …) at reload.rs:152,163,228,317,329,464,469,479,688,775,783,794,810,884,892; 10 s at :188 (set_read_timeout on a blocking UnixStream) and :213 (restart("Connection")).
    • Guards: :152/:464/:775/:884 wait on started/entered Notify gates (HoldTool :96-118, GatedModel :267-285); :810 on stop (spawned :806); :213 on a process restart that must settle while a child holds inherited descriptors.
    • Semantic: :251 is a plain #[test] with a manual current-thread runtime, startup_timeout: 50ms (:269) against sleep(250ms) (:275). The deadline is the subject; nothing else in the case is time-sensitive.
    • Convertible polls: :479 (TurnEnd over chain_events) and :794 (StopInterrupt) wait on committed facts, so session.publication("main").watch() is the event (testing.rs:824, branch.rs:24) and until_events (branch_flow.rs:3603) is the existing shape. :783/:892 poll session.state("main").is_ok(): SessionLines::watch is documented as “changes when state() may read differently” (testing.rs:818, timeline_context.rs:322), and state() answers Err exactly while the Loop port is absent (timeline_context.rs:296-321).
    • For tests: convert in-process polling waits to event waits #2215: :163 is a select probe for the service_reloading window (no sleep); :228 retries session.summaries because RunningServer::restart waits only for process plugins (lib.rs:322-355); :469/:688 poll branch_diagnostics for a Loop generation bump with FiberState::Active — FiberView::restart returns when the row itself restarted, not its dependents, Loader::settled is not reachable from a serve() test, and the branch watch does not signal a fiber becoming Active; :909 consumes session.state notices bounded only by Client::read's 30 s message (transport_flow.rs:333).
    • External: :317 waits for the socket path (transport.rs:165 UnixListener::bind) and :329 retries the bind after the dropped startup releases it.

    Proposed change

    1. Guards: one const SETTLE: Duration plus async fn settled(what: &str, fact: impl Future) -> T in transport_flow.rs, mirroring storage_flow.rs:203-208, and use it at :152, 213, 464, 688, 775, 810, 884. :188 keeps a wall-clock read timeout because it runs on a std thread. No behavior change.
    2. Semantic: add .start_paused(true) to the builder at :253; keep the 50 ms deadline and the 250 ms release sequencing (now virtual). StartupProgress already uses tokio::time::Instant/sleep_until (assembly.rs:120,190), so virtual time drives it.
    3. Convert :479 and :794: subscribe to publication("main").watch() before release/stop, re-read chain_events, wait on changed(), fail naming “turn ended”/“interrupt written”. Convert :783 and :892: take session.watch("main") before tools.restart(), then wait until state("main").is_err().
    4. Leave untouched here: :163, :228, :469, :688 (client-retry and fiber-generation waits, no test-visible event), plus :909's notice loop — tests: convert in-process polling waits to event waits #2215 owns them; their 5 s bound becomes SETTLE when converted.
    5. :317/:329 stay as polls; only the bound becomes SETTLE. Both name what they wait for.

    Risks / exceptions

    • Paused clock: anything in serve that watches real std::time::Instant would never expire; today the startup deadline is tokio-only, and max_blocking_threads(1) still forces the timeout path. Re-read the two assert!(error.contains(...)) lines after the switch.
    • watch must be subscribed before the action; a reload signal emitted in between is invisible to watch (last value only).
    • :317/:329 are OS/filesystem behavior with no event source, and are Unix-only.
    • The branch watch signalling on a Loop generation change is not contractual for FiberState::Active, which is why :469 is not converted.

    Suggested PR: split into (a) transport_flow.rs + reload.rs: guard helper and the six guard sites; (b) reload.rs: start_paused for the startup-deadline case; (c) the four poll conversions with #2215's helper. Verify with cargo test --locked -p dim-app-server --test transport_flow -- reload:: and, before/after (a), cargo test --locked -p dim-app-server --test transport_flow.

  22. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Review correction: 2217-A10 context_flow, context_reads, host_flows

    Verdict: partially correct

    What is wrong: the host_flows.rs step — "the same FLOW_GUARD, applied to all 24 timeout( sites, the paused tests included (there the value is irrelevant — the timer fires only when the flow is stuck)" — is wrong. Two of the 24 sites are inside #[tokio::test(start_paused = true)], where the guard is a virtual-time timer that competes with the flow's own virtual timers; its value decides whether the test fails. Lowering one of them from 600 s to 60 s breaks the test it guards. The site list enumerates only 22 of the 24 sites, which is what hides it.

    Evidence:

    • crates/dim-agent-capabilities/tests/host_flows.rs:2281-2283: #[tokio::test(start_paused = true)] async fn transient_retries_are_bounded_and_stop_after_irreversible_output() { tokio::time::timeout(Duration::from_secs(600), async {.
    • The loop inside it (:2289-2300) runs 11 fixture modes; modes 7 and 8 make 8 model attempts each (expected_calls, :2298-2300). The retry wait is tokio::time::sleep(delay) (crates/dim-agent-capabilities/src/model_provider/recovery.rs:170) with BASE_DELAY 1 s and MAX_BACKOFF 30 s (recovery.rs:16-18): 1+2+4+8+16+30+30 = 91 s of virtual time for one such mode alone.
    • That this accrues under start_paused is already asserted in the same file: host_flows.rs:2738-2751 drives the same retry path with no advance() and asserts started.elapsed() >= Duration::from_millis(72_800).
    • The other timed-out paused site is host_flows.rs:3543-3545 (30 s), a raise to 60 s, harmless.

    A 60 s guard therefore fires inside mode 7's backoff, and the timeout(...).await.unwrap() panics the test.

    Corrected conclusion: convert the 22 wall-clock sites (1214, 1285, 1366, 1435, 2195, 2419, 2594, 2910, 2999, 3083, 3263, 3423, 3614, 3834, 3862, 3928, 3992, 4060, 4123, 4188, 4235, 4410) to FLOW_GUARD and leave the two paused sites (:2283 at 600 s, :3545 at 30 s) as they are. In a paused test a guard must stay above the flow's own virtual budget, so drop that rationale rather than "the value is irrelevant".

    The rest of the batch verifies correct: 16 tokio::time::timeout sites in context_flow.rs, 19 in context_reads.rs excluding :1774, context_reads.rs:1774 → assert!(!stop.is_finished()) (stop is a JoinHandle already blocked at the publication, and returned >= end stays), and the two elapsed >= hold deletions in :1005/:1107 — both fixtures answer hello only after the hold, and released is stored after output() returns (:986-987, :1089-1090), so output.status.success() already implies the wait outlived it.

    Impact: following the step as written makes transient_retries_are_bounded_and_stop_after_irreversible_output fail at 60 s of virtual time with Elapsed — a green test turned red by the cleanup itself.

  23. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Review correction: 2217-A11 integration machine-sensitive time (local_execution, tool_binding, prompt_lifecycle)

    Verdict: partially correct

    What is wrong: two of the proposed replacements make a lower bound weaker than what the test asserts today.

    1. prompt_lifecycle.rs:1207. closing is spawned on the line immediately before the window (:1205), and nothing has awaited it. Replacing timeout(50 ms, async { while !closing.is_finished() { yield_now().await } }) with assert!(!closing.is_finished(), ...) is vacuous there: on a fresh JoinHandle the task need not have been polled at all, so the assertion passes whatever close does. Unlike the other three is_finished() sites (:1158, :1951, :2084), where the handle is created before an awaited started/cancelled host signal, this one has no proof the task reached the held configure.

    2. local_execution.rs:771. That 3 s produced bound must stay below the offload thread's own 5 s self-release at :766; it is not an interchangeable guard. Raising it to FLOW_GUARD (60 s) lets the condvar release first, so the drain completes at ~5 s and produced.expect("all output must reach the pipe before releasing offload") (:780) passes in exactly the case the case exists to catch — the premise the comment itself names ("a premature 5 s release silently drops the 'drains before offload' premise"). The proposed PR also lists :771 twice, once under "move … to FLOW_GUARD" and once under "Stay with tests: convert in-process polling waits to event waits #2215/tests: replace external process/file polling waits with exit or output events #2216: external marker polls local_execution.rs:754, :771".

    Evidence:

    • tests/integration/tests/prompt_lifecycle.rs:1205-1214:
      let closing = tokio::spawn(async move { agent.close().await }); assert!(tokio::time::timeout(Duration::from_millis(50), async { while !closing.is_finished() { tokio::task::yield_now().await; } }).await.is_err());
    • tests/integration/tests/local_execution.rs:766: wait_timeout_while(done.lock().unwrap(), Duration::from_secs(5), |done| !*done); :771: let produced = tokio::time::timeout(Duration::from_secs(3), async { while !harness.cwd.join(format!("done-{attempt}")).exists() … });; :777-778 sets released/notifies; :780 produced.expect(...).

    Corrected conclusion: keep :1207 as a wait that first proves closing is live — either keep the bounded is_finished() loop, or derive it from the signal that already exists (the held configure's host reply at started/finish) instead of replacing it with a bare check. Keep :771 at 3 s (below the 5 s self-release) and do not move it to FLOW_GUARD; :766 is a condvar timeout on a blocking thread, not a flow guard. The rest of the batch verifies correct: the until duplication at :754/791/796, the :1137 poll versus subscribe().wait_for at :1519, the :1396/:1550 windows, the two semantic bounds, and the other three is_finished() conversions.

    Impact: as written, the PR would delete the only check that close waits for a held configure (a regression there would pass), and would remove the only check that the output drains before the offload is released. Both losses are silent — the tests stay green.

    (Non-blocking: the verdict line's "13 guards, 2 semantic bounds, 4 still-pending windows" sums to 19, not the stated 17 rows; the site-by-site enumeration itself covers the ledger's 17 rows — 5 local_execution, 7 tool_binding, 5 prompt_lifecycle — so only the summary numbers need fixing.)

  24. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Review correction: 2217-A4 transport_flow/approval

    Verdict: partially correct

    What is wrong: The two dispatcher.sequence() conversions at :402 and :479 are not "exact observable substitutes" for the short bounds they delete. Both asserts hold before the code under test can act, because the probe gate is holding dispatch for the whole window; they stay true whether or not session.history / Approval::respond wait at all. Deleting the bound therefore removes the only check that the reply is withheld, and the retained assertions pass on a reply produced without waiting. At :479 the sequence of the wrong event is also used: a.response(first) resolves with the first approval/respond, not the second.

    Evidence:

    • crates/dim-app-server/tests/transport_flow/approval.rs:371-384 appends ["first in batch", GATE_INPUT]; :150-151 blocks the dispatcher inside the GATE_INPUT handler (probe.entered.notify_one(); probe.release.notified().await;). Dispatcher::sequence() (crates/dim-agent-runtime/src/core/dispatcher.rs:266, set at :307) is therefore pinned at batch[0].sequence while the gate holds.
    • approval.rs:394 let head = session.sequence("main").unwrap(); is the published head (crates/dim-agent-runtime/src/branch.rs:151-153), i.e. >= batch[1].sequence, so dispatch.sequence() < head is unconditionally true. crates/dim-app-server/src/connection/tree.rs:269, :279-307 computes through = head and blocks while state.sequence < through; a handler that skipped that loop would still return both published batch events and the cursor, so approval.rs:414-421 continues to pass.
    • For :479: approval.rs:461 gates before both responds, :464-476 sends deny then allow. Approval::respond registers its oneshot under its own event id (crates/dim-agent-capabilities/src/approval.rs:379-403: append_registered -> inner.responses.insert(event.id.clone(), waiter) -> result.await), so a.response(first) is released by dispatch of approval/respond fix: correct plugin storage, shutdown, and stream lifecycle handling #1, while dispatch.sequence() < seq(#2) also holds once fix: correct plugin storage, shutdown, and stream lifecycle handling #1 has been dispatched.

    Corrected conclusion: Keep an observable check that the reply has not been produced. #2215's own N-row rule allows it: if no notification exists for "the reply is withheld", keep a bounded quiet window and state the bound as part of the assertion ("history waits for its published snapshot to dispatch within 100 ms"), instead of replacing it with a predicate the test's gate already guarantees. If you keep a dispatcher assert at all, it is at most supporting evidence and must use the awaited event's own sequence (#1 at :479). The rest of A4 is correct: the seven probe.*_entered sites and :817/:871/:948/:1022/:1365/:1421 are guards, :339/:998 are #2215 polls, :1012 stays a stated window, and :735 is covered by the post-release assert at :747.

    Impact: Implementing PR-2 as written drops the only coverage of "history waits for its published snapshot to dispatch" and "RPC cannot succeed before its event is consumed"; a regression that returns either reply without waiting would pass both tests. The claimed mechanism (Dispatcher::sequence() is public, tree.rs blocks on state.sequence < through, Approval::respond waits for dispatch) is real, so only the substitution is wrong.

  25. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Review correction: 2217-A8 goal-parts/evaluator

    Verdict: partially correct

    What is wrong: the classification holds (six 750 ms gate-arrival rows, three write-absence rows, no usable paused clock), but four of the six proposed taken() conversions name a barrier that ends before the step they must rule out. taken() is one try_recv, so at those sites the negative assertion would usually sample an empty channel and pass with the regression present.

    • goal_parts_flow.rs:1022 — failure.await is signalled from the GoalProbeFailState before hook while the record's draft is rewritten, i.e. before the append is refused and before the writer reaches release_settlement(). The second decision the case rules out can only be spawned after that release.
    • goal_parts_flow.rs:1127, :1228, :1339 — the take-up the case rules out is a newly spawned task: a writer that wrongly resumes decisions goes through resume_settlement → interrupted → task → self.work.spawn, and the Stage::Record hold it would land on is that spawned task. Neither Stage::Released arriving at :1120 nor the pause reply the tokio::join! at :1231/:1342 returns proves the spawned task ran; it can still be polled after the sample.

    Evidence:

    • crates/dim-goal/tests/support/parts.rs:230: the hook rewrites the paused block and does let _ = fired.send(()); inside timeline.before(ctx, "GoalProbeFailState", &["input/message"], ...) — the draft stage, so failure.await resolves before the commit is even attempted.
    • crates/dim-goal/src/branch.rs:746-755: Ok(_) => self.resume_settlement() / Err(_) => { self.release_settlement(); } runs after that hook.
    • crates/dim-goal/src/branch/restore.rs:46-50: resume_settlement = release_settlement() then self.interrupted(interrupt); crates/dim-goal/src/branch.rs:1499-1501 fn interrupted calls self.task(...), and crates/dim-goal/src/branch.rs:791 self.work.spawn(async move { ... }) is where the held Stage::Record is reached. State::decision_tasks (src/branch.rs:412) is the only thing that proves that task ended, and no test hook awaits it.

    Corrected conclusion: convert only goal_parts_flow.rs:1600 and goal_evaluator_flow.rs:1040. There the continuation is written by the same task after the record was answered (src/branch.rs:2080-2113: record(after, None, Answers::TurnEnd{..}).await?, then the Decision::Continuation branch), so awaiting env.wait_for(kind="continuation") really does prove the append was never reached. Keep a bounded window at :1022, :1127, :1228, :1339 — a named NEGATIVE, with the false-pass risk the batch already accepts for the write-absence rows — or add a testing hook that awaits decision_tasks first and then use taken().

    Impact: implementing the batch as written would have deleted the only detector for "a failed state record takes no second decision" and "a failed record takes up no interrupt it deferred" at four sites, leaving tests that still read as if they asserted it.

  26. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    Review correction: 2217-A9 branch_flow

    Verdict: partially correct

    What is wrong: the routing holds (four 5 s HeldWriters guards, the 1 s released.cancelled() guard, the 8 s/30 s helper duplicates, the 150 ms windows staying real-time), but :3223 cannot become futures_util::poll!. closing is not the future that waits for dispatch: main.close() starts the close in a spawned task and returns a result waiter, so one poll answers "has the close already finished", not "the future sits at its blocking point". That is the same argument the batch uses to keep :11111, :12960 and :13073/:13097, and it applies here unchanged.

    Evidence:

    • crates/dim-agent-capabilities/tests/branch_flow.rs:3211-3226: let mut closing = main.close(); is polled only inside timeout(50ms, &mut closing), after the committed StopInterrupt is observed on Committed.
    • crates/dim-agent-runtime/src/branch.rs:126-128: Branch::close() → TimelineContext::close() (timeline_context.rs:890) → finish(false), which calls self.close.start(ctx.handle(), async move { ... }).
    • crates/dim-agent-runtime/src/lifecycle.rs:26-38: CloseOnce::start does handle.spawn(async move { ... send.send_replace(Some(result)); }) and returns a future that only waits on that watch. A close that skipped the dispatch wait would complete in the spawned task; a single poll sees Ready only if the task already published, otherwise Pending and the regression passes.

    Corrected conclusion: keep :3223 as a real-time window — it is the assertion, as the batch itself classifies it — optionally with a shared NEGATIVE constant so the number has one home. Readiness has to come from the close itself (a signal the close task emits), not from polling its waiter. The rest of PR 1 stands: the four HeldWriters rows, :2936 → assert!(released.is_cancelled()) (the guard lives in the cancelled() future the drop of waiting destroys, so it is synchronous), and :8985/:6698 → patient.

    Impact: replacing the 50 ms must-not-complete window with a first poll would remove the only check that close answers only after the dispatcher delivered the StopInterrupt, while the test would still look like it asserted that.

  27. eric8810 commented on Nov 29, 2026

    @eric8810
    CollaboratorAuthor

    #2217 is complete in #2355, merged at bd7fc347b.

    The PR classifies the actionable M rows into named hang guards, event waits, and documented semantic wall-clock exceptions. Poll loops remain with #2215, external waits with #2216, and wait_for_login with #2233. Targeted suites passed locally; CI at 4457ddacd was green before merge.

    Closing this issue as complete.

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

Metadata

Metadata

Assignees

Labels

P2roadmap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions