Skip to content

ui-server: a damaged retained code receipt can break a turn's history, the next capture or startup quarantine #4430

Open

Description

@schlessera

Part of #4426 (follow-ups from #4278). Found in the sixth review of PR #4362 (#4297).

Context

Startup quarantine replaces an unusable retained receipt with a durable cause, but it has three gaps. All three need a row damaged outside the product, because capture validates every field before the write (captureCodeChanges, packages/ui-server/src/brain/code-change-worker.ts:38-43).

  • The predicate (USABLE_CODE_RECEIPT, packages/ui-server/src/brain/turn-journal.ts:47-50) checks only the top-level types, so a receipt with paths: [null] or an invalid tree id passes.
    • The history entry then throws in render (CodeChanges, packages/ui-react/src/components/chat/code-changes.tsx:44, mounted without an error boundary at turn-journal.tsx:120).
    • An invalid tree_after becomes the next capture's baseline.
  • Quarantine visits ended turns only (turn-journal.ts:161-162). The previous-endpoint lookup (:312-313), summary (:531), scope facts (:730) and details (:1196) read receipts without the guard, so malformed JSON on a turn owned by a live process throws from each.
  • All quarantine writes are one transaction with no capacity handling (:166-171). If it hits the journal cap, ready rejects, nothing is quarantined, and the next open retries the same transaction.

Scope

The quarantine predicate, the unguarded readers and the quarantine write. No contract change. Out of scope: capture and restore.

Acceptance criteria

  • A retained receipt with a non-object path element, an unknown change kind or an invalid tree id is quarantined with its cause at open.
  • A malformed receipt on a turn that has not ended does not throw from summary, details or the next turn's endpoint lookup. The checkout starts from its starting commit's tree, and the damage is recorded once the turn ends.
  • Quarantine commits per receipt. A capacity refusal leaves the remaining rows for the next open, and ready resolves.
  • CodeChanges renders a receipt with an unusable path list as an incomplete entry instead of throwing.
  • Each test is shown failing with its guard removed.

Activity

  1. added
    type: fixSomething is broken and must behave the way it is documented.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p3Someday. Needs a driving use case before it starts.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 21, 2026
  2. schlessera commented on Nov 21, 2026

    @schlessera
    OwnerAuthor

    Added from the review of PR #4435. Since the boot fix X1, a capacity refusal defers quarantine and ready resolves, so the damaged receipt stays on an ended turn and its readers still throw.

    Additional acceptance criteria:

    • While quarantine is deferred, summary and details for that ended turn do not throw; the receipt reads as an incomplete entry.
    • expire never parses a raw receipt, so collectOne can reclaim capacity from a turn whose receipt is damaged (expire, packages/ui-server/src/brain/turn-journal.ts:574-592; summary, :550; details, :1215).
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-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p3Someday. Needs a driving use case before it starts.type: fixSomething is broken and must behave the way it is documented.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions