Repository navigation
test(native): anchor watcher test bounds to an observed native delivery (HACK-2748) - #1284
Conversation
…ry (HACK-2748) The native watcher tests gave the watcher 8 s from the change to report it. FSEvents promises delivery, not latency: on a loaded Mac the same tests spent seconds waiting for one rename, and in one full-suite run nothing from the burst arrived within 8 s. That bound measured the host, not the watcher. Each test now arms an independent control watcher first, then the watcher under test. The control's delivery is the observed event; after it the watcher under test must report the change within the original 8 s. The host's own delivery gets a 120 s hang guard; production `source sync --watch` has no latency bound at all. A watcher that arms late or drops the change still fails: pointing the watcher under test at a sibling directory fails both tests with "the watcher missed a change the control observed". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
HACK-2748
Root cause
Both native watcher tests gave the watcher 8 s, counted from the change, to report it. FSEvents promises delivery, not latency, so that bound measured the host rather than the watcher.
Evidence from the failing run (macOS, full
--all-featuressuite):fseventsd. Then nothing arrived for the whole 8 s, and the watcher was dropped 8.1 s later when the assertion failed. The next test's watcher got its rename 0.28 s after it registered.I checked whether the watcher can actually lose a burst. I found no evidence that it can:
SourceWatcherSourceWatcher, with and without loadfseventsdadd_clientlog line falls insideFSEventStreamStart, so the watch is armed beforeSourceWatcher::newreturns.fseventsddrops eventsfseventsdsendsUserDropped | MustScanSubDirsfor both watched roots.notifypasses both as rescans, so the watcher wakes withreconcile_required.notifypurging events when it stops a streamFSEventsPurgeEventsForDeviceUpToEventIdfails for non-root users (it is logged as failed in every run), so one stream cannot purge another's events.Change (test only)
Each test now arms two watchers on the source root: an independent control first, then the watcher under test. After the change, the test waits for the control. The control's delivery is the observed event. From that point the watcher under test must report the change within the original 8 s. The host's own delivery gets a 120 s hang guard. This is not a product contract: production
source sync --watchhas no latency bound and keeps waiting.The test still proves what it proved before. A watcher that arms late or drops the change still fails. As a mutation check, I pointed the watcher under test at a sibling directory, and both tests failed in 8.4 s with
the watcher missed a change the control observed after 50ms. The burst test still checkssource_changedand the complete 256-file inventory.The single-rename test had the same 8 s pattern and the same latency on that Mac, so it uses the same helper.
Evidence
cargo +1.97.1 fmt --check: clean.-D warnings, default features and--all-features, all targets: clean.--all-features --no-fail-fastruntime-core suite on macOS, withnextmerged in: 34 binaries, 3031 passed, 2 failed, 189 ignored.project_contractpassed 81/81 in 1.07 s, including both watcher tests. The 2 failures are outside this change, and each passes when run alone:provider::registry_credentials::tests::helper_descendants_holding_stdout_cannot_extend_the_bounded_wait:helper recorded no descendant(registry_credentials.rs:628).graph_cli::relay::tests::review_digest_binds_configuration_and_live_listener_generation:AddrInUse(relay.rs:506).nextwas merged in stopped at the HACK-2743 FIFO tests, which fix(native): make the hostname authority FIFO and Caddy-stop tests deterministic (HACK-2743) #1281 has since fixed.next: both watcher tests 20/20 again under the same load, and fmt and both clippy runs clean.bun run privacy:checkafter staging: ok.Remaining gap
notify8.2.0 ignores the return value ofFSEventStreamStart. If registration fails, the result is a watch that silently never fires. That Mac's log for the last 3 days shows no FSEvents registration errors, so this did not cause the failure, and this PR does not change it.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.