"""Preserve only the explicitly frozen native 52DE82 evidence; never read work/profile.""" import hashlib import json from pathlib import Path repo = Path(__file__).resolve().parents[2] source = repo / '.local/native-qa/contextual-source-20260911-v1' dest = repo / 'harness/experiments/contextual-source-native-20260911' dest.mkdir(parents=True, exist_ok=True) def sha(data): return hashlib.sha256(data).hexdigest() records = [] def preserve(path, target): data = path.read_bytes() out = dest / target out.parent.mkdir(parents=True, exist_ok=True) if out.exists(): assert out.read_bytes() == data, target else: with out.open('xb') as stream: stream.write(data) assert path.read_bytes() == out.read_bytes() == data records.append(dict(original_path=path.relative_to(repo).as_posix(), path=target, bytes=len(data), sha256=sha(data))) frozen = ['baseline', 'checkpoint-lifeline', 'checkpoint-lifeline-undo', 'checkpoint-lifeline-redo', 'checkpoint-chain', 'checkpoint-chain-undo', 'checkpoint-chain-redo', 'checkpoint-machine', 'checkpoint-machine-undo'] for name in frozen: directory = source / name assert directory.is_dir(), name files = sorted(p for p in directory.rglob('*') if p.is_file()) assert files and all(p.suffix == '.arcadia' for p in files), name for path in files: preserve(path, 'source-bytes/' + sha(path.read_bytes()) + '.arcadia') for path in sorted(source.iterdir()): if path.is_file(): assert path.suffix in ('.json', '.log', '.png'), path.name folder = 'screenshots' if path.suffix == '.png' else 'logs' if path.suffix == '.log' else 'provenance' preserve(path, folder + '/' + path.name) for name in ('launch-contextual-source-v1.ps1', 'check-staged-source-v1.ps1'): preserve(source.parent / name, 'method/' + name) preserve(Path(__file__).resolve(), 'preserve.py') # The original build, failed compile attempts and oracle self-checks are already # committed in this adjacent archive. Verify and bind them instead of duplicating. existing = repo / 'harness/experiments/contextual-source-20260911' inventory = existing / 'inventory.json' prior = json.loads(inventory.read_text(encoding='utf-8-sig')) for item in prior['files']: data = (existing / item['path']).read_bytes() assert len(data) == item['bytes'] and sha(data) == item['sha256'].lower(), item['path'] references = [] for path in (inventory, repo / 'harness/staged-source-authoring-contract.rs', repo / 'harness/fixtures/staged-source-authoring/base/project.arcadia', repo / 'harness/fixtures/staged-source-authoring/base/notes.arcadia'): data = path.read_bytes() references.append(dict(path=path.relative_to(repo).as_posix(), bytes=len(data), sha256=sha(data))) unique = {item['path']: item for item in records} manifest = dict(format_version=1, scope='Reboot checkpoint: OA Lifeline Save-adoption Create/Undo/Redo; SA Chain direct Create/Undo/Redo; SA Machine direct Create and Undo only. Machine Redo/reopen, recovery and corrected layout acceptance remain pending.', original_directory=source.relative_to(repo).as_posix(), frozen_directories=frozen, excluded=['work/', 'profile/', 'bin/', 'uncreated machine Redo and reopen checkpoints'], method='Exact byte readback, no oracle execution or mutable workspace reads. Content-addressed source files deduplicate only byte-identical physical files; records map every original path to its preserved bytes, including known detached files.', gui_sha256='52de82e434b636e18db02d381842aa6db84b721cffd5502063f784f37246acce', oracle_sha256='967d9ba3c6fb3a7eefb410833903ec94556ca2d48a67d5072c8bb160f40a00f9c', records=records, references=references, counts=dict(original_records=len(records), unique_payload_files=len(unique), unique_payload_bytes=sum(r['bytes'] for r in unique.values()), physical_source_files=sum(r['path'].startswith('source-bytes/') for r in records), unique_source_files=sum(p.startswith('source-bytes/') for p in unique))) # Correct the literal oracle identity from the already measured manifest. oracle_manifest = json.loads((existing / 'oracle-preparation/manifest.json').read_text(encoding='utf-8-sig')) manifest['oracle_sha256'] = next(a['SHA256'].lower() for a in oracle_manifest['Artifacts'] if a['Path'].endswith('.exe')) readme = '''# Contextual source native evidence — reboot checkpoint, 2026-09-11 Exact preservation of root's closed 52DE82 trial, through Machine Create and one Undo. Machine Redo and final reopen remain pending. No recovery, corrected layout, Linux or full product acceptance is claimed. See ../../release-contextual-source-native-20260911.md for root's observed workflow and ../../release-staged-source-authoring-oracle-20260911.md for the predetermined evaluator. This preservation does not rerun acceptance. `manifest.json` maps every original physical checkpoint file to `source-bytes/`. Identical source bytes are stored once by SHA256; reconstruct a checkpoint by copying each matching original-path suffix to its normal relative filename. The inventory includes retained detached files; it does not assume every physical file is reachable. No mutable `work`, private profile, executable or DLL is copied. `SHA256SUMS.txt` covers each unique preserved payload once. Screenshots, original command results, logs, launch record and corrected checker wrapper retain exact bytes. The initial loader exit -1073741515 with no output is recorded separately; the corrected wrapper scopes PATH to verified native bin and Windows and records exits. This is an environment correction, not a failed semantic oracle reclassified as a pass. OA Use followed by Save adopts the valid parent atomically; it is not a staged-only disk checkpoint. SA Chain uses direct Create. Missing-name clipping and staged-owner false-missing screenshots describe 52DE82 before the later display fixes. Original compiler/input provenance, failed build attempts and oracle self-check logs are already in ../contextual-source-20260911/. The manifest binds that full inventory and this script validates all of its entries without duplicate copies. The original oracle source and base fixture remain linked and hash-bound. Preservation script was prepared privately, then run after root froze Machine Undo and stopped native input for reboot. Original/destination byte equality is checked. No GUI, Cargo, compiler, Git, credential access or live model snapshot was used. ''' (dest / 'README.md').write_text(readme, encoding='utf-8', newline='\n') (dest / 'manifest.json').write_text(json.dumps(manifest, indent=2) + '\n', encoding='utf-8', newline='\n') (dest / 'SHA256SUMS.txt').write_text(''.join(f"{r['sha256']} {p}\n" for p, r in sorted(unique.items())), encoding='utf-8', newline='\n') print(json.dumps(dict(status='PASS exact preservation', counts=manifest['counts'], manifest_sha256=sha((dest / 'manifest.json').read_bytes()), checksums_sha256=sha((dest / 'SHA256SUMS.txt').read_bytes())), indent=2))