Skip to content

test(git-watch): make auto-sync watcher tests deterministic#285

Merged
ScriptedAlchemy merged 8 commits into
masterfrom
fix/git-watch-test-determinism
Jul 5, 2026
Merged

test(git-watch): make auto-sync watcher tests deterministic#285
ScriptedAlchemy merged 8 commits into
masterfrom
fix/git-watch-test-determinism

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

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 real tokio::time::sleep, and the tests faked "has the watcher entered the loop yet?" with a fixed sleep(200ms) and drained on a real 3s timeout — both break under scheduler stalls. Fix: #[tokio::test(start_paused = true)] + a #[cfg(test)]-gated entered_debounce Notify seam on WatchState (fired once just before the loop's notified().await), so the test waits on an observable readiness signal then advance()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

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>
@changeset-bot

changeset-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 873687e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@ScriptedAlchemy ScriptedAlchemy merged commit b6a5cd9 into master Jul 5, 2026
16 checks passed
This was referenced Jul 5, 2026
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.

1 participant