test(agent): steady-state 'ready' signal to kill the startup-timing flake class - #279
Open
LiorFink00 wants to merge 1 commit into
Open
test(agent): steady-state 'ready' signal to kill the startup-timing flake class#279LiorFink00 wants to merge 1 commit into
LiorFink00 wants to merge 1 commit into
Conversation
…lake class Closes #237. A whole class of macOS flakes shared one root cause: a test acted immediately after a weak readiness gate (a bare "armed?" check), racing the agent's sub-second startup - e.g. simulating an atime read before atime_poll had captured its baseline, so the read was captured AS the baseline and missed. Agent: each watcher now emits a single unambiguous steady-state signal once it is fully up - workers spawned AND (for atime) baselines captured: - mark_ready(): writes a `ready` marker + logs "watcher ready", from watch_fifo / watch_mixed / atime_poll / watch_inotify. This makes the ephemeral `ready` marker accurate in every mode (it was previously written in the main flow right after start_watcher returned - before the backgrounded watcher had armed). - mark_armed(): bumps an `atime_armed` generation after EACH baseline (re)capture, so a test can wait past a specific re-arm instead of a blind sleep (the arm->baseline window is a genuine race, #235). Tests: a shared helper (tests/agent_ready.py: wait_ready / wait_atime_gen) replaces the ad-hoc "armed?" gates + sleep(2) settles in the four flaky tests (atime rearm, mixed plant+fire, ephemeral terminate, live-sync reconcile). Verified: the rearm test was 0/15 flaky before under local stress; now 15/15, and all four migrated tests pass 10/10 stress rounds. Full suite: 375 passed, ruff + shellcheck clean. Agent behavior for real endpoints is unchanged (a real reader hits a steady-state agent, never this startup window). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018DARDAxeg4NM8FKoyGMQZy
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.
What
Closes #237. A whole class of macOS flakes this cycle shared one root cause: a test acted immediately after a weak readiness gate (a bare "armed?" check), racing the agent's sub-second startup — e.g. simulating an atime read before
atime_pollhad captured its baseline, so the read was captured as the baseline and missed.Agent
Each watcher now emits a single unambiguous steady-state signal once it's fully up — workers spawned AND (for atime) baselines captured:
mark_ready()— writes areadymarker + logswatcher ready, fromwatch_fifo/watch_mixed/atime_poll/watch_inotify. This also makes the ephemeralreadymarker accurate in every mode (it was previously written in the main flow right afterstart_watcherreturned — before the backgrounded watcher had armed, which is exactly the bug).mark_armed()— bumps anatime_armedgeneration after each baseline (re)capture, so a test can wait past a specific re-arm instead of a blindsleep(the arm→baseline window is a genuine race, agent: atime_poll can swallow a read in the arm→baseline-capture window #235).Tests
A shared helper (
tests/agent_ready.py:wait_ready/wait_atime_gen) replaces the ad-hoc "armed?" gates +sleep(2)settles in the four flaky tests: atime rearm, mixed plant+fire, ephemeral terminate, live-sync reconcile.Verification
test_atime_sensor_is_rearmable: 0/15 flaky before under local stress → 15/15 after.This should end the recurring macOS flake that has repeatedly blocked merges this cycle (it forced re-runs on #268, #272, #258, and others).
🤖 Generated with Claude Code