69 lines
7.0 KiB
Python
69 lines
7.0 KiB
Python
from pathlib import Path
|
|
import hashlib,importlib.util,json,sys,os
|
|
sys.dont_write_bytecode=True
|
|
R=Path('/Users/korizatou114/Projects/とりにく工房ゲーム制作部');A=R/'artifacts/original-completion-2026-10-02';P=Path('/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-EV-retarget-refusal-prep-r02')
|
|
TEST='tests/s3/test_runtime_staff_assignment.gd'
|
|
READER='tests/s6/test_runtime_snapshot_serialization.gd'
|
|
def module(n,p):
|
|
s=importlib.util.spec_from_file_location(n,p);m=importlib.util.module_from_spec(s);s.loader.exec_module(m);return m
|
|
def main():
|
|
assert len(sys.argv)==2
|
|
mode='formal-cross-pid';out=Path(sys.argv[1]);assert out.parent==A and not out.exists() and str(out)==json.loads((P/'preparation.json').read_bytes())['planned_output']
|
|
r=module('role_formal_literal_runner',R/'tools/run_all_tests.py')
|
|
seal=r.read(P/'input-seal.json')
|
|
assert set(str(p.relative_to(P)) for p in P.rglob('*') if p.is_file())==set(seal['files'])|{'input-seal.json','preparation.json'}
|
|
for n,v in seal['files'].items():assert Path(v['path'])==P/n and r.sha(v['path'])==v['sha256'] and Path(v['path']).stat().st_size==v['bytes']
|
|
for name in ['writer.gd','reader.gd']:
|
|
lines=(P/name).read_text().splitlines();bindings=[line[len('const PAIR_ROOT := '):]for line in lines if line.startswith('const PAIR_ROOT := ')]
|
|
assert len(bindings)==1 and json.loads(bindings[0])==str(out/'migration-pair') and not (out/'migration-pair').exists()
|
|
root_before=r.source_refs(R);assert len(root_before)==1299
|
|
adopted=r.read(A/'p03-current1299-defense-empty-two-ref-source-adoption-r01/source-after.json')
|
|
assert {n:v['sha256']for n,v in root_before.items()}==adopted
|
|
refs=dict(root_before);refs[TEST]=seal['files']['writer.gd'];refs[READER]=seal['files']['reader.gd']
|
|
for n,v in refs.items():assert Path(v['path']).stat().st_size==v['bytes'] and r.sha(v['path'])==v['sha256']
|
|
docs={n:r.sha(R/'docs/plans/original-completion-2026-10-02'/n) for n in ('IMPLEMENTATION_PLAN.md','PROGRESS_INTEGRATION.md','work_packages.json','progress_snapshot.json')}
|
|
outer=module('bath_literal_owned_outer',r.SUPPORT/'owned_outer.py');assert not outer.native.helper['live_engines']()
|
|
engine='/Applications/Godot.app/Contents/MacOS/Godot'
|
|
out.mkdir();stage=out/'stage';stage.mkdir();(out/'starters').mkdir();(out/'bootstrap').mkdir()
|
|
for n,v in r.read(r.SUPPORT/'bootstrap-scripts.json').items():
|
|
data=v['text'].encode();assert hashlib.sha256(data).hexdigest()==v['sha256'];(out/'bootstrap'/n).write_bytes(data)
|
|
protected=r.default_player(R);expected={n:{'bytes':v['bytes'],'sha256':v['sha256']}for n,v in refs.items()}
|
|
selected={'root_before':root_before,'map':{n:v['sha256']for n,v in refs.items()},'timeout':180}
|
|
for n,v in refs.items():
|
|
p=stage/n;p.parent.mkdir(parents=True,exist_ok=True);r.copy_source(Path(v['path']),p)
|
|
assert r.inventory(stage,stage=True)==expected
|
|
public=(stage/'project.godot').read_bytes();paths=['res://'+n for n in sorted(refs) if n.endswith('.gd')];r.write(out/'parse-paths.json',paths)
|
|
markers=module('bath_literal_markers',R/'tools/strict_test_markers.py')
|
|
contracts=markers.load_contracts(R/'docs/plans/original-completion-2026-10-02/execution/completion_marker_contracts.json')
|
|
contracts[TEST]={'test':TEST,'template':'EV retarget refusal formal write: <checks> checks, <failures> failures','required':True}
|
|
contracts[READER]={'test':READER,'template':'EV retarget refusal formal read: <checks> checks, <failures> failures','required':True}
|
|
policy=r.read(r.SUPPORT/'suite-policy.json');assert TEST not in policy['suite_policies'] and READER not in policy['suite_policies']
|
|
r.write(out/'runner-input.json',{'mode':mode,'owner_pid':os.getpid(),'wrapper_sha256':r.sha(__file__),'runner_sha256':r.sha(R/'tools/run_all_tests.py'),'selected_source_map':selected['map'],'source_before':root_before,'default_player':protected,'doc4_before':docs,'actual_full':False,'source_adoption':False})
|
|
diagnostics=module('bath_literal_diagnostics',r.SUPPORT/'diagnostic_gate.py');owners=module('bath_literal_owners',r.SUPPORT/'ordinary_proof_gate.py');audio=module('bath_literal_audio',r.SUPPORT/'audio_evidence_gate.py')
|
|
phases=[];previous={};error=None;formal_before=None
|
|
try:
|
|
for phase,test in [('import',None),('parse',None),('writer',TEST),('reader',READER)]:
|
|
if phase=='writer':assert not (out/'migration-pair').exists()
|
|
if phase=='reader':assert r.inventory(out/'migration-pair')==pair_before
|
|
row=r.execute_phase(engine,stage,out,phase,test,selected,expected,previous,policy,contracts,paths,public,protected,R,outer,markers,diagnostics,owners,audio);phases.append(row)
|
|
print(json.dumps({'phase':phase,'passed':row['passed'],'checks':row.get('reported_checks'),'error':row.get('validation_error'),'guard_error':row.get('guard_error')}),flush=True)
|
|
r.require(row['passed'],'strict phase failure stops without retry')
|
|
if phase=='writer':
|
|
pair_before=r.inventory(out/'migration-pair');formal_before={n:v for n,v in pair_before.items()if '/formal/'in n}
|
|
assert len(formal_before)==12
|
|
r.write(out/'actual-formal-before-reader.json',formal_before)
|
|
if phase=='reader':
|
|
after=r.inventory(out/'migration-pair');assert {n:v for n,v in after.items()if '/formal/'in n}==formal_before
|
|
assert all(after[n]==v for n,v in pair_before.items())
|
|
r.write(out/'actual-formal-after-reader.json',{n:v for n,v in after.items()if '/formal/'in n})
|
|
except BaseException as caught:error=type(caught).__name__+': '+str(caught)
|
|
finally:cleanup,cleanup_errors=outer.finish_captured(outer.OWNED)
|
|
passed=error is None and not cleanup_errors and len(phases)==4 and all(x['passed'] for x in phases) and all(x['engine_ended'] for x in cleanup)
|
|
assert r.source_refs(R)==root_before and r.default_player(R)==protected
|
|
assert {n:r.sha(R/'docs/plans/original-completion-2026-10-02'/n) for n in docs}==docs
|
|
assert r.inventory(stage,stage=True)==dict(expected,**previous)
|
|
r.write(out/'runner-ended.json',{'mode':mode,'passed':passed,'phases':phases,'cleanup':cleanup,'cleanup_errors':cleanup_errors,'error':error,'whole_source_unchanged':True,'whole_default_profile_unchanged':True,'doc4_unchanged':True,'source_adoption':False,'normal_GUI_accepted':False,'full_regression_accepted':False,'formal_cross_PID_accepted':False,'actual_captured_PIDs':[p.pid for p in outer.OWNED],'actual_native_processes':len(outer.OWNED),'actual_checks':sum(p.get('reported_checks',0)for p in phases if p['test']) if passed else None,'formal_reader_evidence_scope':'headless direct formal changed-entrance migration refusal with actual paid old room and boarded passenger; actual earlier successful migration backup retained; separate-PID whole original/backup and post-refusal continuation. Operations OFF public fixture passenger; no Main OS/rescue/logistics/full migration acceptance','native_Windows_accepted':False,'whole_goal_accepted':False})
|
|
print(json.dumps({'mode':mode,'passed':passed,'error':error,'actual_native':len(phases),'actual_checks':phases[-1].get('reported_checks')}),flush=True)
|
|
return 0 if passed else 1
|
|
if __name__=='__main__':raise SystemExit(main())
|