44 lines
4.0 KiB
Python
44 lines
4.0 KiB
Python
from pathlib import Path
|
|
import json,hashlib,subprocess,importlib.util,os,shutil
|
|
R=Path('/Users/korizatou114/Projects/とりにく工房ゲーム制作部')
|
|
B=Path('/Users/korizatou114/Projects/TheTree-managed-worktrees/p04-01/.runtime/P04-01/build')
|
|
E=R/'docs/plans/original-completion-2026-10-02/execution/p04-01-current-recheck-20261015'
|
|
T=B/'audit-support/p04-r17-full-inputs-r01'
|
|
assert not T.exists()
|
|
spec=importlib.util.spec_from_file_location('p04_source_runner',R/'tools/run_all_tests.py');module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module)
|
|
current=module.source_refs(R); assert len(current)==1338
|
|
runs=['p04-s1-native-r02','p04-s2a-native-r03','p04-s2b-native-r02','p04-s3-native-r01']
|
|
def digest(p):return hashlib.sha256(p.read_bytes()).hexdigest()
|
|
inputs={};slots={};fixed={};before={}
|
|
for run in runs:
|
|
src=json.loads((B/run/'source_before.json').read_text())
|
|
assert set(src)==set(current)
|
|
assert all((v['bytes'],v['sha256'])==(current[k]['bytes'],current[k]['sha256']) for k,v in src.items())
|
|
before[run]=digest(B/run/'source_before.json')
|
|
row=json.loads((B/run/'runner-input.json').read_text())
|
|
for p in row['fixed_input_pins']+[row['QA']]:
|
|
original=Path(p['path']);assert original.stat().st_size==p['bytes'] and digest(original)==p['sha256']
|
|
fixed[str(original)]={'target':T/'fixed'/p['sha256']/original.name,'bytes':p['bytes'],'sha256':p['sha256']}
|
|
for role in ['writer','reader']:
|
|
receipt=json.loads((B/run/'raw'/f'{role}.json').read_text())
|
|
for key,original in receipt['slots'].items():
|
|
root=Path(original);members=sorted(root.iterdir());assert [p.name for p in members]==['journal.log','manifest.json','thumbnail.png','world.bin'] and all(p.is_file() and not p.is_symlink() for p in members)
|
|
target=T/'formal'/run/role/key
|
|
slots[original]={'relocated':str(target),'run':run,'role':role,'slot':key}
|
|
for p in members:inputs[str(p)]={'target':target/p.name,'bytes':p.stat().st_size,'sha256':digest(p)}
|
|
for rel,v in current.items():inputs[v['path']]={'target':T/'product'/rel,'bytes':v['bytes'],'sha256':v['sha256']}
|
|
for name,v in fixed.items():inputs.setdefault(name,v)
|
|
footprint=sum(v['bytes'] for v in inputs.values());assert shutil.disk_usage(B).free>1024**3+footprint
|
|
T.mkdir(parents=True);mapping={}
|
|
for original,v in sorted(inputs.items()):
|
|
src=Path(original);dst=v['target'];assert src.is_file() and not src.is_symlink() and src.stat().st_size==v['bytes'] and digest(src)==v['sha256']
|
|
dst.parent.mkdir(parents=True,exist_ok=True);subprocess.run(['/bin/cp','-c',str(src),str(dst)],check=True)
|
|
assert src.stat().st_ino!=dst.stat().st_ino and dst.stat().st_size==v['bytes'] and digest(dst)==v['sha256'] and digest(src)==v['sha256']
|
|
mapping[original]={'relocated':str(dst),'bytes':v['bytes'],'sha256':v['sha256'],'separate_inode':True}
|
|
manifest={'protocol':'p04-root-full-input-relocation-v1','role':'exact full input bytes only; not native acceptance or candidate proof','source_count':1338,'product_content_anchor':'5f6bc11d6bb6e92d22d787989b219fef3a435bc1','production_HEAD_at_supply':subprocess.check_output(['git','-C',str(R),'rev-parse','HEAD'],text=True).strip(),'source_before_sha':before,'product_source':current,'original_to_relocated':mapping,'formal_slot_original_to_relocated':slots,'fixed_original_paths':sorted(fixed),'logical_bytes':footprint,'originals_unchanged':True,'no_permission_or_Runner_change':True}
|
|
p=T/'MANIFEST.json';p.write_text(json.dumps(manifest,ensure_ascii=False,indent=2)+'\n')
|
|
report={'manifest':str(p),'bytes':p.stat().st_size,'sha256':digest(p),'files':len(mapping),'formal_files':344,'formal_slots_both_roles':len(slots),'product_files':1338,'logical_bytes':footprint,'all_original_and_relocated_bytes_SHA_match':True,'originals_retained':True}
|
|
(E/'ROOT_R17_FULL_INPUT_RELOCATION_R01.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n')
|
|
(E/'p04-r17-supply-full-inputs-r01.py').write_bytes(Path(__file__).read_bytes())
|
|
print(json.dumps(report,ensure_ascii=False))
|