Repository navigation
Conversation
…uiet gate (awslabs#1367) While agy sits at its ready prompt it repeats one 39-byte block of terminal-mode sequences (ESC[?2004h ESC[?1004h ESC[?1003h ESC[?1006h ESC[>4;2m). Measured on a live idle pane: 60 arrivals in 125 s, 1.99 to 2.21 s apart, so always inside the 3 s STALE_PROCESSING_BUFFER_QUIET_S gate. Each arrival reset the gate and dropped the pending capture candidate, so a composite that still read PROCESSING never reached the capture-pane fallback (awslabs#558) and was never corrected. With the pyte screen in use, _feed_screen_locked now reports whether the chunk changed the text of any row. For each row pyte marked dirty it compares the row's written non-blank cells with the last ones it saw, so the cost follows what the row holds rather than the 400-column width. A chunk that changes no text is still appended to the rolling buffer and still advances the output generation, but it no longer resets the quiet gate, advances the capture generation or drops a candidate. A terminal's first chunk still starts the gate's clock, a failed comparison counts as a change, and raw detection (no screen) is unchanged. Colour-only changes on unchanged text count as no change, because status detection reads text only. - test/providers/fixtures/agy_idle_mode_block_timed.json: the recorded block and its arrival times (no text, no identity). - test/services/test_status_monitor_idle_mode_output.py: on a fake clock, the real monitor, compositor and agy provider replay the recorded working turn and then the measured idle arrivals. get_status() must heal to COMPLETED within 10 s through capture-pane. Controls: real output at the same cadence keeps the gate shut with no capture, raw-detection providers count every chunk, and a table of chunk kinds pins what counts as a change (mode block, cursor move, colour with and without text, same and new character, erase, clear and redraw in one chunk and in two, scroll with identical and with moved rows, and the same rule for another screen provider). Co-authored-by: Kiro Agent <244629292+kiro-agent@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1486 +/- ##
=======================================
Coverage ? 94.40%
=======================================
Files ? 309
Lines ? 60703
Branches ? 9880
=======================================
Hits ? 57308
Misses ? 3395
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #1367
Refs #1375.
Refs #1484.
What this fixes
While
agysits at its ready prompt it repeats one 39-byte block of terminal-mode sequences (ESC[?2004h ESC[?1004h ESC[?1003h ESC[?1006h ESC[>4;2m). The block changes no screen cell, but each arrival reset the status monitor's 3 s quiet gate (STALE_PROCESSING_BUFFER_QUIET_S) and dropped the pending capture candidate. So a composite that still read PROCESSING never reached thecapture-panefallback from #558 and was never corrected. #1322 fixed the cause of #1321's wrong composite. This fixes the gate, so the next compositor defect cannot stall a seat the same way.The recording (step 1 of the issue's plan)
An idle
antigravity_cliseat, read-only for 125 s with timestamps: 60 arrivals, all the same 39 bytes, 1.99 to 2.21 s apart (mean 2.10 s). Every gap is inside the 3 s gate. The block and its arrival times are intest/providers/fixtures/agy_idle_mode_block_timed.json. The bytes hold no text or identity, so nothing needed scrubbing, and the PII guard passes.The change (step 3)
With the pyte screen in use,
_feed_screen_lockednow returns whether the chunk changed the text of any row. For each row pyte marked dirty, it compares the row's written non-blank cells with the last ones it saw. A mode block marks no row, so it costs nothing extra. Feeding the recorded agy turn (91,357 chars) is within noise ofmain(31.1 ms vs 30.4 ms, 512-char chunks). The worst case is ms-scale: about 2 to 3 ms per chunk on a quiet machine, up to roughly 11 ms on a loaded one, and only for a fully painted 200x400 screen scrolled on every chunk (main: 0.01 to 0.15 ms). A chunk that changes no text:A terminal's first chunk still starts the gate's clock. A failed comparison counts as a change. Raw detection (no screen) is unchanged.
Trade-off, as the issue states it: a chunk that changes only modes, the cursor or the colour of unchanged text no longer counts as activity. Status detection reads text only, so this matches what the gate is for. A TUI that animates only by colour on unchanged text, or only through its terminal title, therefore leaves the gate open while it is PROCESSING. That costs one
capture-panesubprocess about every 3 s (STALE_PROCESSING_CAPTURE_INTERVAL_S), and the two-read confirm still protects the verdict. "No provider known to do this" was checked for agy only.The test (step 2)
test/services/test_status_monitor_idle_mode_output.pyruns on a fake clock with the realStatusMonitor, the real pyte compositor and the real agy provider. It replays the recorded working turn (agy_turn_end_stale_esc_to_cancel.txt, cut at "ready for input", which reads PROCESSING), then the measured idle arrivals, pollingget_status()every second. Onlycapture-paneis faked, and it returns the ready screen of the same turn.get_status()must reach COMPLETED within 10 s.What is measured and what is inferred:
agy_turn_end_stale_esc_to_cancel.txt). That agy emits the same block at the same cadence right after a turn ends is inferred, not recorded.There are three controls:
claude_code.Before / after (on
mainat6234f1f5, 2026-11-24)pytest test/services/test_status_monitor_idle_mode_output.py -q --no-covmain6234f1f5(new test and fixture copied on)On
mainthe heal test fails with:get_status() stayed PROCESSING for the whole recording: the mode block reset the quiet gate on each of its 60 arrivals (0 capture-pane reads). The 9 tests that pass onmainare the controls and the rows where a change is expected.Gates
pytest test/services test/providers -m "not e2e" -n auto --no-cov, tempHOME, fromgit archiveextractions ofmain(6234f1f) and this branch, alternating, one run at a time, 10 runs each:mainThere is no evidence of a B2 effect at 10 against 10 (5 of 10 against 3 of 10 runs with a failure, Fisher p about 0.65), and the failing tests do not exercise
status_monitor. No id repeated, but the*.mcp.jsonfake-home family (parameter sets oftest_terminal_identity_forwarding) failed on both sides. The failures are in tests that this change does not touch:*.mcp.jsonunder the fake home that xdist workers share (#1459 gives each worker its own), the FIFO reader's file descriptor intest_fifo_reader, the 0.1 s loop-stall bound intest_startup_handler_nonblockingunder load, and the #1458 teardown race (#1463).mainflakedtest_fifo_reader::test_data_received_across_writer_reconnectsin an earlier pass as well. At 10 runs against 10, 3 against 5 is within noise.An earlier pass of three runs per tree showed 4 failures on this branch and none on
main. The 10-run comparison does not reproduce that, so I no longer think this change is linked to them.black, isort and ruff pass on the changed files, and
mypy_ratchet.pypasses on 0574733 (61 fewer errors than the baseline).Lost dispatch: pre-existing, not changed here
When a submission is dropped after
notify_input_sentand the pane keeps showing the previous ready screen,started_on_last_inputreads True at about 1.0 s onmain, and the status readscompleted. This holds with and without mode-only chunks. The path is the quiescence screen detection, which reads the stale ready screen and stamps it above the dispatch boundary. It is not thecapture-panefallback this PR changes.I checked it on both trees with the same deterministic test (real
StatusMonitor, pyte and agy provider on a fake clock; finished turn,notify_input_sent(assume_processing=True), buffer cleared asdispatch_inputdoes, pane unchanged, the recorded mode block every ~2.1 s, polled every second for 60 s). It fails the same way onmain(6234f1f) and on this branch: first started at 1.0 s, final statuscompleted. With no chunks at all (a quiet pane) neither tree reads started. This PR does not change that behaviour, and the test is not part of it because it fails onmain.Overlap with #1437
#1437 (another author; head
cbff1830, open, GitHub reports itCONFLICTING) also editsservices/status_monitor.py. Checked on 2026-11-23:status_monitor.pydiff applies tomain79aa1a36(git apply --checkexit 0). On this branch, a strictgit apply --checkfails at hunk 2 (@@ -599): the hunk adds_releases_waiting_on_processingjust above_feed_screen_locked, and its trailing context isdef _feed_screen_locked(...) -> None:, which this PR changes to-> bool.status_monitor.py: this PR first, then fix(status_monitor): let an opted-in provider release waiting_user_answer when a prompt answered in the pane resumes work #1437, or fix(status_monitor): let an opted-in provider release waiting_user_answer when a prompt answered in the pane resumes work #1437 first, then this PR rebased.main,CHANGELOG.mdand twotest/providersfiles, resolved to fix(status_monitor): let an opted-in provider release waiting_user_answer when a prompt answered in the pane resumes work #1437's side), this PR's tests,test_status_monitor.pyand fix(status_monitor): let an opted-in provider release waiting_user_answer when a prompt answered in the pane resumes work #1437's Kiro tests give397 passed.-> boolsignature and docstring.Not covered: whether other providers send screen-neutral idle output. This change does not depend on it.
Co-authored-by: Kiro Agent 244629292+kiro-agent@users.noreply.github.com