"""Move any browser-written submissions.jsonl out of the delivered site into output/evidence/browser_submissions.jsonl (appending, deduplicated by line). Idempotent: does nothing if the site has no submissions.jsonl. Stdlib only.""" from pathlib import Path src = Path('output/site/submissions.jsonl') dst = Path('output/evidence/browser_submissions.jsonl') dst.parent.mkdir(exist_ok=True) if not src.exists(): print('no submissions.jsonl in output/site; nothing to preserve') else: existing = dst.read_text().splitlines() if dst.exists() else [] new = src.read_text().splitlines() merged = existing + [l for l in new if l not in existing] dst.write_text('\n'.join(merged) + '\n') src.unlink() print('evidence file now:') print(dst.read_text()) print('site dir now:', sorted(p.name for p in Path('output/site').iterdir()))