"""Preserve closed native trial 2 and its actual attempt-5 inputs and gates.""" from pathlib import Path import datetime import hashlib import json import shutil base = Path(__file__).resolve().parent root = Path('C:/ar-text-9e8r6t') dest = root / 'harness/experiments/text-workspace-native2-20260913' dest.mkdir() records = [] def keep(source, relative): target = dest / relative target.parent.mkdir(parents=True, exist_ok=True) assert not target.exists() raw = source.read_bytes() shutil.copyfile(source, target) assert target.read_bytes() == raw records.append({'path': relative, 'bytes': len(raw), 'sha256': hashlib.sha256(raw).hexdigest()}) trial = base / 'trial-text-2' closed = json.loads((trial / 'closed.json').read_text()) assert closed['exitCode'] == 0 and closed['binaryUnchanged'] and closed['dllUnchanged'] for source in sorted(trial.rglob('*')): rel = source.relative_to(trial) if source.is_file() and (len(rel.parts) == 1 or rel.parts[0] == 'screenshots' or rel.parts[0].startswith('verification-')): keep(source, 'trial-text-2/' + rel.as_posix()) gate = root / '.local/text-workspace-gates-20260912' for source in sorted((gate / 'attempt-5').iterdir()): if source.is_file() and source.suffix in ['.json', '.log', '.zip']: keep(source, 'attempt-5/' + source.name) for name in ['fixture-manifest.json', 'launch.py', 'verify_saved.py', 'bind_gates.py']: keep(base / name, 'helpers/' + name) keep(gate / 'gate.py', 'helpers/gate.py') keep(Path(__file__), 'helpers/archive_trial2.py') for fixture in ['simple', 'representative']: for variant in ['baseline', 'expected']: folder = base / fixture / variant for source in sorted(folder.rglob('*')): if source.is_file(): keep(source, 'fixtures/' + fixture + '/' + variant + '/' + source.relative_to(folder).as_posix()) scope = base / 'scope-stress' scope_manifest = json.loads((scope / 'manifest.json').read_text()) for name, row in scope_manifest['files'].items(): raw = (scope / 'model' / name).read_bytes() assert len(raw) == row['after_bytes'] and hashlib.sha256(raw).hexdigest() == row['after_sha256'] for source in sorted(scope.rglob('*')): if source.is_file(): keep(source, 'fixtures/scope-stress/' + source.relative_to(scope).as_posix()) with (dest / 'manifest.json').open('x', encoding='utf-8', newline='\n') as output: json.dump({'atUtc': datetime.datetime.now(datetime.timezone.utc).isoformat(), 'scope': 'Closed attempt-5 native trial2. Selection and transaction results are bounded; inherited Find/drawer simultaneous Escape found and subsequent correction pending. Runtime binaries remain preserved separately by hash.', 'scopeStressFilesUnchanged': True, 'files': records}, output, indent=2) output.write('\n') print(json.dumps({'directory': str(dest), 'files': len(records), 'bytes': sum(row['bytes'] for row in records), 'manifestSha256': hashlib.sha256((dest / 'manifest.json').read_bytes()).hexdigest()}))