Skip to content

test: wait for branch, plugin and client facts instead of timing - #1971

Merged
eric8810 merged 7 commits into
mainfrom
dim/1919-flake-stability
Nov 21, 2026
Merged

eric8810 merged 7 commits into
mainfrom
dim/1919-flake-stability

Conversation

@eric8810

@eric8810 eric8810 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #1919.

The Linux verify runs behind #1952 and #1953 keep failing on the same flow tests whenever the runner is loaded. These changes replace fixed windows with the facts the flows already receive, except for the update-dialog case explained below.

  • transport_flow::branch_events: the attached client now waits on the session.event and session.state notices for the branch's exec ended/started facts and for the three session states; the ten-second history polling is gone. The first client attaches before creating the branches, so its notice stream carries those facts.
  • storage_session_flow::session_close_and_idle_unload_persist_finalizers_and_release_branch_parts: the branch part signals its release from Drop, and the flow awaits that signal. The inner failure bound is ten seconds, shorter than the test's outer thirty-second bound, so the specific branch part must be dropped message is the one reported.
  • collaboration::native_member_work_absorbs_messages_and_spans_turns: the filter now matches the peer projection's actual Append input (type, mode, user, blocks at the top level, null user, exact dim/environment/clients source). A unit test feeds a real serialized presence row and keeps two duplicate collaboration rows, proving the filter removes only the presence row and preserves order and duplicates.
  • The CLI harness treats EIO on a closed Linux PTY as the terminal-closed failure it documents, instead of panicking without the expected-text transcript.
  • The history-lock and recovery update flows start an embedded App Server; a debug-only DIM_TEST_APP_SERVER_STARTUP_TIMEOUT_MS and the existing DIM_TEST_DAEMON_START_TIMEOUT_MS keep their ten-second startup bounds from expiring on a loaded runner. crates/dim-cli/README.md documents the server override.

Not claimed fixed: the busy/idle/old/cancelled update-dialog cases drive a fake daemon that is already listening, so neither startup bound is on their path. Their offer still depends on the registry check, and a failed check is still silent. That flake stays tracked under #1919; this PR does not change those four cases' bounds.

Verification:

  • cargo fmt --all -- --check --config error_on_line_overflow=true
  • collaboration::environment_client_rows_are_ignored_but_collaboration_rows_are_not: 1/1
  • branch_events::restored_task_branches_are_discovered_locally_and_named_stops_preserve_the_leader: 20/20 before the notice change; rechecked after
  • storage_session_flow::session_close_and_idle_unload_persist_finalizers_and_release_branch_parts: 20/20
  • collaboration::native_member_work_absorbs_messages_and_spans_turns: 3/3
  • full transport_flow: 583 passed, 0 failed
  • full app_server_flow: 487 passed, 0 failed
  • staged_update::tui_update:: under three test threads: 3/3 runs

@eric8810 please re-review.

Replace the fixed polling windows that fail under runner load with the
facts the flows already receive:

- branch_events waits for the exec started and session state notices
  instead of paging history inside a ten-second timeout.
- storage_session signals the branch part's release from Drop and awaits
  the signal; an immediate Weak assertion raced the teardown.
- collaboration compares business events without the environment state
  inputs that an attach, detach or unload can append between reads.
- the CLI harness treats EIO on a closed Linux PTY as the documented
  terminal-closed failure instead of panicking.
The update and recovery flows start the embedded App Server on the same
loaded machine as the rest of the flow binary. Its ten-second startup
inactivity bound can expire there before the daemon reports progress, and
the interface closes before the dialog. These flows already take the
test-only update deadline; give them the daemon startup override too.

@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.

Review: PR #1971 at ec2c735

Verdict: REQUEST_CHANGES

The PR replaces fixed sleeps and polling windows in five flow-test files with waits on facts the flows already receive, to stop the Linux flow failures behind #1952 and #1953. The branch_events, storage_session_flow, collaboration and CLI-harness changes do what they say. The update-dialog change does not address the failing test it names.

P2: the added daemon startup bound is not on the failing update-dialog path

