"""Create synthetic replay history through the real server CLI.
Run in the target checkout while T3CODE_DEV_SEED=0 vp run dev --no-seed is running:
  python setup.py <ids-output.json>
Copy seed.ts to apps/server/scripts/proof-seed.ts, then run:
  node apps/server/scripts/proof-seed.ts .t3/userdata/statev2.sqlite <ids-output.json>
Seed after startup: restart recovery otherwise cancels native work before Stop.
No production state, provider credentials, or real agent calls are needed.
"""
import pathlib,subprocess,json,sys
root=pathlib.Path.cwd();workspace=root/'.t3/workspaces/stop-proof'
workspace.mkdir(parents=True,exist_ok=True)
subprocess.run(['git','init','-q','--initial-branch=main',str(workspace)],check=True)
subprocess.run(['git','-C',str(workspace),'-c','user.name=Proof','-c','user.email=proof@example.invalid','commit','--allow-empty','-qm','Synthetic proof workspace'],check=True)
def cli(args):
 result=subprocess.run(['node','apps/server/src/bin.ts',*args,'--base-dir',str(root/'.t3')],text=True,capture_output=True,check=True)
 return result.stdout
cli(['project','add',str(workspace),'--title','Stop stale delegated work'])
ids=[]
for title in ['Parent review','Finished delegated child','Native worker','Nested native worker']:
 result=cli(['thread','start',str(workspace),'Complete this synthetic task.','--title',title,'--provider','devReplay','--model','multi-turn','--wait','--json'])
 ids.append(json.loads(result)['threadId'])
pathlib.Path(sys.argv[1]).write_text(json.dumps(ids))
