Skip to content

ui-server: a private-state refusal reaches the client under another error code #4497

Open

Description

@schlessera

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, reporting ATTACHMENT_REJECTED at :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, in JournalStorageUnavailable. emitTurnError checks only the top-level reason (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 gets JOURNAL_UNAVAILABLE instead of PRIVATE_STATE_UNVERIFIED.
  • Exposure has no turn code. assertReadable (packages/ui-server/src/brain/governed-turn.ts:120-122) throws for private_state_unverified, private_state_in_brain and database_in_brain, but emitTurnError maps 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.md and http.md.
  • A private-state refusal wrapped by storageError or the journal admission catch reaches the client as its own code, not JOURNAL_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

  1. added
    area: ui-server
    priority: p3
    on Nov 23, 2026
  2. changed the title [-]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[/+] on Nov 23, 2026
  3. added
    type: fix
    blocked
    agent-ready
    and removed on Nov 23, 2026
  4. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Unblocked: #4487 is closed, so scripts/sync-project.ts is removing the blocked label.

  5. removed
    blocked
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-serverpriority: p3type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions