"""Run from either app checkout after vp i. MODEL is supplied privately.
Start each side with T3CODE_DEV_SEED=0 vp run dev.
Observe parent and child in the real web client, recording the interaction.
"""
import json, os, pathlib, subprocess, datetime
root = pathlib.Path.cwd()
out = pathlib.Path(os.environ["EVIDENCE_DIR"]) / datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%dT%H%M%SZ")
out.mkdir(parents=True)
fixture = pathlib.Path(os.environ["REVIEW_FIXTURE"])
home = root / ".t3"
def cli(*args):
    r = subprocess.run(["node", "apps/server/src/bin.ts", *args, "--base-dir", str(home)], text=True, capture_output=True, check=True)
    return r.stdout
prompt = "Delegate one small read-only review of the working diff, math.ts and README.md, to Codex at medium effort using delegate_task. First discover capabilities. Ask the child to read those files and the diff and give a concise correctness review. Do not change files. Wait for the delegated completion and then give the parent a one-sentence summary."
print(cli("project", "add", str(fixture), "--title", "Compaction review"))
launch=json.loads(cli("thread", "start", str(fixture), prompt, "--title", "Recorded parent review", "--provider", "codex", "--model", os.environ["MODEL"], "--json"))
(out / "launch.json").write_text(json.dumps(launch))
print(launch["threadId"])
# Before starting dev, write settings.json with Codex setupMode existing and
# launchArgs: -c model_auto_compact_token_limit=12000 -c model_reasoning_effort="medium"
# Fixture initial commit: math.ts exports sum reducing from 0; README describes it.
# Working diff changes the reduce initial accumulator from 0 to 1.
