from pathlib import Path
import json,hashlib,subprocess
s=Path(Path('/tmp/ev-18359-audit-location').read_text());o=s/'evidence';original=Path('/tmp/ev-18359-evidence');d=json.loads((original/'runtime-trace.json').read_text());r=json.loads((o/'rebuild-verified.json').read_text());cleanup=json.loads((o/'cleanup.json').read_text())
text='''# Proof audit PASS 2

Findings: none blocking; no required proof row missing or contradictory. Read-only audit of [#18359](https://git.cafe/pingdotgg/t3code/pulls/18359), [GitHub mirror #18359](https://github.com/pingdotgg/t3code/pull/18359). No repository edits, commits, pushes, comments, watches, children, browser operations or live userdata reads. Original evidence and worktree preserved.

Exact reviewed and rebuilt head: [394f9be](https://git.cafe/pingdotgg/t3code/commit/394f9be427e329ba0d353d3d6c879fe7dee7e939), full SHA `394f9be427e329ba0d353d3d6c879fe7dee7e939`; base [dd5b540](https://git.cafe/pingdotgg/t3code/commit/dd5b5401e1f240f4314af29edf431369d182f386), full SHA `dd5b5401e1f240f4314af29edf431369d182f386`. Checkout `/home/ubuntu/wt/pr-18359` clean before and after. Saved service and current source SHA256 both `549a72f7b0b2fe398909d150312294b1a4af7501d0247f504a6d285e158e37c2`. origin/main resolves to the supplied base. Original runtime report embeds head as metadata; corroboration is clean source, saved byte-identical service, the matching spans/source lines, and this independent rebuild from the unchanged current head. It is not a cryptographic attestation of historical process memory.

| Row | Status | Reviewed proof |
|---|---|---|
| R0 | PASS | Existing W at T, exact base/thread files, no recreation span, one real native turn and completed durable run. |
| R1 | PASS | W absent, stale/prunable registration and branch T retained; prune/recreate succeeds before root/native start, same T/files and crossed tags. |
| R2 | PASS + independent rebuild | Missing branch created at current named project C, exact base/project files; tag named project-current still T. |
| R3 | PASS | W and branch absent; detached project C; run/attempt/node failed with null startedAt; zero new provider turn, native start/resume, session event, openSession/root-start span. Persisted error confirmed. |
| R4 | PASS | Same thread/server/native conversation; named project branch repaired, new completed run at C. Prior failed run and identical error projection retained. |
| T1 | PASS | Source + exact green log: interruption escapes without events; retry returns typed error without settlement/start; final settles once, three create calls, sanitized durable message. |
| T2 | PASS | Existing 8-case managed-path table retained and green; valid managed/symlink-root paths recreate, invalid cases do not. |
| T3 | PASS | Original 32 tests preserved; red32/green34; source retains bypasses and command ordering. Bypass safety is source inspection, not a claim each bypass has a new dedicated test. |
| T4 | PASS | Driver uses refname:lstrip=2, exact local-head names despite tag collisions; consumers inspected. Runtime crossed tags agree. |
| T5 | OPTIONAL | Other typed Git failure phases not separately injected; not required by the matrix. |

## Original artifact audit

Read all supplied scripts: seed, launch, generic MCP caller, snapshot, rows, sequence, assemble, report, cleanup, server startup and redgreen. Seed uses only fresh fixture Git. Launch and caller use supported MCP/auth services with scoped revocation and NodeServices/Net layers. Snapshots use read-only SQLite against isolated state. Rows mutate only explicit fixture W/project, wait for CLI completion, then snapshot; sequence preserves preliminary evidence and resets only the fixture. Assembly correlates run intervals and computes assertions; it does not replace raw proof. Report is generated narrative with hardcoded IDs/head, checked against raw records. Cleanup records descendants before stopping dev runner. Redgreen temporarily substituted only the service then restored in finally; this reviewer did not repeat that repo mutation.

Inspected all 5 before/after snapshots, all 157 authoritative row event payloads, all 140 supplied service spans (including preliminary history) and all 153 native whitelist records. Independently recomputed selected event sets/spans/native starts from the raw snapshots and compared to runtime-trace rows. Native response turn IDs match durable provider-turn native refs and runAttemptIds; root/run/attempt links agree. The shared server trace ID alone is insufficient correlation; sequence boundaries, run/attempt/node IDs, native thread/turn IDs and ordered nonoverlapping intervals together establish it. Provider start follows successful recovery for R1/R2/R4. R3 has five failed recreation executions (worker retries) but one durable attempt and final settlement, no provider startup.

Exact original Git fixture tips:
'''
text+='\n'.join(f'- {k}: `{v}`' for k,v in d['tips'].items())+'\n'
text+='''
Crossed tags stay feature/restore=C and project-current=T before and after every row. Fully qualified branch refs and rev-parse HEAD establish tips; Git symbolic-ref --short prints heads/feature/restore under ambiguity, which is legitimate and not confused with the driver's exact branch-name list. R0/R1 files are base.txt=`base\\n`, thread.txt=`thread work\\n`, project.txt absent. R2/R4 files are base.txt=`base\\n`, project.txt=`new project code\\n`, thread.txt absent. Project stays at C throughout, with detached symbolic-ref failure only for R3. R1 before-worktree porcelain explicitly marks stale registration prunable. R2/R3 before snapshots and action outputs establish branch deletion independent of tags.

R3 durable error is a turn-item.updated event and the turn_items projection, not only a server warning. Title `Couldn't recreate thread workspace`, class `provider_error`, message `Could not recreate branch 'feature/restore' at /tmp/ev-18359/worktrees/project/restore: the project workspace has no current branch to start it from (detached HEAD?).` Error item links to ordinal7 run/root node with providerTurnId null. R4 preserves the exact item and ordinal7 failure. The error item's own startedAt denotes writing the error; the run/attempt/node startedAt values are all null. No uncommitted-file restoration is claimed.

## Exact red/green evidence

Command: `vp test run apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts`.
Red substituted service from origin/main (currently exact supplied base), retaining branch tests/testkit/Git driver. It fails assertion 852 (expected branch feature/restore, received empty detached branch) and 926 (expected typed failure, got success), with 2 failed/32 passed, exit1. These are behavioral failures, not import/setup failures. It does not prove the retained-only subcase independently failed. Green at full supplied head has 34 passed, exit0. Read both complete logs and substitution script; saved service bytes match current. Both prior code reviews report MERGE. check:changed log has format/lint/knip/graphql/affected typecheck/tests all pass and 197 tests; those are retained checks, not newly rerun by this proof audit.

## What else changed

Complete diff is four .ts files, 338 insertions/56 deletions: recovery helper chooses retained head or fresh current named project head after status invalidation; final typed recovery failure stops startup and persists a curated error while preserving interruption/nonfinal retries. Existing failure-settlement helper moved earlier and gained explicit message override; its other callers retain prior fallback formatting. Shared Git branch listing changed refname:short to refname:lstrip=2, also correcting unique-name/MCP consumers. Tests add real Git service layers plus recovery/failure cases and harness injection. No protocol/auth/mode/UI/migration changes or committed scratch. Branch-base metadata sharing is an existing createWorktree side effect activated by providing the base; no rollback of partial Git effects or remote/uncommitted-work recovery is promised. T5 breadth stays optional.

## Independent affected-row rebuild

Fresh scratch: `'''+str(s)+'''`; no original fixture/home overwritten. Parameterized copies of supplied seed.py, launch.mts, mcp-call.mts, rows.py and snapshot.py are retained under evidence/. Repo imports remain current head, dependencies linked read-only from owning package. First launch attempt had a duplicated scratch prefix and correctly failed validation before a thread was created; corrected script uses the true registered worktree.

Commands, in order:

```sh
vp run dev:server --no-seed --home-dir '''+str(s/'home')+'''
python3 '''+str(o/'seed.py')+'''
node apps/server/src/bin.ts project add '''+str(s/'fixture/project')+' --base-dir '+str(s/'home')+'''
git -C '''+str(s/'fixture/project')+' worktree add '+str(s/'home/worktrees/project/restore')+''' refs/heads/feature/restore
git -C '''+str(s/'home/worktrees/project/restore')+''' symbolic-ref HEAD refs/heads/feature/restore
node '''+str(o/'launch.mts')+'''
node '''+str(o/'mcp-call.mts')+''' t3_thread_wait '{"threadId":"mcp:5f010c03-57ae-462c-bee4-b7182d7d91f8"}'
python3 '''+str(o/'rows.py')+''' R2
```

Actual setup seeded before server startup; listed commands describe the dependent setup/runtime steps. Baseline launch used existing_worktree, real codex/gpt-6.1-sol; wait returned completed/timedOut false. R2 driver removed only fresh W, pruned registration and deleted heads/feature/restore; crossed tags remained. It then used supported CLI send --wait --json and read-only isolated DB snapshots. No DB writes by the audit.
'''
text+='\nFresh Git tips:\n'+'\n'.join(f'- {k}: `{v}`' for k,v in r['tips'].items())+'\n'
text+='\nRebuilt run/ordering details:\n```json\n'+json.dumps({k:r[k] for k in ['status','head','run','nativeStarts','spans']},indent=2)+'\n```\n'
text+='\nExact driver output:\n```text\n'+(o/'rebuild.log').read_text()+'\n```\n'
text+='''
Independent assertions checked missing before-directory/branch, final full HEAD=C, exact files and all crossed refs, unchanged project C, one native turn/start with real requested model/cwd, successful recovery span ending before root-start and native-start. Full Git, run, native and event detail is retained in rebuild-verified.json. This independently reconstructs one required affected row; original R0–R4 remain the complete matrix.

## Cleanup

Captured server socket owner PID and confirmed /proc cwd was this worktree's apps/server; walked only its ancestor chain to identify the just-started dev runner and recorded descendants before termination. SIGTERM to dev runner left watcher/provider children, so sent SIGTERM only to those previously recorded owned descendants. No pattern killing. Final check: no live recorded descendants and port15571 unbound. Scratch/evidence preserved. Repo clean at unchanged full head. All CLI/test commands have exited.

```json
'''+json.dumps(cleanup,indent=2)+'\n```\n'
text+='\n## Independent original-artifact validation transcript\n\n```text\n'+(o/'original-validation.log').read_text()+(o/'native-correlation.log').read_text()+'```\n'
text+='''
## FRICTION

- fixture | First scratch path replacement duplicated the common /tmp/ev-18359 prefix | Use single-pass literal substitution; preserved corrected scratch scripts.
- Git | Crossed tags make symbolic-ref --short emit heads/feature/restore | Compare fully qualified refs and full tip SHA; distinguish CLI short spelling from listLocalBranchNames output.
- cleanup | Dev-runner exit left its watcher and Codex descendants alive | Capture owned process tree before stopping and terminate only recorded descendants; verify no survivors and no listener.

VERDICT: SUFFICIENT
'''
(o/'audit-pass2.md').write_text(text);print(o/'audit-pass2.md')
