from pathlib import Path import ast,json,hashlib,shlex old=Path('/tmp/erri-package-prep-2121');out=Path('/tmp/erri-package-prep-0150');root=Path('/home/jakub/devel/escapistsrereintroduced') pairs=[('/tmp/erri-package-20261002-convoy-survivors-final','/tmp/erri-package-mounted-pair-0150'),('/tmp/erri-packed-chat-20261002-convoy-survivors-final','/tmp/erri-packed-chat-mounted-pair-0150'),('/tmp/erri-playtest-source-20261002-convoy-survivors.zip','/tmp/erri-playtest-source-20261003-mounted-pair.zip'),('playtest-source-2026-10-02-convoy-survivors','playtest-source-2026-10-03-mounted-pair'),('playtest-2026-10-02-convoy-survivors','playtest-2026-10-03-mounted-pair'),('package-2026-10-02-convoy-survivors','package-2026-10-03-mounted-pair'),('native-2026-10-02-convoy-survivors-normal','native-2026-10-03-mounted-pair-normal'),('packed-2026-10-02-convoy-survivors','packed-2026-10-03-mounted-pair'),('/tmp/erri-playtest-2121','/tmp/erri-gameplay-root-0150'),('/tmp/erri-package-prep-2121','/tmp/erri-package-prep-0150')] def adapt(s): for a,b in pairs:s=s.replace(a,b) return s for name in ['assemble.py','verify.py','preflight.py','finalize_docs.py']: s=adapt((old/name).read_text()) if name=='assemble.py': s=s.replace("assert all(digest(f/n)==h for n,h in suite_inputs.items())","from suite_binding import verify_suite_binding\nsuite_binding=verify_suite_binding(f, suite_dir, authored)") s=s.replace("'live_source_match_not_claimed':True,", "'live_source_match_not_claimed':True,'suite_reuse_binding':suite_binding,") if name=='preflight.py': s=s.replace("assert all(inputs.get(n)==h for n,h in source.items()) and all((f/n).is_file() and sha(f/n)==h for n,h in inputs.items())", "from suite_binding import verify_suite_binding\nsuite_binding=verify_suite_binding(f, suite, source)") if name=='verify.py': s=s.replace("assert all(digest(f/n)==h for n,h in suite_inputs.items())", "from suite_binding import verify_suite_binding\nsuite_binding=verify_suite_binding(f, Path('/tmp/erri-gameplay-root-0150'), authored)") s=s.replace('repository_check_reused_for_identical_source=True,','repository_check_reused_for_identical_source=True,suite_reuse_binding=suite_binding,') if name=='finalize_docs.py': s=s.replace(" assert all((f/n).is_file() and sha(f/n)==h for n,h in inputs.items())", " from suite_binding import verify_suite_binding\n checks['suite_reuse_binding']=verify_suite_binding(f,s,frozen)") a=s.index(" inclusion='");b=s.index(" limits='",a) s=s[:a]+" inclusion='This snapshot adds event-time capture cancellation for original active hunter vehicles, the current inherited terrain presentation, and paired radio interception by two original convoy escorts. Both real order receipts precede detours; finite forces, crew identities, stock and fixed deadlines are preserved. Earlier convoy-survivor, radio interruption and finite-transfer corrections remain included.'\n"+s[b:] s=s.replace("The exact source passes **{count} registered regression programs**.", "The unchanged authored source, tests and tools reuse the completed **{count}-program regression pass**; four later prose-only documentation updates are separately reviewed.") s=s.replace('2 October 2026 — convoy-survivors development handoff','3 October 2026 — mounted-pair development handoff') s=s.replace("previous='**2 October 2026 — transfer-fixes development handoff:**'", "previous='**2 October 2026 — convoy-survivors development handoff:**'") s=s.replace('## Previous transfer-fixes handoff (historical)','## Previous convoy-survivors handoff (historical)') s=s.replace('the 2 October convoy-survivors snapshot','the 3 October mounted-pair snapshot') ast.parse(s);(out/name).write_text(s) c=json.loads(adapt((old/'config.json').read_text()));c['suite_reuse_review']='/tmp/erri-playtest-review-0150/preflight.json';(out/'config.json').write_text(json.dumps(c,indent=2)+'\n') commands=json.loads(adapt((old/'commands.json').read_text())) for x in commands: if 'fresh frozen suite' in x['purpose']:x['purpose']='READ ONLY: require successful preserved suite plus exact source/test/tool reuse and independently reviewed four-doc prose delta' (out/'commands.json').write_text(json.dumps(commands,indent=2)+'\n') (out/'commands.txt').write_text('\n\n'.join('# '+x['purpose']+'\n'+shlex.join(x['argv'])+(' > '+shlex.quote(x['stdout_stderr_log'])+' 2>&1' if 'stdout_stderr_log' in x else '') for x in commands)+'\n') for n in ['README.md','docs/current-status.md','docs/playtest-build.md']: p=out/'docs-baseline'/n;p.parent.mkdir(parents=True,exist_ok=True);p.write_bytes((root/n).read_bytes()) (out/'template-provenance.json').write_text(json.dumps({'templates':{str(old/n):hashlib.sha256((old/n).read_bytes()).hexdigest() for n in ['assemble.py','verify.py','preflight.py','finalize_docs.py','config.json','commands.json']},'native_executed':False,'target_writes':False,'qualification':'Pending new exact package/runtime evidence; suite reuse requires explicit independently reviewed prose-only deltas.'},indent=2)+'\n')