Skip to content

test(safety): prove streaming recovery, restart and two owner views - #4262

Merged
schlessera merged 6 commits into
mainfrom
test/3606-integrated-recovery
Nov 20, 2026
Merged

schlessera merged 6 commits into
mainfrom
test/3606-integrated-recovery

Conversation

@schlessera

@schlessera schlessera commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Closes #3606

What changed

Adds a joined offline recovery journey through real ingestion detection, streaming HTTP proxying, the FULL SQLite write worker, authenticated owner review and two independent WebSocket-backed client stores. A/B/C remain separate, open or delayed input refuses review, A/B leave C restrictive, finalized C restores normal, and future same-source D restricts again. Fresh database/writer/history instances replay committed verdicts and retain an unfinished-result coverage gap. A pinned browser test alternates single-trigger review between two independent roots/sockets and checks both views after every verdict. Both provider-history probes now resume a legacy policy prefix while proposing upgraded wording and changing live taint facts.

Why this shape

#3596's existing focused tests cover the broader edge matrix. This joins their production boundaries without duplicating APIs or changing behavior. The readiness correction on #3606 records that the contract additions were delivered by its closed prerequisites. No shipped code, public contract or consumer-visible artifact changes; no changeset is needed.

Proof

Base cb4236234c1cce1f45d034e9eb34d15eda41f934; head ce1f1dc8e4fd14c7368f9a750fbc0904fcd3b03b. The review fixes are f1fdb4b1b016777ad6d55d2e226ac01509d9cfed; subsequent clean merges refreshed the branch onto delivered #4255, #3622 and #4258.

  • bun run test packages/ui-server/tests/safety-recovery-journey.test.ts: 5 pass, 110 assertions after restoring all mutations.
  • Focused ledger, proxy, review, loss recovery, history, owner transport and journey suites: 121 pass, 795 assertions (before the unrelated CONTRACT: feat(ui-server): resolve Settings repository identity without Git acquisition #4255 base refresh).
  • Pinned offline Chromium node scripts/visual.mjs --project=ui-react-layout --filter=safety-review.layout: 9 pass, including 320/1280 light/dark interaction/reload and the new two-view journey. Rootless Docker requires readable bind inputs; original launch failed module resolution, then the first two-view fixture exposed its shared global socket. Independent socket routing fixes that harness error; all nine now pass.
  • Original mutation: change proxy occurrence creation from open to finalized during delivery. The joined test fails JOURNEY_STREAM_CANNOT_BE_REVIEWED with expected not_finalized, received null (2 pass / 1 fail; no setup error). Restore the guard: 3 pass / 0 fail. Mutation is not committed.
  • Review-fix mutations: (1) force effective admission restriction false: JOURNEY_A_CANNOT_RESTORE_ADMISSION, expected false / received true; (2) force it true: JOURNEY_FINAL_C_RESTORES_REAL_ADMISSION, expected true / received false; (3) remove pending-input registration: JOURNEY_PENDING_ADD_BLOCKS_REAL_ADMISSION, expected false / received true; (4) ignore restriction and recording availability only for a failed recorder: JOURNEY_FAILURE_LATCH_BLOCKS_REAL_ADMISSION, expected false / received true. Each named runtime test fails 0 pass / 1 fail on that assertion. Restore all four: 5 pass / 0 fail, 110 assertions on the final head. None of the mutations is committed.
  • bun run build and NODE_OPTIONS=--max-old-space-size=6144 bun run typecheck pass; the latter includes the review fixes before the unrelated base refresh. Exact final-head bun run check:pr --base origin/main passes.
  • Local provider-history execution refused worker namespace setup; no passing local provider receipt is claimed. Both updated keyless guards executed and passed in automatic main 44759131939.

The two review findings are fixed in the journey: real Pi outward admission uses admissionSafety and an offline fake-Git process effect after A/B/C/D; the proxy bridge also carries live safety. A real FULL-writer barrier delays detector B after A was reviewed, while both client reads and an exact HTTP verdict retry wait. Success keeps B independent until its own verdict. Injected SQLite recording failure preserves the failure latch through both clients, retry and database restart; actual dispatch remains blocked throughout.

Coverage mapping: new joined journey and browser views cover criterion 1 and streaming/delayed criterion 2; existing CONNECT proxy test covers opaque closure. The integrated delayed-write/failure/restart scenarios join criterion 3; existing safety-review/history/ledger/loss suites additionally cover stale/reordered delivery and retirement. Existing ledger upgrade/capacity/pruning cases cover criterion 4. Updated provider probes plus existing live-admission/outward/private-grant/voice tests cover criterion 5; hosted guards remain mandatory.

{"version":1,"kind":"brain-check-pr-receipt","head":"ce1f1dc8e4fd14c7368f9a750fbc0904fcd3b03b","base":"origin/main","mode":"focused","startedAt":"2026-11-20T14:41:19.698Z","finishedAt":"2026-11-20T14:42:30.615Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":19129.550969},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":206.85383000000002},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":138.25333699999464},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":21.255186999995203},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":51389.28271399999}]}

