Repository navigation
fix(autonudge): wake when the judge sheds a fresh row instead of judging it quiet - #16192
Conversation
…ing it quiet The wake judge read each session target 12 rows per tick from its cursor, so a worker writing faster than that left the cursor behind and its DONE line was never screened until the quiet-streak floor fired. The 40-item and 8000-char caps also shed fresh rows silently, oldest first. A session target is now paged to its end, up to 3 pages a tick; both caps shed already-seen items before fresh ones; and any fresh item a cap still drops, or a target left behind after the last page, wakes the tick. Fixes #16151
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The second commit wakes every new judged loop on its first tick: any target with more than 12 rows of history fires, and the description never mentions it. Watch
[DESIGN-REVIEWED] a13369e Description read[DESCRIPTION-READ] f65f67b7d051068caa0d33f2f5efdeb69a98e981934b8c51430c7eafde1fbb79 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The second commit's "skipped" rule makes every first judged tick wake once a target has more than 12 rows, so a reset now forces a turn, not just a re-read. Not justified as shipped
What this change shipsInventory (8 items) — 6 justifiedIntent: a judged loop wakes on the tick a busy worker writes
[FIRST-PRINCIPLES-REVIEWED] a13369e Description read[DESCRIPTION-READ] 07cc8e0bde8405fe616500284b1ca09c90ec20a761b43003634292e62072c473 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsAdvisory finding only; nothing blocks. FINDING — src/kiro_crew/autonudge_judge.py:856 — The first tick always fires on a target with more history than one page (more than 12 rows), or with a trimmed prefix, whenever no cursor is stored. That covers every fresh arm, every brief update ( [OPUS-REVIEWED] a13369e Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
A first read with no cursor starts at the tail and never sees the rows before it, so a target with more history than one page is now reported as behind and wakes the loop instead of being judged quiet. Drop issue numbers from the comments the comment-history gate flags.
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] a13369e Description read[DESCRIPTION-READ] 805163fd5a21b892c49b40659da4ec6ccb5d8d42d93965e4e16b37d2a3928a65 That sha256 names everything this verdict read: the PR description, plus the 43 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Problem / Motivation
Goal: a judged auto-nudge loop wakes on the tick a worker writes
DONE:,BLOCKED:or a question, however busy that worker is.The wake judge reads each
chat-*target 12 rows per tick, starting at its cursor. A worker that writes more than 12 rows between ticks (tool rows count) leaves the cursor further behind every tick, so its finalDONE:line is never offered to the judge. The judge answers quiet, and the loop wakes only when the quiet-streak floor (_MAX_QUIET_STREAK = 10) fires: five hours at a 30-minute interval. Two later caps lose rows the same way:screen_evidencekeeps at most 40 items andbuild_stateat most 8000 characters, and both shed fresh rows the cursor has already passed, so those rows are never offered again either. Reported in #16151.Why it matters
A conductor patrolling workers with a judge sleeps through finished, blocked and questioning workers for hours, and nothing tells it a row was lost: the tick reads as an honest quiet.
Not a goal
work-ledger, PR or plain-timer paths; they do not read transcripts.What changed (motivation -> approach -> change)
Observed symptom -> root cause -> change.
The cursor promises every row is screened once, while the three caps drop rows past the cursor without saying so. Only the scrub path (
scrub_fresh) and an unreadable target already wake on a loss. This PR applies that one rule to the other three: a fresh row that does not reach the judge wakes the tick.collect_evidencereads a session target again fromnext_sincewhile it is short of the transcript'stotal, up toMAX_PAGES_PER_TARGETpages (3, derived asMAX_EVIDENCE_ITEMS // MAX_ROWS_PER_TARGET, so the walk never exceeds what the item cap can carry). A target still behind after the last page is counted as unread, which fires the tick. A page that refuses keeps the pages already read. The gateway's_read_sessionreturnstotalbeside the rows and cursor.screen_evidence(40 items) and_shed_index(8000 characters) drop items marked seen on an earlier tick before any fresh item. A seen item is context the judge already answered about; a fresh session row is never offered again.shed_fresh.judge_tickwakes whenshed_fresh > 0, through the same exitscrub_freshuses.rfc-wake-judge(on main,status: partial) gains the paging rule in thesessionevidence entry and the seen-first order plus theshed_freshwake in the shed-order paragraph.Backwards compatibility
Compatible: the only
read_sessioncaller is the gateway's_read_session, changed in this PR to return the extratotal. A loop whose evidence fits its caps judges exactly as before. A loop whose fresh evidence does not fit wakes where it judged quiet.Removes nothing: no field, route, record or capability is removed; the caps still shed, only the order and the wake on a fresh loss change.
Tests
New
TestNothingNewIsLostAndJudgedCalmintest/test_autonudge_wake_judge.py:test_a_busy_target_is_paged_to_its_end_so_the_last_line_is_read: 29 new rows, the last aDONE:line, are all collected in one tick.test_a_target_still_behind_after_the_page_budget_is_dropped: a target past the 3-page budget counts as unread and the tick falls back to a wake.test_a_page_that_refuses_keeps_the_pages_already_read: a refusal on a later page keeps the earlier pages.test_the_page_budget_stays_inside_the_points_item_walk: pages x rows never exceeds the 40-item cap.test_the_item_cap_sheds_seen_items_before_fresh_onesandtest_the_item_cap_counts_every_fresh_item_it_sheds.test_the_char_budget_sheds_seen_items_firstandtest_the_char_budget_counts_a_fresh_item_it_sheds.test_a_busy_worker_whose_rows_do_not_fit_fires_the_tick: a fresh shed wakesjudge_tick.test_shedding_only_seen_context_does_not_take_the_shed_exit: dropping only seen context stays quiet, so a busy loop does not wake every tick on old rows.test/test_autonudge_wake_judge.py: 305 passed. With the six other suites that touch the judge and nudge-wake point: 946 passed. mypy, flake8, black, isort on the changed files: clean.scripts/docs_lint.py: passes.Manual verification
N/A -- the judge has no UI; the tests drive
collect_evidence,screen_evidence,build_stateandjudge_tickwith real row shapes.Related Issues
Fixes #16151
Other suggestions
The judge polls transcripts for session evidence. #16149 (merged) gives the crew-log bus keyed subscriptions with a late-join baseline. Session evidence could later come from a keyed session subscription instead of a transcript poll; that is a design change for
rfc-wake-judge, not this fix.Pattern harvest
Rule candidate: review-prompt
Pattern: a bounded read or cap that drops rows a cursor has already passed must report the loss, never let the caller treat the result as complete.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement