# Proof audit pass 2

Issue: [#21219](https://git.cafe/pingdotgg/t3code/issues/21219)
Reviewed head: [d230223ec5](https://git.cafe/pingdotgg/t3code/commit/d230223ec5638f895f94db0668680322d7474fe0), base [b5a226e49c](https://git.cafe/pingdotgg/t3code/commit/b5a226e49c).
Runtime implementation: [597823c8ad](https://git.cafe/pingdotgg/t3code/commit/597823c8ad18a4870c39d834e907b5ef56476e4e). The head adds only test assertions; production code is identical.

## Findings

No blocking defect or scoped proof gap found. Read the worktree AGENTS.md, issue, complete four-file diff, relevant protocol decoder, prompt completion, registry failure classifier, finalizer, replay helper and control tests, and every supplied evidence file. No repository edits, forge writes, server/browser operations, or test reruns performed. Used pr-audit, cafe-cli/cafe-issues for the read-only issue lookup, and ghdrop for this authorized report upload.

The fix preserves optional idle error data in PromptResponse and fails non-following ACP prompt results with stopReason:error. It reuses the existing following-agent-work error conversion, preserving the provider classifier. The decoder already accepts the idle error extension despite the older generated schema. Null and missing errors share the same optional-chain/nullish fallback; explicit null coverage is not needed to establish this scoped behavior. Success/default stop reason, usage and metadata forwarding remain unchanged by inspection. Error code/message/data are passed into the same AcpRequestError conversion; arbitrary error data is not newly published.

The two regressions use an accepted v2 prompt with continuations disabled and agentId acplause, so they exercise the affected non-following branch. Both assert failed and a useful message. The head then submits prompt 2, waits on the event queue for its completed terminal, checks a distinct providerTurnId, and counts the first turn's terminal across that boundary. A duplicate first-turn terminal would become the next terminal and fail the completed/distinct-ID assertions. Queue consumption is deterministic, without sleeps or polling. This establishes the requested bound through the next prompt completion, not exactly-once behavior against arbitrary future external input. The existing finalizer also sets context.finalized before yielding and ignores repeated finalization.

Runtime evidence records real acplause invalid-auth failures on both the fresh-provider resumed thread and the original Codex-to-acplause handoff. Each has running -> failed, one durable failed transition, one provider_error failure item, and Missing Authentication header; the primary records the same visible outcome. The fresh route is a new prompt in the previously created fresh-provider thread, not proof of a newly allocated post-fix session. That distinction does not leave the reported idle-completion bug unproven. Runtime verification targets the unchanged production revision.

Evidence provenance limits: before-runtime and red-test are concise reports, with red explicitly attributed to the original delegated test run, rather than raw red runner output. The fixed transcript contains correlated persistence observations and the primary's integrated observation, not a fixed raw ACP wire trace; retained wire logs only prove baseline traffic. These limits are disclosed and acceptable for the requested test-plus-runtime proof. No successful real-provider call is claimed with the invalid key. No fresh independent execution or independent endorsement of the two prior reviewers is claimed by this audit.

## Matrix row statuses

Visual fixture matrix: EMPTY. No changed renderer, CSS, interaction, or client-wire contract. Screenshots, recordings, and pixel rebuilds: NOT APPLICABLE.

| Pass-1 runtime/protocol row | Status | Evidence and assessment |
| --- | --- | --- |
| 1. Revision, environment, green tests | PASS | Runtime head and test-only head reconciled by git diff; isolated worktree, Node/provider versions and ports recorded. Raw green outputs show 42 client+registry, 59 adapter, and repeated strengthened 16 registry tests: 101 distinct tests, not 117. Format/lint reports pass. Exact command lines are not retained in every raw log; suite identities and runner outcomes are sufficient here. |
| 2. Real failure and original handoff | PASS | before-runtime contrasts completed with fixed-runtime/primary-after-browser failed on both routes; useful authentication message and one failure item each. Real provider observation; invalid nonsecret key. |
| 3. Missing details and conversion | PASS | Both error-bearing and omitted-error regressions pass; nonempty fallback asserted. Null follows identical nullish fallback by inspection. Existing client test checks structured idle error preservation; adapter mapping inspected for code/message/data and flavor classification. No claim that raw data is exposed to users. |
| 4. Successful completion | PASS | Strengthened regressions complete the next accepted v2 prompt with end_turn in the same non-following session. Other adapter/client success controls pass; default stop reason and usage/metadata forwarding remain unchanged. Not a real-provider success claim. |
| 5. Cancellation and user Stop | PASS | 59 adapter controls include cancelled outcome, native cancellation drain before next prompt, and interrupted Stop; registry refused-Stop/retry remains green. Cancellation mapping is untouched. Controlled fixtures, not real invalid-key cancellation. |
| 6. Following-agent-work | PASS | Registry output includes completed/failed idle, approvals/questions, child handoff after error/end_turn, nested output, termination and Stop. Helper extraction is semantically equivalent to the original mapping. |
| 7. Terminal uniqueness | PASS, BOUNDED | Both target failures remain single-terminal through distinct next-prompt completion. Real failure routes each record one durable failed transition and failure item. Existing controls cover cancellation drain and child uniqueness. No arbitrary-future or explicit duplicate-idle injection claim; neither is required by the narrowed operational brief. |
| 8. Integrated persistence transcript | PASS | Both real routes record failed persistence and primary visible error; adapter status is distinguished from durable projection and control-only cancellation/interruption. Fixed raw protocol logs are explicitly not claimed. |

No browser, server, repo-wide check, or direct server tsc was run. No PR exists or was created. Worktree remained clean.

## FRICTION

category | problem | avoidance
--- | --- | ---
Brief | docs/EVIDENCE.md is absent | Used the explicit operational brief and matching server-only proof rule in AGENTS.md.
Evidence provenance | Red output is a delegated summary; fixed wire logs retain only baseline traffic | Reported those limits; used the supplied correlated durable transitions and integrated observations without claiming raw fixed-wire proof.
Scope | Pass-1 broad exactly-once wording exceeds the final bounded claim | Reviewed the actual deterministic next-prompt boundary and made no arbitrary-future guarantee.
Checks | Prior direct server tsc hung | Did not repeat it or broaden checks; inspected focused green outputs and the test-only diff.

VERDICT: SUFFICIENT
