fix: remove wall-clock-timing races from 3 flaky zeph-core tests - #6685
Merged
Conversation
after_tool_hooks_run_concurrently_across_tier_indices and pre_tool_use_hooks_fire_concurrently_across_tier_indices inferred hook concurrency from elapsed time vs N * per-task-delay, which spuriously failed under CI load. Replaced with structural proofs: an atomic max-in-flight high-water mark for the in-process hook path, and a two-phase rendezvous/witness barrier for the subprocess-based hook path (serial dispatch can never satisfy the barrier, so it fails deterministically instead of racing a fixed sleep against subprocess- start spread). dump_request_smoke_returns_promptly_and_write_still_lands raced a 50ms wall-clock budget to prove dump_request returns before its spawn_blocking write completes. Replaced with a test-only TestWriteGate channel handshake (30s bound, so a regression to an inline write path fails with a clear panic instead of hanging the CI shard). Closes #6679
This was referenced Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three tests inferred concurrency or non-blocking behavior from fixed wall-clock thresholds, which spuriously failed under CI load (confirmed on two consecutive GitHub Actions runs of the same commit on PR #6678):
after_tool_hooks_run_concurrently_across_tier_indices(apply_tier_results_tests.rs) — replaced the elapsed-time-vs-N*delaycomparison with an atomic max-in-flight high-water mark around the in-processRuntimeLayer::after_toolcalls. Serial execution can never exceed 1, somax_in_flight == nis a sound structural proof.pre_tool_use_hooks_fire_concurrently_across_tier_indices(pre_tool_use_concurrency_tests.rs,#[cfg(unix)]) —PreToolUsehooks run as real subprocesses with no shared in-process memory, so this uses a two-phase rendezvous/witness barrier instead: every hook must individually observe allNmarkers present before creating a witness file, which serial dispatch can never satisfy. This replaced an earlier marker-file-poller draft that still raced a fixed sleep against subprocess-start spread (caught in review — the original CI failure showed ~980ms spread for 4x60ms hooks, exactly the kind of assumption this rewrite removes).dump_request_smoke_returns_promptly_and_write_still_lands->dump_request_returns_before_blocking_write_completes(debug_dump/mod.rs) — replaced a 50ms wall-clock budget with a test-onlyTestWriteGatechannel handshake (30s bound, so a regression to an inline write path fails with a clear panic instead of hanging the CI shard) that provesdump_requestreturns before itsspawn_blockingwrite completes, with no timing race window at all.No production behavior changed — only test assertions/instrumentation, plus a
#[cfg(test)]-only field onDebugDumper.Closes #6679
Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins(15154 passed, 0 failed)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler")#[cfg(unix)]gating is complete