Repository navigation
Conversation
tests/hermes_cli/test_pty_session.py::test_reaper_loop_invokes_reap starts the reaper at interval=0.01, sleeps 0.05, then asserts the reap counter >= 2. On a loaded CI runner that stopwatch measures the machine rather than the reaper: we observed "assert 1 >= 2" on a PR that touches no pty code at all. Tests only — hermes_cli/pty_session.py is untouched; no production seam needed. - test_reaper_loop_invokes_reap now awaits an asyncio.Event the fake reap_idle sets on its second call, under a 10s wait_for hang guard. The witness is the iteration COUNT reached, so load costs time, never correctness. - The four sibling drain tests in the same file replace fixed asyncio.sleep(0.05) budgets with a wait_until(predicate) helper that polls the exact fact each test asserts (buffer contents / socket close code). Converting the whole family in one pass keeps the file from taxing unrelated PRs later. The one remaining sleep(0.05) in the file is deliberately left alone: it precedes an assertion that something did NOT happen, so load only makes it more permissive. RED proofs, each red naming the new witness rather than an incidental error: - run_reaper "while True" -> "for _ in range(1)": AssertionError: reaper loop only invoked reap_idle 1 time(s) - _drain "self.buffer.append(chunk)" -> pass: 3 failures, all "timed out after 10.0s waiting for the drain task to buffer ..." GREEN before and after each mutation: 16 passed.
This branch has not been deployed
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.
Defect
tests/hermes_cli/test_pty_session.py::test_reaper_loop_invokes_reapis a wall-clock flake. It starts the reaper atinterval=0.01, sleeps0.05, then asserts the reap counter>= 2:On a loaded CI runner that stopwatch measures the machine, not the reaper. We hit
assert 1 >= 2on a PR that touches no pty code at all (agent/credential_pool.pyonly) — the test reds out other people's work.Conversion
Tests only —
hermes_cli/pty_session.pyis untouched; no production seam was needed.test_reaper_loop_invokes_reapnow awaits anasyncio.Eventthe fakereap_idlesets on its second call, under a 10swait_forhang guard. The witness is the iteration count reached, so load costs time, never correctness.asyncio.sleep(0.05)budgets with await_until(predicate)helper that polls the exact fact each test asserts (buffer contents / socket close code). Converting the whole family in one pass keeps the file from taxing unrelated PRs later.The one remaining
sleep(0.05)in the file is deliberately left alone: it precedes an assertion that something did not happen (s.attached is True,last_detached_at is None), so load only makes it more permissive.RED proofs
Each mutation's red names the new witness, not an incidental error. Production restored and re-verified green after each.
run_reaperwhile True→for _ in range(1)AssertionError: reaper loop only invoked reap_idle 1 time(s)_drainself.buffer.append(chunk)→passtimed out after 10.0s waiting for the drain task to buffer ...Verification
Also verified under load on the equivalent file in our downstream tree: 20/20 green for the reaper test and 20/20 for the whole file with 64 CPU burners on 32 cores (load average 14 → 75).