89 lines
5.4 KiB
Python
89 lines
5.4 KiB
Python
"""Preparation only: copy and hash frozen inputs; never execute model/oracle/GUI code."""
|
|
import hashlib
|
|
import json
|
|
import shutil
|
|
import zipfile
|
|
from datetime import datetime, timezone
|
|
from pathlib import Path
|
|
|
|
root = Path(__file__).resolve().parent
|
|
repo = root.parent.parent
|
|
gates = repo / '.local/canvas-union-windows-20260911'
|
|
freeze = 'a57c334b302eb13352b4bb65df1c75d94d002348'
|
|
|
|
def digest(data):
|
|
return hashlib.sha256(data).hexdigest().upper()
|
|
|
|
def write_new(path, data):
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
with path.open('xb') as out:
|
|
out.write(data)
|
|
|
|
records = []
|
|
def copy_exact(source, target, expected=None):
|
|
source = Path(source)
|
|
data = source.read_bytes()
|
|
sha = digest(data)
|
|
if expected:
|
|
assert sha == expected.upper(), (source, sha, expected)
|
|
destination = root / target
|
|
write_new(destination, data)
|
|
assert destination.read_bytes() == data == source.read_bytes()
|
|
records.append(dict(origin=str(source), target=target, bytes=len(data), sha256=sha))
|
|
|
|
assert not (root / 'preparation-manifest.json').exists(), 'Never overwrite a prior preparation'
|
|
manifest_bytes = (gates / 'inputs.json').read_bytes()
|
|
assert digest(manifest_bytes) == '47FEC9CADC0E7FAE99D789376C111C02EEAAB7FAC3740DE48174A06F61FE16B3'
|
|
inputs = json.loads(manifest_bytes)
|
|
indexed = {item['path']: item for item in inputs['files']}
|
|
assert len(indexed) == 529
|
|
archive = gates / 'exact-inputs.zip'
|
|
archive_sha = digest(archive.read_bytes())
|
|
with zipfile.ZipFile(archive) as frozen:
|
|
selected = {
|
|
'harness/fixtures/scenario-lifecycle-native/typography-wide/rationale.arcadia': ('baseline-wide/rationale.arcadia', 'working-wide/rationale.arcadia'),
|
|
'harness/fixtures/scenario-lifecycle-native/typography-wide/project.arcadia': ('baseline-wide/project.arcadia', 'working-wide/project.arcadia'),
|
|
'harness/fixtures/scenario-lifecycle-native/typography-clusters/project.arcadia': ('baseline-clusters/project.arcadia', 'working-clusters/project.arcadia'),
|
|
'harness/fixtures/scenario-lifecycle-native/typography-clusters/rationale.arcadia': ('baseline-clusters/rationale.arcadia', 'working-clusters/rationale.arcadia'),
|
|
'harness/fixtures/scenario-lifecycle-native/README.md': ('provenance/lifecycle-fixture-README.md',),
|
|
}
|
|
for name, destinations in selected.items():
|
|
data = frozen.read(name)
|
|
record = indexed[name]
|
|
assert len(data) == record['bytes'] and digest(data) == record['sha256'].upper(), name
|
|
for destination in destinations:
|
|
write_new(root / destination, data)
|
|
records.append(dict(origin=str(archive) + '::' + name, target=destination, bytes=len(data), sha256=digest(data)))
|
|
|
|
copy_exact(gates / 'bin/arcadia-studio.exe', 'bin/arcadia-studio.exe', '69DBB90FA299B3B3D90140C7934891F79166025893AF9B35B2B8D754A37A0D40')
|
|
copy_exact(gates / 'bin/libunwind.dll', 'bin/libunwind.dll', 'AA282FA47BB2C4E210CEA5E470CDBDCA58568F0BE0BC73E404D86AB9CD95EF6A')
|
|
for name in ('inputs.json', 'binary-manifest.json', 'after-build-verify-head.json', 'studio-build-status.json', 'desktop-clippy-status.json', 'desktop-all-targets-status.json', 'focused-lifecycle-status.json'):
|
|
copy_exact(gates / name, 'provenance/' + name)
|
|
for source, target, expected in (
|
|
('.local/native-865483b/oracles/lifecycle.exe', 'oracles/lifecycle.exe', '798D7A1907B894C13549BAD35511B21D6BC7F3D67D63674042B7DF71184C7524'),
|
|
('.local/native-865483b/oracles/libunwind.dll', 'oracles/libunwind.dll', 'AA282FA47BB2C4E210CEA5E470CDBDCA58568F0BE0BC73E404D86AB9CD95EF6A'),
|
|
('harness/lifecycle-native-contract.rs', 'provenance/lifecycle-native-contract.rs', 'FC5E71F9870D7B98E0F52EAF20C831EBFFBE9F7A9B8960269DC9BE3D9BF0D9E4'),
|
|
):
|
|
copy_exact(repo / source, target, expected)
|
|
for source, target in (
|
|
('.local/native-865483b/oracles/manifest.json', 'provenance/oracles-865-copy-manifest.json'),
|
|
('.local/lifecycle-native-ytr83r-20260911/status.json', 'provenance/lifecycle-oracle-status.json'),
|
|
('harness/experiments/lifecycle-native-ytr83r-20260911/typography-admission.json', 'provenance/typography-admission.json'),
|
|
('harness/experiments/lifecycle-native-ytr83r-20260911/typography-predictions.json', 'provenance/typography-predictions.json'),
|
|
):
|
|
copy_exact(repo / source, target)
|
|
|
|
for directory in ('profile', 'unrelated-cwd', 'logs', 'screenshots', 'checkpoints'):
|
|
(root / directory).mkdir(exist_ok=False)
|
|
for record in records:
|
|
if record['target'].startswith(('baseline-', 'bin/', 'oracles/', 'provenance/')):
|
|
(root / record['target']).chmod(0o444)
|
|
result = dict(prepared_utc=datetime.now(timezone.utc).isoformat(), source_commit=freeze,
|
|
scope='Preparation only for independent OA/SA camera, clipping, minimum-size, zoom and hit checks with passive Save equality. Pre-grapheme a57; no package or new combined Unicode acceptance.',
|
|
archive=dict(path=str(archive), sha256=archive_sha), input_manifest_sha256=digest(manifest_bytes),
|
|
frozen_input_count=529, files=records,
|
|
empty_profile=str(root / 'profile'), unrelated_cwd=str(root / 'unrelated-cwd'),
|
|
restricted_path='C:\\Windows\\System32;C:\\Windows;' + str(root / 'bin'))
|
|
write_new(root / 'preparation-manifest.json', (json.dumps(result, indent=2) + '\n').encode())
|
|
print(json.dumps(dict(files=len(records), copied_bytes=sum(r['bytes'] for r in records), archive_sha256=archive_sha), indent=2))
|