Checklist

  • Focused local preflight, mutation receipts, selected candidate proof and complete selected main proof passed.
  • Original acceptance criteria retained and mapped above.
  • Independent review has no findings at 2ead77c4e060acdd45f1161b2a2102f781e510b6; clean base merges remain covered and the review gate reports refusal: null.
  • 0.45.0 issue milestone verified; PR receives the same milestone.
  • No consumer-visible change, personal data, machine-surface change, or new guard.

Anything left open

Nothing remains for #3606. Epic #3596 remains open for combined-review follow-ups #4267 and #4268 and the parent's final review reconciliation. #4261 was resolved as documented Bun matcher misuse; the restored late-write checks pass with the existing safe assertion helper.

SDK-option review follow-up

The second review finding is fixed in 2ead77c4e060acdd45f1161b2a2102f781e510b6. The full Claude guard now compares captured SDK systemPrompt options for every scenario, including safety, posture, title and immutable reads; each must capture all three turns with a present option. The hosted-budget case now records the production fingerprint of the actual SDK systemPrompt option rather than comparing an empty list. The same comparison helper runs against real option assembly locally, independently of the CLI's replayed system bytes.

Audit: grepped both backends' provider-history and Apify guards. Claude reference/renewal/freshness/compute and Apify already checked options; the gaps above are now covered. Pi's actual serialized worker system is observed directly by its guards, without Claude's replayed-preset layer hiding a separate option.

Mutation: bypass the retained append for the safety-wording scenario so the real SDK option changes from Legacy safety policy to Reviewed safety policy. The shared guard fails SAFETY_UPGRADE_RETAINS_SDK_OPTIONS: first differing byte 66 on those exact option bytes (1 pass / 1 fail). Restore retention: both local taint-note/SDK-option tests pass (2 pass / 0 fail, 7 assertions). No product append-only break was found and no production mutation is committed. Final-head typecheck with the required memory setting and focused preflight pass. Both installed-provider guards are confirmed passing in main 44759131939; the local option-boundary test supplies additional mutation evidence.

Refreshed candidate

Merged delivered #3622 from main without conflicts. The diff remains the same nine test/helper files; duplicate-block and whitespace checks pass. The clean review at 2ead77c4e060acdd45f1161b2a2102f781e510b6 covers this clean base merge, and the review gate reports refusal: null. Focused preflight passes on refreshed head 04fde16ca8b4edc9c5d8f41e77adbf79cc85754f. Optional draft feedback may be cancelled by confirmation; candidate fast proof and the squash main run supply the required qualification.

Clean base refresh after #4258: merged main cb4236234c1cce1f45d034e9eb34d15eda41f934 without conflicts. The candidate diff remains the same nine test/helper files; duplicate and whitespace checks pass. Preflight passes on refreshed head ce1f1dc8e4fd14c7368f9a750fbc0904fcd3b03b; prior reviewed source remains unchanged.

Final delivery and main qualification

Merged as c5071f7025b4eab3ff40e2a7c77c5a0d8ee05542. Candidate 44756418291 passed, with synthetic checkout 9d66284253db80edaee10659e35b39a048173091, parents cb4236234c1cce1f45d034e9eb34d15eda41f934 / ce1f1dc8e4fd14c7368f9a750fbc0904fcd3b03b, and tree d5d1de3ac7cc98a82bd763728443a6caf350cf0f. The actual squash parent and tree match, and its ancestry on main was independently verified.

