Files
TheTree_mock/docs/plans/original-completion-2026-10-02/execution/p18-01-resume-20261015/thetree-p18-current-composition-reuse-r02.py

17 lines
2.9 KiB
Python

import subprocess,json,hashlib,io
from pathlib import Path
r=Path('/Users/korizatou114/Projects/とりにく工房ゲーム制作部');e=r/'docs/plans/original-completion-2026-10-02/execution/p18-01-resume-20261015';proof=Path('/Users/korizatou114/Projects/TheTree-managed-worktrees/p18-01-model/.runtime/P18-01-CODE/build/p18-merged-native-evidence-265ce30-r01');submitted='265ce30f81b1302ca374330f7129f02d6fde4697';git=lambda *args:subprocess.check_output(['git',*args],cwd=r);main=git('rev-parse','main').decode().strip();tree=git('merge-tree','--write-tree',main,submitted).decode().splitlines()[0];entries=[]
for row in git('ls-tree','-rz',tree).split(b'\0'):
if not row:continue
meta,name=row.split(b'\t',1);mode,kind,obj=meta.split();name=name.decode()
if name.split('/')[0] in ['autoload','scripts','scenes','data','tests','assets','tools'] and Path(name).name!='.DS_Store' and '__pycache__' not in Path(name).parts or name in ['project.godot','export_presets.cfg','Makefile','AGENTS.md','docs/plans/original-completion-2026-10-02/execution/completion_marker_contracts.json']:
assert mode in [b'100644',b'100755'] and kind==b'blob';entries.append((name,obj))
raw=subprocess.check_output(['git','cat-file','--batch'],input=b'\n'.join(obj for _,obj in entries)+b'\n',cwd=r);f=io.BytesIO(raw);pins={}
for name,obj in entries:
header=f.readline().split();assert header[0]==obj and header[1]==b'blob';n=int(header[2]);body=f.read(n);assert f.read(1)==b'\n';pins[name]={'bytes':n,'sha256':hashlib.sha256(body).hexdigest()}
marker=pins.pop('docs/plans/original-completion-2026-10-02/execution/completion_marker_contracts.json');receipt=json.loads((proof/'receipt.json').read_text());source=receipt['source_map'];differences=[name for name in sorted(set(pins)|set(source)) if pins.get(name)!=source.get(name)];start=json.loads((proof/'runner-input.json').read_text());engine=Path(start['engine']);h=hashlib.sha256()
with engine.open('rb') as file:
for chunk in iter(lambda:file.read(1024*1024),b''):h.update(chunk)
checks={'complete_source_map_matches':not differences,'marker_matches':marker['sha256']==receipt['marker_contract_sha256'],'engine_matches':h.hexdigest()==receipt['engine_sha256'],'project_settings_match':pins['project.godot']['sha256']==receipt['project_settings_sha256']}
result={'main_base':main,'submitted':submitted,'composition_tree':tree,'source_files':len(pins),'source_bytes':sum(x['bytes'] for x in pins.values()),'differences':differences,'checks':checks,'all_preliminary_checks_passed':all(checks.values()),'actual_native_runs':0,'scope':'source/settings/marker/engine applicability only; mandatory normal Runner verifier still required on its actual candidate, including policy and proof integrity','formal_original_credit':0};(e/'CURRENT_MAIN_265_REUSE_PREFLIGHT_R02.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n');print(json.dumps(result,ensure_ascii=False));assert all(checks.values())