"""Synthetic data only. Usage: python3 seed.py EVIDENCE_DIR
Start each checkout with T3CODE_DEV_SEED=0 vp run dev -- --host 127.0.0.1.
For each side, run from that checkout:
 node apps/server/src/bin.ts project add EVIDENCE_DIR/SIDE/workspace-demo --title 'Workspace demo' --base-dir .t3
 node apps/server/src/bin.ts thread start EVIDENCE_DIR/SIDE/workspace-demo 'Ready to search workspace files.' --title 'Workspace search' --provider devReplay --model multi-turn --wait --json --base-dir .t3
Then run browser-driver.mjs with checkout, side (base/head), web port, server port,
thread id, and run; set EVIDENCE_DIR in its environment. Run sides sequentially.
"""
from pathlib import Path
import os
import sys
root = Path(sys.argv[1])
for side in ['base', 'head']:
    project = root / side / 'workspace-demo'
    (project / 'src').mkdir(parents=True, exist_ok=True)
    for n in range(50):
        (project / 'src' / f'file{n:02d}.ts').write_text(f'export const example{n} = {n};\n')
chunk = (b'plain text watcher workload with words and lines\n' * 24000)[:1048576]
chunk = chunk.ljust(1048576, b'x')
with (root / 'large-pending.txt').open('wb') as f:
    for _ in range(6144):
        f.write(chunk)
    f.flush()
    os.fsync(f.fileno())
    os.posix_fadvise(f.fileno(), 0, 0, os.POSIX_FADV_DONTNEED)