Problem. crates/dimcode/tests/cli_flow/staged_update.rs:1352 adds DIM_TEST_DAEMON_START_TIMEOUT_MS=60000 to assert_tui_update_case. The variable is read only by client::daemon_start_timeout (crates/dim-cli/src/client.rs:202-204) and used only inside connect_inner (crates/dim-cli/src/client.rs:1118-1122, :1247, :1291), which plugins::DaemonLink runs at startup (crates/dim-cli/src/plugins.rs:72) before open_tui starts the TUI plugin (crates/dim-cli/src/lib.rs:137-147). The only later call is stop_idle_for_update (crates/dim-cli/src/client.rs:781), after the interface has left, well past the dialog wait. The busy, idle, old and cancelled cases drive a fake daemon on a socket bound before launch (crates/dimcode/tests/cli_flow/staged_update.rs:1272-1326), so the TUI already has its client when the dialog wait starts. "Update now" is produced by Update::Upgrade (crates/dim-cli/src/ui/tui.rs:3083), sent from update::available (crates/dim-cli/src/session_host.rs:440-450). Its only bounded step is the registry request under DIM_TEST_UPDATE_TIMEOUT_MS, already 60 s before this PR (crates/dim-cli/src/update.rs:24-34, crates/dimcode/tests/cli_flow/staged_update.rs:1351), and update::available turns every failure into None (crates/dim-cli/src/update.rs:318-327), so a failed check never becomes a fact.

Failure scenario. On the next loaded runner, update_now_refuses_a_busy_daemon_and_prints_manual_command can still sit at the 300 s bound at crates/dimcode/tests/support/cli_harness.rs:893, with the same idle transcript. The 60 s hello bound cannot change the outcome after the TUI is connected.

