test(git-watch): make auto-sync watcher tests deterministic#285
Merged
Conversation
Two root causes, two fixes. Tier A (debounce_loop_coalesces_and_drains, source_file_edit_triggers_no_sync): genuinely clock-racing on real tokio sleeps -> tokio paused-time (start_paused) + a cfg(test)-gated entered_debounce Notify seam so the test waits on an observable readiness signal instead of a fixed sleep, then advances time to drive the coalesce deadline. Tier B (fifty_commit_rebase, deleted_branch GC, concurrent single-flight, ensure_watching, disabled_watcher): not clock-fragile at all -- resource-starvation timeouts under parallel load -> nextest slow-timeout/test-group config, assertions unchanged. No release-build behavior change. Verified 8/8 under stress. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Collapse duplicated state lookup into ready_registered_state, signal entered_debounce once before the debounce loop, and trim restating comments.
This was referenced Jul 5, 2026
Closed
Merged
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.
The git_watch timing tests (from #280's auto-sync, now in master) intermittently redden any PR's CI under parallel load — they surfaced on #284 and would keep recurring. This fixes them at the root.
Two root causes (the earlier "all timing flakes" read was wrong)
A workflow diagnosis split the 7 tests cleanly:
Tier A — genuinely clock-racing (
debounce_loop_coalesces_and_drains_events,source_file_edit_triggers_no_sync): the debounce loop runs on realtokio::time::sleep, and the tests faked "has the watcher entered the loop yet?" with a fixedsleep(200ms)and drained on a real 3s timeout — both break under scheduler stalls. Fix:#[tokio::test(start_paused = true)]+ a#[cfg(test)]-gatedentered_debounceNotify seam onWatchState(fired once just before the loop'snotified().await), so the test waits on an observable readiness signal thenadvance()s time to deterministically drive the coalesce deadline. Every guarantee preserved (coalescing = exactly-one-drain-to-clean; no-source-sync = last_sync unchanged after time advanced past both deadlines — strictly stronger than a real sleep).Tier B — not clock-fragile at all (
fifty_commit_rebase_needs_one_sync,deleted_branch_store_is_garbage_collected,concurrent_syncs_are_single_flight,ensure_watching_registers_dedups_and_caps,disabled_watcher_never_registers): no sleep/Instant/now() anywhere — they do real git + extraction work and get starved against nextest's slow-timeout under load. Fix: a nextest slow-timeout/test-group adjustment in.config/nextest.toml— assertions untouched.No behavior change
The only product-code change is the
#[cfg(test)]-gated seam (a module-private struct field, zero release-build effect).Verified
Workflow verify: 8/8 stress runs, lib green, clippy clean. My independent re-stress of the flakiest test: 5/5. CI running.
Recovery: session `2c51d204-…`, workflow `wf_310146b1-bf3`, fact 41.
🤖 Generated with Claude Code