Skip to content

test: separate native delivery from confirmation deadlines - #406

Open
iainlane wants to merge 2 commits into
serokell:masterfrom
iainlane:codex/confirmation-without-notification
Open

iainlane wants to merge 2 commits into
serokell:masterfrom
iainlane:codex/confirmation-without-notification

Conversation

@iainlane

@iainlane iainlane commented Oct 6, 2026 •

Copy link
Copy Markdown

The native confirmation watcher test can fail on Darwin even though the watcher delivers the correct notification. The test creates and immediately removes the confirmation canary, then gives danger_zone one second to receive WaitEvent::Confirmed. That deadline also requires the operating system to deliver the native callback within one second.

The failure from upstream cf64c8c is:

thread 'tests::confirmation_watcher_observes_immediate_canary_removal' (137448906) panicked at src/bin/activate.rs:422:36:
observe canary removal: TimesUp
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

In a failing diagnostic run, FSEventStreamStart returned success and danger_zone returned Err(TimesUp) at the original one-second deadline. Keeping the watcher alive for three further seconds exposed the matching Remove(File) callback. Notify accepted the canonical canary path. The original failure was retained: the diagnostic did not extend the deadline or turn the failed assertion into a pass.

That trace demonstrates late delivery in this run. FSEvents notification latency is non-deterministic on a multitasking operating system. The production confirmation timeout defaults to 30 seconds; this investigation has not reproduced a failure at that default.

In the tests, separate the native notification test from the confirmation deadline. The previous wallclock deadline was prone to tripping on slow/loaded systems, making the test appear flaky. To help with this, the integration test now awaits the watcher channel directly and requires WaitEvent::Confirmed, without such a deadline. Behaviour isn't changed - it still creates and removes the canary immediately, and the watcher still requires the matching removal event and path. However, since we're removing the wallclock deadline, we need another way to cap test runs. So in CI we're adding a sixty-minute watchdog to stop a stalled build or test run.

Test the confirmation policy separately from native delivery latency. Five direct tests use a paused Tokio clock and cover confirmation, cancellation, watcher errors, channel closure and timeout. The timeout test requires expiry at exactly the configured seven-second deadline. Tokio's test-util feature is a development dependency; the lockfile and production dependencies are unchanged.

Activation confirmation waits for a file watcher to report removal of
the canary. On Darwin, the immediate-removal test can time out after the
canary has already been deleted because the watcher reports no event.

Keep the watcher and also inspect the canary within the existing
confirmation deadline. Only confirm when the canary entry is absent and
its parent directory still exists. Inspection errors return an error,
and a dangling symlink remains pending. The general wait and cancellation
paths are unchanged.

Add deterministic tests for removal without a notification, later
removal, a persistent canary, inspection errors, a missing parent and a
dangling symlink. The original missed-event and parent-removal failures
are reproduced before the correction. The full patched package suites
pass on Darwin and Linux with 17 library and 11 activation tests each.
The native canary-removal test can report TimesUp because it requires
FSEvents to deliver a callback within one second. A failing diagnostic
retained the original timeout and then received the matching removal
callback after that deadline. The observed failure was late delivery,
not evidence that confirmation handling lost the notification.

Remove the polling fallback and restore upstream production behaviour.
Have the native integration test await the watcher channel directly,
without a wallclock deadline. The test still requires the actual
confirmation event after immediately creating and removing the canary.
If the watcher never delivers confirmation, the test remains pending
until the test runner is stopped. Set a sixty-minute watchdog on the CI
check job so CI stops a stalled build or test run.

Test confirmation, cancellation, watcher errors, channel closure and
timeout separately with a paused Tokio clock. The timeout test requires
expiry at exactly the configured seven-second deadline. Enable Tokio's
test-util feature only for development; the lockfile and production
dependencies remain unchanged.

The focused Darwin suite passes all ten activation tests. The retained
red trace shows the original timeout followed by the matching native
removal callback. Pinned Rust formatting also passes.
@iainlane iainlane changed the title Handle missed activation confirmation notifications test: separate native delivery from confirmation deadlines Oct 6, 2026
@iainlane
iainlane marked this pull request as ready for review October 6, 2026 22:16
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