Automatic main 44759131939, attempt 1 passed all selected heavy categories freshly. The complete selected inventory is 19 jobs: 17 successful actual execution checkouts all equal the squash, and two planner-intended repetition skips (repetition passed on the candidate). Metadata names the actual squash parent. Actual logs confirm both installed provider-history guards, the SDK-option upgrade check, all four healthy Claude/Pi UID 1000/0 native cells, and the separate negative control. Detailed job identities are recorded on #3606. PR and issue retain milestone 0.45.0; #3606 is closed and #3596 stays open for its new combined-review follow-ups.

@schlessera schlessera added this to the 0.45.0 milestone Nov 20, 2026
@schlessera schlessera added type: test Coverage, harness or proof work with no behaviour change. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. area: ui-react React chat/files/voice components, stores, WebSocket transport. area: backends AgentBackend implementations and the seam they share. security Auth, isolation, egress, secrets, or anything in the threat model. labels Nov 20, 2026
@uploads-sh

uploads-sh Bot commented Nov 20, 2026

Copy link
Copy Markdown

No uploads on this PR yet

This PR changes UI files (packages/ui-react/tests/browser/safety-review.layout.tsx). Screenshots help reviewers see what changed.

  • From the CLI: uploads put before.png after.png --pr 4262
  • From an agent: ask it to attach screenshots with uploads.sh
  • By hand: drag images into the PR description and they're imported automatically
Tips for agents

Label each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one put per shot:

uploads put after.png --pr 4262 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 4262 --app ios --screen "Chat" --state after

No CLI? With the Uploads MCP, call sign_upload_url for files on disk (or put) with repo, pr: 4262 and the same screen, state and caption fields.

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 uploads list --pr 4262. More in the github-screenshots skill or the agent docs.

