Repository navigation
fix(subagent): clear an owed expiry report only on a delivery ack - #20508
Conversation
95fa989 to
410fe47
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that every gateway route that really delivers sets What this change shipsInventory (6 items) — 6 justifiedIntent: after a restart, the parent still hears that a memory-wait spawn expired and will never run. This is a FIX (#16861).
[FIRST-PRINCIPLES-REVIEWED] 410fe47 Description read[DESCRIPTION-READ] d392cc6d4c99d6dfa10a055977299de1438edf2dd7ef6fc43f8e441fdf854fd2 That sha256 names the PR description this verdict read. Recompute it with |
|
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that every delivering route sets [DESIGN-REVIEWED] 410fe47 Description read[DESCRIPTION-READ] dd52a32778f38627e73f445f508c34efb5b9cace282d8fbc347101d411f6ffa3 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 |
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 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
Problem / Motivation
Goal: A memory-wait expiry's owed report is cleared only when the gateway says it delivered the report, so no current or future gateway path can drop it across a restart.
Today
taskq_clear_owed_report_if_deliveredclears the store's owed mark when the report task returned True and none of_digest_held,_delivery_queued,_report_undeliveredis set. That is a guess from missing flags. A gateway route that parks or swallows the report without setting one of them would clear the mark while the parent was never told, and a restart then drops the expiry for good. Deferred from #16347 (Design Review).Why it matters
The expiry report is the parent's only word that a spawn will never run: it has no run folder for orphan recovery to find. Any new delivery route in the gateway (channel, cron, digest, announce) that forgets to set a "parked" flag silently loses it. A positive ack makes the safe outcome the default.
Not a goal
report_owedfromSubagentDeliveryon the digest and queued-announce paths. Those reports are delivered later, by a settle that only holds ids, so they still need the debt carried with them; their settles are unchanged.deliveredtombstone is written._report_undeliveredkeeps that job.What changed (motivation → approach → change)
Symptom: the owed mark is cleared on the absence of flags. Cause: there is no positive signal from where the report lands. Change: a new
SubagentInfo._report_deliveredflag insubagent.py. Inslack/gateway.pyit is set where a report reaches the parent: after the parent's injected turn returns, when the blocking tool already collected it inline, and when a route has no conversation so the notice is the whole delivery. Insubagent_manager/terminal.pythe reporter sets it when nothing consumes reports, and when the parent was retired. The direct clear (subagent_manager/admission/taskq_bridge.py) and the digest settle (subagent_manager/waves.py) now clear only on that flag. The flag is classified as not delivery state in the routing table, anddocs/system-specs/modules/subagent.mdis updated.Backwards compatibility
Compatible: every route that delivered before now sets the ack, and every parked or failed route still leaves the mark owed; the only new outcome is "owed" for a route that sets nothing.
Removes nothing:
_report_undeliveredstays and still gates thedeliveredtombstone; no key, record or reader is dropped.Tests
test_a_report_parked_without_an_acknowledgement_stays_owed(new): an_on_donethat returns normally and sets no flag leaves the expiry owed. Red on main (the old three-flag check clears it), green here.on_donenow acknowledges, like a real delivering route.test/test_subagent_queue_max_wait.pyrun 3 times with-n 4and once in shuffled order, 48 passed each time.Manual verification
N/A: the change is internal store bookkeeping, covered end to end by the gateway-through tests in
test_subagent_queue_max_wait.py.Related Issues
Closes #16861
Pattern harvest
Rule candidate: review-prompt
Pattern: "done" inferred from the absence of every known failure flag instead of a positive ack set where the work lands.
Checklist