"""Read only the synthetic proof thread's native transcript and app projections."""
import json,pathlib,sqlite3,sys
checkout,root,sha=sys.argv[1:];root=pathlib.Path(root);tid=json.loads((root/'thread.json').read_text())['threadId'];db=sqlite3.connect(f'file:{checkout}/.t3/userdata/statev2.sqlite?mode=ro',uri=True)
pt=json.loads(db.execute('select payload_json from orchestration_v2_projection_provider_threads where thread_id=?',(tid,)).fetchone()[0]);native=pt['nativeThreadRef']['nativeId'];nativefile=next((pathlib.Path.home()/'.claude/projects').glob('*/'+native+'.jsonl'))
messages=[]
for line in nativefile.open():
 d=json.loads(line)
 if d.get('type')=='assistant':
  for b in d.get('message',{}).get('content',[]):
   if b.get('type')=='text':messages.append({'timestamp':d.get('timestamp'),'text':b['text']})
runs=[json.loads(r[0]) for r in db.execute('select payload_json from orchestration_v2_projection_runs where thread_id=? order by ordinal',(tid,))]
items=[json.loads(r[0]) for r in db.execute('select payload_json from orchestration_v2_projection_turn_items where thread_id=? order by ordinal',(tid,))]
report={'commit':sha,'environment':'Web dev app; synthetic workspace; native Claude session; same session throughout','runs':[{k:r.get(k) for k in ['ordinal','status','requestedAt','startedAt','completedAt']} for r in runs],'nativeAssistantMessages':messages,'appAssistantMessages':[{'text':i['text'],'timestamp':i.get('completedAt')} for i in items if i['type']=='assistant_message'],'nativeSessionCount':db.execute('select count(*) from orchestration_v2_projection_provider_threads where thread_id=?',(tid,)).fetchone()[0]}
(root/'runtime-transcript.json').write_text(json.dumps(report,indent=2));print(json.dumps(report,indent=2))
