"""Prepare documentation only under /tmp. Never writes successor or old packages. Run --verified only after assemble.py and verify.py complete successfully. """ from pathlib import Path import argparse,json,hashlib,subprocess,sys A=argparse.ArgumentParser();A.add_argument('--verified',action='store_true');args=A.parse_args() R=Path('/home/jakub/devel/escapistsrereintroduced');B=Path('/tmp/erri-playtest-menu-fix-1349');O=Path('/tmp/erri-playtest-menu-fix-docs-1349');BUILD=R/'.build/playtest-2026-10-02-hq-memory-menu-fix' sys.path.insert(0,str(R/'tools'));from source_manifest import addon_manifest read=lambda p:json.loads(p.read_text());sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() baseline=read(B/'baseline.json');assert len(baseline['working_modified'])==97 if not (O/'validation-bindings.json').exists():raise SystemExit('WAITING: parent must seal frozen-source/test-root/live-preservation bindings.') bindings=read(O/'validation-bindings.json');SOURCE=Path(bindings['source_root']);TESTROOT=Path(bindings['suite_root']);live=read(Path(bindings['live_preservation'])) assert addon_manifest(SOURCE)==baseline['source'] and len(baseline['source'])==409 assert addon_manifest(R)==live['source'] assert all(sha(R/n)==v for n,v in live['working_modified'].items()) assert set(live['source_delta'])=={'addons/core/Scripts/Game/ERR/00_Core/ERR_TerrainTakeover.c','addons/core/Scripts/Game/ERR/00_Core/ERR_TerrainTakeoverClient.c','addons/core/Scripts/Game/ERR/00_Core/ERR_TerrainTakeoverPresentation.c'} assert {n for n in set(baseline['source'])|set(live['source']) if baseline['source'].get(n)!=live['source'].get(n)}==set(live['source_delta']) assert hashlib.sha256(subprocess.check_output(['git','diff','--cached','--binary'],cwd=R)).hexdigest()==baseline['index_diff_sha256'] original=read(Path('/tmp/erri-heartbeat-20260930-1542-reference.json'));assert len(original)==533 and all(sha(Path('/home/jakub/devel/escapists')/n)==v for n,v in original.items()) prior=read(R/'docs/evidence/playtest-refresh-2026-10-02-objective-map/candidate-sha256.json');priorroot=R/'.build/playtest-2026-10-02-objective-map';assert len(prior)==416 and {str(p.relative_to(priorroot)):sha(p) for p in priorroot.rglob('*') if p.is_file()}==prior if not Path(bindings['suite_result']).exists(): raise SystemExit('WAITING: corrected-source suite result is not available yet.') suite=read(Path(bindings['suite_result']));assert suite['exit']==0 and suite['inputs_unchanged'] and suite['regression_programs']==285 and all(x['exit']==0 for x in suite['programs']) assert all(sha(TESTROOT/n)==v for n,v in read(Path(bindings['suite_inputs'])).items()) assert addon_manifest(TESTROOT)==baseline['source'] route=R/'docs/evidence/native-2026-10-02-hq-memory-menu-fix-normal' if not (route/'report.json').exists(): raise SystemExit('WAITING: corrected normal-route archive is not available yet.') report=read(route/'report.json');assert report['assertions_passed']==63 and report['smoke_completions']==1 and not report['script_or_runtime_failures'] and len(report['engine_errors'])==13 assert read(route/'source-sha256.json')==baseline['source'] failed_root=R/'.build/playtest-2026-10-02-hq-memory' failed_manifest=read(O/'failed-candidate-sha256.json') assert {str(p.relative_to(failed_root)):sha(p) for p in failed_root.rglob('*') if p.is_file()}==failed_manifest initial_report=read(Path('/tmp/erri-packed-chat-20261002-hq-memory-final/packed-startup-report.json')) assert len(initial_report['script_or_runtime_failures'])==1 and len(initial_report['engine_errors'])==18 qualification='Native packaging and ordinary startup of this new package are still pending; no packaged-runtime verification is claimed.' counts='409 authored files; final PAK payload and runtime counts pending the exact handoff.' if args.verified: if not (BUILD/'handoff.json').exists():raise SystemExit('WAITING: corrected package has not been assembled yet.') h=read(BUILD/'handoff.json');assert h['authored_files']==409 and len(h['runtime_files'])==3 and h['normal_mission_ready'] and h['local_participant_verified'] and h['repository_regression_programs']==285 and h['packed_script_failures']==0 and not h['release_qualified'] and not h['published'] assert h['packed_resource_errors']==17 and not h['strict_packed_consumption_verified'] assert h['route_package_source_match'] and h['source_zip_exact_membership_and_hashes_verified'] and h['extracted_source_and_runtime_reverified'] startup=read(R/'docs/evidence/packed-2026-10-02-hq-memory-menu-fix/archive-review.json');assert startup['cleanup_confirmed'] and startup['runtime_bytes_match_handoff'] and startup['local_prisoner_verified'] and startup['strict_failure_retained'] counts=f"409 authored files, {h['pak_payload_files']} exact PAK payloads and three runtime files match editable source and `handoff.json`." qualification=f"Fresh ordinary startup of this exact package verifies the normal mission and local prisoner with zero script/runtime failures and {h['packed_resource_errors']} retained engine errors. Strict packaging/startup failures remain recorded." features='A startup guard now skips automatic terrain takeover in mode-less menu worlds; ordinary supported scenarios and unsupported-mode diagnostics keep their existing behavior. This snapshot includes observer recovery/defeat guidance, finite resupply of supported reloadable launchers, and one original armed convoy escort receiving a radio interception order ahead of delivered player travel history. Earlier finite logistics, controller ownership and authored discovery/mine-warning map presentation remain included. The frozen snapshot includes the earlier parallel task’s automatic terrain takeover behavior; newer concurrent terrain-name/presentation edits remain in the live workspace and are not in this package; this handoff’s fresh scripted route targets Everon.' limits='This is an **unqualified development candidate**. Physical launcher delivery, native interception movement/holding/rejoining, a complete human escape, real multiplayer/JIP/reconnect/twelve-player play, comparative FPS and a clean release remain unverified. Historical standard-map visual checks do not prove physical held-map rendering or current remote UI behavior. No new native flight or prison-input experiments are included.' readme=f'''# Development playtest — 2 October 2026, HQ travel memory and menu startup fix The combined addon is **Co10 Escape Reintroduced**, GUID `2528466DE220D91C`. Load the normal Everon scenario `{{C1E20667DCE324ED}}Missions/ERR_Everon.conf` from `packages/core`. Editable Workbench source is in `source/addons/core/addon.gproj`. Install RHS Status Quo, WCS Armaments, WCS BMP-1, Parachute Framework and their supporting packs separately. `source/EXTERNAL-ADDONS.json` records the audited closure. Original Escapists is not required; third-party assets are not bundled. {features} {counts} The exact source passes **285 registered regression programs** and the fresh hidden/muted scripted normal escape completes **63 assertions and one round**, with zero script/runtime failures and thirteen retained engine errors. {qualification} {limits} The earlier `playtest-2026-10-02-hq-memory` candidate is retained as failed diagnostic evidence: its packed startup produced one script error (eighteen total engine errors) when automatic terrain preflight ran in the main menu. This corrected candidate replaces it as the current handoff; the earlier bytes and failed reports remain unchanged. Previous packages, the original 533-file reference and the original 97-path baseline and explicitly captured concurrent live edits are preserved before these documentation updates. Nothing was committed or published. See the [player route](../../docs/player-route.md), [setup guide](../../docs/playtest-build.md), [current status](../../docs/current-status.md), [interception behavior](../../docs/mounted-interception.md), [artifact evidence](../../docs/evidence/package-2026-10-02-hq-memory-menu-fix/handoff.json) and [packed startup evidence](../../docs/evidence/packed-2026-10-02-hq-memory-menu-fix/archive-review.json). ''' outputs={'.build/playtest-2026-10-02-hq-memory-menu-fix/README.md':readme} # Preserve every historical section and the concurrently authored terrain text. for n in ['playtest-build.md','current-status.md','original-feature-coverage.md','next-gameplay-increments.md']: source=B/n;assert source.read_bytes()==(R/'docs'/n).read_bytes() s=source.read_text() if n=='playtest-build.md': start=s.index('The latest retained, hash-verified handoff is');end=s.index('## Identities and required dependencies') s=s[:start]+f'''The latest retained handoff is [2 October — HQ travel memory](../.build/playtest-2026-10-02-hq-memory-menu-fix/README.md), at `.build/playtest-2026-10-02-hq-memory-menu-fix`. {counts} {features} All **285 registered regression programs pass**. The fresh normal-route fixture completes **63 assertions and one round**, with zero script/runtime failures and thirteen retained engine errors. {qualification} {limits} See [current status](current-status.md). The earlier objective-map package and all previous candidates remain unchanged. Later source edits are not automatically present in this snapshot. '''+s[end:] elif n=='current-status.md': head='# Current development status\n';assert s.startswith(head) s=head+f'''\n**2 October 2026 — corrected HQ-memory/menu-startup development handoff:** [separate package and editable source](../.build/playtest-2026-10-02-hq-memory-menu-fix/README.md). {counts} {features} The exact source passes **285 registered regression programs** and the [fresh normal escape fixture](evidence/native-2026-10-02-hq-memory-menu-fix-normal/report.json) completes **63 assertions and one round**, with zero script/runtime failures and thirteen retained engine errors. {qualification} The initial HQ-memory candidate and its one script/eighteen engine errors remain retained; this corrected package includes the demonstrated menu-world guard. {limits} Previous packages, original missions and inherited work remain preserved; nothing was committed or published. [Package hashes](evidence/package-2026-10-02-hq-memory-menu-fix/handoff.json). '''+s[len(head):] elif n=='original-feature-coverage.md': start=s.index('The latest retained candidate is');end=s.index(' Source-bound native evidence',start) s=s[:start]+'The latest retained candidate is the [2 October HQ-memory playtest](../.build/playtest-2026-10-02-hq-memory-menu-fix/README.md). It adds observer recovery guidance, finite supported-launcher resupply and one original convoy escort’s radio-directed road interception, while retaining the parallel terrain takeover work and earlier map/logistics features. Physical launcher delivery and interception driving remain unqualified.'+s[end:] s=s.replace('Full vehicle/barricade roadblocks remain absent.','One existing armed convoy escort can receive a finite road-interception radio order from delivered travel history; native interception movement/hold/rejoin remain unqualified. Barricade props and full original roadblock parity remain absent.',1) else: lines=s.splitlines(True);assert lines[0].startswith('# ') s=lines[0]+'''\n**Latest separate development handoff:** [2 October HQ travel memory](../.build/playtest-2026-10-02-hq-memory-menu-fix/README.md). It includes recovery-status hints, finite supported-launcher resupply, motorized interception source and the parallel automatic terrain takeover work. Fresh source checks pass 285 regression programs and 63 scripted normal-route assertions. Runtime/package qualification is stated in the handoff; physical interception/launcher delivery, human escape, multiplayer and comparative FPS remain open. Earlier dated evidence below retains its original scope.\n\n'''+''.join(lines[1:]) outputs['docs/'+n]=s for name,text in outputs.items(): q=O/'proposed'/name;q.parent.mkdir(parents=True,exist_ok=True);q.write_text(text) review={'mode':'verified-final-proposal' if args.verified else 'pending-package-draft','target_writes':False,'authored_files':409,'source_scope':'sealed409 snapshot; newer live terrain-name/presentation edits excluded','validation_bindings':bindings,'inherited_paths':97,'original_files_verified':533,'prior_candidate_files_verified':416,'failed_diagnostic_candidate_files_verified':len(failed_manifest),'index_diff_sha256':baseline['index_diff_sha256'],'documentation_baselines':{f'docs/{n}':sha(B/n) for n in ['playtest-build.md','current-status.md','original-feature-coverage.md','next-gameplay-increments.md']},'proposed_destinations':list(outputs),'remaining_finalization':['Run prepare.py --verified only after exact package startup verification.','Root applies proposed README and four docs, records before/after documentation hashes and final candidate inventory.','Preserve package/native strict failure reports and initial process-concurrency refusal.','Reverify source, original, old candidate and cached index after final docs.']} (O/'proposal.json').write_text(json.dumps(review,indent=2)+'\n');print(json.dumps(review,indent=2))