Workspace admins can turn this comment off in Settings → GitHub · docs

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 6e5c22a against base bd751d4. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4262,
  "head": "6e5c22a70003f9bd6b38937b4791a4431031f69e",
  "base": "bd751d43435bbffa919d987323d17098eb5f7166",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/tests/safety-recovery-journey.test.ts:86: Recovery is asserted only through projections and client stores; no admission is attempted after reviewing A, B or C. The proxy bridge also omits admissionSafety. A regression that restores normal admission prematurely or keeps it blocked after complete review would pass, leaving the normal-admission acceptance criterion unproved."
    },
    {
      "summary": "packages/ui-server/tests/safety-recovery-journey.test.ts:103: The added recovery scenarios only reopen a settled database with completed or unfinished tool delivery. They never delay a database write or inject recording failure, and the streaming journey awaits every write. Thus the required integrated pending-add/failure-latch and late-write races remain unqualified; the issue explicitly says individual foundation tests do not establish this journey."
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 6e5c22a against base d88c227. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4262,
  "head": "6e5c22a70003f9bd6b38937b4791a4431031f69e",
  "base": "d88c227c66f374224e35a245dc1c8ef8ba2fbe26",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/tests/safety-recovery-journey.test.ts:86: Recovery is asserted only through projections and client stores; no admission is attempted after reviewing A, B or C. The proxy bridge also omits admissionSafety. A regression that restores normal admission prematurely or keeps it blocked after complete review would pass, leaving the normal-admission acceptance criterion unproved.",
      "disposition": "fixed",
      "commit": "f1fdb4b1b016777ad6d55d2e226ac01509d9cfed"
    },
    {
      "summary": "packages/ui-server/tests/safety-recovery-journey.test.ts:103: The added recovery scenarios only reopen a settled database with completed or unfinished tool delivery. They never delay a database write or inject recording failure, and the streaming journey awaits every write. Thus the required integrated pending-add/failure-latch and late-write races remain unqualified; the issue explicitly says individual foundation tests do not establish this journey.",
      "disposition": "fixed",
      "commit": "f1fdb4b1b016777ad6d55d2e226ac01509d9cfed"
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 6e5c22a against base bd751d4. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4262,
  "head": "6e5c22a70003f9bd6b38937b4791a4431031f69e",
  "base": "bd751d43435bbffa919d987323d17098eb5f7166",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/tests/safety-recovery-journey.test.ts:86: Recovery is asserted only through projections and client stores; no admission is attempted after reviewing A, B or C. The proxy bridge also omits admissionSafety. A regression that restores normal admission prematurely or keeps it blocked after complete review would pass, leaving the normal-admission acceptance criterion unproved.",
      "disposition": "fixed",
      "commit": "f1fdb4b1b016777ad6d55d2e226ac01509d9cfed"
    },
    {
      "summary": "packages/ui-server/tests/safety-recovery-journey.test.ts:103: The added recovery scenarios only reopen a settled database with completed or unfinished tool delivery. They never delay a database write or inject recording failure, and the streaming journey awaits every write. Thus the required integrated pending-add/failure-latch and late-write races remain unqualified; the issue explicitly says individual foundation tests do not establish this journey.",
      "disposition": "fixed",
      "commit": "f1fdb4b1b016777ad6d55d2e226ac01509d9cfed"
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head aff2c41 against base d88c227. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4262,
  "head": "aff2c419bc201e7fbedfc9a92f5bd90aae691c6c",
  "base": "d88c227c66f374224e35a245dc1c8ef8ba2fbe26",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-backend-claude/tests/provider-history.test.ts:199 checks only the captured system bytes for the upgrade scenario, omitting capture.appends. The local Claude CLI replays the original system prompt and masks changes to the SDK systemPrompt option, as documented above. Existing option checks exclude safety, so this guard can pass even if upgraded wording breaks the provider prefix in production. Assert identical captured SDK options across these turns too."
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head aff2c41 against base d88c227. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4262,
  "head": "aff2c419bc201e7fbedfc9a92f5bd90aae691c6c",
  "base": "d88c227c66f374224e35a245dc1c8ef8ba2fbe26",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-backend-claude/tests/provider-history.test.ts:199 checks only the captured system bytes for the upgrade scenario, omitting capture.appends. The local Claude CLI replays the original system prompt and masks changes to the SDK systemPrompt option, as documented above. Existing option checks exclude safety, so this guard can pass even if upgraded wording breaks the provider prefix in production. Assert identical captured SDK options across these turns too.",
      "disposition": "fixed",
      "commit": "2ead77c4e060acdd45f1161b2a2102f781e510b6"
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 2ead77c against base d88c227. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4262,
  "head": "2ead77c4e060acdd45f1161b2a2102f781e510b6",
  "base": "d88c227c66f374224e35a245dc1c8ef8ba2fbe26",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

Copy link
Copy Markdown
Owner Author

Collision scan for head 2ead77c4e060acdd45f1161b2a2102f781e510b6 (bun scripts/collisions.ts --json --pr 4262):

The shared integration reservation serializes confirmation and merge; no other holder is disturbed. Draft heavy feedback is optional feedback, not proof, and may be superseded by candidate confirmation.

Copy link
Copy Markdown
Owner Author

Refreshed collision scan for head 04fde16ca8b4edc9c5d8f41e77adbf79cc85754f, base 65883f2d5332220db8a17fd1ddba0f926a1888be:

No path or unknown collision was reported. Shared integration ownership remains authoritative. Refreshed focused journey and SDK-option tests: 7 pass, 117 assertions. The clean main merge introduced no duplicate blocks; the ancestor review remains accepted with refusal=null.

Copy link
Copy Markdown
Owner Author

Collision scan for refreshed head ce1f1dc8e4fd14c7368f9a750fbc0904fcd3b03b on main cb4236234c1cce1f45d034e9eb34d15eda41f934:

Clean base merge; the diff remains nine test/helper files with no duplicate blocks. Focused preflight passes; review refusal is null. PR and issue release milestones read back as 0.45.0. Confirmation uses the shared reservation and does not disturb other holders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: backends AgentBackend implementations and the seam they share. area: ui-react React chat/files/voice components, stores, WebSocket transport. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. security Auth, isolation, egress, secrets, or anything in the threat model. type: test Coverage, harness or proof work with no behaviour change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: prove single-trigger recovery across streaming, restart and two clients

1 participant