Files
Takeshi b84bade045 Save The Tree implementation and acceptance work in progress
Preserve production code, regression fixtures, audio assets and provenance, test infrastructure, and the original-completion plan and progress ledger. Final game and Windows acceptance remain pending; excluded local artifacts and native experiments are not part of this snapshot.
2026-10-11 15:58:00 +09:00

62 lines
6.1 KiB
Python

"""Whole real ordinary-owner proof parser; synthetic controls are not engine evidence."""
from pathlib import Path
import hashlib,json
def sha(p):return hashlib.sha256(Path(p).read_bytes()).hexdigest()
def read(p):return json.loads(Path(p).read_bytes())
def require(ok,msg):
if not ok:raise AssertionError(msg)
def control_gate(control,pid):
require(control['owned_engine_pid']==pid and type(control['owner_instance_id']) is int and control['owner_instance_id']>0 and control['passed'] is True,'actual owner/PID/pass')
require(control['maximum_wait_us']==500000 and control['whole_Runtime_field_deletions']==0,'whole Runtime and bound')
for key in ['ordinary_owner_release_verified','clock_process_flags_unchanged','root_gui_input_flag_unchanged','audio_teardown_passed']:require(control[key] is True,key)
for key in ['gameplay_expectations_changed','clock_flags_intentionally_modified','application_close_called','SceneTree_quit_overridden','WindowQuit_verified','formal_acceptance']:require(control[key] is False,key)
before,after=control['before'],control['after'];ids=before['owner_ids'];owner=control['owner_instance_id']
require(all(type(i) is int and i>0 for i in ids) and ids==sorted(set(ids)) and owner in ids,'alive distinct owner set')
expected=sorted(i for i in ids if i!=owner);require(control['expected_remaining_owner_ids']==expected and after['owner_ids']==expected,'ordinary exact owner removal')
require(before['owner_meta_present'] is True and before['closing'] is False,'ordinary scope')
for key in ['clock_process','clock_physics_process','clock_process_mode','root_gui_disable_input']:require(before[key]==after[key],'unchanged control '+key)
if expected:require(after['owner_meta_present'] is True and after['closing'] is False and after['auto_accept_quit'] is False,'remaining owner retains shared coordinator')
else:require(after['owner_meta_present'] is False and after['auto_accept_quit']==before['original_auto_accept_quit'],'last-owner restores original automatic quit')
return owner
def audio_gate(path,pid,directory,out,owner):
proof=read(path);require(path.name=='owner_'+str(owner)+'.json' and path.parent==directory,'actual audio owner filename')
require(proof['owned_engine_pid']==pid and proof['owner_instance_id']==owner and proof['passed'] is True,'actual audio PID/owner/pass')
require(proof['maximum_wait_us']==500000 and 0<proof['waited_actual_us']<500000 and proof['deadline_reached'] is False,'strict elapsed deadline')
for key in ['owner_freed','all_owned_targets_released','whole_runtime_unchanged']:require(proof[key] is True,key)
for key in ['bus_deleted','cues_muted_for_test','actual_human_hearing','WindowQuit_verified','formal_acceptance']:require(proof[key] is False,key)
initial,final=proof['initial_targets'],proof['final_targets'];require(len(initial)==len(final)>=8,'actual WeakRef target count')
signatures=lambda rows:[(r['kind'],r['role'],r['instance_id']) for r in rows]
require(signatures(initial)==signatures(final) and len(set(signatures(initial)))==len(initial),'actual initial/final targets exact IDs')
require(all(r['alive'] is True for r in initial) and all(r['alive'] is False for r in final),'real WeakRef release')
for kind in ['stream','packet_sequence']:require({r['role'] for r in initial if r['kind']==kind}=={'click','success','refusal','notification'},'all four actual roles '+kind)
snapshots=proof['full_typed_snapshots'];require(set(snapshots)=={'before','after'},'whole before/after pair')
pins={};paths=[]
for part,pin in snapshots.items():
p=Path(pin['path']);require(p.parent==directory and p.name==path.stem+'-'+part+'.varbytes' and p.is_file() and not p.is_symlink(),'whole typed path')
require(pin['field_deletions']==0 and p.stat().st_size==pin['bytes']>0 and sha(p)==pin['sha256'],'whole typed size/SHA/deletions')
paths.append(p);pins[str(p.relative_to(out))]={'bytes':p.stat().st_size,'sha256':sha(p)}
require(paths[0].read_bytes()==paths[1].read_bytes(),'literal allbytes before/after equality')
return {'report_path':str(path),'report_sha256':sha(path),'owner_instance_id':owner,'waited_actual_us':proof['waited_actual_us'],'initial_targets':initial,'final_targets':final,'full_typed_snapshot_files':pins},set(paths)|{path}
def ordinary_gate(directory,pid,out,labels):
directory=Path(directory);out=Path(out);require(directory.is_relative_to(out) and not directory.is_symlink(),'owned proof directory')
require(labels and len(labels)==len(set(labels)),'unique planned labels')
names=['control.json'] if labels==['single'] else ['control-'+label+'.json' for label in labels]
audio=directory/'owned-audio';require(audio.is_dir() and not audio.is_symlink(),'real owned audio directory')
require(set(directory.iterdir())=={audio,*[directory/n for n in names]},'all actual control files exact; no duplicate/missing/extra')
rows=[];ids=[];audio_paths=set()
for label,name in zip(labels,names):
p=directory/name;require(p.is_file() and not p.is_symlink(),'control regular file')
control=read(p);owner=control_gate(control,pid);require(owner not in ids,'distinct actual sequential owner IDs')
detail,paths=audio_gate(audio/('owner_'+str(owner)+'.json'),pid,audio,out,owner);audio_paths|=paths;ids.append(owner)
rows.append({'label':label,'actual_owner_instance_id':owner,'control_path':str(p),'control_sha256':sha(p),'control':control,'audio':detail})
require(set(audio.iterdir())==audio_paths,'all actual audio JSON/typed set exactly enumerated')
if len(labels)>1:
# These three exact fixtures create the replacement Main only after releasing
# its predecessor. Do not invent continuity of Runtime between gameplay steps.
for row in rows:require(row['control']['before']['owner_ids']==[row['actual_owner_instance_id']] and row['control']['after']['owner_ids']==[],'sequential source owner scope')
return {'verified':True,'planned_label_sequence':labels,'actual_owner_ID_sequence':ids,'unique_controlproof_paths':[r['control_path'] for r in rows],'ordinary_owner_pairs':rows,'expected_control_count':len(labels),'actual_audio_report_count':len(rows),'whole_typed_field_deletions':0,'Clock_GUI_flags_intentionally_modified':False,'application_close_called':False,'all_files_enumerated':True,'WindowQuit_verified':False,'formal_acceptance':False}