import subprocess,json,sys,pathlib,datetime
side=sys.argv[1]
checkout=pathlib.Path(sys.argv[2]).resolve()
project=str(pathlib.Path(sys.argv[3]).resolve())
cli=['node','apps/server/src/bin.ts']
def run(args):return subprocess.run(cli+args,cwd=checkout,text=True,capture_output=True,check=True).stdout
subprocess.run(cli+['project','add','--base-dir','.t3',project,'--title','Checkpoint priority'],cwd=checkout,text=True,capture_output=True)
child_task = "You are one of 12 children. Call orchestrator_capabilities once. Launch exactly TWO background grandchildren via delegate_task, mode async and isolation shared, each with task: Run bash command sleep 900 and do nothing else. Once both launches return, run bash command sleep 900 yourself. Do not edit files, run git or create any other descendants. Do not print private model identifiers or machine information."
prompt = "You are the PARENT of a workload with 12 children and 24 grandchildren. Do not execute the child task yourself. Call orchestrator_capabilities once, then make all TWELVE delegate_task calls below, using isolation shared and mode async with your inherited provider and model. Each call has the identical task shown below. The 12 calls are required even if an individual result says to end your turn. Launch the remaining children first. Do not edit files or run git.\n" + "\n".join(f"Call {i}: delegate_task(title='Child {i:02d}', isolation='shared', mode='async', task={child_task!r})" for i in range(1,13)) + "\nOnly AFTER all 12 calls return, run bash command sleep 900 yourself. This explicitly authorizes all descendants. Never print private model identifiers or machine information."

result=run(['thread','start','--base-dir','.t3','--provider','pi','--model',__import__('os').environ['EVIDENCE_PI_MODEL'],'--title','Checkpoint priority parent',project,prompt,'--json'])
pathlib.Path(side+'-parent.json').write_text(result)
print(result)
