Skip to content

test(agent): steady-state 'ready' signal to kill the startup-timing flake class - #279

Open
LiorFink00 wants to merge 1 commit into
mainfrom
test/agent-steady-state-signal
Open

test(agent): steady-state 'ready' signal to kill the startup-timing flake class#279
LiorFink00 wants to merge 1 commit into
mainfrom
test/agent-steady-state-signal

Conversation

@LiorFink00

Copy link
Copy Markdown
Collaborator

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_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's 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 also 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, which is exactly the bug).
  • 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, 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.
  • All four migrated tests: 10/10 stress rounds (40 runs) clean.
  • Full suite 375 passed, 1 skipped; ruff + shellcheck clean.
  • Real-endpoint behavior unchanged — a real reader hits a steady-state agent, never this startup window.

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

…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
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.

test infra: add an 'agent steady-state' signal to kill the startup-timing flake class

1 participant