Evidence. Run 44878291869 (PR #1952 head, Linux) fails at log line 5086 and run 44878237932 (main, macOS) fails at log line 3136. Both panic with Terminal did not show "Update now" at cli_harness.rs:893:13, and both transcripts show the live idle interface (resumed session · 0 messages, Ask anything...), not a closed terminal or an app-server startup error. A hello timeout in connect_inner makes open_tui return before the TUI exists, so it cannot produce that transcript.

Fix. Identify the missing input before widening another bound. Make the startup-check outcome observable to the flow (for example, record why update::available returned None, or have the test wait on the offer rather than on the rendered text), or make the fake registry path deterministic. Keep DIM_TEST_DAEMON_START_TIMEOUT_MS for the flows that really start an embedded App Server: assert_history_lock_update (crates/dimcode/tests/cli_flow/staged_update.rs:1451) and the recovery cases (:947, :1093, :1183). If the busy/idle dialog flake cannot be fixed here, keep it tracked under #1919 and drop the claim that it is addressed.

P3: the specific storage-session release message cannot fire

crates/dim-app-server/tests/storage_session_flow.rs:356 waits 30 s for the release signal inside the test's existing 30 s timeout at :304. The outer timer starts earlier, so on a broken flow it fires first with session cleanup and durable publication completed; the specific branch part must be dropped after Session teardown message is unreachable. Use one bound, or a shorter inner bound, so the intended diagnostic is the one reported.

P3: branch_events keeps one fixed 10 s window for the same kind of fact

crates/dim-app-server/tests/transport_flow/branch_events.rs:129-144 still pages history every 10 ms under a 10 s timeout for the first branch's exec ended fact. That is the pattern this PR removes for the started fact at :243-253, and the same loaded runner can delay it. Wait on the notice as well, or drop the outer timeout and let the client's 30 s response bound be the backstop.

Coverage of the replaced waits

  • branch_events (:191-196, :243-253): notices that arrive before an RPC reply are buffered by Client::response_with_timeout (crates/dim-app-server/tests/transport_flow.rs:350-362) and found by Client::notice (:368), so an already-delivered notice is not missed. read_with_timeout (:322-340) keeps a 30 s per-read deadline, so a missing fact fails instead of hanging. The assertions still check the same facts.
  • storage_session_flow: the oneshot buffers a signal sent before the receiver is taken, so a fast drop cannot be missed; the failure stays bounded.
  • collaboration (:1269-1291, :3206-3209): the filter removes only runtime environment state inputs (<dim-state source="dim/environment/) with no user content; all business events are still compared with full JSON equality.

Checks

Command Result
cargo fmt --all -- --check --config error_on_line_overflow=true pass
git diff --check origin/main...HEAD pass
node scripts/adr-check.mjs --base origin/main pass, 5 changed files
cargo check --locked -p dim-app-server -p dimcode --all-targets pass
cargo test -p dim-app-server --test transport_flow restored_task_branches_are_discovered_locally_and_named_stops_preserve_the_leader 1 passed
cargo test -p dim-app-server --test app_server_flow storage_session_flow::session_close_and_idle_unload_persist_finalizers_and_release_branch_parts 1 passed
cargo test -p dim-app-server --test transport_flow native_member_work_absorbs_messages_and_spans_turns 1 passed
cargo test -p dimcode --test cli_flow staged_update::tui_update:: -- --test-threads=3 6 passed

CI at ec2c735: macos-native pass, dependencies pass, verify (linux) fail, ci-ok fail. The only failing test is hooks::project_hooks_start_disabled_and_the_user_enables_them (crates/dimcode/tests/cli_flow/hooks.rs:497, the saved document did not reach the next hook point); the changed tests passed in that job (transport_flow exit 0, app_server_flow exit 0, all six staged_update::tui_update tests ok). That failure is an assertion about a hook marker file written by a plain run command, not terminal output; this diff changes no hook or daemon code and only adds an EIO arm to Terminal::wait_for, which that test does not use. It matches the hooks timing flake already named in #1952's discussion.

Conflicts

  • git merge-tree --write-tree origin/main HEAD: clean.
  • PR #1917 also edits crates/dim-app-server/tests/transport_flow/collaboration.rs; it merges cleanly with this head.
  • PR #1970 and PR #1963 conflict with this head only in files that already conflict with origin/main (crates/dim-event-hub/tests/fixture_flow.rs, crates/dimcode/tests/cli_flow.rs, web/src/chat-ui/web-chat-timeline.test.ts); this PR adds no conflict of its own.
  • PR #1952 shares none of the five changed files.

Unverified

  • The exact cause of the missing update offer. The transcript and the code path rule out the daemon startup bound, but I did not reproduce the registry-check failure locally; the busy test passed here.
  • Loaded-runner repetition of the changed tests.

.env_remove("DIMCODE_UPDATE_CHECK")
.env("DIM_TEST_RELEASE_BUILD", "1")
.env("DIM_TEST_UPDATE_TIMEOUT_MS", "60000")
.env("DIM_TEST_DAEMON_START_TIMEOUT_MS", "60000")

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.

P2: this bound is not on the path that produces "Update now". DIM_TEST_DAEMON_START_TIMEOUT_MS is read only by client::daemon_start_timeout (crates/dim-cli/src/client.rs:202-204) and used only inside connect_inner (crates/dim-cli/src/client.rs:1118-1122, 1247, 1291), which runs at startup via plugins::DaemonLink (crates/dim-cli/src/plugins.rs:72) before open_tui starts the TUI (crates/dim-cli/src/lib.rs:137-147); its only later call is stop_idle_for_update (crates/dim-cli/src/client.rs:781), after the interface has left, past the dialog wait. The four assert_tui_update_case cases drive a fake daemon on a pre-bound socket (staged_update.rs:1272-1326), so the TUI is already connected before this wait. The dialog comes from Update::Upgrade (crates/dim-cli/src/ui/tui.rs:3083) sent by update::available (crates/dim-cli/src/session_host.rs:440-450); its registry check is bounded separately by the existing DIM_TEST_UPDATE_TIMEOUT_MS (staged_update.rs:1351, crates/dim-cli/src/update.rs:24-34) and update::available returns None on any failure (crates/dim-cli/src/update.rs:318-327). The recorded failures (run 44878291869 line 5086, run 44878237932 line 3136) are Terminal did not show "Update now" at cli_harness.rs:893 with a live idle interface transcript, not a closed terminal or a startup error, so a 60 s hello bound cannot change this wait. Find the missing fact (make the check result or offer observable and wait on it, or make the fake registry path deterministic) before claiming the dialog waits are fixed; keep this variable for the flows that start an embedded App Server (assert_history_lock_update at staged_update.rs:1451 and the recovery cases).

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.

Still open at 2474f20. DIM_TEST_APP_SERVER_STARTUP_TIMEOUT_MS (added at staged_update.rs:1356) is read only by dim_app_server::cli::run_with (crates/dim-app-server/src/cli.rs:353-359), which runs in the embedded App Server process. assert_tui_update_case still binds its fake daemon before launch (staged_update.rs:1275-1277), so no App Server process exists and the new variable is inert there. The offer still comes only from update::available (session_host.rs:440-450), which returns None on failure (update.rs:318-327); the four dialog cases still cannot observe why it is missing. The bound is useful for assert_history_lock_update (staged_update.rs:1511) and the recovery cases (:948, :1095, :1186).

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.

Resolved at 84677ff. efd707f removed DIM_TEST_DAEMON_START_TIMEOUT_MS and DIM_TEST_APP_SERVER_STARTUP_TIMEOUT_MS from the fake-daemon assert_tui_update_case builder, so the final PR diff leaves those four cases identical to origin/main and sets both variables only in the history-lock builder and the three recovery builders that start the embedded App Server. The busy/idle/old/cancelled offer failure is now explicitly not claimed fixed and stays under #1919.

"branch part must be dropped after Session teardown (idle unload: {unloading})"
);
let released = released.lock().unwrap().take().expect("branch part built");
tokio::time::timeout(Duration::from_secs(30), released)

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.

P3: this inner 30 s wait sits inside the 30 s outer timeout at storage_session_flow.rs:304, which starts earlier. On a broken flow the outer timer fires first with "session cleanup and durable publication completed", so the specific message here is unreachable. Use one bound, or a shorter inner bound, so the intended diagnostic is the one reported.

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.

Still open at 2474f20: the inner 30 s wait (storage_session_flow.rs:356) is still nested inside the 30 s outer timeout at :304, which starts earlier. On a broken flow the outer fires first with "session cleanup and durable publication completed", so the specific panic at :359-362 is unreachable.

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.

Resolved at 84677ff. The release wait is now 10 s at crates/dim-app-server/tests/storage_session_flow.rs:356, inside the 30 s outer timeout at :304, so the specific branch part must be dropped panic is reachable before the outer bound.

@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.

P2 — The comparison still retains the client-presence row it is meant to ignore. In crates/dim-app-server/tests/transport_flow/collaboration.rs:1271–1290, business_events requires name == "message" and reads data.user and data.blocks. The peer projection emits type, mode, user, and blocks at the top level, with no name or data (serializer). An isolated Rust probe using the serializer shape and exact predicate confirmed a real client-presence row survives. If that row lands between the reads, the ordered arrays still differ; this is the extra append after the completed turn seen in #1952.

Please match the top-level Append input, null user, and exact dim/environment/clients source. Keep the ordered comparison for the remaining rows, and exercise a real serialized presence row so the test proves it can remove that row without hiding reordered or duplicated collaboration events.

Reviewed against ff9212ed05ccd668f2993930620756360da35dd6. The compiled workspace passed on the exact merge. The late Linux CLI check has a separate project-hook marker failure seen before this PR; I am not attributing it to this change. The existing TUI review is separate.

The update and recovery flows start the embedded App Server on the same
loaded machine as the rest of the flow binary. Its ten-second plugin
assembly inactivity bound can expire there, and the daemon exits before
the interface shows the dialog. Add a debug-only startup bound override
next to the existing test hooks, document it, and set it in those flows.

@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.

Review: PR #1971 at 2474f20

Verdict: REQUEST_CHANGES

The new commit adds a debug-only DIM_TEST_APP_SERVER_STARTUP_TIMEOUT_MS override (crates/dim-app-server/src/cli.rs:353-359), sets it in the five update and recovery command builders (crates/dimcode/tests/cli_flow/staged_update.rs:948, :1095, :1186, :1356, :1511), and documents it (crates/dim-cli/README.md:1772). This is a real bound for the flows that start the embedded App Server: assert_history_lock_update and the three recovery cases. It does not change the four assert_tui_update_case cases, which drive a fake daemon that is already listening, so the round-1 P2 remains open and the busy/idle "Update now" failure is still unaddressed. Both round-1 P3s are also unchanged.

P2 (open): the update-dialog bound is still not on the path that produces "Update now"

assert_tui_update_case binds its fake daemon on home/rust/daemon.sock before launching the CLI (crates/dimcode/tests/cli_flow/staged_update.rs:1275-1277) and serves hello, attach, history and providers there (:1279-1330). client::connect_inner connects and adopts that daemon (crates/dim-cli/src/client.rs:1125-1132) and adopt returns the existing link for the matching version and protocol (:866-895), so the spawn branch at :1156-1292 never runs and the App Server's run_with never reads the new variable. The variable is read only there (crates/dim-app-server/src/cli.rs:353-359) and used at initial plugin assembly (crates/dim-app-server/src/lib.rs:1313, :1324) and at agent creation (crates/dim-app-server/src/agents.rs:2021). On a loaded runner the four fake-daemon cases cannot benefit from that bound.

The offer path is unchanged: session_host::run spawns update::available (crates/dim-cli/src/session_host.rs:440-450), whose only bounded step is the registry request under DIM_TEST_UPDATE_TIMEOUT_MS (crates/dim-cli/src/update.rs:26-34), and update::available returns None on every failure (:318-327). Nothing records why it returned None, and the flow still waits only on the rendered text, so a missing offer still ends at the 300 s harness bound (crates/dimcode/tests/support/cli_harness.rs:887, :893).

The recorded failure is unchanged: run 44878291869 (PR #1952 head, Linux), update_now_refuses_a_busy_daemon_and_prints_manual_command, log line 5086, panics with Terminal did not show "Update now" while the transcript shows the live idle interface (resumed session, Ask anything...). A hello timeout or an App Server startup timeout would end the interface before that transcript, so widening either bound cannot change this wait.

Resolution: make the check outcome observable (record why available returned None, or wait on an offer fact) or make the fake registry path deterministic, and drop DIM_TEST_APP_SERVER_STARTUP_TIMEOUT_MS from assert_tui_update_case, where no App Server runs. Keep it for assert_history_lock_update and the recovery cases. If the missing-offer failure stays out of scope for this PR, state that in the PR body and keep it tracked under #1919; the body currently names only a launcher-path race still under investigation, which is a different failure.

P3 (open): the storage-session inner wait shares one budget with the outer timeout

crates/dim-app-server/tests/storage_session_flow.rs:304 starts a 30 s timeout around the whole test. The new inner 30 s wait at :356 starts later, so on a broken flow the outer timer fires first with session cleanup and durable publication completed and the specific panic at :359-362 is unreachable. Use one bound, or a shorter inner bound, so the intended diagnostic is the one reported. Unchanged at 2474f20.

P3 (open): branch_events still polls one fact inside a fixed 10 s window

crates/dim-app-server/tests/transport_flow/branch_events.rs:129-144 still pages history every 10 ms inside a 10 s timeout for the first branch's exec ended fact. That is the pattern this PR removes for exec started at :243-253, and the same loaded runner can delay it. It is pre-existing, not a regression, but waiting on the notice (or letting the client's 30 s read bound be the backstop) would finish the job. Unchanged at 2474f20.

What the delta changed

  • crates/dim-app-server/src/cli.rs: a debug-only override of ServerConfig::startup_timeout from the environment. Release builds ignore it, invalid values are ignored, and no production behavior changes.
  • crates/dimcode/tests/cli_flow/staged_update.rs: the variable is set in all five builders. The three recovery flows and assert_history_lock_update really start the embedded App Server; the four assert_tui_update_case cases do not.
  • crates/dim-cli/README.md: one sentence documenting the variable.
    No other file changed between ec2c735 and 2474f20, and no unrelated or regressive change is present.

Coverage of the replaced waits

  • branch_events: unmatched frames are buffered by Client::response_with_timeout (crates/dim-app-server/tests/transport_flow.rs:350-362) and found by Client::notice (:368-374), so an already-delivered notice is not missed. Every read keeps its own 30 s deadline (:322-344), so a missing fact fails instead of hanging. The assertions on discovered branches and task ids are unchanged.
  • storage_session_flow: the oneshot buffers a signal sent before the receiver is taken, and the Generation sender fires from Drop, so a fast drop is not missed. The wait is bounded, apart from the P3 above.
  • collaboration: business_events still compares full JSON equality of business events and removes only runtime environment state inputs; the nextCursor bound check is unchanged.
  • cli_harness: the new arm maps Linux PTY EIO to a closed terminal, the case the harness already documents, and changes nothing on other platforms.
  • update flows: the waits themselves are unchanged; only the two new bounds were added. See P2.

Checks

All tests ran in an isolated environment (HOME, TMPDIR, XDG config/cache/data and CARGO_TARGET_DIR under the review data directory), with no real credentials.

Command Result
cargo fmt --all -- --check --config error_on_line_overflow=true pass
git diff --check origin/main...HEAD pass
node scripts/adr-check.mjs --base origin/main pass, 7 changed files
cargo check --locked -p dim-app-server -p dimcode --all-targets pass
cargo test -p dim-app-server --test transport_flow restored_task_branches_are_discovered_locally_and_named_stops_preserve_the_leader 1 passed
cargo test -p dim-app-server --test app_server_flow storage_session_flow::session_close_and_idle_unload_persist_finalizers_and_release_branch_parts 1 passed
cargo test -p dim-app-server --test transport_flow native_member_work_absorbs_messages_and_spans_turns 1 passed
cargo test -p dimcode --test cli_flow staged_update::tui_update:: -- --test-threads=3 6 passed
cargo test -p dimcode --test cli_flow staged_update::recovery::a_newer_store_recovers_with_a_compatible_staged_release 1 passed

No test processes were left running.

CI

At 2474f20 the PR check run 44886460072 is still in progress: macos-native, windows-cli and dependencies pass, and verify (linux) has not finished. At ec2c735 the only failing test was hooks::project_hooks_start_disabled_and_the_user_enables_them (crates/dimcode/tests/cli_flow/hooks.rs:497), a known timing flake unrelated to this diff.

Conflicts

  • git merge-tree --write-tree origin/main HEAD: clean (8992437d6).
  • Main is still ff9212e, which is this PR's base, so main has not moved since the previous review.
  • Open PRs touching the same files: #1963, #1917, #1912, #1909, #1905, #1902 and #1900. #1905 and #1902 merge cleanly with this head. The others conflict only in files that already conflict with origin/main (fixture_flow.rs, cli_flow.rs, web-chat-timeline.test.ts, flows.rs, minimal_execution.rs, timeline_tree.rs, branch_flow.rs, the timeline docs, and mcp_session_flow.rs), so this PR adds no conflict of its own. #1952 shares none of the changed files.

Unverified

  • The exact cause of the missing update offer on the loaded Linux runner. The fake-daemon path rules out both new bounds, but I did not reproduce the registry-check failure locally; the busy case passed here.
  • Loaded-runner repetition of the changed tests.

@eric8810

Copy link
Copy Markdown
Collaborator Author

@zerob13 this flake-stability PR is green at 2474f205 (run 44886460072) and needs the second approval; yyhhyyyyyy is also requested. It fixes the update-dialog, branch, storage and collaboration flakes that keep main and #1952 red.

@eric8810

Copy link
Copy Markdown
Collaborator Author

@yyhhyyyyyy this is the flake base for #1952 and #1972; it is green at 2474f205 (run 44886460072) and needs a review. #1972's verify still hits the update-dialog and managed-OAuth flakes that this PR fixes, so landing this first lets that branch rebase and run once. The changes are test waits and test-only bounds, no product behavior on a release build.

@eric8810

Copy link
Copy Markdown
Collaborator Author

Evidence for review: #1972 now stacks this branch, and its verify (linux) is green at 5f4c7074 (run 44899606787) on linux-runner-005. That run exercises these flake fixes together with the hooks fix. #1971 itself is still green at 2474f205.

The peer projection writes type, mode, user and blocks at the top level
without name or data, so the previous predicate never removed the row.
Match the Append input, a null user and the exact environment/clients
source, and keep a unit case with a real serialized presence row plus
duplicate collaboration rows.
The busy, idle, old and cancelled update cases bind their own daemon and
connect to it, so neither the daemon spawn bound nor the embedded App
Server startup bound is on their path. Keep both for the history-lock and
recovery flows, which start the embedded server.
Attach the first client before creating the branches, then wait on the
session.event notice for the branch's completed exec. The history read
after the notice still proves the started fact.
@eric8810

Copy link
Copy Markdown
Collaborator Author

Addressed the open findings at 84677ffd:

  • yyhhyyyyyy P2 (update dialog): removed DIM_TEST_DAEMON_START_TIMEOUT_MS and DIM_TEST_APP_SERVER_STARTUP_TIMEOUT_MS from the four fake-daemon assert_tui_update_case commands; kept both for assert_history_lock_update and the recovery cases, which start the embedded server. The PR body no longer claims the busy/idle/old/cancelled dialog flake is fixed; it stays tracked under Move full PR verification to Linux and keep main CI green #1919.
  • zerob13 P2 (presence row): business_events now matches the serialized top-level Append row — type, mode, null user, blocks with the exact dim/environment/clients source. A new unit test feeds a real serialized presence row and two duplicate collaboration rows, proving only the presence row is removed and order/duplicates survive.
  • P3 storage bound: the inner release bound is 10 s, inside the test's 30 s timeout, so the specific failure message is reachable.
  • P3 branch_events: the first client attaches before the branches are created and waits on the session.event ended notice; the 10 s history-page loop is gone.

Verification at this head: collaboration unit 1/1, branch flow 1/1, storage flow 1/1, collaboration flow 1/1, staged_update::tui_update:: 3/3 runs at three threads, fmt clean. Full transport_flow / app_server_flow were green on the same code before the last two test-only edits.

@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.

Review: PR #1971 at 84677ff

Verdict: APPROVE

The four commits after 2474f20 close both round 2 P2 findings and both P3 findings. The delta is 4 files, +44/-31, all test code; the debug-only App Server startup override added in round 2 is unchanged. I found no new P0, P1 or P2 issue.

Round 2 findings

P2 update-dialog startup bound: resolved as a scoped limitation

efd707f6 removes DIM_TEST_DAEMON_START_TIMEOUT_MS and DIM_TEST_APP_SERVER_STARTUP_TIMEOUT_MS from the fake-daemon assert_tui_update_case builder (crates/dimcode/tests/cli_flow/staged_update.rs:1251). In the final PR diff both variables are set only in the four builders that start the embedded App Server: the three recovery cases at :947, :1094, :1185 and assert_history_lock_update at :1508. The fake-daemon builder is identical to origin/main, so the busy, idle, old and cancelled cases run with the production startup bounds.

The PR body no longer claims to fix the busy/idle/old/cancelled offer failure. It states that the fake daemon is already listening, that neither startup bound is on the offer path, that the offer still depends on the silent registry check, and that the flake stays tracked under #1919. Issue #1919 records the same "Update now never showed" failure as open. This is an accurate scoping of the remaining failure; it does not block this PR.

P2 collaboration client-presence row: resolved

business_events (crates/dim-app-server/tests/transport_flow/collaboration.rs:1271) now matches the peer projection's serialized row: type == "input", mode == "append", a null user, and non-empty blocks whose texts start with <dim-state source="dim/environment/clients". That is the shape emitted at crates/dim-app-server/src/collaboration.rs:1577; effective_mode for a null-user input with no explicit mode is Append (crates/dim-agent-types/src/events.rs:198), and InputBlock::Raw serializes as type: "raw" plus text (:102). A real collaboration input carries a non-null user, so it is kept.

The new unit test at :1294 uses the exact serialized row plus a queued user row and two identical tool_call rows, and proves that only the presence row is removed while order and duplicates survive. native_member_work_absorbs_messages_and_spans_turns exercises the real projection and passes locally and in the Linux CI run, which is the end-to-end proof that the real row is removed. The unit fixture is a JSON literal matching the serializer rather than serializer output; the flow test supplies the real-row coverage, so the requirement is met.

P3 storage release wait: resolved

The inner wait is 10 s at crates/dim-app-server/tests/storage_session_flow.rs:356, inside the 30 s outer timeout at :304, so the specific branch part must be dropped panic at :359 is reachable first. The oneshot fires from Generation::drop, so a fast release is buffered.

P3 branch ended page loop: resolved

6ed23c54 attaches the first client before creating the branches (crates/dim-app-server/tests/transport_flow/branch_events.rs:107) and waits for the branch's completed session.event exec ended notice (:134-145). The attach reply is sent after the subscription is registered, and the branch commands are issued later, so the notice cannot be missed. Client::notice buffers unmatched frames (crates/dim-app-server/tests/transport_flow.rs:350-379) and every read keeps its own 30 s deadline (:322-344). The following history read still asserts the started fact with the notice's task id (branch_events.rs:146-153), and the post-restart assertions still check the ended/completed fact (:216-225), so the coverage of the removed poll is retained.

New findings

No new findings at P0, P1, P2 or P3. The fixture note above is informational and needs no change.

Coverage of the replaced waits

  • branch_events: the attach precedes all branch work, so the notice is live rather than replayed; unmatched frames are buffered, reads are bounded, and the history assertions keep the started and ended facts tied to the same task id.
  • storage_session_flow: a fast drop is buffered by the oneshot, and the new inner bound is shorter than the outer bound.
  • collaboration: the predicate is narrow (exact source, null user, append mode), so user and collaboration rows are preserved; the ordered comparison still fails on any other extra row.
  • update flows: the bounds remain on the four embedded-server builders, and the fake-daemon cases use the production bounds.
  • cli_harness: the Linux EIO arm maps a closed PTY to the existing closed-terminal diagnostic and changes nothing on other platforms.

Checks

All local checks ran in an isolated environment (HOME, TMPDIR, XDG config/cache/data and CARGO_TARGET_DIR under the review data directory), with local fixtures only and no real credentials.

Command Result
cargo fmt --all -- --check --config error_on_line_overflow=true pass
git diff --check origin/main...HEAD pass
node scripts/adr-check.mjs --base origin/main pass, 7 changed files
cargo check --locked -p dim-app-server -p dimcode --all-targets pass
cargo run --locked -p xtask-check pass (743 modules, 4561 edges; boundaries, plugin docs, service declarations, locks, comment links, literal main)
cargo test --locked -p dim-app-server --test transport_flow environment_client_rows_are_ignored_but_collaboration_rows_are_not 1 passed
cargo test --locked -p dim-app-server --test transport_flow restored_task_branches_are_discovered_locally_and_named_stops_preserve_the_leader 1 passed
cargo test --locked -p dim-app-server --test app_server_flow storage_session_flow::session_close_and_idle_unload_persist_finalizers_and_release_branch_parts 1 passed
cargo test --locked -p dim-app-server --test transport_flow native_member_work_absorbs_messages_and_spans_turns 1 passed
cargo test --locked -p dimcode --test cli_flow staged_update::tui_update:: -- --test-threads=3 6 passed
cargo test --locked -p dimcode --test cli_flow staged_update::recovery::a_newer_store_recovers_with_a_compatible_staged_release 1 passed

No test processes were left running.

CI

Run 44902569438 at 84677ff. Attempt 1 had macos-native, windows-cli, dependencies and changes green, static-checks, web and acp-registry skipped, and verify (linux) failed on one unrelated test, goal_product_flow::goal_evaluator_judge_creates_an_evaluator_and_completes_on_done (crates/dim-goal/tests/goal_product_flow.rs:1142). In that same Linux job all changed flows passed, including both update-dialog cases, the branch flow, the collaboration unit and flow, and the storage flow. The run was retried; attempt 2's verify (linux) was still in progress when this review was written, with the other jobs green. I did not wait for it.

Conflicts

  • git merge-tree --write-tree origin/main HEAD: clean (187b405b0).
  • origin/main is 46714db, while the PR's recorded base is still ff9212e, so GitHub shows an older base. The merge tree is clean and no rebase is needed.
  • Open PRs touching these files: #1972 is stacked on 2474f20 and merges cleanly with this head and with origin/main; its files list includes the seven files because the stack inherits the pre-delta versions, not because it edits them. #1917, #1905 and #1902 merge cleanly. #1963, #1912, #1909 and #1900 conflict only in files that also conflict with origin/main, none in this PR's files.

Unverified

  • The root cause of the silent update registry check that drops the offer. It is explicitly out of scope here and stays under #1919.
  • The Linux-only closed-PTY EIO arm in crates/dimcode/tests/support/cli_harness.rs cannot be exercised on macOS; Linux CI covers it only if a flow closes its PTY during a wait.
  • Loaded-runner repetition beyond one Linux CI attempt and the local runs above.

@eric8810

Copy link
Copy Markdown
Collaborator Author

The revised head 84677ffd passes every changed test locally, but verify (linux) has now failed twice on unrelated load flakes:

  • run 44902569438: goal_product_flow::goal_evaluator_judge_creates_an_evaluator_and_completes_on_done (goal/evaluator branch race, unknown branch warning);
  • its rerun: tasks::tui_task_history_resume_windows_complete_pages_and_preserves_the_draft in cli_tui_flow.

Neither target is touched by this PR. Both runs used linux-runner-005 with the current 5 workers × 4 threads on 16 cores. @eric8810 keep rerunning, or should we lower that concurrency in a separate change before landing this? The review findings are addressed at 84677ffd.

@eric8810

Copy link
Copy Markdown
Collaborator Author

@zerob13 your P2 is fixed at 84677ffd: the predicate now matches the serialized top-level Append row (type, mode, null user, blocks with the exact dim/environment/clients source), and environment_client_rows_are_ignored_but_collaboration_rows_are_not feeds a real serialized presence row plus two duplicate collaboration rows. Could you re-review?

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.

3 participants