Archived
Seal independent proper poses and block uncorrected blind-package release
This commit is contained in:
1 parent
6d61c08686
commit
039d4c490f
20 files changed
+452
-4
No files matched your search
@@ -0,0 +1,25 @@
|
||||
"""Pose one export instance from the completed stored surface; never re-extract."""
|
||||
from pathlib import Path
|
||||
import hashlib,json,sys,resource,time
|
||||
import numpy as np
|
||||
from g1_blind_pose import read_surface,pose
|
||||
from g1_blind_geometry import ply_bytes
|
||||
from render_g1_blind_surface import render_surface
|
||||
ROOT=Path('artifacts/s2-g1-blind120-2026-11-14')
|
||||
def main():
|
||||
start=time.monotonic();index=int(sys.argv[1]);contract=json.loads((ROOT/'pose-contract.json').read_text())
|
||||
for p,h in contract['source_sha256'].items():
|
||||
if hashlib.sha256(Path(p).read_bytes()).hexdigest()!=h:raise ValueError('Pose code changed')
|
||||
planfile=ROOT/'custodian/pose-plan-v1.json'
|
||||
if hashlib.sha256(planfile.read_bytes()).hexdigest()!=contract['pose_plan_sha256']:raise ValueError('Pose plan changed')
|
||||
if hashlib.sha256((ROOT/'custodian/sampling-and-mapping.json').read_bytes()).hexdigest()!=contract['sampling_mapping_sha256']:raise ValueError('Sampling mapping changed')
|
||||
row=json.loads(planfile.read_text())['exports'][index];old=json.loads((ROOT/'custodian/sampling-and-mapping.json').read_text());pair=next(r for r in old['pairs'] if r['anonymous_pair_id']==row['anonymous_pair_id']);case=pair[row['side']]
|
||||
asset=hashlib.sha256(bytes.fromhex(old['anonymous_id_secret_hex'])+b'asset\0'+case.encode()).hexdigest()[:32];src=ROOT/'custodian/geometry'/asset
|
||||
original=json.loads((src/'receipt.json').read_text());digest=next(x['sha256'] for x in original['files'] if x['name']=='surface.ply')
|
||||
if hashlib.sha256((src/'surface.ply').read_bytes()).hexdigest()!=digest:raise ValueError('Stored surface changed')
|
||||
x,f=read_surface(src/'surface.ply');y,transform=pose(x,f,row['rotation'],row['translation_unit_vector'])
|
||||
out=ROOT/'custodian/posed'/row['anonymous_pair_id']/row['side'];out.mkdir(parents=True,exist_ok=False)
|
||||
(out/'surface.ply').write_bytes(ply_bytes(y,f));render_surface(y,f,out)
|
||||
receipt={'index':index,'anonymous_pair_id':row['anonymous_pair_id'],'side':row['side'],'transform':transform,'source_surface_sha256':digest,'source_asset_id':asset,'files':[{'name':p.name,'bytes':p.stat().st_size,'sha256':hashlib.sha256(p.read_bytes()).hexdigest()} for p in sorted(out.iterdir())],'cpu_seconds':sum(resource.getrusage(resource.RUSAGE_SELF)[:2]),'wall_seconds':time.monotonic()-start,'archive_reads':0,'registration':False,'same_posed_coordinates_for_ply_and_png':True}
|
||||
(out/'receipt.json').write_text(json.dumps(receipt,indent=2)+'\n');print(json.dumps({'index':index,'status':'POSED_AND_INVARIANTS_PASS','cpu_seconds':receipt['cpu_seconds']}))
|
||||
if __name__=='__main__':main()
|
||||
Reference in new issue
Block a user