Files
MeltMind/tools/finalize_g1_band_packet.py
T

74 lines
5.2 KiB
Python

"""Apply Claude 1794676093.443769 to the unshared packet without rerendering.
Preserve the first package/manifest and custody seal; publish three labels and
presentation provenance. Secret entropy stays sealed until verdicts are frozen.
"""
from pathlib import Path
import hashlib
import json
import shutil
import zipfile
from s2_e1_supervisor import save
ROOT=Path('artifacts/s2-g1-band25-2026-11-15')
def sha(p):return hashlib.sha256(Path(p).read_bytes()).hexdigest()
def main():
old=ROOT/'superseded-before-handoff';old.mkdir(exist_ok=False)
bundle=ROOT/'blind-package'
for source in [ROOT/'blind-package.zip',bundle/'manifest.json',bundle/'README.md',ROOT/'public/package-result.json']:
shutil.copy2(source,old/source.name)
original=json.loads((bundle/'manifest.json').read_text())
for item in original['files']:
assert sha(bundle/item['path'])==item['sha256']
instruction=(bundle/'README.md').read_text().replace('Use rigid / template / variant / unrelated / unresolved and give local geometric evidence.', 'Use exactly three labels: rigid / same part, unrelated, UNRESOLVED; give local geometric evidence.')
instruction += '\n## Frozen presentation settings\n\nSee manifest.json presentation_settings for seed custody seal, cameras, original full-mesh point/triangle counts, and pose settings. No registration branch labels are included. The source/pose entropy is sealed until all 25 verdicts are frozen: publishing it before review would allow reconstruction of the anonymous assignment. Exported geometry and public cameras are sufficient to reproduce the displayed views directly without that secret.\n'
(bundle/'README.md').write_text(instruction)
mapping=json.loads((ROOT/'custodian/mapping.json').read_text())
counts=[]
for row in mapping['pairs']:
pid=row['anonymous_pair_id']
for side in ['left','right']:
with (bundle/'pairs'/pid/f'{side}.ply').open() as stream:
header=[next(stream).strip() for _ in range(9)]
counts.append(dict(anonymous_pair_id=pid,side=side,vertices=int(header[2].split()[-1]),triangles=int(header[6].split()[-1])))
settings=dict(seed=dict(kind='secret per-package SeedSequence entropy; exact value retained under custody',
entropy_sha256=hashlib.sha256(bytes.fromhex(mapping['entropy_hex'])).hexdigest(),
mapping_sha256=sha(ROOT/'custodian/mapping.json'),release='after all 25 verdicts and attestation are frozen'),
poses_per_pair=2,poses_per_side=1,pose_rule='independent proper QR rotation and uniform [-2,2]^3 translation times original bbox diagonal; original bbox centre subtracted',
point_count='all original boundary vertices; no point subsampling, decimation or rescaling',mesh_counts=counts,
projection='orthographic painter sort by triangle centroid depth, double-sided abs-normal shading',
overview_cameras=['identity XY','coordinate order XZY','coordinate order YZX',
'rows (1,-1,0)/sqrt(2), (1,1,-2)/sqrt(6), (1,1,1)/sqrt(3)'],
detail_cameras='same oblique basis, four fixed bbox quadrants',
panel_pixels=[704,704],composite_pixels=[1408,1408],dpi=110,
overview_margin_fraction=.04,each_view_uses_own_extent=True,
display_center='posed bbox centre subtracted for display only; unchanged PLY geometry',
render_source_sha256=sha('tools/render_g1_blind_surface.py'),pose_source_sha256=sha('tools/g1_blind_pose.py'))
files=[dict(path=str(p.relative_to(bundle)),bytes=p.stat().st_size,sha256=sha(p)) for p in sorted(bundle.rglob('*')) if p.is_file() and p!=bundle/'manifest.json']
save(bundle/'manifest.json',dict(scope='anonymous geometry and blank labels only',version=2,pairs=25,
allowed_labels=['rigid / same part','unrelated','UNRESOLVED'],presentation_settings=settings,files=files))
temp=ROOT/'blind-package-v2.zip'
with zipfile.ZipFile(temp,'x',compression=zipfile.ZIP_DEFLATED,compresslevel=6) as z:
for p in sorted(bundle.rglob('*')):
if p.is_file():
info=zipfile.ZipInfo(str(p.relative_to(bundle)),date_time=(1980,1,1,0,0,0));info.external_attr=0o100644<<16;info.compress_type=zipfile.ZIP_DEFLATED;z.writestr(info,p.read_bytes())
with zipfile.ZipFile(temp) as z:
for entry in z.infolist():
assert entry.date_time==(1980,1,1,0,0,0) and z.read(entry.filename)==(bundle/entry.filename).read_bytes()
temp.replace(ROOT/'blind-package.zip')
report=json.loads((ROOT/'public/package-result.json').read_text())
report.update(version=2,finalizing_ruling='1794676093.443769',zip_sha256=sha(ROOT/'blind-package.zip'),
zip_bytes=(ROOT/'blind-package.zip').stat().st_size,manifest_sha256=sha(bundle/'manifest.json'),
superseded_pre_handoff_zip_sha256=sha(old/'blind-package.zip'),no_geometry_rerender=True,
allowed_labels=['rigid / same part','unrelated','UNRESOLVED'],seed_sealed_until_frozen_verdicts=True)
save(ROOT/'public/package-result.json',report)
print(json.dumps({k:v for k,v in report.items() if k!='presentation_receipt'}))
if __name__=='__main__':main()