Repository navigation
feat(ledger): resolve slot keys and wire eight session emitters - #11185
Conversation
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Child-closer repair rests on the module's most fragile cross-thread protocol to write a closer whose absence readers must already tolerate — weigh whether it earns its cost. WatchThe The PR corrects SuggestionsItems 7 and 9's residual (unattributed spend when the owning session is torn down) recurs by construction; if a third instance appears, that is the signal to pin the id at scheduling time rather than accept another named absence. [DESIGN-REVIEWED] 372a0ca |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Background-spend logging is a point patch — the identical per-session summary call in Not justified as shipped
What this change shipsInventory (10 items) — 8 justifiedIntent: record in the session ledger the approvals, plans, background spend and subagent lifecycle the gateway already performs — an ADDITION (flag-off, log-only), under RFC
[FIRST-PRINCIPLES-REVIEWED] 372a0ca |
GPT 5.6 Review (fork) — 🔴 changes requested (blocking)Reviewed 1 of 2 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands. BLOCKING -- src/kiro_crew/llm_helpers.py:1934 -- Idle-expiry consolidation resolves ownership after session removal BLOCKING -- src/kiro_crew/crew_log/emit.py:3530 -- Origin cap silently evicts accepted queued children [BLOCK-MERGE] 372a0ca Adjudication (Opus 4.8) — is blocking on each finding proportionate?I have what I need. Both findings verified against the diff (changed lines) and base tree. F2 — F1 (fenced) — [ADJUDICATION] 372a0ca total=1 uphold=0 downgrade=1 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed Review detailsI've traced the one candidate to ground. The candidate flags Falsification: the only route to No findings. [OPUS-REVIEWED] 372a0ca |
be4ce08 to
c2e7216
Compare
c2e7216 to
ecfb435
Compare
ecfb435 to
e790a9d
Compare
e790a9d to
62f7cb7
Compare
Owner disposition: Stop-triggered rejection recorded as a human decisionThe review lane's finding on The mechanism, verified in code. Why it is not fixed in this PR. Every existing host deny cause -- timeout, no-budget, The fix, so it is not re-derived. Add a per-approval-id set on the slot, write the id into it Residual risk, stated plainly. A user pressing Stop while a tool approval is pending has that Accepted by the owner (Raymond) as a known limitation for this PR. The lane's red stays up rather |
Owner disposition: idle-expiry consolidation spend is not attributedThe review lane's finding on The mechanism. A memory consolidation scheduled by idle expiry runs after the slot's teardown Why it is not fixed here. The lane's remedy -- pin the provider session id before scheduling and Why an omission and not a wrong entry. The alternative to omitting is to resolve the key later Residual risk, stated plainly. Memory consolidation triggered by idle expiry is billed but not Accepted by the owner (Raymond) as a known limitation for this PR, alongside the cold-title case it |
|
/ai-review override gpt 4ad2154: The sole blocking finding (idle-expiry consolidation spend on history_consolidation.py resolving to no ACP session id after teardown) is a reachable but deliberately-accepted limitation documented in the PR body's Other suggestions items 2 and 7 -- the prescribed remedy (resolve the session id later, after teardown) reopens the exact wrong-attribution defect an earlier round of this same lane made the author fix, trading a visible absence for a confident wrong attribution in an append-only file that nothing rewrites, which is strictly worse for every reader. |
|
AI-review override not recorded: keep the reason to 500 characters or fewer. |
|
/ai-review override gpt 4ad2154: The one blocking finding (idle-expiry consolidation spend unattributed in history_consolidation.py) is a deliberately-accepted limitation documented in the PR body Other suggestions 2 and 7: the prescribed fix (resolve the session id after teardown) reopens the wrong-attribution defect an earlier round of this same lane made the author fix, trading a visible absence for a confident wrong attribution in an append-only file nothing rewrites -- strictly worse for readers. |
Human judgment recorded@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
Human judgment recorded, but the following reviewer lane(s) could not be re-run automatically: GPT 5.6. Re-run the lane's latest workflow run for |
Owner disposition: a claim-unavailable spawn records no asking turnThe review lane's finding on The mechanism. A spawn raised during a live turn can find no admission claim available. That exit What it costs, and what it does not. The lane's own adjudicator reached the same reading and flagged it rather than upholding it: "the A correction to my own comment. The comment beside that Why the fix is not in this PR. The remedy is small and correct -- pin the dispatch before Residual, stated plainly. A subagent spawned during a live turn that waits for an admission claim The finding sits behind the security fence, which keeps it blocking whatever the adjudication says, |
|
Superseded: F1 is fixed on My earlier disposition placed this in a follow-up PR. That is withdrawn: the fix is
It also retires the false premise I reported in the disposition above. The comment in Verification: 1046 focused tests pass; two mutations killed (drop the pin -- the new The crew log stays default-off behind |
|
Owner disposition -- F1 on The finding says
The prescribed fix -- derive the duration from The fence keeps this blocking whatever the adjudication says, and the fork lane ignores The crew log stays default-off behind |
|
Rebased onto #11310 retired ten names from the session vocabulary (
One test change came out of the rebase rather than the conflict. #11310 added Verification on the rebased tree: 734 focused tests over the files #11310 also touched The crew log stays default-off behind |
|
Owner disposition -- F1 on What is true: the debt check is keyed by session, not by What is not true is "never reconsidered". The repair reads the FILE: That deferral is the direction this design chose on purpose, and the same function's docstring The prescribed fix -- suppress only when this child's own terminal is owed -- needs a per-agent The fence keeps this blocking whatever the adjudication says, and the fork lane ignores The crew log stays default-off behind |
|
Red classification for
Earlier reds on the superseded heads are gone rather than merely quiet: the four |
|
Rebased onto the crew-log rename (#11549). New head Four conflicts, and the rule for all of them was the same: keep what this branch changes, in the
The two new files landed in the new layout: Verification after the rename: 802 tests over the crew-log suites plus the steer guard, the approval The crew log stays default-off behind |
|
Red classification for Three main-owned test groups, each reproduced on pristine
The other review lanes on this head: Opus 4.8, Code Review and Security Scope green; Design Review |
|
Owner disposition for The finding's prescribed fix is a session-scoped data home for these tests. That is not a local change to one fixture; it is a different isolation contract for the suite, and it costs the property the current one buys. Why a shared home breaks these tests. All 44 tests in the file read one path, What the residue path actually requires. The write reaches the real home only if it lands after
Why the shape is not this PR's to change. The fixture is the same barrier The fence keeps this blocking regardless, and this lane's comment carries no override command. A repository writer owns that call; the reasoning above is the record for it. |
|
New red on The failing step is Evidence that it is not this PR's:
Why it surfaced now rather than on the commit that created it: the gate reads Not fixed here: adding tests for a cgroup-reaping module is unrelated to a crew-log resolver, and the gate's own message forbids the alternative ("do not extend the baseline"). It needs a main-side change that raises that file's coverage, tracked separately. |
|
Owner disposition -- GPT 5.6 on Both findings are left standing. F1 is already dispositioned in the body; F2 is new to the board and is declined on its merits, traced below. Posted as a comment rather than a body edit because 14 checks are still in flight on this head and an F1 -- F2 -- It is declined because the prescribed fix has two halves and neither is a mechanical move. Per-queued-message origin state cannot change what this entry says. One merged continuation is one dispatch and Omitting What makes the residual bounded is the entry the lane's own adjudication names: Residual, stated plainly: when several follow-ups from different turns merge into one continuation, that continuation's One imprecision in my own tree, recorded rather than left silent: the comment at the Both findings are security-class fenced, so this lane consumes no override marker and the red stands until a repository writer clears it after verifying the rationale themselves. |
|
/ai-review override gpt 965e2f1: Recoverable, the third test, verified in code on this head rather than taken from the machine rationale. F1: persist_token_record_async writes the spend on its own path inside the same usage_has_billing gate (llm_helpers.py:1509-1525), so a missing mirror entry never loses a billing record. F2: _record_crew_log_steer(info, "follow_up") at continuation.py:802 records each ask at the turn that made it, so a merged spawn naming the last turn loses no causation. |
Human judgment recorded@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
Human judgment recorded, but the following reviewer lane(s) could not be re-run automatically: GPT 5.6. Re-run the lane's latest workflow run for |
…t that unlocks The emitter keys every entry by an ACP session id. Several sites that produce facts about a session hold only a key -- a background model call charged to it, a subagent it spawned, its own task list -- so eight of the schema's families had no emitter. `crew_log.resolve` closes that gap with two synchronous reads: the slot's live ACP client during a turn, and the session registry otherwise. It never consults the persisted session map, whose `get` prunes a stale entry, and it answers "unknown" rather than guessing. The resolver answers a question about the PRESENT -- which unit a slot's work is landing in now -- because a reset, an agent or model switch, a compaction and a provider swap all tear the ACP session down and the successor cold-starts a new id. So anything that outlives the moment it asked must carry the answer rather than ask again, and both new emit paths do: * a background call resolves its owner BEFORE the model call and writes to that pin in the teardown. Resolving at teardown would hand the spend to a successor session that never incurred it, silently, in a file nothing rewrites. What that misses -- a call charged to a session whose ACP session is already gone reaches no unit -- the emitter spec now states, along with why resolving later would be worse rather than better. * a child is pinned when its spawn is ACCEPTED, which is the only moment the asking turn is knowable, and its entry is written when the run actually STARTS. A queued follow-up cannot use the live reading at all -- its watcher dispatches after the continued run finished -- so its asking turn is pinned where the follow-up was requested and carried to the dispatch, the same way `_preassigned_id` and the inherited context groups already ride that call. An opener and its closer are bound by control flow rather than by convention, because an unclosed pair in an append-only file cannot be repaired later: * `approval/requested` is written one statement before the try whose `finally` writes the decision, not at the future's registration further up. Everything between the two is cancellable -- the Slack mirror awaits a network post, and its `except Exception` cannot catch the CancelledError slot deletion raises -- so an entry written up there could escape that try and leave a request nothing ever decides. The cost is that a prompt cancelled during its Slack delivery goes unrecorded, which is a fact missing rather than a pair got wrong. * a child's pin carries an `opened` flag, set only where the run really starts, so a spawn declined at the approval gate -- which returns through the finalize claim without ever reaching `_run` -- leaves no opener, and no steer or outcome can appear without its cause. Eight families now write: `approval/requested` and `approval/decided`, which never needed the resolver because the prompt is raised inside the runner's turn where the session id and ordinal are already in scope, and whose decision is recorded at the one `finally` every exit converges on; `subagent/spawned|steered|completed|failed`, into the PARENT's log; `background/completed` for `title`, `summary` and `memory_consolidation`, from the same point the background helpers already record usage, so a call reaches a session's log exactly when it reaches the account's bill; and `plan/updated`, inside the slot's own change gate. Every field is absent rather than placeheld when its site observed nothing. A spawn from a slash command, a cron or a hook has no asking turn, and turns are numbered from one, so `turn` is omitted rather than written as a `0` naming a turn that never existed -- the same choice `model/selected` already makes. `tool` and `reason` on an approval, `model` and `agent` on a spawn, and a background call's unbilled token dimensions all follow the same rule. Bounds are measured, never assumed. A plan entry is capped by COUNT and by BYTES, through the store's own serializer, because `ensure_ascii` spends six bytes on a BMP character and twelve on a surrogate pair: a dozen separately-legal rows of emoji serialize past the entry ceiling, where the append is refused and the whole update disappears. Both caps keep the real count in `total`. The flag buys silence, not just a skipped write. `on_plan_updated` and `on_approval_requested` check it themselves, because both do real work -- a redaction per task, a serialize probe per admitted row -- before `_write` gets its own chance to no-op, and the runner calls both unconditionally. Every subagent and background emitter is guarded at its caller instead, so with the feature off none of them is reached at all. Three of the design's claims turned out to be wrong and the specs now say so rather than promising a schedule: * `subagent/spawned` carries no `ref`. No subagent path opens a log, so the citation would name a file that does not exist -- indistinguishable, to a reader, from one that was deleted. * `subagent/completed` carries no `tokens` and no `credits`. Nothing in that runtime measures either, and a zero would present an absent measurement as a measurement of zero. * `tool/searched`, `tool/loaded`, `skill/searched` and `skill/loaded` stay unwritten because the backend CLI's built-in tools DO reach the gateway, as ordinary tool-call frames, so those calls are already recorded. A second entry would put one fact at two seqs. `summary/written`, `remote/placed|lost`, the `digest` background kind and `message/steered` stay unwritten for their own stated reasons, each now in the Emitter column instead of a dash. Four rows of the schema table are corrected to match the frozen code: the approval pair's field is `approval_id`, never `id`, and the fields the emitters omit are marked optional rather than shown as always present. `reason`, `by` and `cause` are new optional fields; `by` and `cause` are written only for a decline the host itself made, which is the one decision the site can attribute. Everything stays behind KIROCREW_CREW_LOG; the default is off.
|
Owner disposition -- GPT 5.6 on No code push for either finding; this is the PR's agreed stopping point on code. F1 points at an existing body item. F2 is real, was downgraded by the adjudication, and it exposes a wrong sentence in my own body item 6, which I am recording here rather than letting stand. F1 -- F2 -- The part that matters for this PR's honesty is the consequence, and here my own body text is wrong. Item 6 says the bound "prefers a finished child, and any remaining loss is counted". The first half holds. The second does not for this case: in The effect of an evicted pin is bounded, which is why the remedy was judged disproportionate rather than the finding waved off: Residual, stated plainly: with more than 2048 origin pins alive at once, a child still queued can have its pin dropped as if it had finished, its spawn and terminal entries are then both absent, and that particular drop is not counted. It changes no control decision and stays inside one user's own log. The wording of item 6 will be corrected in the body the next time an edit is safe. It is not edited now because ten checks are still in flight on this head and a body edit fires Both lanes on this head are fenced or review-side, so no override marker applies and the red stands until a repository writer clears it after verifying these rationales themselves. |
Problem / Motivation
The session ledger that #10091 shipped defines 34 entry types and writes 17 of them. The other 17 are schema-only: their shape is frozen and documented, and no code emits them.
Eight of those describe work the gateway does on a user's behalf and currently leaves no trace of:
#10091 gave one reason for leaving them out, and it was an identity problem. The emitter keys every entry by an ACP session id, which the turn path has in hand. Skill injection, background model calls and subagent dispatch hold only the key naming a slot, so they had no way to say which ledger their fact belonged in.
Why it matters
Two of these gaps are about money and consent. A background model call spends the user's budget without being asked, and until now that spend appeared in the usage store with nothing in the session it was charged to. An approval is the one moment the agent stops and asks permission; a log that omits both the request and the answer cannot reconstruct what the user agreed to.
The subagent gap is about work that is invisible after the fact. A session can dispatch children that run for half an hour, and the parent's log said nothing about having done so.
The remaining nine types stay unwritten, and this PR replaces "deferred" in their Emitter column with the specific reason each one is not derivable, so the next contributor does not re-litigate a decision or, worse, add a second emitter for a fact already recorded.
What changed (motivation, approach, change)
Goal. Wire the eight types whose facts the gateway can actually observe, and say plainly why the other nine cannot be.
Approach. The identity gap turned out to be smaller than #10091 assumed, and investigating it changed the shape of this PR three times:
_run_chat, where the session id and turn number are already in scope. feat(ledger): append-only per-unit ledgers with a lifecycle writer #10091's note saidApprovalCoordinatorholds only a slot key -- true of that class, but the sites that raise and decide an approval are not in it.src/kiro_crew/crew_log.resolve.py: one exact registry read plus an attribute read on the provider it returns, andUNKNOWNwhen the slot has no live ACP session. There is deliberately no slot-keyed level: an earlier draft read the slot's live_acp_clientfirst and fell back to the registry, but the registry answers the same id during a turn as between turns -- the provider it holds IS the one the runner reads -- so that level had no caller and no question only it could answer. It is read-only and builds no index. The persistedSessionMapis deliberately not consulted -- itsgetrepairs or removes a stale entry, which is a write, and it answers only for ids that reached disk, so it would miss exactly the live session a caller is asking about.tool_search,skill_searchand reading a skill file already arrive as ordinary ACP tool-call frames, sotool/calledrecords them today. A second entry would put one fact under two seqs.subagent/spawnedcarries noref; arefwritten now would cite a file that does not exist, which a reader cannot tell from one that was deleted. It becomes writable unchanged the day subagent sessions get ledgers.What this builds. One rule governs every emitter here: an entry says only what was observed at its emit site. Three consequences did real work:
_log_spawned, the codebase's own "this run is really starting" funnel, is what opens it. A spawn declined at the approval gate leaves no opener, and the closers are gated on opened so they close nothing. A queued member re-entering the spawn path keeps its original asking turn.plan/updatedclips each task's text by characters, but the store serializes withensure_ascii, which spends six bytes on a BMP character and twelve on a surrogate pair. A hundred separately-legal rows of emoji serialized past the entry ceiling, where the append is refused and the whole update disappears. Each row is now measured through the store's own serializer before it is admitted, andtotalstill reports the real count.Zero is never written as a measurement.
subagent/completedcarries notokensand nocreditsbecause nothing in the subagent runtime measures either; a spawn with no asking turn omitsturnrather than writing0, since turns are numbered from one.Everything stays behind
KIROCREW_CREW_LOG, default off, and the two emitters the runner calls unconditionally now return before doing any work when the flag is off.Log-only: no projections, no fold, no endpoint, no UI.
This implements merged RFC #10090 (
docs/request-for-change/rfc-append-only-ledger.md) and follows #10091 (merged as 69aeb28).Tests
37 new tests in
test/test_crew_log_resolver.py, plus the existing shape-contract test intest/test_crew_log_emit.pyextended to pin the eight new types.What they lock in, by area:
UNKNOWN; a raising registry answersUNKNOWNinstead of propagating; a bare slot name is retried in dashboard form but a key that already carries a namespace is never rewritten; resolution reads only live state.plan/updated-- only the two states the stream carries; no task list writes nothing while an empty list records a cleared plan; a plan of emoji is bounded by bytes and still lands; one oversize row does not suppress the whole entry; a clipped plan still reports its real size; the entry is marked ignorable.background/completed-- records the dimensions that were billed and omits the rest; names no turn; a call with no owner or no kind writes nothing; the owner is resolved before the call, not after it.ref; a spawn with no asking turn omits the field; a completed child reports no tokens and no credits; a stopped child is not recorded as a completion; an origin is pinned once so a queued member keeps its asking turn; a pin is invisible until the run actually starts; opening twice cannot produce two openers; a declined spawn releases its pin and closes nothing; forgetting an opened origin returns it once; an unrecorded dispatch produces no closer; the origin map is bounded by uptime rather than by live turns.Every one of those assertions is mutation-verified: 20 mutations, each inverting one behaviour the diff introduced, all 20 killed. Two mutations written in an earlier round were discarded honestly rather than counted -- one anchored to two call sites, and one that could not fail because an empty session id already no-ops a layer lower.
Full local run on this head: 1013 focused tests plus 199 in the remaining ledger suites, 0 failures;
mypy src/kiro_crew/clean over 1548 files; black 26.3.1 (diff-scoped), isort, flake8, comment-history (gated onorigin/main) and docs-lint all pass.Manual verification
N/A -- unit coverage sufficient. Every emitter is a pure function of values already in scope at its site, and the site wiring is one line each; there is no integration path, external service or UI surface that unit coverage does not reach. The feature is off by default, so there is no runtime behaviour to exercise without setting the flag.
Other suggestions
Three things a reviewer may want to weigh in on:
crew-log-core.mdsection 5 disagreed with the frozen code on the approval types. The table said{turn, id, tool, reason}; the shipped and tested function takesapproval_idand had neitherreasonnorby. Renames are forbidden by the freeze, so the table was corrected to match the code, andreason,byandcausewere added as optional parameters, which is additive. Flagging it because a spec correcting itself to the code is worth a second pair of eyes.A background call charged to a session whose ACP session is already gone is not recorded. Resolving later would find some session, but on the only interleaving where late resolution succeeds and early resolution fails, the session it finds was created after the call was ordered -- so the spend would be attributed to work that did not cause it. In an append-only file a confident wrong attribution is worse than a visible absence, so the limitation is named in the spec rather than papered over.
A local review lane suggested tightening
"done" if task.get("completed")to... is True, in case the field arrives as a truthy non-bool. It is declined and recorded here instead: the field is a JSON boolean on this stream, where both forms agree, and the stricter form would make a real1read asopen-- wrong in the opposite direction. It is left as the maintainer's call.A review lane's finding on the child closer is FIXED, in the emitter AND in the order the terminal path writes. Between a child's
info.donebecoming true and its terminal entry reaching the file, the manager stops listing it, so a resume repair entering that window could writeoutcome: "unknown"ahead of the real outcome and leave two outcomes for oneagent_idin a file nothing rewrites. The submit that carries a terminal entry returns before the entry lands, so the manager's run map cannot answer this on its own, and its completed-run retention is bounded by a policy that evicts the oldest by start time, so a long-running child that has just finished can be dropped from it too. The emitter answers instead, because it is the one component that knows what it still owes: it reports no child of a session gone while an entry for that session is outstanding, and the debt set holds a queued entry, one the writer has claimed out of the queue and not yet attempted, a retained one, and an owed loss marker alike. An entry a hard ceiling refuses is absent from that set, which is the wanted answer, because that closer is never coming and the opener is the repair's to close. The terminal path carries the other half: the entry is handed to the writer BEFOREinfo.doneflips. An earlier revision of this item argued the two statements were adjacent and so the gap was unobservable -- that holds only for tasks on the event loop, and the component that reads it is the crew log's writer, which drains on its own thread and can therefore land between them. Recording first means the debt exists by the time the child leaves the running set, so the probe refuses on one or the other at every instant; the order is pinned by a test that reads the function, because a test on the calling thread cannot schedule itself into the writer's window.Function-local
crew_log.emitimports are kept over thetop-level-importsadvisory. They are the convention here rather than an exception to it -- 18 function-local against 5 module-scope, including the sites that merged with the first PR in this series -- and at module scope every gateway start would import the ledger store whether or not the flag is set.The child-origin pin map's bound is FIXED to prefer a finished child, and a live child's pin is never dropped without being counted. A review lane was right that
_child_originholds at most 2048 pins and evicted the oldest blindly, so an accepted child's attribution could go: itssubagent/spawnedabsent when the pin went before the run started, its opener left unmatched when the pin went after. Nothing releases the pin of a child a crash took, so those accumulate and the bound was reachable across long uptime rather than only by that many children genuinely running. The cap now asks the liveness probe over a bounded window of the oldest pins and drops a FINISHED child's pin in preference -- the entries that pin could still carry are never coming, so dropping it costs nothing, and the same step is what reclaims the pins of children lost to a crash. Only when every candidate is still running does the oldest go, and then the drop is counted inlost_child_origins()and named in the log once, beside the writer's other loss counts. No entry is written for it and no schema field was added: no declared type describes a lost pin, and adding one would be a shape change made to record a bug rather than a fact of the session. The lane's own remedy -- hold every pin to its terminal and gate admission before the bound is exceeded -- is deliberately NOT taken: this is a default-off log, and a log that refuses a real subagent spawn to protect its own bookkeeping has become the more expensive failure. Residual, stated plainly, in two parts. With 2048 children running at once and none of them finished, one live pin is still dropped -- bounded, and visible in the counter and the log rather than silent. And a child still WAITING in the admission queue is absent from the manager's run map, which is registered at dispatch, so the probe reports it as not running and it is dropped through the preference branch instead: that drop is not counted, because only the fallback increments the counter. Both cost a matched PAIR of entries rather than a contradiction -- an emptied pin makes every caller bail, so neither an opener nor a closer is written -- and both need more than 2048 pins alive at once, since the reap only runs above the ceiling. A second bound was added at the same point of retention after a later review round: the session id a pin carries is authored by the provider, and a cap on the NUMBER of pins bounds memory only when each pin's own fields are bounded too, so an id longer than the declared maximum is refused and counted through the same counter. It is refused rather than shortened because an identity that has been cut down names a different unit or none at all. The maximum sits far above any id this codebase produces, so it rejects nothing legitimate.A review lane's finding that a cold session's title spend goes unrecorded is real, but its prescribed fix is declined because it reopens a defect the same lane made me fix. On a first send to a new chat the auto-title call can run before the foreground ACP session is registered, so the slot key resolves to no session id and the emitter's empty-id no-op drops that spend entry: the tokens are billed and the log does not say so. The lane's remedy is to resolve and pass the session id after
get_or_createregisters it -- that is, LATER. An earlier round of the same lane found the opposite defect on this exact path and the fix for it was to hoist the resolution ABOVE the first suspension point, because the acquisition can take the background runtime lock and start a runtime, and a slot reset, switch or compaction inside that window gives the successor a new session id -- so a late lookup files the spend against a session that never incurred it. Taking the new remedy would trade a visible absence for a confident wrong attribution in a file nothing rewrites, which is the worse of the two for every reader. The absence is therefore accepted and named here, with the residual stated: a title generated before its session registers is not attributed, and the spend is visible in usage accounting rather than in this log.A review lane found that a Stop-triggered rejection was recorded as a human decision, and it is FIXED.
approval/decided.byexists to tell a host decision from a person's, and an absentbyis defined here as a person's answer. The dashboard Stop path resolves each pending approval with an ordinary"rejected"and raises nothing, so neither the auto-decline cause nor the cancellation flag was set and the closer named nobody -- writing a host stop into an append-only file as a refusal someone made. The earlier cancellation fix covered only the fallback path; this is the primary one. Every other host cause is detected by the awaiting code itself and is a local variable, while Stop is detected outside the runner, so the provenance is carried on the slot: the ids a Stop rejected are recorded where it resolves the future -- that site already knows, since it logs the same fact to SEL asrejected_on_stop-- and the runner reads one id and DISCARDS it at the emit. Per id rather than a slot-wide flag, so a later human rejection on the same slot cannot inherit the attribution, and marked before the future resolves, since resolving can wake the reader at once. Nocauseis borrowed for it: that vocabulary renders user-facing denial text and falls back to the policy wording, so a name from it would put a sentence about policy in front of someone who simply pressed Stop.by="host"with no cause is what the schema allows and what is true.A review lane's finding that idle-expiry consolidation loses its ledger charge is real, and it is the same cause as item 7 rather than a new one. A memory consolidation scheduled by idle expiry runs after the slot's teardown has begun. The call is charged by session key, and the resolver answers only what is true when it is asked: once the reset has removed the provider there is no ACP session id for that key, so the resolver returns empty and the emitter's empty-id no-op drops the entry -- the tokens are billed and this log does not say so. The lane's remedy, pinning the id before scheduling and passing it through consolidation, is right in principle for this path, because a session being expired is exactly the one that should be charged; carrying it there means threading a resolved id through the consolidation call path as a new parameter, in a subsystem this PR otherwise only adds emit calls to, and this PR has reached its agreed change budget. Resolving later instead is refused for the reason item 7 gives: an earlier round of this same lane made me hoist resolution above the first suspension point, because a reset, switch or compaction inside that window gives the successor a new session id and a late lookup files the spend against a session that never incurred it. Residual, stated plainly: a consolidation triggered by idle expiry is billed and not recorded here. It is bounded to that trigger -- a consolidation on a live session resolves normally -- it changes no control decision, and the spend stays visible in usage accounting. The lane's red is left standing rather than argued away.
A review lane found that a spawn was recorded before its startup prerequisites succeeded, and it is FIXED. The
subagent/spawnedentry was written on entry to the confirmed-start funnel, ahead of the write that persists the run's memory binding. When that write fails the run never allocates a provider and settles as a failure, so the entry stated a start that did not happen. It now sits past that write, beside the stat that counts a confirmed start for the same reason. Nothing is left dangling by the earlier exit: the pin is released by the terminal report, and a pin that was never opened closes nothing, so a run that could not persist its binding writes no opener and no closer rather than a pair describing a run that never began.A review lane's finding that a suppressed follow-up is recorded as a steer is real, and it is left standing because the fix decides what the entry MEANS. A queued follow-up is recorded when
spawn_steeraccepts it, which is also what the reply promises the caller:queued, with its watcher armed. If the user then stops the run, the watcher takes theuser_stoppedbranch, announces a synthetic failure and never dispatches the continuation -- and no compensating entry lands, because the run's real terminal already released the pin, so a second announce for the sameagent_idwrites nothing. The lane's remedy, recording at dispatch instead, is not a relocation: several queued messages drain as ONE continuation, so N accepted corrections would become one entry, and a follow-up accepted before a restart would be absent from the log the caller was told it was queued in. Choosing between accepted and delivered as the meaning ofsubagent/steeredis a decision about the frozen vocabulary, not a mechanical move, and it is deliberately not made under this PR's change budget. Residual, stated plainly: a follow-up accepted and then suppressed by a user stop reads in the crew log as a steer that happened, with the run's own failure entry nearby but not linked to it. It changes no control decision, and the suppression is recorded in the audit log asfollowup_suppressed.A review lane found that a plan task's id skipped redaction, and it is FIXED. The text of a task went through the redactor and its id did not, while the write path applies no entry-level redaction of its own -- it hands the row to the append as it stands. A task id is as agent-authored as the text beside it, so a credential echoed into one persisted verbatim in a file nothing rewrites. The id now goes through the same redactor, stringified FIRST because the redactor answers a non-string with the empty string and every numeric id would otherwise be erased. An ordinary id is untouched, which the test asserts beside the redacted case.
A review lane found the child-liveness debt check blind to a batch the writer had already claimed, and it is FIXED -- in two steps, because the first fix suppressed the very repair it protects. The writer takes a session's owed entries OUT of the queue before it appends them, so between that claim and the last append those entries were in none of the three places the check looked: a caller asking whether this process still owed the session anything was told no, and the repair could write an
unknownoutcome ahead of a real terminal sitting in the batch. Counting the claimed entries fixed that and introduced the opposite fault, which the next review round caught: a resume submits its own open-and-repair work through the same writer, so the repair runs INSIDE a claimed batch and was reading its own job as debt -- every child looked live on exactly the path the repair exists for, and a dangling opener would never have been closed. The count is therefore per ENTRY and an entry stops counting as it is ATTEMPTED, so the job doing the asking is never among the ones it waits for, while everything behind it still is. Whatever a pass does not reach is released on the way out, where each of those entries is already written, dropped with a loss marker, or back in the queue -- so no count is carried twice and none is dropped. The inline ordering path reads the same predicate and keeps its own separate gate on the writer being busy, so nothing can slip ahead of a batch in flight.A review lane's finding that merged follow-ups name only the last asking turn is real, and it is left standing because its remedy either loses information or changes the frozen vocabulary. Each queued follow-up is appended to the same run, and the origin pin holds one
(session, turn)pair, so two asks from different turns produce one continuation whosesubagent/spawnednames the later turn. The lane's first remedy, per-message origin state, cannot change what this entry says: one merged continuation is one dispatch and the entry carries oneturn, so richer upstream state still collapses to a single field unless that field becomes list-valued, which is a vocabulary change rather than a change to this code. Its second, omittingturnwhen a continuation spans turns, removes information rather than adding it: today a reader learns the most recent ask, after the change they learn nothing about any ask, and the dropped turn is not recovered elsewhere. What bounds the residual is that every individual ask is recorded assubagent/steeredat the turn that made it, before the pin is overwritten, so turn 2's causation is in the file in turn 2's bracket under the sameagent_ida reader groups a child's entries by. Residual, stated plainly: when several follow-ups from different turns merge, that continuation's spawn entry names the last asking turn and not the earlier ones. It changes no control decision, and each ask stays recorded at its own turn. The call-site comment now says which turn a merged dispatch names.A review lane found the child-liveness probe could close a child whose closer was not yet written, and it is FIXED -- in two steps, because my first attempt rested on a premise the code does not support. The probe answers from two reads in different lock domains. I first reordered them, arguing that a child seen gone must already owe its closer because the terminal path records before flipping
done. The lane's next round showed that is false on the path that matters: normal completion flipsdonein the run loop, the manager's running set is everything not done, and the terminal entry is handed over later from the report task -- so between them the child is neither running nor owed, and either read order says gone. I traced both sites before accepting it. The reorder stays because it is still the correct order, but what closes the window is the child's OWN origin pin: it is opened when the spawn is recorded and the probe now refuses while it is held, and the terminal path releases it AFTER handing the closer to the writer rather than before, so the writer's debt takes over from the pin with no instant in between. Reporting stays one-shot without the pin pop, because every route to the terminal report is gated on_claim_finalize, which hands out one token. Three mutations pin it: dropping the probe's pin guard, releasing before the handover, and never releasing. What remains is the pin the FIFO drops at its own ceiling, which item 6 counts rather than hides. Two stale comments asserting the old premise were corrected in the same change.Related Issues
No linked issue.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)