Repository navigation
Description
Part of #4426. Found in the second independent review of PR #4490, which fixes #4486 and #4487.
Blocked by #4487
(The PRIVATE_STATE_UNVERIFIED turn refusal and its mapping in emitTurnError are introduced by PR #4490; neither exists on main.)
Context
Line numbers are at PR #4490's head c1f7103a1; the two handler excerpts are unchanged from main 356fa7d.
- Chat and retry. The chat handler resolves staged tracks and attachment bytes from the brain before the turn is admitted (
packages/ui-server/src/ws/handlers/chat-message.ts:28-42, reportingATTACHMENT_REJECTEDat:40). The retry handler does the same (packages/ui-server/src/ws/handlers/retry.ts:46-56, reporting "An original file is unavailable" at:56). When admission would refuse with a private-state reason, a file error can be reported first instead of the documented refusal code. The turn is still refused, so this is error identity only, not an isolation gap. - Journal paths (second-review finding F128). Both
storageError(packages/ui-server/src/brain/turn-journal.ts:66-67, used for example at:820) and the admission catch (:849-857) wrap any non-journal error, a typed private-state refusal included, inJournalStorageUnavailable.emitTurnErrorchecks only the top-levelreason(packages/ui-server/src/ws/bridge-capabilities/turn-error.ts:16-19). If the refusal is first seen in journal initialization, observation or policy, the client therefore getsJOURNAL_UNAVAILABLEinstead ofPRIVATE_STATE_UNVERIFIED. - Exposure has no turn code.
assertReadable(packages/ui-server/src/brain/governed-turn.ts:120-122) throws forprivate_state_unverified,private_state_in_brainanddatabase_in_brain, butemitTurnErrormaps only the first. An exposure that appears after boot reaches the client under the generic path.
Scope
Error identity only: check admission before resolving brain files in chat and retry, and map a private-state refusal to its own code wherever it is wrapped (for example by following the cause chain in emitTurnError).
Exclusions: the availability verdict and the refusal itself; the recorded diagnostic (#4495); scan correctness (#4494, #4499).
Acceptance criteria
- With isolation unverified, chat and retry report
PRIVATE_STATE_UNVERIFIED, not an attachment or original-file error, even when the message carries tracks or attachment refs. - With a confirmed exposure after boot, chat and retry report a private-state code that names the exposure reason. If that needs a new wire code, it is added (additively) to
docs/integration-contract/wire.mdandhttp.md. - A private-state refusal wrapped by
storageErroror the journal admission catch reaches the client as its own code, notJOURNAL_UNAVAILABLE. A test throws the typed refusal from inside journal begin to prove it. (Round 3 of CONTRACT: fix(ui-server): contain checkout capture and alias scan failures #4490 removed the per-call checkpoint guard that was the main source of such refusals; the mapping must still hold for any remaining source.) - Failing-first tests cover both handlers and the journal-wrapped case.
Verification
bun run test on the targeted WebSocket handler and journal test files, with failing-first and mutation receipts in the PR.
Contract impact
Which error code a refused turn carries is wire contract. Reporting the documented code is a fix; a new code for exposure is additive and needs a CONTRACT: commit with the contract doc updated in the same commit.
2026-11-23 triage at main 356fa7d: re-pointed citations at PR #4490's current head c1f7103a1, added the retry handler and the unmapped exposure reasons, declared the dependency on #4487, added scope, exclusions, verification and contract impact.
Activity
[-]ui-server: chat and retry report an attachment error instead of the private-state refusal[/-][+]ui-server: a private-state refusal reaches the client under another error code[/+]schlessera commentedon Nov 23, 2026
Unblocked: #4487 is closed, so
scripts/sync-project.tsis removing theblockedlabel.