Repository navigation
CONTRACT: fix(ui-server): contain a safety-recording failure to what it puts at risk and recover automatically (#3812, #3810) - #3827
Conversation
…it puts at risk (#3812, #3810) A single turn's safety-write error used to set one durable flag for the whole brain, after which every turn in every chat was refused until an operator ran a script. The failure is now contained at the narrowest scope that durably takes it, and the host recovers by itself: - Before delivery (a failed begin, or a refused reservation whose producer holds its input) refuses that one turn with the retryable SAFETY_RECORDING_UNAVAILABLE error. Nothing latches. - Lost evidence after delivery marks only that turn's collection failed, so its chat keeps a permanent recording_failed gap and runs restricted. A reservation still open when its collection ends becomes the same gap. - Only when that chat fact cannot commit does the brain latch, through the emergency reserve or in-process. New turns still begin, each with a permanent gap committed before delivery, and run under the tainted policy. A turn is refused only when that restricted begin cannot commit (safety_recording_paused). A reconciler retries, backing off to once a minute, and clears the latch once the producers that predate it drained. - Boot resolves a set latch and pending reservations after restart classification; a legacy row that cannot migrate gaps its own turn. Every latch keeps its first cause and a count (safety_latch), logs one structured stderr line, and only a capacity check classifies as capacity. Every recovery is audited in safety_recoveries with trigger, actor, time and the cleared cause. Contract: additive error code SAFETY_RECORDING_UNAVAILABLE and failure classes safety_recording_unavailable / safety_recording_paused (docs/integration-contract/wire.md). Projection reasons are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…owner recovery fallback (#3810) Owner GET /api/status gains safetyRecording: whether the brain-wide recorder is latched, since when, its reason and first cause, whether only this process retains the loss, and the last recovery. Other principals never see it. POST /api/status/safety-recording/recover gives recoverSafetyRecording a production caller as the owner's fallback to automatic recovery: it refuses with 409 producers_open, changing nothing, while a producer is open, and records the owner as the actor. Contract: additive status field and route (docs/integration-contract/http.md#safety-recording-status-additive-3810). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iled (#3810) A message refused with SAFETY_RECORDING_UNAVAILABLE now returns with copy that says safety recording failed or is paused and that nothing was sent, instead of "The brain refused this message." A failed turn with the new failure classes reads the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eservations Self-review and the affected suites found four gaps in the containment change: - A brain latch raised inside a worker call that does not report its scope (a loss at safetyEnd, a peer process) never scheduled automatic recovery. Every call now checks for a latch when it settles. - Construction checked the latch unguarded and threw on a broken store. - An in-process-only brain restriction logged nothing; it now logs one line. - Automatic recovery deleted every pending reservation, including those of open collections it had just gapped, so their commits failed. It now removes only reservations of ended collections; an open one is resolved by its own end. Also registers the recovery route in the mounted-route lifetime audit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…3812) An independent review found two paths where automatic recovery could clear the brain latch with a possibly delivered input left ungapped: - A producer refused early under a latch (or after its own chat failed) retained nothing. A producer that does not hold its input now records its chat's loss before the refusal returns; one that holds it gets the retryable before-delivery refusal. - A loss with no collection of its own latched the brain with no scope, so recovery gapped nothing. A known chat now takes a failed epoch of its own without latching the brain; a loss that names no chat marks the latch `unscoped`, durably, and recovery then gaps every collection, also after a restart. Also from the review: a capacity cause keeps its class across the write worker, the queue-capacity refusal is classified as capacity, a loss only this process retained keeps its original cause for the recovery audit, and two assertions that could pass on a broken tree now check the durable fact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ute (#3810) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No uploads on this PR yet This PR changes UI files (
Tips for agentsLabel each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one uploads put after.png --pr 3827 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 3827 --app ios --screen "Chat" --state afterNo CLI? With the Uploads MCP, call This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with Workspace admins can turn this comment off in Settings → GitHub · docs |
A tool result already exists when its safety record is written, and a runtime may keep it in its own session: the installed Claude runtime replays a result whose PostToolUse hook stopped the turn on the next resumed request. Treating a refused result reservation as "before delivery" therefore left the chat normal and complete while the model had seen the untrusted output. Only begin(), which the backend awaits before the tool runs, may now take the pre-delivery shortcut. Result records are no longer tagged beforeDelivery, so a failed reservation is contained at chat scope by the writer and the collector records the loss on the chat as well. The new installed-Claude test proves the replay and the permanent gap; the Pi writer-loss test again requires the loss to stay with its chat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d cause, and say what frees spent room (#3812, #3810) - Automatic recovery now waits until every producer that predates the latch has ended, failed or not. Only turns begun restricted run beside it; a failed producer's durable or in-memory loss no longer exempts it from the drain. - /api/status `safetyRecording.cause` falls back to the cause this process holds while its notice cannot commit, marked `durable: false`; a committed latch cause carries `durable: true`. - Every capacity refusal names what it spent (`turn`, `chat` or `brain`). A turn refused for spent chat or brain room ends with the additive failure classes `safety_recording_chat_full` (start a new chat) or `safety_recording_brain_full` (retrying won't help), and the PWA no longer asks the owner to try again. Additive: one optional field on the status cause and two failure classes, documented in docs/integration-contract/http.md and wire.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the pinned browser (#3812) The real Chat page in the pinned Chromium talks to the real app and its own safety recorder. The first chat's search result reaches the runtime and its record is refused, so that chat keeps a permanent recording gap; a second chat, started from the page's New chat, sends twice and is answered under normal policy, and the brain never latches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sult the host cannot record (#3812) Second review of #3827 at 511e94a. P1: result() checked the turn's liveness before its try, so a turn stopped as its result arrived skipped both the record and safetyFail(), while the installed Claude runtime replays that result on resume. A result that reaches the host is now recorded whatever happened to the turn: stopping refuses new tools, never the record of one that ran. Any failure while recording still leaves the chat a permanent gap. Audit of every exit between a tool running and its result's record, in both backends. Also fixed: - a result queued behind a failed begin() inherited its refusal; - a result for a call whose begin() failed partway recorded nothing for the unrecorded input (the call is now not admitted: gap); - the Pi host refused a stopped turn's safetyResult before recording it (now recorded, then the post-record live check refuses the worker); - a malformed or replayed Pi safetyResult left no gap (new internal inputSafety.lost); - the Pi worker skipped the report when the session's own afterToolCall failed. P2a: a latch records the safety revision it was set at (durable and in process). Automatic recovery exempts only turns begun restricted after it; one begun restricted under an earlier latch drains first. P2c: unbound room (count and both byte checks) is brain-full only when ended unbound collections alone fill it; room an open first turn or a pending write holds is a retryable refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…corded (#3812) A turn stopped while a tool runs reaches neither Claude result hook, yet the runtime keeps the call in its session and may replay its output on resume. The collector only gapped a chat when a delivered hook failed, so a Grep stopped mid-run left its chat normal and complete. Every call `begin()` admits is now an obligation, recorded before the tool runs (`safety_obligations`, migration 085). It is discharged only when its result is durably recorded, or when the backend refuses the call, which proves it never ran: a rejected `begin()`, a Claude PreToolUse or `canUseTool` deny, or a Pi permission answer other than allow. A collection that ends owing one, however it ended, and an obligation still open at boot, give the chat a permanent `recording_failed` gap naming the call. Nothing depends on the runtime delivering a hook. A fully observed result of a stopped turn is still recorded as an occurrence, with no gap. A refused call stays refused, so a parallel hook cannot reopen it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d, and discharge it with that record (#3812) A refusal proved a call never ran only until the backend let it run. A later permission request for the same Pi call id, rejected as a replay, refused for a stopped turn or denied, discharged the obligation of a call that had already run, and its chat ended normal and complete. Backends now tell the collector when they let a call run (the Pi dispatcher's allow, the Pi gate's pass, Claude's permission callback allow); from then on a refusal or a rejected begin() for that id discharges nothing, and only the call's recorded result does. An allow the collector can no longer note is refused instead. A result's last exposure now commits with its call's discharge in one transaction, so neither a collection's end nor a restart can find the record durable and the call still owed. A collection's end also waits, bounded, for a result record already under way: stopping a turn refuses new tools, never the record of one that ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d re-anchor citations into the files it touches (#3812) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…own tests do Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eclared endpoints (#3810) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/decisions/claude-code-runtime.md
…ves (#3812) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review follow-up, second and first rounds, moved here from the PR body, which is at GitHub's size limit. The text is unchanged. Second review, at 511e94aOne blocking finding and two medium ones. Each fix has a failing-first run on 511e94a's sources and a mutation receipt. The first round's fixes are unchanged and still pass (below).
Exit-path audit. Each path between a tool running and its result's record now records the result or leaves the chat a permanent gap.
Failing-first (511e94a sources, new tests):
Mutations (each restored; every one fails its named test):
A test note: Bun's Runs after the second follow-up (exit codes read from each command):
First review, at 88e5805Independent review at 88e5805 found one blocking and four further issues. Each fix has a failing-first run on 88e5805's sources and a mutation receipt.
Failing-first (88e5805 sources, new tests):
Mutations (each restored):
Runs after the follow-up. 19 focused files: every |
…mission (#3812) The Claude backend counted admissions per hook, keyed by call id alone. When a different tool reused an id, its hooks were not the ones that had seen the id. A Bash call reusing an auto-allowed Grep's id reached the mutating hook first, which had never seen that id, so its count did not pass the maximum. Its denial then found one admission and discharged the Grep's obligation before the shared hook counted the Bash call. The chat ended normal and complete, although the search had run. Admissions are now counted per (tool name, id). For one tool name, the same hooks run on every admission, so whichever hook starts first counts it. Backends report the tool name with each admission. The collector keeps the tool names seen for each id. A refusal discharges an obligation only when the id was admitted exactly once, under one tool name, and was never allowed. Also brings three comments that still described the superseded no-refusal rule in line with the narrowed rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#3812) The browser dispatch audit pins inbound.ts by hash. It now also imports refusalReason from lib/turn-failure.ts, which imports only protocol types and constants; inbound.ts still takes only runStateForFrame from the chat handlers and never reaches chatFrameHandlers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #3812
Closes #3810
What changes
A hosted instance refused every turn in every chat after one turn's safety-recording write failed: the guard set one durable flag for the whole brain, labelled it
capacity, kept no cause, and only a hand-run script cleared it. This PR applies the maintainer's 2026-11-09 ruling (#3812, proportionate containment) and keeps #3810's diagnostics, with #3812's restrict-before-refuse superseding #3810's "a latched recorder still refuses turns".safetyBeginfails, or a tool's input record is refused before the tool runs (the backend awaitsbeginbefore executing)capacity; every turn refusedSAFETY_RECORDING_UNAVAILABLE. Nothing latches. Spent room says what frees it:safety_recording_chat_full(start a new chat) orsafety_recording_brain_full(retrying won't help).safetyFail, failed commit, loss at end, any failure recording a tool result, a result report the host refuses)recording_failedgap and runs restricted; its producer stops. Other chats are unaffected. A reservation still open when its collection ends becomes the same gap. A result is never "before delivery": its bytes exist, and the Claude runtime replays it on resume. A turn stopped while a tool runs still records that tool's result. Every call admitted before it runs owes its result's record until that record is durable, or until the host's own denial of the only admission under that id, with no allow before it, proves the call never ran. A collection that ends owing one (a turn stopped before the runtime reported the result, a hook the runtime never ran, a call refused any other way) and a call still owed at boot leave the same gap. A denied permission card leaves the chat as it was.recording_failedgap committed before delivery, and run under the tainted policy. A reconciler keeps retrying (backoff up to 1/min, no retry cap) and clears the latch withrecoverSafetyRecordingsemantics once every producer that predates it has ended, failed or not.safety_recording_paused(SafetyRecordingUnavailable,safety-store.ts).failed=1or pending reservationscapacity.Diagnosability (#3810):
SafetyCapacityExhausted) classifies ascapacity; everything else isrecording_failed, in all facades and the migration.safety_latch; chat-scoped causes insafety_collections.failure_cause. Identifiers and error text only.GET /api/statusgainssafetyRecording(latched,since,reason,cause,retained,lastRecovery); other principals never see it. While only this process holds the loss,causeis that in-memory cause withdurable: false.POST /api/status/safety-recording/recover(owner) is the fallback and the production caller ofrecoverSafetyRecording: strict quiescence, 409producers_openwithout changing anything, actor recorded.safety_recoverieswith trigger, actor, time, gapped count and the cause it cleared.Contract (additive,
CONTRACT:commits): error codeSAFETY_RECORDING_UNAVAILABLEand failure classessafety_recording_unavailable/safety_recording_paused/safety_recording_chat_full/safety_recording_brain_full(wire);safetyRecordingstatus field (withcause.durable) and the recovery route (http, http-api). Projection reasons and the wire meaning ofrecording_failedare unchanged. Migration085addsrestricted_begin,failure_cause,safety_latch,safety_recoveries,safety_obligations.Security properties kept
recording_failed,recording_failed_recoveredorhost_restart_unknown); no recovery clears a gap or an unresolved occurrence.recordingAvailablefalse) until its collection ends.begincaller: Claude's PreToolUse hooks andcanUseTooldeny on failure; Pi'sbeforeToolCallandtool_callhandlers throw, andpi-agent-core'sprepareToolCallturns that into an error result without executing. A result that reaches the host is recorded whatever happened to its turn, and every result the host cannot record, in both backends, leaves a permanent gap on its chat (exit-path audit under Review follow-up).begin()admits is an obligation, durable before the tool runs. Its durably recorded result discharges it; the record and the discharge commit together. A refusal discharges it only when it proves the call never ran: the backend's own denial, of the only admission ever made under the id, under one tool name, with no allow observed (fifth and sixth reviews). A second admission of the id, an allow before the refusal, a rejected request or an unreported admission proves nothing. A collection that ends owing one, through cancellation, abort, a missing hook, an unproven refusal or a restart, leaves its chat a permanent gap naming the call.Proportionate-containment checklist
SAFETY_LIMITSand other guards are out of scope.attemptSafetyRecovery(event-writes.ts) on a backoff timer, plus boot recovery increateUiDb. Owner route is a fallback only; a human adds nothing there.safety_latch,safety_collections.failure_cause,safety_recoveries, one log line each; owner/api/status.safetyRecording.safety-gap.layout.tsx"a second chat stays usable while one chat carries a recording gap" (real app, real recorder, real Chat page).safety-containment.test.ts: "a failed safetyBegin refuses only that turn…", "a lost post-delivery occurrence restricts its chat permanently and leaves another chat normal", "an unwritable evidence store restricts the brain, new turns run restricted, and it clears itself";approval-scope-isolation"other chat loss";session-safety-boundaries"other-chat-recording-loss".Review follow-up
Sixth review, at 07165d5
One blocking finding (P1) and one nonblocking (P3). Both are fixed.
Fix (as specified):
admitting(toolUseId, toolName)carries the tool name, in both backends.event-writes.ts(safetyDischarge),safety-store.ts(openSafetyObligation), and thesafety-result-exitsheader.session-safety-reviews.mdcondition 2 now says "under one tool name".New permanent tests: the reviewer's two cross-tool probes, on the installed runtime (Odysseus world, offline).
safety-result-retention"a denied shell call reusing a search's id cannot settle the search that ran". This is the natural-order probe, with the search's result report dropped. A second variant holds the shared hook 150 ms. The search's bytes reach the model, the background Bash under the same id is denied by its own hook, and the chat stays restricted with a durablerecording_failedgap.safety-result-retention"a denial of another tool under the search's id cannot settle the search that already ran…" (retooledmode). This one uses real cancellation under controlled hook scheduling. The Read's native-read hook waits until the search has printed its matches, stops the turn and denies the Read. The shared hook is held until that deny lands. Both result hooks are skipped, and the chat stays restricted with a gap namingtoolu_sirens.safety-result-exitsgains aretooledvariant: one admission undergrep, one underbash, then a deny, and the call stays owed;permission-wiring-units"a reused id under another tool name is a new admission, reported by its first hook even when that hook never saw the id";Failing-first. The four guard sources were checked out from 07165d5, with this branch's tests: 6 fail, 112 pass, exit 1.
SAFETY_RETOOLED_SHELL_DENIAL_CANNOT_SETTLE_THE_RUN_SEARCHfails in both shell variants (expectedrestricted, receivednormal).SAFETY_RETOOLED_DENIAL_CANNOT_SETTLE_THE_RUN_SEARCHfails (expectedrestricted, receivednormal).CLAUDE_REUSED_ID_UNDER_ANOTHER_TOOL_IS_A_NEW_ADMISSION,PI_EVERY_PERMISSION_REQUEST_IS_AN_ADMISSIONandPI_GATE_EVERY_TOOL_CALL_IS_AN_ADMISSION.retooledvariant passes on 07165d5 too: that collector already counted the two reports as two admissions. It pins the collector's own tool-name rule.Mutations. Run at the fix, each restored with
git checkout HEAD --; tree clean afterwards. Every one exits 1:SAFETY_RETOOLED_SHELL_DENIAL_CANNOT_SETTLE_THE_RUN_SEARCH),SAFETY_RETOOLED_DENIAL_CANNOT_SETTLE_THE_RUN_SEARCH,CLAUDE_REUSED_ID_UNDER_ANOTHER_TOOL_IS_A_NEW_ADMISSIONretooled(SAFETY_UNPROVEN_REFUSAL_KEEPS_THE_OBLIGATION); the Pi grant test (SAFETY_PI_REFUSAL_KEEPS_THE_OBLIGATION, wherebrain_read_basethenbashreuse an id)SAFETY_DUPLICATE_DENIAL_CANNOT_SETTLE_THE_RUN_SEARCH,readmittedRuns after the sixth follow-up. Each exit code was read from its own command.
At a4ab6c5 (the fix, with
origin/main0129244 merged):no-consoleandhttp-inventory: exit 0.tsc --noEmit(16 GB heap),bun run lintandbun run api-report(no diff): each exit 0.hygiene-media-effects"mixed versions: a keep-copy answer…", where thebrain hygieneCLI subprocess was killed at the 30 s budget (exited null). That file passed on its own on the same host (34/34, exit 0), and the failure is filed as ui-server: a hygiene keep-copy mixed-versions test exceeds its 30 s budget under load, and its CLI subprocess is killed #3878.At 7ad2bb7 (
origin/mainb77987a merged, which touches none of this PR's guard files):tsc --noEmit(16 GB heap): exit 0.bun run api-report: exit 0, no diff.bun run check:pr --base origin/main: exit 0 (receipt below).Failing-first and mutations ran at a5c7ed8, before those merges, which touched none of the guard sources or their tests.
Fifth review, at 8abd1d0
Two blocking findings, P1a and P1b. Both are fixed. P1a went through two coordinator decisions, described below. Each new test fails on the source it guards against, at its named assertion, and each guard has a mutation receipt. The earlier rounds' fixes are unchanged and still pass (runs below).
P1a (security), fixed: a refusal settled a Claude call that had already run. The installed Claude 2.1.293 admits the same
tool_use_idtwice. In the reviewer's run:begin();The round-4 allow note couldn't catch this. Bare
allowedToolsruns a call without ever consultingcanUseTool, and the Agent and Bash rewrite hooks can returnallowthe same way.First decision (a04ba5d): no refusal discharges an obligation once
begin()has made it durable. A measurement against that commit showed the cost was too coarse. A user's Deny on a Claude permission card comes after the hook'sbegin(), so every denied card left that chat a permanentrecording_failedgap and ran it restricted. A probe confirmed it: Grep outside the allowlist, card denied →failure: recording_failed,restriction: restricted.Coordinator's narrowed decision (5808ed4), under proportionate containment rules 1 and 2: a refusal discharges an obligation only when all three of these hold.
canUseTooldeny (which covers a denied card), a ClaudePreToolUsehook deny, or a Pi permission deny or gate block.Anything else proves nothing, and only the recorded result discharges. That covers a second admission (the reviewer's case), an allow followed by a refusal, a rejected request (a stopped turn, a replayed Pi request), and an id whose admissions were never reported. Rationale: when the gate denied the only admission of that id, the tool could not have run under it. The duplicate-id attack needs two admissions, and the second one makes the id undischargeable by refusal.
How admissions are counted. Backends report each admission through a new internal
inputSafety.admitting(toolUseId).refused(toolUseId, denied)now says whether the refusal is the backend's own denial.PreToolUsehook runs once per admission, so the highest per-hook count is the number of admissions. The count is taken synchronously at the start of each fenced hook, so a second admission is reported by whichever of its hooks starts first, before any of its waits, decisions orbegin().begin()calls would be wrong both ways. One admission records its input from several hooks (for example the RTK rewrite and the mutating hook for one Bash call). And the reviewer's second admission was denied before it ever reachedbegin().permissionrequest (a replay included) and eachtool_callevent. Only a deny answer is a denial; a dispatcher rejection is not.Where the counts live. In the turn's collector, not on the obligation row:
An id the collector can't track (more than 2,000 in one turn) keeps no count, so no refusal discharges it.
allowed()again notes the allow, and refuses the call when it can't. A rejectedbegin()discharges nothing by itself; the denial the backend returns on it does, if the three conditions hold.Stopped turns (confirmed by the coordinator). A Claude
PreToolUsehook orcanUseToolthat denies because the turn was cancelled is still the backend's own pre-execution deny. On the id's only admission, with no allow observed, it discharges, because that gate refused the call. Pi's stopped-turn rejection (the dispatcher rejects the request because the turn is no longer live) is a rejection, not a deny, so condition 1 excludes it and the call stays owed. Pinned byPI_REJECTED_REQUEST_IS_NO_DENIALand therejectedvariant.P1b (security), fixed: a Pi grant was usable before the collector's last check. The
permissionhandler published the grant, and only then did the dispatcher awaitallowed(). A concurrentreadBasefor the same id used the grant while a same-id refusal was turning the answer into a deny. Real note bytes came back, both permission answers said deny, and the chat ended normal and complete.Fix: the handler's new
permit()step runs in this order:revalidatePiAdmission, orsafetyAdmissionRefusalfor an application tool);A refused check denies the call and publishes nothing. A stopped turn rejects it. The dispatcher's wrapper now only refuses non-allow outcomes.
Audit: every place a Pi grant or capability becomes usable.
permission(worker RPC)permission, application toollockadmission(final bash){ ok: true }fileObservationbridge,readBaseapplytool_call)allowed()resolvesrememberPiAdmissionlock,admissionand the in-process bash recheck each need a grant or a gate pass as wellNew permanent tests (Odysseus world, keyless, offline):
safety-result-retention"a denial under an id the runtime admitted twice cannot settle the search that already ran, so its chat keeps a permanent gap". This is the reviewer's reproduction:MEASURED_RUNTIME);It asserts that the runtime admits the id twice, that both result hooks are skipped, that the chat is restricted and incomplete with a
recording_failedgap namingGrep (toolu_sirens), and that the host reported both admissions.safety-result-retention"a search denied at its permission card never runs, and its chat stays normal with no gap". The installed runtime, under an enforced turn allowlist that leaves Grep out, asks the callback once. Penelope denies the card. The test asserts that the search never ran (the wrapper's mark is absent), that there is no gap, and that the chat stays normal and complete, also after recovery. It also asserts that the host saw exactly one admission. (The runtime exposes Grep only when its own allowlist names it, and then runs it without asking. So the card is reached through the enforced allowlist, the production path for an off-list call.)safety-result-exits:readBaseearly, then sends a denied bash request under the same id. It asserts that nothing is read, both answers deny, the obligation is kept (two admissions), and the end leaves the gap.rejected,readmitted,allowed,unreported): one variant per condition, plus the untracked default.Backend units:
permission-wiring-units"each admission the runtime makes is reported once, by whichever of its hooks starts first": a Write passes several hooks.Failing-first. The guard sources (
safety-collector.ts,worker-rpc.ts,permission-gate.ts,permission-hooks.ts) were checked out from the named commit, with this branch's tests:On 8abd1d0 (the reviewed head): 13 fail, 100 pass, exit 1. The finding tests fail at their named assertions:
SAFETY_DUPLICATE_DENIAL_CANNOT_SETTLE_THE_RUN_SEARCH(expectedrestricted, receivednormal), afterSAFETY_RUNTIME_ADMITS_ONE_ID_TWICE,SAFETY_SECOND_ADMISSION_IS_DENIEDandSAFETY_RUNTIME_SKIPPED_BOTH_RESULT_HOOKSpassedSAFETY_PI_UNCHECKED_GRANT_NEVER_READS(expected 0, received 1)rejected,readmitted,unreportedSAFETY_UNPROVEN_REFUSAL_KEEPS_THE_OBLIGATION(expected 1, received 0)The other failures are the new reporting assertions, which 8abd1d0's backends don't make:
CLAUDE_ONE_ADMISSION_IS_REPORTED_ONCE,PI_NON_ALLOW_PERMISSION_REFUSES_THE_CALL,PI_GATE_BLOCK_REFUSES_THE_CALLand similar. On 8abd1d0 a card Deny already left no gap, so the installed card-deny test gets past its gap checks there. It fails only atSAFETY_RUNTIME_ADMITS_THE_DENIED_SEARCH_ONCE.On a04ba5d (the first, unnarrowed P1a): 12 fail, 101 pass, exit 1. The narrowing tests fail at their named assertions:
SAFETY_CARD_DENY_LEAVES_NO_GAPSAFETY_CLAUDE_CARD_DENY_DISCHARGES_THE_CALL(expected 0, received 1)SAFETY_REFUSED_AND_RECORDED_CALLS_OWE_NOTHING(expected 0, received 1)SAFETY_REFUSED_EDIT_OWES_NOTHING(expected 0, received 1)Mutations. Run at the narrowed fix, each restored with
git checkout HEAD --; tree clean afterwards. Every one exits 1:SAFETY_DUPLICATE_DENIAL_CANNOT_SETTLE_THE_RUN_SEARCH,normal);readmitted(SAFETY_UNPROVEN_REFUSAL_KEEPS_THE_OBLIGATION); the Pi grant test (SAFETY_PI_REFUSAL_KEEPS_THE_OBLIGATION)rejected(SAFETY_UNPROVEN_REFUSAL_KEEPS_THE_OBLIGATION)allowed(SAFETY_UNPROVEN_REFUSAL_KEEPS_THE_OBLIGATION); "a Claude call its callback allowed stays owed…" (SAFETY_LATER_REFUSAL_KEEPS_THE_OBLIGATION)CLAUDE_ONE_ADMISSION_IS_REPORTED_ONCECLAUDE_SECOND_ADMISSION_IS_REPORTED_AT_ONCEPI_EVERY_PERMISSION_REQUEST_IS_AN_ADMISSION. An unreported id is fail-safe: it can't be discharged by refusalpermit()publishes the grant before the check, withdrawing it on refusal as 8abd1d0 didSAFETY_PI_UNCHECKED_GRANT_NEVER_READSExisting tests changed, and why.
safety-result-exits, reverted to their original expectations, which the narrowed rule makes correct again:SAFETY_REFUSED_CALL_STAYS_REFUSED,SAFETY_REFUSED_CALL_DOES_NOT_STOP_ITS_TURN,SAFETY_REFUSED_AND_RECORDED_CALLS_OWE_NOTHING,SAFETY_REFUSED_CALL_LEAVES_NO_GAPandSAFETY_DISCHARGED_CALLS_KEEP_COVERAGE. The only change: it reports one admission per call, and the refusal is the backend's denial (refused(id, true)).begin()no longer discharges by itself, soSAFETY_REFUSED_EDIT_OWES_NOTHINGnow follows that denial.safety-result-retention: the harness gains theduplicateanddeniedmodes. Its collector wrapper now forwards the denial flag and counts admissions. The three existing cases are unchanged.permission-wiring-units: the describe is now "admissions, refusals and the collector's last check".CLAUDE_DENY_REFUSES_THE_CALLandCLAUDE_UNCHECKED_ALLOW_IS_REFUSEDnow expect[id, true].tools-permission:PI_GATE_BLOCK_REFUSES_THE_CALLexpects[id, true], plusPI_GATE_EVERY_TOOL_CALL_IS_AN_ADMISSION.worker-rpc: a deny is[id, true]and a rejection[id, undefined], plusPI_EVERY_PERMISSION_REQUEST_IS_AN_ADMISSIONandPI_REJECTED_REQUEST_IS_NO_DENIAL.PI_UNCHECKED_ALLOW_IS_REFUSEDexpects[id, true].*_CHECKED,*_UNCHECKED_*).Docs.
session-safety-reviews.mdstates the three conditions, what stays conservative, where the counts live, and the grant ordering.@internalSDK docs foradmitting,refusedandallowedare updated.check-citationsfinds none drifted in this round's files; 310 are drifted in the repo, down from 334.api-report: no diff, sinceadmittingis@internal.Containment checklist, for the changed guards. Each one only keeps or adds restriction relative to a recorded result.
Runs after the fifth follow-up. Each exit code was read from its own command.
At c68a17b (the narrowed fix, with
origin/main46085b2 merged; 07165d5 then also merges main's test-only 7f1c158, inpackages/common, which this PR does not touch):provider-historyandprovider-history-apify, both backends), plusno-consoleandhttp-inventory: 43/43, exit 0.tsc --noEmit(16 GB heap): exit 0.bun run lint: exit 0.bun run api-report: exit 0, no diff.bun run check:pr --base origin/main: exit 0 at 07165d5, modefocused; all five checks passed: lint and leakage gates, environment documentation, pending changeset package names, contribution changeset, affected fast invariants (receipt below).Before the narrowing, at a04ba5d+d088575c3 (
origin/main5537ccb merged), the same set was green:Failing-first and mutations ran at 5808ed4, before
origin/main46085b2 was merged. That merge touched none of the guard sources or their tests.Left open after this round.
permit()after the collector's check;PreToolUsehook runs once per admission, and the runtime never runs a call before all its hooks have returned. The duplicate-id and card-deny tests characterize both on the installed 2.1.293.Fourth review, at 0085b9b
One blocking finding (P1) and one regression from the obligation ledger (P2). Both are fixed. Each new test fails on 0085b9b's sources at its named assertion, and each guard has a mutation receipt. The earlier rounds' fixes are unchanged and still pass (runs below).
P1 (security), fixed: a later Pi refusal erased the obligation of a call that had already run. The dispatcher called
refused(toolCallId)on every permission denial or rejection, and the collector deleted the obligation. So a call could be allowed, run the real curatedgrep, go unreported, and then lose its obligation to a later permission request for the same id: a replay rejection, a stopped-turn rejection or a denial. Its chat then ended normal and complete. Rejecting a later request proves nothing about an earlier call.Fix: a refusal discharges an obligation only if the backend never let that call run. Each backend notes its allow with a new internal
inputSafety.allowed(toolUseId)before it returns the allow:permissionallow;canUseToolallow, which is the runtime's last gate.Once a call is noted as allowed, it stays owed until its result is recorded. A later refusal of the same id discharges nothing, and neither does a rejected
begin(), a stopped turn or a replay. The rule is enforced in one place, the collector (dischargeRefused), and it covers all four refusal sites:begin();allowed()rejects a call that was already refused, or whose latestbegin()didn't complete. The backend then refuses the call instead of running it with no obligation. The Pi dispatcher also withdraws its grant. The note is kept in memory on the turn's collector, the finding's second option: only that collector discharges, and a restart gaps every open obligation anyway.P2 (regression), fixed: shutdown could gap a result that was already recorded. The result's finalized exposure committed in one transaction and the obligation's discharge in the next. A collection end landing between the two gapped a durable record (
SAFETY_CANCELLED_RECORDED_RESULT_IS_NO_GAPfailed in both of the reviewer's runs).Fix: the result's last exposure write now carries the obligation id, and
safetyCommitdischarges it in the same transaction (discharged: trueconfirms it). No end and no restart can see the record durable and the call still owed. A result with nothing to record is recorded by its discharge alone. A record that fails stays owed, and the chat keeps its gap, as before.That alone left the real-runtime test a race: the end could still land before the record's first write. So
safetyEndnow also waits, bounded at 10 s with an unref'd timer, for that turn's result records already under way, and then ends the collection. Stopping a turn already refused new tools but never a record; the end now keeps that promise. A record that starts after the end began is refused and gapped, as before. A record that has not settled within the bound is refused by the end, and its chat keeps the gap.Exit-path audit, allowed calls. Extends the third review's table.
grep), unreported; laterpermissionRPC reusing its id is rejected as a replaysafety-result-exits"a Pi call allowed and run stays owed…: replayed"begin()is rejected (its edited input cannot be recorded, before delivery, which gaps nothing by itself)tool_callfor the id is blockedcanUseToolallowed, the turn stopped before either result hook; a later fencedPreToolUsedeny andcanUseTooldeny for the idbegin()didn't complete)PI_UNNOTED_ALLOW_IS_DENIED,PI_GATE_UNNOTED_CALL_IS_BLOCKED,CLAUDE_UNNOTED_ALLOW_IS_DENIEDThe four refusal sites from the third review still discharge when the backend never let the call run. Those tests are unchanged and pass:
CLAUDE_DENY_REFUSES_THE_CALL,PI_NON_ALLOW_PERMISSION_REFUSES_THE_CALL,PI_GATE_BLOCK_REFUSES_THE_CALL,SAFETY_REFUSED_EDIT_OWES_NOTHING,SAFETY_REFUSED_AND_RECORDED_CALLS_OWE_NOTHING.Failing-first. The new and extended tests, run against 0085b9b's sources (the 7 source files checked out from 0085b9b, tests from this branch). 13 fail, 88 pass, exit 1. Each fails at its named assertion:
safety-result-exits"a Pi call allowed and run stays owed whatever a later request for it says", ×4 (replayed,stopped,denied,unrecordable)SAFETY_LATER_REFUSAL_KEEPS_THE_OBLIGATION, afterSAFETY_PI_CALL_IS_ALLOWED,SAFETY_PI_ALLOWED_CALL_OWES_ITS_RESULTandSAFETY_PI_ALLOWED_SEARCH_RANpassed (and, forunrecordable,SAFETY_PI_REFUSED_ADMISSION_GAPS_NOTHING_BY_ITSELF)safety-result-exits"a Pi call the in-process gate let through stays owed…"SAFETY_LATER_REFUSAL_KEEPS_THE_OBLIGATIONsafety-result-exits"a Claude call its callback allowed stays owed…"SAFETY_LATER_REFUSAL_KEEPS_THE_OBLIGATIONsafety-result-exits"a result's last record discharges its call in the same commit…"SAFETY_RECORDED_RESULT_IS_DISCHARGED_IN_ITS_OWN_COMMIT(owed 1 afterSAFETY_RESULT_RECORD_IS_DURABLE)safety-result-exits"a collection's end waits for a stopped turn's result record already under way"SAFETY_END_WAITS_FOR_A_RECORD_UNDER_WAY(ended: 1while the record was held)worker-rpc"every permission answer but allow…" (extended)PI_ALLOWED_PERMISSION_IS_NOTED_BEFORE_IT_RUNSworker-rpc"an allow the collector can no longer note is denied, and its grant withdrawn"PI_UNNOTED_ALLOW_IS_DENIEDtools-permission"a call the gate lets through is noted before it runs…"PI_GATE_UNNOTED_CALL_IS_BLOCKEDpermission-wiring-units"a call the backend lets run stays owed" (extended)CLAUDE_CALLBACK_ALLOW_IS_NOTEDpermission-wiring-units"a callback allow the collector cannot note is denied instead"CLAUDE_UNNOTED_ALLOW_IS_DENIEDThe P2 interleaving tests are deterministic, with no sleeps. One holds the collector inside its own
writes.recordcall. The other uses the write worker's FIFOidle()barrier: had the end been sent, the writer has applied it by then.Mutations. Run at the fix, each restored with
git checkout HEAD --; tree clean afterwards. Exit 1 for every one:refused()ignores the allowSAFETY_LATER_REFUSAL_KEEPS_THE_OBLIGATION: Pireplayed,stopped,denied,unrecordable; Pi gate; Claudebegin()ignores the allowunrecordableatSAFETY_LATER_REFUSAL_KEEPS_THE_OBLIGATION(only it)PI_ALLOWED_PERMISSION_IS_NOTED_BEFORE_IT_RUNS,PI_UNNOTED_ALLOW_IS_DENIED, and the 4 Pi dispatcher variantsPI_GATE_UNNOTED_CALL_IS_BLOCKED, the gate end-to-end testcanUseTooldoesn't note its allowCLAUDE_CALLBACK_ALLOW_IS_NOTED,CLAUDE_UNNOTED_ALLOW_IS_DENIED, the Claude end-to-end testsafetyCommitskips the discharge, which falls back to a separate commitSAFETY_RECORDED_RESULT_IS_DISCHARGED_IN_ITS_OWN_COMMITsafetyEnddoesn't wait for records under waySAFETY_END_WAITS_FOR_A_RECORD_UNDER_WAYThe reviewer's regression.
safety-result-retention"a turn stopped as its result arrives still records the result the runtime replays" (SAFETY_CANCELLED_RECORDED_RESULT_IS_NO_GAP, installed Claude, real resume) passed 10 consecutive runs, each exit 0.Existing tests changed.
worker-rpc"every permission answer but allow…" gives its fake collectorallowedand asserts that the allow is noted. The dispatcher now refuses discharge through a collector that cannot note allows, so a collector withoutallowedwould no longer see the refusals this test counts.permission-wiring-units'wiring()helper records allows and lock releases.Assertions are otherwise unchanged.
The reviewer's barrier probe, which holds
safetyDischarge, no longer reaches its barrier: a result with occurrences now discharges inside its last commit. The new "same commit" test holds that commit instead.Docs.
session-safety-reviews.mdstates the allow rule, the single commit and the end's wait. The changeset says the same for users. Twelve citations into the files this PR touches are re-anchored (check-citations: none drifted in those files; 323 drifted in the repo, down from 335).Containment checklist, for the changed guards. Each one only keeps or adds restriction.
site: "safetyEnd"or"boot-obligation").allowed()refuses one call, and the turn continues.Runs after the fourth follow-up (at 8abd1d0, with
origin/maind79eeed merged; each exit code read from its command):origin/maind79eeed merged):http-inventory. Its prose count said 179 declared endpoints, but the app declares 180. This has been wrong since the recovery route was added in an earlier round. It is fixed in 862316a, and the test now passes 5/5.worker-session,worker-session-units,provider-historyandprovider-history-apifyfor both backends, at the same sources. 855/855, exit 0.provider-history,provider-history-apify, both backends): 35/35, exit 0.no-console: 3/3, exit 0.origin/main61c97a5, at 8abd1d0:tsc --noEmit(16 GB heap): exit 0.bun run lint: exit 0.bun run api-report: exit 0, no diff.allowedis@internal.http-inventoryand main's changednative-journal-observer,reference-worktree-journalandcompute-host(53 files): 932/932, exit 0.bun run check:pr --base origin/main: exit 0 (receipt below).Left open after this round.
allowedToolsnever reachescanUseTool, so the host sees no allow for it. APreToolUsehook'sallowis no such signal either: a parallel hook's deny wins. If the runtime admitted the sametool_use_idagain after running it, a deny of that second admission would still discharge the call. The installed runtime admits each id once. Pi worker requests, which are adversarial input, are fully covered. Closing this for Claude needs a host-visible signal that the runtime has started the tool, and the SDK has none.allowed()is in memory and adds no write. A result with occurrences no longer pays a separate discharge round trip; a result with nothing to record still pays one.Third review, at e162f73
One blocking finding; everything else passed. The fix has a failing-first run on e162f73's sources and a mutation receipt for every new guard. The first and second rounds' fixes are unchanged and still pass (below).
PostToolUsenorPostToolUseFailure. The runtime still kept the call in its session (in the reviewer's run, the matched note was replayed on resume), and the chat reported normal, complete, zero unresolved. Ending a collection assumed a missing hook leaves an open exposure, but Grep has no input-side occurrence. Fix: an obligation ledger. Every callbegin()admits is recorded as an obligation (safety_obligations, migration 085) before the tool runs. It is discharged only when the call's result is durably recorded, or when the backend refuses the call, which proves it never ran. A collection that ends owing one, however it ended, gets a permanentrecording_failedgap naming the call (failure_cause.site: "safetyEnd"). An obligation still open at boot gets the same gap (site: "boot-obligation"). The ledger is the host's own record, so it does not depend on Claude delivering any hook. Refusals that discharge: a rejectedbegin()(both backends refuse the call on rejection), every deny a fenced ClaudePreToolUsehook orcanUseToolreturns, every Pipermissionanswer other than allow (a deny or a rejection:pi-agent-core'sprepareToolCallblocks the call before it runs), and a Pitool_callblock. A refused call stays refused, so a parallel hook's laterbegin()cannot reopen it. Round 2's semantics hold: a stopped turn's fully observed result is recorded as an occurrence, discharges its call, and leaves no gap.permission, result atsafetyResult), so the same ledger covers it. A worker that dies mid-tool, or never reports, leaves the gap.Exit-path audit, obligation ledger. Extends the second review's audit below, whose restart row now also names the owed call's gap. Each path between
begin()admitting a call and its result's record now records the result, refuses the call, or leaves the chat a permanent gap, whatever the runtime delivers.safety-result-retention"a turn stopped while its search runs…" (installed Claude, real resume)site: "safetyEnd")safety-result-exits"a call admitted and never reported…"host_restart_unknownonlysite: "boot-obligation"); a recorded call in the same turn is not namedsafety-result-exits"…still owed when the host dies…"SAFETY_CANCELLED_RECORDED_RESULT_IS_NO_GAP,SAFETY_REFUSED_AND_RECORDED_CALLS_OWE_NOTHINGPreToolUsedeny (cancel, stale admission, policy, a hook that throws) orcanUseTooldenypermission-wiring-units"refusals owe no result"permissionanswer other than allow (deny, or rejection such as a stop after admission)worker-rpc"every permission answer but allow…"tool_callgate blocktools-permission"a call the gate blocks…"begin()is a refusal: owes nothing, no gapsafety-result-exits"…edited input cannot be recorded…"SafetyRecordingUnavailable, call refused, no gapsafety-result-exits"…admission cannot be recorded…"begin()after a refusal of the same call (a parallel hook)SAFETY_REFUSED_CALL_STAYS_REFUSEDFailing-first (e162f73 sources, the reviewer's reproduction made permanent):
safety-result-retention"a turn stopped while its search runs reaches neither result hook, and its chat keeps a permanent gap" (installed Claude 2.1.293; the search is the installed runtime's own ripgrep, behind a wrapper that holds its exit)SAFETY_UNRECORDED_RESULT_RESTRICTS_ITS_CHAT: expectedrestricted, receivednormal, afterSAFETY_ACTUAL_SEARCH_RAN,SAFETY_RUNTIME_RESUMES_THE_INTERRUPTED_CALL,SAFETY_RUNTIME_SKIPPED_BOTH_RESULT_HOOKSandSAFETY_RUNTIME_KEEPS_THE_CALL_IN_ITS_SESSIONpassedThe runtime's resumed session carries either the matches or its own "[Tool call interrupted…]" note for the call (the reviewer saw both); the test accepts either and asserts the gap. The ledger's unit tests use the new API (
refused,safety_obligations), so their red receipts are the mutations below.Mutations (scratch worktree at the fix; each restored, tree clean after):
SAFETY_UNRECORDED_RESULT_RESTRICTS_ITS_CHAT(installed Claude),SAFETY_OWED_RESULT_IS_A_DURABLE_GAPSAFETY_OWED_AT_RESTART_IS_A_DURABLE_GAPbegin()opens no obligationSAFETY_UNRECORDED_RESULT_RESTRICTS_ITS_CHAT,SAFETY_ADMITTED_CALL_OWES_ITS_RESULT, and 3 moreSAFETY_CANCELLED_RECORDED_RESULT_IS_NO_GAP(installed Claude),SAFETY_REFUSED_AND_RECORDED_CALLS_OWE_NOTHING,SAFETY_ONLY_THE_UNREPORTED_CALL_IS_OWEDSAFETY_REFUSED_AND_RECORDED_CALLS_OWE_NOTHINGbegin()not dischargedSAFETY_REFUSED_EDIT_OWES_NOTHINGSAFETY_REFUSED_CALL_STAYS_REFUSEDSAFETY_UNRECORDED_ADMISSION_REFUSES_THE_CALLPreToolUsedeny not refusedCLAUDE_DENY_REFUSES_THE_CALLcanUseTooldeny not refusedCLAUDE_DENY_REFUSES_THE_CALLpermissionnot refusedPI_NON_ALLOW_PERMISSION_REFUSES_THE_CALLpermissionnot refusedPI_NON_ALLOW_PERMISSION_REFUSES_THE_CALLPI_GATE_BLOCK_REFUSES_THE_CALLExisting test changed.
live-safety-admission"parallel Claude native-read" checked that the sibling hook had returned after a singlesetImmediate. Every admission is now a write-worker round trip, so the probe waits on a completion barrier (every sibling hook returned) instead, per test waits. The fence property it proves, and its assertions, are unchanged.safety-result-retention's helper gained therunningmode and counts both result hooks; its two earlier cases are unchanged.Runs after the third follow-up (at 0085b9b, with
origin/maina75d54a merged; exit codes read from each command):safety-*suite in ui-server, every suite usingcreateSafetyCollector,session-safety-boundaries,approval-scope-isolation,http-supported-mounts,live-safety-admission,owner-safety-review,host-publication-safety,web-pi-delivery,chat-deletion,chat-lifecycle,native-history-removal,db-migration-runner,journal-database,software-status,relay-recording-settlement,ws-apify,no-console; ui-backend-piworker-rpc,tools-permission,extension-inspection,worker-session,worker-session-units; ui-backend-claudepermission-wiring-units,follow-up,characterization-permissions,allowlist-enforcement,confirm-bash,confirm-archive,edited-approval; ui-reactrender/turn-failure; rootfirst-party-failure-classes: 759/759, exit 0.ui-backend-claudeandui-backend-piprovider-history,provider-history-apify): 35/35, exit 0.safety-result-retention, 5 consecutive runs before the merge (0fadb44b2, same sources): 3/3 each, exit 0.tsc --noEmit(16 GB heap): exit 0.bun run lint: exit 0.bun run api-report: exit 0, no diff (refusedis@internal).bun run check:pr --base origin/mainat 0085b9b: exit 0 (receipt below).origin/mainadded085_journal_object_quarantine.journal.sql. The runner keys receipts on file names, so both 085 files apply (db-migration-runner,journal-database,safety-ledgergreen).Second and first reviews, at 511e94a and 88e5805
Moved, unchanged, to this comment to keep the body under GitHub's size limit. Their fixes still hold; see the runs above.
Validation
Failing-first. A probe using only APIs present on both trees (
zz-containment-receipts.test.ts, not committed) onorigin/maine8ea534, then on this branch:origin/mainRECEIPT_3812_BEGIN_FAILURE_REFUSES_ONLY_ITS_TURNrefused: Safety recording requires recoveryRECEIPT_3812_CHAT_LOSS_LEAVES_OTHER_CHAT_USABLErestricted, expectednormalRECEIPT_3812_UNWRITABLE_NOTICE_STILL_RUNS_NEW_TURNS_RESTRICTEDrefused: Safety recording requires recoveryRECEIPT_3812_INCIDENT_STATE_BOOTS_AND_ADMITS(failed=1,reason='capacity', no pending, no open)failedstill 1 after bootRECEIPT_3810_NON_CAPACITY_RESERVE_ERROR_IS_RECORDING_FAILEDcapacityMutations (scratch worktree at the PR head; each restored):
safetyBeginerrora failed safetyBegin refuses only that turn…an unwritable evidence store … clears itself,a durable brain latch …(refused as paused)condition not reached),automatic recovery waits for an uncovered producer to drainSAFETY_INCIDENT_STATE_RECOVERS_AT_BOOTSAFETY_BRAIN_RESTRICTION_RUNS_NEW_TURNSSAFETY_NON_CAPACITY_ERRORS_ARE_RECORDING_FAILED,SAFETY_RESERVE_ERROR_IS_RECORDING_FAILED,SAFETY_MIGRATION_FAILURE_IS_RECORDING_FAILEDSAFETY_LATER_LATCH_ONLY_COUNTSSAFETY_STATUS_HIDDEN_FROM_OTHERSSAFETY_FAILED_COMMIT_CHAT_RUNS_RESTRICTED(safety-ledger)a producer refused under a brain latch still leaves its own chat a durable gapSAFETY_UNNAMED_LOSS_IS_DURABLY_UNSCOPEDSAFETY_SESSION_LOSS_NEVER_LATCHES_THE_BRAINSAFETY_CAPACITY_SURVIVES_THE_WORKERSAFETY_RETAINED_LOSS_KEEPS_ITS_ORIGINAL_CAUSErefusalReasonthe paused recorder is named: expected 'The brain refused this message.' to be 'Safety recording is paused on this se…'Runs.
safety-containment.test.ts16/16; every suite importing the changed governance modules plushttp-supported-mountsandgovernance-roadblocks: 33 files, 590 pass before the last two fixes, then the touched ones re-run green (safety-occurrences,http-supported-mounts,safety-containment,safety-ledger,safety-loss-recovery,governance-roadblocks: 250/250; then 70/70 after the review fixes). The completeui-serverpackage suite is ~10 h locally and is left to hosted proof.draft-store,render/turn-failure,render/worker-host-notice: 88/88.node scripts/visual.mjs --project=ui-react-layout --filter=outgoing-snapshots: 9/9, incl. the new refusal-copy case.tsc --noEmitclean;bun run lintclean.Existing tests changed and why. They encoded the brain-wide latch. Each keeps its original property under the new scope: a loss notice that cannot commit still restricts (the injection now fails the chat fact too); final provider admission still rechecks a loss (now the turn's own) and gains
other-chat-recording-loss(passes); approvals still withdraw on related loss (own loss) and survive another chat's (other chat loss); capacity still refuses before delivery and still refuses new chats at a full brain, but no longer burns the emergency cell.hold-safety-recovery.tskeeps the reconciler from racing tests that drive recovery by hand. The 081 replay test also replays 085.Independent review. gpt-6-astra (high), adversarial ledger on
git diff origin/main...HEAD: two P1 findings (an early refusal under a latch retained no loss; a loss with no collection latched the brain with no durable scope, so recovery gapped nothing), three P2 (capacity class lost across the worker, retained cause discarded, two assertions that could pass on a broken tree). All five were confirmed and fixed infix(ui-server): never let recovery clear a loss that named no chat, each with a mutation receipt above. It verified: uncovered open producers block automatic recovery, restricted-begun turns stay restricted after recovery, the reconciler's checks and clearing share one transaction, the status field is owner-only and the recovery POST sits behind the global origin policy.Not covered here.
PreToolUsehooks have not all returned, and runs each matchingPreToolUsehook once per admission.Collisions. recorded in a comment with the head before confirmation.
check:pr (
--base origin/main, after the sixth review follow-up, at 7ad2bb7 withorigin/mainb77987a merged; exit 0):{ "version": 1, "kind": "brain-check-pr-receipt", "head": "6c7331bd052d3e53c75882f59708bfa45fc9b63c", "base": "origin/main", "mode": "focused", "startedAt": "2026-11-10T23:12:48.870Z", "finishedAt": "2026-11-10T23:14:36.441Z", "checks": [ { "name": "all lint and leakage gates", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 11711.230719 }, { "name": "environment documentation", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 94.46436099999846 }, { "name": "pending changeset package names", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 60.56257000000005 }, { "name": "contribution changeset", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 19.174386999999115 }, { "name": "affected fast invariants", "categories": [ "verify", "unit" ], "outcome": "passed", "elapsedMs": 95594.809689 } ] }🤖 Generated with Claude Code