Freeze P08 mixed migration acceptance and reusable historical fixtures
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,131 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-EV-retarget-refusal-native-r02/migration-pair"
|
||||
const MODE := "read"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
var room_id: StringName
|
||||
const OLD_TARGET:=Vector3i(-7,3,0)
|
||||
const SLOT: String="user://p03-EV-refusal/manual"
|
||||
func package_hashes() -> Dictionary:
|
||||
var values: Dictionary={}
|
||||
for suffix: String in ["",SaveService.MIGRATION_BACKUP_SUFFIX]:
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
values[suffix+"/"+name]=FileAccess.get_sha256(ProjectSettings.globalize_path(SLOT+suffix).path_join(name))
|
||||
return values
|
||||
func refusal(label: String) -> void:
|
||||
var before: Dictionary=runtime.create_snapshot()
|
||||
var packages: Dictionary=package_hashes()
|
||||
var prepared: Dictionary=runtime.prepare_facility_dimension_snapshot(room_id)
|
||||
expect(not prepared.get(&"ok",false) and &"TRANSPORT_REPLAN_REQUIRED" in prepared.get(&"retargeting",{}).get(&"errors",[]),"actual occupied trip explicitly refuses retarget")
|
||||
expect(prepared.get(&"routes",{}).get(&"guest_replans",[]).size()==1,"one actual guest destination requires replan")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(SLOT)
|
||||
expect(not preview.get(&"ok",false),"formal migration review rejects occupied retarget")
|
||||
var result: Dictionary=runtime.migrate_facility_dimensions_at_path(SLOT)
|
||||
expect(not result.get(&"ok",false) and result.get(&"code",&"")==&"DIMENSION_MIGRATION_REJECTED" and result.get(&"details",{}).get(&"rolled_back",false),"formal batch refuses and rolls back isolated candidate")
|
||||
expect(var_to_bytes(before)==var_to_bytes(runtime.create_snapshot()),"entire live world unchanged after all three migration paths")
|
||||
expect(package_hashes()==packages,"all original and real preexisting backup files unchanged")
|
||||
write_proof(MODE+"-"+label+"-refusal.var",{&"prepared":prepared,&"preview":preview,&"result":result,&"packages":packages})
|
||||
capture(label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new();clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42588)[&"valid"],"canonical current initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"own fresh evidence directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived definition")
|
||||
for row: Array in [[&"guest_elevator",Vector3i(-8,0,0)],[&"reception",Vector3i(-6,0,0)],[&"premium_room",Vector3i(-6,2,0)],[&"guest_stairs",Vector3i(-7,2,0)],[&"guest_stairs",Vector3i(-7,3,0)]]:
|
||||
if not command(&"build_facility",{&"definition_id":row[0],&"origin":row[1]}).is_success():
|
||||
runtime.free();clock.free();state.free()
|
||||
print("EV retarget refusal formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures);return
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(row[0]).build_minutes)
|
||||
for instance: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if instance.definition_id==&"premium_room":room_id=instance.instance_id
|
||||
expect(not room_id.is_empty(),"normally paid completed old-size room")
|
||||
expect(not runtime.path_service.find_path(Vector3i(-8,0,0),OLD_TARGET).is_empty(),"real paid old upper entrance reachable through EV and corridors")
|
||||
var baseline: Dictionary=runtime.create_snapshot()
|
||||
expect(SaveService.save_snapshot(SLOT,baseline)[&"ok"],"formal old room baseline before real backup creation")
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"current approved footprint registry")
|
||||
var first: Dictionary=runtime.migrate_facility_dimensions_at_path(SLOT)
|
||||
expect(first.get(&"ok",false) and first.get(&"backup_created",false),"normal unoccupied migration creates actual verified backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(baseline),"first migration leaves live original geometry")
|
||||
expect(var_to_bytes(SaveService.load_snapshot(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX).get(&"snapshot",{}))==var_to_bytes(baseline),"actual backup exactly restores pre-migration baseline")
|
||||
write_proof("baseline.var",baseline)
|
||||
command(&"spawn_guest",{&"guest_id":&"p03.retarget.passenger",&"guest_type_id":&"traveler",&"gold":100,&"options":{&"current_cell":Vector3i(-8,0,0),&"state":GuestRuntime.State.MOVING,&"state_entered_at":clock.absolute_minute-1,&"planned_exit_at":clock.absolute_minute+2000,&"target_facility_id":room_id,&"path_handle":{&"target_cell":OLD_TARGET}}})
|
||||
clock.advance_minutes(2)
|
||||
var trip: Dictionary=runtime.elevators.get_actor_trip(&"guest:p03.retarget.passenger")
|
||||
expect(not trip.is_empty() and trip.get(&"state",&"")==&"BOARDED","real passenger owns actual boarded EV trip")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
expect(SaveService.save_snapshot(SLOT,legacy)[&"ok"],"formal original includes occupied trip and old entrance")
|
||||
write_proof("legacy.var",legacy);write_proof("identity.var",{&"room_id":room_id,&"serial":serial,&"request_id":trip.get(&"request_id",&"")})
|
||||
copy_package(ProjectSettings.globalize_path(SLOT),PAIR_ROOT.path_join("original/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current approved footprint registry")
|
||||
var identity: Dictionary=read_proof("identity.var");room_id=identity[&"room_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("original/formal"),ProjectSettings.globalize_path(SLOT))
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
expect(runtime.restore_snapshot(SaveService.load_snapshot(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX).get(&"snapshot",{})),"separate PID restores real earlier backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("baseline.var")),"whole earlier backup state matches")
|
||||
expect(runtime.restore_snapshot(SaveService.load_snapshot(SLOT).get(&"snapshot",{})),"actual original boarded package restores")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole boarded original restored exactly")
|
||||
capture("checkpoint");refusal("reject1");refusal("reject2")
|
||||
if MODE=="write":copy_package(ProjectSettings.globalize_path(SLOT),PAIR_ROOT.path_join("after-refusal/formal"))
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.refusal.uncapped",Callable(self,"observe")),"whole uncapped post-refusal journal")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(10);capture("final20")
|
||||
expect(runtime.facility_service.get_instance(room_id).occupied_cells.size()==6,"rejected conversion retains original facility shape")
|
||||
expect(runtime.elevators.get_actor_trip(&"guest:p03.retarget.passenger").is_empty() and runtime.path_service.get_transit_actor_ids().is_empty(),"original EV trip finishes without orphan transit after refusal")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"post-refusal continuation remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"entire post-refusal journal matches without deletion or replacement")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("EV retarget refusal formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,131 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-EV-retarget-refusal-native-r02/migration-pair"
|
||||
const MODE := "write"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
var room_id: StringName
|
||||
const OLD_TARGET:=Vector3i(-7,3,0)
|
||||
const SLOT: String="user://p03-EV-refusal/manual"
|
||||
func package_hashes() -> Dictionary:
|
||||
var values: Dictionary={}
|
||||
for suffix: String in ["",SaveService.MIGRATION_BACKUP_SUFFIX]:
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
values[suffix+"/"+name]=FileAccess.get_sha256(ProjectSettings.globalize_path(SLOT+suffix).path_join(name))
|
||||
return values
|
||||
func refusal(label: String) -> void:
|
||||
var before: Dictionary=runtime.create_snapshot()
|
||||
var packages: Dictionary=package_hashes()
|
||||
var prepared: Dictionary=runtime.prepare_facility_dimension_snapshot(room_id)
|
||||
expect(not prepared.get(&"ok",false) and &"TRANSPORT_REPLAN_REQUIRED" in prepared.get(&"retargeting",{}).get(&"errors",[]),"actual occupied trip explicitly refuses retarget")
|
||||
expect(prepared.get(&"routes",{}).get(&"guest_replans",[]).size()==1,"one actual guest destination requires replan")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(SLOT)
|
||||
expect(not preview.get(&"ok",false),"formal migration review rejects occupied retarget")
|
||||
var result: Dictionary=runtime.migrate_facility_dimensions_at_path(SLOT)
|
||||
expect(not result.get(&"ok",false) and result.get(&"code",&"")==&"DIMENSION_MIGRATION_REJECTED" and result.get(&"details",{}).get(&"rolled_back",false),"formal batch refuses and rolls back isolated candidate")
|
||||
expect(var_to_bytes(before)==var_to_bytes(runtime.create_snapshot()),"entire live world unchanged after all three migration paths")
|
||||
expect(package_hashes()==packages,"all original and real preexisting backup files unchanged")
|
||||
write_proof(MODE+"-"+label+"-refusal.var",{&"prepared":prepared,&"preview":preview,&"result":result,&"packages":packages})
|
||||
capture(label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new();clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42588)[&"valid"],"canonical current initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"own fresh evidence directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived definition")
|
||||
for row: Array in [[&"guest_elevator",Vector3i(-8,0,0)],[&"reception",Vector3i(-6,0,0)],[&"premium_room",Vector3i(-6,2,0)],[&"guest_stairs",Vector3i(-7,2,0)],[&"guest_stairs",Vector3i(-7,3,0)]]:
|
||||
if not command(&"build_facility",{&"definition_id":row[0],&"origin":row[1]}).is_success():
|
||||
runtime.free();clock.free();state.free()
|
||||
print("EV retarget refusal formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures);return
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(row[0]).build_minutes)
|
||||
for instance: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if instance.definition_id==&"premium_room":room_id=instance.instance_id
|
||||
expect(not room_id.is_empty(),"normally paid completed old-size room")
|
||||
expect(not runtime.path_service.find_path(Vector3i(-8,0,0),OLD_TARGET).is_empty(),"real paid old upper entrance reachable through EV and corridors")
|
||||
var baseline: Dictionary=runtime.create_snapshot()
|
||||
expect(SaveService.save_snapshot(SLOT,baseline)[&"ok"],"formal old room baseline before real backup creation")
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"current approved footprint registry")
|
||||
var first: Dictionary=runtime.migrate_facility_dimensions_at_path(SLOT)
|
||||
expect(first.get(&"ok",false) and first.get(&"backup_created",false),"normal unoccupied migration creates actual verified backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(baseline),"first migration leaves live original geometry")
|
||||
expect(var_to_bytes(SaveService.load_snapshot(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX).get(&"snapshot",{}))==var_to_bytes(baseline),"actual backup exactly restores pre-migration baseline")
|
||||
write_proof("baseline.var",baseline)
|
||||
command(&"spawn_guest",{&"guest_id":&"p03.retarget.passenger",&"guest_type_id":&"traveler",&"gold":100,&"options":{&"current_cell":Vector3i(-8,0,0),&"state":GuestRuntime.State.MOVING,&"state_entered_at":clock.absolute_minute-1,&"planned_exit_at":clock.absolute_minute+2000,&"target_facility_id":room_id,&"path_handle":{&"target_cell":OLD_TARGET}}})
|
||||
clock.advance_minutes(2)
|
||||
var trip: Dictionary=runtime.elevators.get_actor_trip(&"guest:p03.retarget.passenger")
|
||||
expect(not trip.is_empty() and trip.get(&"state",&"")==&"BOARDED","real passenger owns actual boarded EV trip")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
expect(SaveService.save_snapshot(SLOT,legacy)[&"ok"],"formal original includes occupied trip and old entrance")
|
||||
write_proof("legacy.var",legacy);write_proof("identity.var",{&"room_id":room_id,&"serial":serial,&"request_id":trip.get(&"request_id",&"")})
|
||||
copy_package(ProjectSettings.globalize_path(SLOT),PAIR_ROOT.path_join("original/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current approved footprint registry")
|
||||
var identity: Dictionary=read_proof("identity.var");room_id=identity[&"room_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("original/formal"),ProjectSettings.globalize_path(SLOT))
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
expect(runtime.restore_snapshot(SaveService.load_snapshot(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX).get(&"snapshot",{})),"separate PID restores real earlier backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("baseline.var")),"whole earlier backup state matches")
|
||||
expect(runtime.restore_snapshot(SaveService.load_snapshot(SLOT).get(&"snapshot",{})),"actual original boarded package restores")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole boarded original restored exactly")
|
||||
capture("checkpoint");refusal("reject1");refusal("reject2")
|
||||
if MODE=="write":copy_package(ProjectSettings.globalize_path(SLOT),PAIR_ROOT.path_join("after-refusal/formal"))
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.refusal.uncapped",Callable(self,"observe")),"whole uncapped post-refusal journal")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(10);capture("final20")
|
||||
expect(runtime.facility_service.get_instance(room_id).occupied_cells.size()==6,"rejected conversion retains original facility shape")
|
||||
expect(runtime.elevators.get_actor_trip(&"guest:p03.retarget.passenger").is_empty() and runtime.path_service.get_transit_actor_ids().is_empty(),"original EV trip finishes without orphan transit after refusal")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"post-refusal continuation remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"entire post-refusal journal matches without deletion or replacement")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("EV retarget refusal formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,68 @@
|
||||
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())
|
||||
@@ -0,0 +1,143 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-batch-later-refusal-native-r02/migration-pair"
|
||||
const MODE := "read"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
var room_id: StringName
|
||||
const OLD_TARGET:=Vector3i(-7,3,1)
|
||||
const SLOT: String="user://p03-batch-later-refusal/manual"
|
||||
func package_hashes() -> Dictionary:
|
||||
var values: Dictionary={}
|
||||
for suffix: String in ["",SaveService.MIGRATION_BACKUP_SUFFIX]:
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
values[suffix+"/"+name]=FileAccess.get_sha256(ProjectSettings.globalize_path(SLOT+suffix).path_join(name))
|
||||
return values
|
||||
func refusal(label: String) -> void:
|
||||
var before: Dictionary=runtime.create_snapshot()
|
||||
var packages: Dictionary=package_hashes()
|
||||
var first: Dictionary=runtime.prepare_facility_dimension_snapshot(job_id)
|
||||
expect(first.get(&"ok",false),"first paid legacy job is independently migratable before later refusal")
|
||||
var prepared: Dictionary=runtime.prepare_all_facility_dimension_snapshots()
|
||||
expect(not prepared.get(&"ok",false) and prepared.get(&"facility_id",&"")==room_id and prepared.get(&"rolled_back",false),"actual second-target rejection rolls back earlier applied job")
|
||||
expect(prepared.get(&"details",{}).get(&"routes",{}).get(&"errors",[]).any(func(error: Variant):return error is Dictionary and error.get(&"code",&"")==&"TASK_DESTINATION_CHANGED"),"real old upper-entry task specifically refuses lost destination")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(SLOT)
|
||||
expect(not preview.get(&"ok",false),"formal preview rejects later target")
|
||||
var result: Dictionary=runtime.migrate_facility_dimensions_at_path(SLOT)
|
||||
expect(not result.get(&"ok",false) and result.get(&"code",&"")==&"DIMENSION_MIGRATION_REJECTED" and result.get(&"details",{}).get(&"rolled_back",false),"formal batch refuses and rolls back isolated candidate")
|
||||
expect(var_to_bytes(before)==var_to_bytes(runtime.create_snapshot()),"entire live world unchanged after all three migration paths")
|
||||
expect(package_hashes()==packages,"all original and real preexisting backup files unchanged")
|
||||
write_proof(MODE+"-"+label+"-refusal.var",{&"first":first,&"prepared":prepared,&"preview":preview,&"result":result,&"packages":packages})
|
||||
capture(label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new();clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42588)[&"valid"],"canonical current initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"own fresh evidence directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://tests/fixtures/legacy_staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived definition")
|
||||
for row: Array in [[&"warehouse",Vector3i(-6,0,1)],[&"service_stairs",Vector3i(-7,1,1)],[&"service_stairs",Vector3i(-7,2,1)],[&"service_stairs",Vector3i(-7,3,1)],[&"staff_dormitory",Vector3i(-6,2,1)],[&"reception",Vector3i(-6,0,0)],[&"guest_stairs",Vector3i(4,1,0)],[&"guest_stairs",Vector3i(4,2,0)],[&"guest_stairs",Vector3i(4,3,0)]]:
|
||||
if not command(&"build_facility",{&"definition_id":row[0],&"origin":row[1]}).is_success():
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Batch later refusal formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures);return
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(row[0]).build_minutes)
|
||||
for instance: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if instance.definition_id==&"staff_dormitory":room_id=instance.instance_id
|
||||
expect(not room_id.is_empty(),"normally paid completed archived dormitory")
|
||||
if not command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)}).is_success():runtime.free();clock.free();state.free();quit(1);return
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid first-target partial job")
|
||||
if job_id.is_empty():runtime.free();clock.free();state.free();quit(1);return
|
||||
var baseline: Dictionary=runtime.create_snapshot()
|
||||
expect(SaveService.save_snapshot(SLOT,baseline)[&"ok"],"formal old room baseline before real backup creation")
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
paths.erase("res://tests/fixtures/legacy_staff_dormitory.tres");paths.append("res://data/facilities/expansion/staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"current approved footprint registry")
|
||||
var first: Dictionary=runtime.migrate_facility_dimensions_at_path(SLOT)
|
||||
expect(first.get(&"ok",false) and first.get(&"backup_created",false),"normal unconstrained two-target migration creates actual verified backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(baseline),"first migration leaves live original geometry")
|
||||
expect(var_to_bytes(SaveService.load_snapshot(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX).get(&"snapshot",{}))==var_to_bytes(baseline),"actual backup exactly restores pre-migration baseline")
|
||||
write_proof("baseline.var",baseline)
|
||||
expect(command(&"register_staff",{&"staff_id":&"batch_maintainer",&"role_id":&"porter",&"options":{&"current_cell":Vector3i(-7,1,1),&"state":StaffRuntime.State.AVAILABLE}}).is_success(),"public worker for actual old-entry task")
|
||||
expect(runtime.staff_service.create_task(&"maintenance",10,clock.absolute_minute,{&"target_entity_id":room_id,&"target_cell":OLD_TARGET,&"estimated_minutes":30},&"batch_old_entry_task").is_success(),"public actual old-entry maintenance task")
|
||||
expect(runtime.staff_service.assign_task_to_staff(&"batch_old_entry_task",&"batch_maintainer",clock.absolute_minute).is_success(),"public real task owner assignment")
|
||||
clock.advance_minutes(1)
|
||||
var task: StaffTask=runtime.staff_service.get_task(&"batch_old_entry_task")
|
||||
expect(not task.is_terminal() and task.assigned_staff_id==&"batch_maintainer" and runtime.staff_service.get_staff(&"batch_maintainer").current_task_id==task.task_id,"real old-entry work remains in flight at formal save")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
expect(SaveService.save_snapshot(SLOT,legacy)[&"ok"],"formal original includes partial job and real upper-entry task")
|
||||
write_proof("legacy.var",legacy);write_proof("identity.var",{&"room_id":room_id,&"serial":serial,&"job_id":job_id,&"task_id":&"batch_old_entry_task"})
|
||||
copy_package(ProjectSettings.globalize_path(SLOT),PAIR_ROOT.path_join("original/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres");paths.append("res://data/facilities/expansion/staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current approved footprint registry")
|
||||
var identity: Dictionary=read_proof("identity.var");room_id=identity[&"room_id"];job_id=identity[&"job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("original/formal"),ProjectSettings.globalize_path(SLOT))
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
expect(runtime.restore_snapshot(SaveService.load_snapshot(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX).get(&"snapshot",{})),"separate PID restores real earlier backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("baseline.var")),"whole earlier backup state matches")
|
||||
expect(runtime.restore_snapshot(SaveService.load_snapshot(SLOT).get(&"snapshot",{})),"actual original batch-source package restores")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole original batch source restored exactly")
|
||||
capture("checkpoint");refusal("reject1");refusal("reject2")
|
||||
if MODE=="write":copy_package(ProjectSettings.globalize_path(SLOT),PAIR_ROOT.path_join("after-refusal/formal"))
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.refusal.uncapped",Callable(self,"observe")),"whole uncapped post-refusal journal")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
expect(runtime.facility_service.get_instance(room_id).occupied_cells.size()==8,"later rejected dorm retains entire original footprint")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==6,"earlier rolled-back job completes with its original legacy footprint")
|
||||
expect(runtime.staff_service.get_task(&"batch_old_entry_task").state==StaffTask.State.COMPLETED and runtime.staff_service.get_staff(&"batch_maintainer").current_cell==OLD_TARGET and runtime.staff_service.get_staff(&"batch_maintainer").current_task_id.is_empty(),"actual original maintenance reaches old entry and finishes without orphan work")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"post-refusal continuation remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"entire post-refusal journal matches without deletion or replacement")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Batch later refusal formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,143 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-batch-later-refusal-native-r02/migration-pair"
|
||||
const MODE := "write"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
var room_id: StringName
|
||||
const OLD_TARGET:=Vector3i(-7,3,1)
|
||||
const SLOT: String="user://p03-batch-later-refusal/manual"
|
||||
func package_hashes() -> Dictionary:
|
||||
var values: Dictionary={}
|
||||
for suffix: String in ["",SaveService.MIGRATION_BACKUP_SUFFIX]:
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
values[suffix+"/"+name]=FileAccess.get_sha256(ProjectSettings.globalize_path(SLOT+suffix).path_join(name))
|
||||
return values
|
||||
func refusal(label: String) -> void:
|
||||
var before: Dictionary=runtime.create_snapshot()
|
||||
var packages: Dictionary=package_hashes()
|
||||
var first: Dictionary=runtime.prepare_facility_dimension_snapshot(job_id)
|
||||
expect(first.get(&"ok",false),"first paid legacy job is independently migratable before later refusal")
|
||||
var prepared: Dictionary=runtime.prepare_all_facility_dimension_snapshots()
|
||||
expect(not prepared.get(&"ok",false) and prepared.get(&"facility_id",&"")==room_id and prepared.get(&"rolled_back",false),"actual second-target rejection rolls back earlier applied job")
|
||||
expect(prepared.get(&"details",{}).get(&"routes",{}).get(&"errors",[]).any(func(error: Variant):return error is Dictionary and error.get(&"code",&"")==&"TASK_DESTINATION_CHANGED"),"real old upper-entry task specifically refuses lost destination")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(SLOT)
|
||||
expect(not preview.get(&"ok",false),"formal preview rejects later target")
|
||||
var result: Dictionary=runtime.migrate_facility_dimensions_at_path(SLOT)
|
||||
expect(not result.get(&"ok",false) and result.get(&"code",&"")==&"DIMENSION_MIGRATION_REJECTED" and result.get(&"details",{}).get(&"rolled_back",false),"formal batch refuses and rolls back isolated candidate")
|
||||
expect(var_to_bytes(before)==var_to_bytes(runtime.create_snapshot()),"entire live world unchanged after all three migration paths")
|
||||
expect(package_hashes()==packages,"all original and real preexisting backup files unchanged")
|
||||
write_proof(MODE+"-"+label+"-refusal.var",{&"first":first,&"prepared":prepared,&"preview":preview,&"result":result,&"packages":packages})
|
||||
capture(label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new();clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42588)[&"valid"],"canonical current initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"own fresh evidence directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://tests/fixtures/legacy_staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived definition")
|
||||
for row: Array in [[&"warehouse",Vector3i(-6,0,1)],[&"service_stairs",Vector3i(-7,1,1)],[&"service_stairs",Vector3i(-7,2,1)],[&"service_stairs",Vector3i(-7,3,1)],[&"staff_dormitory",Vector3i(-6,2,1)],[&"reception",Vector3i(-6,0,0)],[&"guest_stairs",Vector3i(4,1,0)],[&"guest_stairs",Vector3i(4,2,0)],[&"guest_stairs",Vector3i(4,3,0)]]:
|
||||
if not command(&"build_facility",{&"definition_id":row[0],&"origin":row[1]}).is_success():
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Batch later refusal formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures);return
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(row[0]).build_minutes)
|
||||
for instance: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if instance.definition_id==&"staff_dormitory":room_id=instance.instance_id
|
||||
expect(not room_id.is_empty(),"normally paid completed archived dormitory")
|
||||
if not command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)}).is_success():runtime.free();clock.free();state.free();quit(1);return
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid first-target partial job")
|
||||
if job_id.is_empty():runtime.free();clock.free();state.free();quit(1);return
|
||||
var baseline: Dictionary=runtime.create_snapshot()
|
||||
expect(SaveService.save_snapshot(SLOT,baseline)[&"ok"],"formal old room baseline before real backup creation")
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
paths.erase("res://tests/fixtures/legacy_staff_dormitory.tres");paths.append("res://data/facilities/expansion/staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"current approved footprint registry")
|
||||
var first: Dictionary=runtime.migrate_facility_dimensions_at_path(SLOT)
|
||||
expect(first.get(&"ok",false) and first.get(&"backup_created",false),"normal unconstrained two-target migration creates actual verified backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(baseline),"first migration leaves live original geometry")
|
||||
expect(var_to_bytes(SaveService.load_snapshot(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX).get(&"snapshot",{}))==var_to_bytes(baseline),"actual backup exactly restores pre-migration baseline")
|
||||
write_proof("baseline.var",baseline)
|
||||
expect(command(&"register_staff",{&"staff_id":&"batch_maintainer",&"role_id":&"porter",&"options":{&"current_cell":Vector3i(-7,1,1),&"state":StaffRuntime.State.AVAILABLE}}).is_success(),"public worker for actual old-entry task")
|
||||
expect(runtime.staff_service.create_task(&"maintenance",10,clock.absolute_minute,{&"target_entity_id":room_id,&"target_cell":OLD_TARGET,&"estimated_minutes":30},&"batch_old_entry_task").is_success(),"public actual old-entry maintenance task")
|
||||
expect(runtime.staff_service.assign_task_to_staff(&"batch_old_entry_task",&"batch_maintainer",clock.absolute_minute).is_success(),"public real task owner assignment")
|
||||
clock.advance_minutes(1)
|
||||
var task: StaffTask=runtime.staff_service.get_task(&"batch_old_entry_task")
|
||||
expect(not task.is_terminal() and task.assigned_staff_id==&"batch_maintainer" and runtime.staff_service.get_staff(&"batch_maintainer").current_task_id==task.task_id,"real old-entry work remains in flight at formal save")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
expect(SaveService.save_snapshot(SLOT,legacy)[&"ok"],"formal original includes partial job and real upper-entry task")
|
||||
write_proof("legacy.var",legacy);write_proof("identity.var",{&"room_id":room_id,&"serial":serial,&"job_id":job_id,&"task_id":&"batch_old_entry_task"})
|
||||
copy_package(ProjectSettings.globalize_path(SLOT),PAIR_ROOT.path_join("original/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres");paths.append("res://data/facilities/expansion/staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current approved footprint registry")
|
||||
var identity: Dictionary=read_proof("identity.var");room_id=identity[&"room_id"];job_id=identity[&"job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("original/formal"),ProjectSettings.globalize_path(SLOT))
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
expect(runtime.restore_snapshot(SaveService.load_snapshot(SLOT+SaveService.MIGRATION_BACKUP_SUFFIX).get(&"snapshot",{})),"separate PID restores real earlier backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("baseline.var")),"whole earlier backup state matches")
|
||||
expect(runtime.restore_snapshot(SaveService.load_snapshot(SLOT).get(&"snapshot",{})),"actual original batch-source package restores")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole original batch source restored exactly")
|
||||
capture("checkpoint");refusal("reject1");refusal("reject2")
|
||||
if MODE=="write":copy_package(ProjectSettings.globalize_path(SLOT),PAIR_ROOT.path_join("after-refusal/formal"))
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.refusal.uncapped",Callable(self,"observe")),"whole uncapped post-refusal journal")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
expect(runtime.facility_service.get_instance(room_id).occupied_cells.size()==8,"later rejected dorm retains entire original footprint")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==6,"earlier rolled-back job completes with its original legacy footprint")
|
||||
expect(runtime.staff_service.get_task(&"batch_old_entry_task").state==StaffTask.State.COMPLETED and runtime.staff_service.get_staff(&"batch_maintainer").current_cell==OLD_TARGET and runtime.staff_service.get_staff(&"batch_maintainer").current_task_id.is_empty(),"actual original maintenance reaches old entry and finishes without orphan work")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"post-refusal continuation remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"entire post-refusal journal matches without deletion or replacement")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Batch later refusal formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,68 @@
|
||||
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-batch-later-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':'Batch later refusal formal write: <checks> checks, <failures> failures','required':True}
|
||||
contracts[READER]={'test':READER,'template':'Batch later 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 later-target rejection and whole two-target rollback, actual paid partial premium job and completed old dorm with real assigned upper-entry task; real earlier backup unchanged and separate-PID whole continuation. Operations OFF public worker fixture, no Main OS or 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') if phases else None}),flush=True)
|
||||
return 0 if passed else 1
|
||||
if __name__=='__main__':raise SystemExit(main())
|
||||
@@ -0,0 +1,143 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-inflight-EV-dimension-native-r01/migration-pair"
|
||||
const MODE := "read"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var original_requests: Dictionary={}
|
||||
var arrivals: Dictionary={}
|
||||
var arrival_errors: Array[String]=[]
|
||||
const GOAL:=Vector3i(0,1,0)
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:
|
||||
journal.append(event.to_dictionary())
|
||||
if event.event_type==&"ELEVATOR_ARRIVED":
|
||||
var request_id: StringName=event.payload[&"request_id"]
|
||||
if not original_requests.has(request_id):arrival_errors.append("unexpected request")
|
||||
arrivals[request_id]=int(arrivals.get(request_id,0))+1
|
||||
if event.payload[&"cell"]!=GOAL or event.payload.get(&"emergency",false):arrival_errors.append("wrong arrival")
|
||||
func advance(minutes: int) -> void:
|
||||
for step: int in range(minutes):
|
||||
clock.advance_minutes(1)
|
||||
for guest: GuestRuntime in runtime.guest_service.get_guests():
|
||||
if guest.current_cell==GOAL:
|
||||
expect(runtime.guest_service.begin_leaving(guest.guest_id,clock.absolute_minute,&"P03_GOAL_REACHED").get(&"ok",false),"actual arrival begins normal departure")
|
||||
expect(runtime.guest_service.despawn_guest(guest.guest_id,clock.absolute_minute).get(&"ok",false),"actual completed passenger leaves normal lifecycle")
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
command(&"build_facility",{&"definition_id":&"guest_elevator",&"origin":Vector3i.ZERO})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_elevator").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid old-size construction is in flight")
|
||||
for index: int in range(5):
|
||||
command(&"spawn_guest",{&"guest_id":StringName("p03.inflight.passenger.%d"%index),&"guest_type_id":&"traveler",&"gold":100,&"options":{&"current_cell":Vector3i.ZERO,&"state":GuestRuntime.State.MOVING,&"state_entered_at":clock.absolute_minute-1,&"planned_exit_at":clock.absolute_minute+2000,&"path_handle":{&"target_cell":GOAL}}})
|
||||
clock.advance_minutes(2)
|
||||
var car: Dictionary=runtime.elevators.get_report()[&"shafts"][0]
|
||||
expect(car[&"phase"]==&"BOARDING" and car[&"passenger_count"]==4 and car[&"waiting_count"]==1,"actual four boarded passengers and one queued passenger at save")
|
||||
expect(runtime.path_service.get_current_density(Vector3i.ZERO)==1 and runtime.path_service.get_transit_actor_ids().size()==4,"real cabin seats excluded from floor density")
|
||||
for trip: Dictionary in runtime.elevators.get_report()[&"trips"]:original_requests[trip[&"request_id"]]=trip[&"actor_id"]
|
||||
expect(original_requests.size()==5,"all five actual request IDs saved")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
var original_job: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(original_job[&"progress"]>0 and original_job[&"reserved_cells"].size()==6,"old-size job is partly paid and reserved")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_job)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"serial":serial,&"original_requests":original_requests})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];serial=identity[&"serial"];original_requests=identity[&"original_requests"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Dictionary=read_proof("original-job.var")
|
||||
var actual: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==4 and actual[&"progress"]==original[&"progress"] and actual[&"construction_cost"]==original[&"construction_cost"] and actual[&"started_at"]==original[&"started_at"],"migration preserves actual paid work and changes footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
advance(1);capture("next1")
|
||||
advance(1);capture("next2")
|
||||
advance(8);capture("next10")
|
||||
advance(150);capture("final160")
|
||||
var exactly_once:=arrivals.size()==5 and arrival_errors.is_empty()
|
||||
for request_id: StringName in original_requests:exactly_once=exactly_once and arrivals.get(request_id,0)==1
|
||||
expect(exactly_once,"all five migrated actual EV request IDs arrive exactly once without emergency")
|
||||
expect(runtime.guest_service.get_guests().is_empty() and runtime.elevators.get_report()[&"trips"].is_empty() and runtime.path_service.get_transit_actor_ids().is_empty(),"no orphan passenger seat trip or path transit after actual arrivals")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==4,"resized paid job completes exactly once in actual Runtime")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Inflight EV dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,143 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-inflight-EV-dimension-native-r01/migration-pair"
|
||||
const MODE := "write"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var original_requests: Dictionary={}
|
||||
var arrivals: Dictionary={}
|
||||
var arrival_errors: Array[String]=[]
|
||||
const GOAL:=Vector3i(0,1,0)
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:
|
||||
journal.append(event.to_dictionary())
|
||||
if event.event_type==&"ELEVATOR_ARRIVED":
|
||||
var request_id: StringName=event.payload[&"request_id"]
|
||||
if not original_requests.has(request_id):arrival_errors.append("unexpected request")
|
||||
arrivals[request_id]=int(arrivals.get(request_id,0))+1
|
||||
if event.payload[&"cell"]!=GOAL or event.payload.get(&"emergency",false):arrival_errors.append("wrong arrival")
|
||||
func advance(minutes: int) -> void:
|
||||
for step: int in range(minutes):
|
||||
clock.advance_minutes(1)
|
||||
for guest: GuestRuntime in runtime.guest_service.get_guests():
|
||||
if guest.current_cell==GOAL:
|
||||
expect(runtime.guest_service.begin_leaving(guest.guest_id,clock.absolute_minute,&"P03_GOAL_REACHED").get(&"ok",false),"actual arrival begins normal departure")
|
||||
expect(runtime.guest_service.despawn_guest(guest.guest_id,clock.absolute_minute).get(&"ok",false),"actual completed passenger leaves normal lifecycle")
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
command(&"build_facility",{&"definition_id":&"guest_elevator",&"origin":Vector3i.ZERO})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_elevator").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid old-size construction is in flight")
|
||||
for index: int in range(5):
|
||||
command(&"spawn_guest",{&"guest_id":StringName("p03.inflight.passenger.%d"%index),&"guest_type_id":&"traveler",&"gold":100,&"options":{&"current_cell":Vector3i.ZERO,&"state":GuestRuntime.State.MOVING,&"state_entered_at":clock.absolute_minute-1,&"planned_exit_at":clock.absolute_minute+2000,&"path_handle":{&"target_cell":GOAL}}})
|
||||
clock.advance_minutes(2)
|
||||
var car: Dictionary=runtime.elevators.get_report()[&"shafts"][0]
|
||||
expect(car[&"phase"]==&"BOARDING" and car[&"passenger_count"]==4 and car[&"waiting_count"]==1,"actual four boarded passengers and one queued passenger at save")
|
||||
expect(runtime.path_service.get_current_density(Vector3i.ZERO)==1 and runtime.path_service.get_transit_actor_ids().size()==4,"real cabin seats excluded from floor density")
|
||||
for trip: Dictionary in runtime.elevators.get_report()[&"trips"]:original_requests[trip[&"request_id"]]=trip[&"actor_id"]
|
||||
expect(original_requests.size()==5,"all five actual request IDs saved")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
var original_job: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(original_job[&"progress"]>0 and original_job[&"reserved_cells"].size()==6,"old-size job is partly paid and reserved")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_job)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"serial":serial,&"original_requests":original_requests})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];serial=identity[&"serial"];original_requests=identity[&"original_requests"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Dictionary=read_proof("original-job.var")
|
||||
var actual: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==4 and actual[&"progress"]==original[&"progress"] and actual[&"construction_cost"]==original[&"construction_cost"] and actual[&"started_at"]==original[&"started_at"],"migration preserves actual paid work and changes footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
advance(1);capture("next1")
|
||||
advance(1);capture("next2")
|
||||
advance(8);capture("next10")
|
||||
advance(150);capture("final160")
|
||||
var exactly_once:=arrivals.size()==5 and arrival_errors.is_empty()
|
||||
for request_id: StringName in original_requests:exactly_once=exactly_once and arrivals.get(request_id,0)==1
|
||||
expect(exactly_once,"all five migrated actual EV request IDs arrive exactly once without emergency")
|
||||
expect(runtime.guest_service.get_guests().is_empty() and runtime.elevators.get_report()[&"trips"].is_empty() and runtime.path_service.get_transit_actor_ids().is_empty(),"no orphan passenger seat trip or path transit after actual arrivals")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==4,"resized paid job completes exactly once in actual Runtime")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Inflight EV dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,68 @@
|
||||
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-inflight-EV-dimension-prep-r01')
|
||||
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':'Inflight EV dimension formal write: <checks> checks, <failures> failures','required':True}
|
||||
contracts[READER]={'test':READER,'template':'Inflight EV dimension 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 legacy-dimension migration with four actual boarded passengers and one queued passenger plus paid concurrent construction; separate-PID original backup and migrated full continuation; Operations OFF public guest inputs; changed destination rejection, Main OS input, rescue/logistics and whole migration remain unaccepted','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())
|
||||
@@ -0,0 +1,121 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-inflight-dimension-native-r01/migration-pair"
|
||||
const MODE := "read"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"guest_stairs",&"origin":Vector3i(4,y,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid old-size construction is in flight")
|
||||
command(&"spawn_guest",{&"guest_id":&"p03.inflight.guest",&"guest_type_id":&"traveler",&"gold":100,&"options":{&"current_cell":Vector3i(4,0,0),&"state":GuestRuntime.State.MOVING,&"state_entered_at":clock.absolute_minute-1,&"planned_exit_at":clock.absolute_minute+2000,&"path_handle":{&"target_cell":Vector3i(4,3,0)}}})
|
||||
clock.advance_minutes(1)
|
||||
var guest: GuestRuntime=runtime.guest_service.get_guest(&"p03.inflight.guest")
|
||||
expect(guest!=null and guest.current_cell==Vector3i(4,0,0) and guest.state==GuestRuntime.State.MOVING,"actual partial staircase travel at save time")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
expect(legacy[&"systems"][&"runtime"][&"movement_credits"].size()==1 and legacy[&"systems"][&"runtime"][&"movement_credits"][0][&"credit"]==1000,"actual fractional movement credit saved")
|
||||
var original_job: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(original_job[&"progress"]>0 and original_job[&"reserved_cells"].size()==6,"old-size job is partly paid and reserved")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_job)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"serial":serial})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Dictionary=read_proof("original-job.var")
|
||||
var actual: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==4 and actual[&"progress"]==original[&"progress"] and actual[&"construction_cost"]==original[&"construction_cost"] and actual[&"started_at"]==original[&"started_at"],"migration preserves actual paid work and changes footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
expect(runtime.guest_service.get_guest(&"p03.inflight.guest").current_cell==Vector3i(4,1,0),"real half-step finishes exactly once after migration")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==4,"resized paid job completes exactly once in actual Runtime")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Inflight dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,121 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-inflight-dimension-native-r01/migration-pair"
|
||||
const MODE := "write"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"guest_stairs",&"origin":Vector3i(4,y,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid old-size construction is in flight")
|
||||
command(&"spawn_guest",{&"guest_id":&"p03.inflight.guest",&"guest_type_id":&"traveler",&"gold":100,&"options":{&"current_cell":Vector3i(4,0,0),&"state":GuestRuntime.State.MOVING,&"state_entered_at":clock.absolute_minute-1,&"planned_exit_at":clock.absolute_minute+2000,&"path_handle":{&"target_cell":Vector3i(4,3,0)}}})
|
||||
clock.advance_minutes(1)
|
||||
var guest: GuestRuntime=runtime.guest_service.get_guest(&"p03.inflight.guest")
|
||||
expect(guest!=null and guest.current_cell==Vector3i(4,0,0) and guest.state==GuestRuntime.State.MOVING,"actual partial staircase travel at save time")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
expect(legacy[&"systems"][&"runtime"][&"movement_credits"].size()==1 and legacy[&"systems"][&"runtime"][&"movement_credits"][0][&"credit"]==1000,"actual fractional movement credit saved")
|
||||
var original_job: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(original_job[&"progress"]>0 and original_job[&"reserved_cells"].size()==6,"old-size job is partly paid and reserved")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_job)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"serial":serial})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Dictionary=read_proof("original-job.var")
|
||||
var actual: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==4 and actual[&"progress"]==original[&"progress"] and actual[&"construction_cost"]==original[&"construction_cost"] and actual[&"started_at"]==original[&"started_at"],"migration preserves actual paid work and changes footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
expect(runtime.guest_service.get_guest(&"p03.inflight.guest").current_cell==Vector3i(4,1,0),"real half-step finishes exactly once after migration")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==4,"resized paid job completes exactly once in actual Runtime")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Inflight dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,68 @@
|
||||
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-inflight-dimension-prep-r01')
|
||||
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':'Inflight dimension formal write: <checks> checks, <failures> failures','required':True}
|
||||
contracts[READER]={'test':READER,'template':'Inflight dimension 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 legacy-dimension migration, real paid concurrent construction and fractional guest stair travel; separate-PID original backup and migrated continuation; Operations OFF controlled guest input, no Main OS input, rescue/logistics/occupied EV/whole original 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())
|
||||
@@ -0,0 +1,151 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-logistics-dimension-native-r02/migration-pair"
|
||||
const MODE := "read"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
if not result.is_success():runtime.free();clock.free();state.free();quit(1)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
for row: Array in [[&"warehouse",Vector3i(-8,0,1)],[&"kitchen",Vector3i(2,0,1)],[&"staff_door",Vector3i(0,0,1)]]:
|
||||
command(&"build_facility",{&"definition_id":row[0],&"origin":row[1]})
|
||||
clock.advance_minutes(180)
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"guest_stairs",&"origin":Vector3i(4,y,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid old-size construction is in flight")
|
||||
if job_id.is_empty():runtime.free();clock.free();state.free();quit(1);return
|
||||
var warehouse: FacilityInstance
|
||||
var kitchen: FacilityInstance
|
||||
for room: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if room.definition_id==&"warehouse":warehouse=room
|
||||
if room.definition_id==&"kitchen":kitchen=room
|
||||
expect(warehouse!=null and kitchen!=null,"real paid supply endpoints completed")
|
||||
if warehouse==null or kitchen==null:runtime.free();clock.free();state.free();quit(1);return
|
||||
command(&"hire_staff_candidate",{&"candidate_id":&"staff_gina"})
|
||||
command(&"set_staff_work_assignment",{&"staff_id":&"staff_gina",&"facility_id":warehouse.instance_id,&"template_id":&"DAY"})
|
||||
command(&"purchase_supplies",{&"warehouse_id":warehouse.instance_id,&"item_id":SupplyCatalog.RAW_FOOD,&"quantity":8})
|
||||
command(&"set_kitchen_production",{&"facility_id":kitchen.instance_id,&"enabled":true,&"target_stock":4})
|
||||
var loaded:=false
|
||||
for minute: int in range(60):
|
||||
clock.advance_minutes(1)
|
||||
var worker: StaffRuntime=runtime.staff_service.get_staff(&"staff_gina")
|
||||
if not worker.carried_inventory_id.is_empty():loaded=true;break
|
||||
expect(loaded,"normally hired porter actually picks up purchased cargo")
|
||||
if not loaded:runtime.free();clock.free();state.free();quit(1);return
|
||||
var porter: StaffRuntime=runtime.staff_service.get_staff(&"staff_gina")
|
||||
expect(runtime.inventory_service.total_quantity(porter.carried_inventory_id,SupplyCatalog.RAW_FOOD)==4,"actual cargo contains four paid food units from an eight-unit purchase")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
var original_job: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(original_job[&"progress"]>0 and original_job[&"reserved_cells"].size()==6,"old-size job is partly paid and reserved")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_job)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"serial":serial})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Dictionary=read_proof("original-job.var")
|
||||
var actual: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==4 and actual[&"progress"]==original[&"progress"] and actual[&"construction_cost"]==original[&"construction_cost"] and actual[&"started_at"]==original[&"started_at"],"migration preserves actual paid work and changes footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
expect(SupplyLogisticsBridge.validate_crosslinks(runtime.logistics_requests,runtime.staff_service,runtime.inventory_service,runtime.facility_service),"actual cargo crosslinks after first continued minute")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
var porter: StaffRuntime=runtime.staff_service.get_staff(&"staff_gina")
|
||||
var delivered:=0
|
||||
for request: LogisticsRequest in runtime.logistics_requests.values():
|
||||
if request.state==LogisticsRequest.State.COMPLETED and request.item_requirements.has(SupplyCatalog.RAW_FOOD):delivered+=1
|
||||
expect(delivered==2 and porter.carried_inventory_id.is_empty(),"two real four-unit shipments complete and releases porter cargo")
|
||||
var kitchen: FacilityInstance
|
||||
for room: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if room.definition_id==&"kitchen":kitchen=room
|
||||
expect(kitchen!=null and runtime.inventory_service.total_quantity(kitchen.local_inventory_id,SupplyCatalog.RAW_FOOD)==8,"all eight purchased units actually arrive at kitchen")
|
||||
expect(SupplyLogisticsBridge.validate_crosslinks(runtime.logistics_requests,runtime.staff_service,runtime.inventory_service,runtime.facility_service),"all final physical cargo ownership crosslinks valid")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==4,"resized paid job completes exactly once in actual Runtime")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Logistics dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,151 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-logistics-dimension-native-r02/migration-pair"
|
||||
const MODE := "write"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
if not result.is_success():runtime.free();clock.free();state.free();quit(1)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
for row: Array in [[&"warehouse",Vector3i(-8,0,1)],[&"kitchen",Vector3i(2,0,1)],[&"staff_door",Vector3i(0,0,1)]]:
|
||||
command(&"build_facility",{&"definition_id":row[0],&"origin":row[1]})
|
||||
clock.advance_minutes(180)
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"guest_stairs",&"origin":Vector3i(4,y,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid old-size construction is in flight")
|
||||
if job_id.is_empty():runtime.free();clock.free();state.free();quit(1);return
|
||||
var warehouse: FacilityInstance
|
||||
var kitchen: FacilityInstance
|
||||
for room: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if room.definition_id==&"warehouse":warehouse=room
|
||||
if room.definition_id==&"kitchen":kitchen=room
|
||||
expect(warehouse!=null and kitchen!=null,"real paid supply endpoints completed")
|
||||
if warehouse==null or kitchen==null:runtime.free();clock.free();state.free();quit(1);return
|
||||
command(&"hire_staff_candidate",{&"candidate_id":&"staff_gina"})
|
||||
command(&"set_staff_work_assignment",{&"staff_id":&"staff_gina",&"facility_id":warehouse.instance_id,&"template_id":&"DAY"})
|
||||
command(&"purchase_supplies",{&"warehouse_id":warehouse.instance_id,&"item_id":SupplyCatalog.RAW_FOOD,&"quantity":8})
|
||||
command(&"set_kitchen_production",{&"facility_id":kitchen.instance_id,&"enabled":true,&"target_stock":4})
|
||||
var loaded:=false
|
||||
for minute: int in range(60):
|
||||
clock.advance_minutes(1)
|
||||
var worker: StaffRuntime=runtime.staff_service.get_staff(&"staff_gina")
|
||||
if not worker.carried_inventory_id.is_empty():loaded=true;break
|
||||
expect(loaded,"normally hired porter actually picks up purchased cargo")
|
||||
if not loaded:runtime.free();clock.free();state.free();quit(1);return
|
||||
var porter: StaffRuntime=runtime.staff_service.get_staff(&"staff_gina")
|
||||
expect(runtime.inventory_service.total_quantity(porter.carried_inventory_id,SupplyCatalog.RAW_FOOD)==4,"actual cargo contains four paid food units from an eight-unit purchase")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
var original_job: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(original_job[&"progress"]>0 and original_job[&"reserved_cells"].size()==6,"old-size job is partly paid and reserved")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_job)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"serial":serial})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Dictionary=read_proof("original-job.var")
|
||||
var actual: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==4 and actual[&"progress"]==original[&"progress"] and actual[&"construction_cost"]==original[&"construction_cost"] and actual[&"started_at"]==original[&"started_at"],"migration preserves actual paid work and changes footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
expect(SupplyLogisticsBridge.validate_crosslinks(runtime.logistics_requests,runtime.staff_service,runtime.inventory_service,runtime.facility_service),"actual cargo crosslinks after first continued minute")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
var porter: StaffRuntime=runtime.staff_service.get_staff(&"staff_gina")
|
||||
var delivered:=0
|
||||
for request: LogisticsRequest in runtime.logistics_requests.values():
|
||||
if request.state==LogisticsRequest.State.COMPLETED and request.item_requirements.has(SupplyCatalog.RAW_FOOD):delivered+=1
|
||||
expect(delivered==2 and porter.carried_inventory_id.is_empty(),"two real four-unit shipments complete and releases porter cargo")
|
||||
var kitchen: FacilityInstance
|
||||
for room: FacilityInstance in runtime.facility_service.get_instances():
|
||||
if room.definition_id==&"kitchen":kitchen=room
|
||||
expect(kitchen!=null and runtime.inventory_service.total_quantity(kitchen.local_inventory_id,SupplyCatalog.RAW_FOOD)==8,"all eight purchased units actually arrive at kitchen")
|
||||
expect(SupplyLogisticsBridge.validate_crosslinks(runtime.logistics_requests,runtime.staff_service,runtime.inventory_service,runtime.facility_service),"all final physical cargo ownership crosslinks valid")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==4,"resized paid job completes exactly once in actual Runtime")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Logistics dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,68 @@
|
||||
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-logistics-dimension-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':'Logistics dimension formal write: <checks> checks, <failures> failures','required':True}
|
||||
contracts[READER]={'test':READER,'template':'Logistics dimension 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 formal migration with real paid supplies, normally hired porter and actual cargo plus concurrent paid legacy construction; whole separate-PID continuation and backup; Operations OFF, unchanged actual supply endpoints, no Main OS or full 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())
|
||||
@@ -0,0 +1,129 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-multiple-jobs-dimension-native-r01/migration-pair"
|
||||
const MODE := "read"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var dorm_job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://tests/fixtures/legacy_staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"guest_stairs",&"origin":Vector3i(4,y,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"warehouse",&"origin":Vector3i(-6,0,1)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"warehouse").build_minutes)
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"service_stairs",&"origin":Vector3i(-7,y,1)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"service_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
command(&"build_facility",{&"definition_id":&"staff_dormitory",&"origin":Vector3i(-6,2,1)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
if job.definition_id==&"staff_dormitory" and not job.is_terminal():dorm_job_id=job.job_id
|
||||
expect(not job_id.is_empty() and not dorm_job_id.is_empty(),"two real paid archived construction jobs are simultaneously in flight")
|
||||
if job_id.is_empty() or dorm_job_id.is_empty():runtime.free();clock.free();state.free();quit(1);return
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
var original_jobs: Array=[runtime.construction_service.get_job(job_id).create_snapshot(),runtime.construction_service.get_job(dorm_job_id).create_snapshot()]
|
||||
expect(original_jobs[0][&"reserved_cells"].size()==6 and original_jobs[1][&"reserved_cells"].size()==8 and original_jobs.all(func(job: Dictionary):return job[&"work_units_done"]==70000 and job[&"progress"]==466 and job[&"state"]=="BUILDING"),"actual two seven-minute jobs retain paid progress and old14 reserved cells")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_jobs)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
paths.erase("res://tests/fixtures/legacy_staff_dormitory.tres");paths.append("res://data/facilities/expansion/staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and preview.get(&"facility_ids",[]).size()==2 and preview.get(&"facility_ids",[]).has(job_id) and preview.get(&"facility_ids",[]).has(dorm_job_id) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"dorm_job_id":dorm_job_id,&"serial":serial})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres");paths.append("res://data/facilities/expansion/staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];dorm_job_id=identity[&"dorm_job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Array=read_proof("original-job.var")
|
||||
for index: int in range(2):
|
||||
var id: StringName=job_id if index==0 else dorm_job_id
|
||||
var actual: Dictionary=runtime.construction_service.get_job(id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==(4 if index==0 else 2) and actual[&"progress"]==original[index][&"progress"] and actual[&"construction_cost"]==original[index][&"construction_cost"] and actual[&"started_at"]==original[index][&"started_at"],"batch preserves actual paid work and changes each footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
expect(runtime.construction_service.get_job(job_id).work_units_done==80000 and runtime.construction_service.get_job(dorm_job_id).work_units_done==80000,"both real jobs continue one minute exactly")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
for id: StringName in [job_id,dorm_job_id]:
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==(4 if id==job_id else 2),"each actual resized job completes with its own facility owner")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Multiple jobs dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,129 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-multiple-jobs-dimension-native-r01/migration-pair"
|
||||
const MODE := "write"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var dorm_job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://tests/fixtures/legacy_staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"guest_stairs",&"origin":Vector3i(4,y,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"warehouse",&"origin":Vector3i(-6,0,1)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"warehouse").build_minutes)
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"service_stairs",&"origin":Vector3i(-7,y,1)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"service_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
command(&"build_facility",{&"definition_id":&"staff_dormitory",&"origin":Vector3i(-6,2,1)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
if job.definition_id==&"staff_dormitory" and not job.is_terminal():dorm_job_id=job.job_id
|
||||
expect(not job_id.is_empty() and not dorm_job_id.is_empty(),"two real paid archived construction jobs are simultaneously in flight")
|
||||
if job_id.is_empty() or dorm_job_id.is_empty():runtime.free();clock.free();state.free();quit(1);return
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
var original_jobs: Array=[runtime.construction_service.get_job(job_id).create_snapshot(),runtime.construction_service.get_job(dorm_job_id).create_snapshot()]
|
||||
expect(original_jobs[0][&"reserved_cells"].size()==6 and original_jobs[1][&"reserved_cells"].size()==8 and original_jobs.all(func(job: Dictionary):return job[&"work_units_done"]==70000 and job[&"progress"]==466 and job[&"state"]=="BUILDING"),"actual two seven-minute jobs retain paid progress and old14 reserved cells")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_jobs)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
paths.erase("res://tests/fixtures/legacy_staff_dormitory.tres");paths.append("res://data/facilities/expansion/staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and preview.get(&"facility_ids",[]).size()==2 and preview.get(&"facility_ids",[]).has(job_id) and preview.get(&"facility_ids",[]).has(dorm_job_id) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"dorm_job_id":dorm_job_id,&"serial":serial})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres");paths.append("res://data/facilities/expansion/staff_dormitory.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];dorm_job_id=identity[&"dorm_job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Array=read_proof("original-job.var")
|
||||
for index: int in range(2):
|
||||
var id: StringName=job_id if index==0 else dorm_job_id
|
||||
var actual: Dictionary=runtime.construction_service.get_job(id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==(4 if index==0 else 2) and actual[&"progress"]==original[index][&"progress"] and actual[&"construction_cost"]==original[index][&"construction_cost"] and actual[&"started_at"]==original[index][&"started_at"],"batch preserves actual paid work and changes each footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
expect(runtime.construction_service.get_job(job_id).work_units_done==80000 and runtime.construction_service.get_job(dorm_job_id).work_units_done==80000,"both real jobs continue one minute exactly")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
for id: StringName in [job_id,dorm_job_id]:
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==(4 if id==job_id else 2),"each actual resized job completes with its own facility owner")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Multiple jobs dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,68 @@
|
||||
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-multiple-jobs-dimension-prep-r01')
|
||||
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':'Multiple jobs dimension formal write: <checks> checks, <failures> failures','required':True}
|
||||
contracts[READER]={'test':READER,'template':'Multiple jobs dimension 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 legacy-dimension migration, real paid concurrent construction and fractional guest stair travel; separate-PID original backup and migrated continuation; Operations OFF controlled guest input, no Main OS input, rescue/logistics/occupied EV/whole original 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())
|
||||
@@ -0,0 +1,134 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-rescue-dimension-native-r01/migration-pair"
|
||||
const MODE := "read"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
command(&"build_facility",{&"definition_id":&"infirmary",&"origin":Vector3i(-6,0,1)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"infirmary").build_minutes)
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"guest_stairs",&"origin":Vector3i(4,y,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid old-size construction is in flight")
|
||||
for id: StringName in [&"patient",&"porter"]:
|
||||
command(&"register_staff",{&"staff_id":id,&"role_id":&"porter",&"options":{&"current_cell":Vector3i(3,0,1) if id==&"patient" else Vector3i(5,0,1),&"health":0 if id==&"patient" else 100,&"state":StaffRuntime.State.AVAILABLE,&"role_tags":[&"medic"],&"permitted_task_tags":[&"rescue"]}})
|
||||
var carrying:=false
|
||||
for minute: int in range(6):
|
||||
clock.advance_minutes(1)
|
||||
for task: StaffTask in runtime.staff_service.get_tasks():
|
||||
if task.task_type==&"rescue_transport" and task.state==StaffTask.State.MOVING:carrying=true
|
||||
if carrying:break
|
||||
expect(carrying,"actual rescue transport started without forced movement")
|
||||
if not carrying:runtime.free();clock.free();state.free();quit(1);return
|
||||
var patient: StaffRuntime=runtime.staff_service.get_staff(&"patient")
|
||||
var porter: StaffRuntime=runtime.staff_service.get_staff(&"porter")
|
||||
expect(patient.current_cell==porter.current_cell and patient.health==0,"actual carried patient shares porter cell without healing")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
var original_job: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(original_job[&"progress"]>0 and original_job[&"reserved_cells"].size()==6,"old-size job is partly paid and reserved")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_job)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"serial":serial})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Dictionary=read_proof("original-job.var")
|
||||
var actual: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==4 and actual[&"progress"]==original[&"progress"] and actual[&"construction_cost"]==original[&"construction_cost"] and actual[&"started_at"]==original[&"started_at"],"migration preserves actual paid work and changes footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
expect(runtime.staff_service.get_staff(&"patient").health==0,"first post-migration minute does not skip actual transport")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
var patient: StaffRuntime=runtime.staff_service.get_staff(&"patient")
|
||||
expect(patient.health==100 and patient.state==StaffRuntime.State.OFF_DUTY and patient.current_cell.x<0 and patient.current_cell.z==1,"actual carrier transport and treatment finish after migrated continuation")
|
||||
expect(runtime.staff_service.validate_invariants()[&"ok"],"rescue ownership invariants preserved")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==4,"resized paid job completes exactly once in actual Runtime")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Rescue dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,134 @@
|
||||
extends SceneTree
|
||||
const PAIR_ROOT := "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p03-current1299-rescue-dimension-native-r01/migration-pair"
|
||||
const MODE := "write"
|
||||
var checks:=0
|
||||
var failures:=0
|
||||
var runtime: Variant
|
||||
var clock: Variant
|
||||
var state: Variant
|
||||
var job_id: StringName
|
||||
var serial:=0
|
||||
var journal: Array[Dictionary]=[]
|
||||
func _initialize() -> void:call_deferred("run")
|
||||
func expect(ok: bool,label: String) -> void:
|
||||
checks+=1
|
||||
print(("PASS " if ok else "FAIL ")+label)
|
||||
if not ok:failures+=1;push_error("P03_INFLIGHT "+label)
|
||||
func write_proof(name: String,value: Variant) -> void:
|
||||
var path:=PAIR_ROOT.path_join(name)
|
||||
expect(not FileAccess.file_exists(path),"fresh proof "+name)
|
||||
var file:=FileAccess.open(path,FileAccess.WRITE)
|
||||
expect(file!=null,"open proof "+name)
|
||||
if file!=null:file.store_buffer(var_to_bytes(value));file.close()
|
||||
func read_proof(name: String) -> Variant:
|
||||
var data:=FileAccess.get_file_as_bytes(PAIR_ROOT.path_join(name))
|
||||
expect(not data.is_empty(),"read whole proof "+name)
|
||||
return bytes_to_var(data)
|
||||
func command(kind: StringName,payload: Dictionary) -> CommandResult:
|
||||
serial+=1
|
||||
var result: CommandResult=runtime.submit_command(kind,payload,&"player",&"",0,-1,StringName("p03.inflight.%d"%serial))
|
||||
expect(result.is_success(),"public paid command "+String(kind)+": "+result.message)
|
||||
return result
|
||||
func copy_package(source: String,destination: String) -> void:
|
||||
expect(DirAccess.make_dir_recursive_absolute(destination)==OK,"package destination "+destination)
|
||||
for name: String in [SaveService.WORLD_FILE,SaveService.MANIFEST_FILE,SaveService.THUMBNAIL_FILE,SaveService.JOURNAL_FILE]:
|
||||
var original:=FileAccess.get_file_as_bytes(source.path_join(name))
|
||||
expect(not original.is_empty() and not FileAccess.file_exists(destination.path_join(name)),"fresh formal member "+name)
|
||||
var file:=FileAccess.open(destination.path_join(name),FileAccess.WRITE)
|
||||
expect(file!=null,"open formal member "+name)
|
||||
if file!=null:file.store_buffer(original);file.close()
|
||||
expect(original==FileAccess.get_file_as_bytes(destination.path_join(name)),"complete formal member "+name)
|
||||
func observe(event: SimulationDomainEvent) -> void:journal.append(event.to_dictionary())
|
||||
func capture(label: String) -> void:
|
||||
var snapshot: Dictionary=runtime.create_snapshot()
|
||||
write_proof(MODE+"-"+label+".var",snapshot)
|
||||
if MODE=="read":expect(var_to_bytes(snapshot)==var_to_bytes(read_proof("write-"+label+".var")),"entire separate-PID snapshot "+label)
|
||||
func run() -> void:
|
||||
root.get_node("GameClock").set_paused(true);root.get_node("GameClock").set_process(false)
|
||||
root.get_node("SimulationRuntime").configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false})
|
||||
runtime=load("res://autoload/simulation_runtime.gd").new()
|
||||
clock=load("res://autoload/game_clock.gd").new();state=load("res://autoload/game_state.gd").new()
|
||||
clock.reset(1,6,0);state.reset();expect(runtime.initialize(clock,state,42586)[&"valid"],"current canonical initialization")
|
||||
clock.set_paused(true);runtime.configure_save_policy({&"enabled":false,&"daily_checkpoint_enabled":false,&"auto_migrate":false})
|
||||
var paths: Array[String]=FacilityCatalog.FACILITY_PATHS+FacilityCatalog.INFRASTRUCTURE_FACILITY_PATHS+FacilityCatalog.RESCUE_FACILITY_PATHS
|
||||
var slot: String="user://p03-inflight-dimension/manual"
|
||||
if MODE=="write":
|
||||
expect(DirAccess.make_dir_recursive_absolute(PAIR_ROOT)==OK,"fresh external proof directory")
|
||||
paths.append("res://tests/fixtures/legacy_premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"explicit archived dimension fixture")
|
||||
command(&"build_facility",{&"definition_id":&"infirmary",&"origin":Vector3i(-6,0,1)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"infirmary").build_minutes)
|
||||
for y: int in [1,2,3]:
|
||||
command(&"build_facility",{&"definition_id":&"guest_stairs",&"origin":Vector3i(4,y,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"reception",&"origin":Vector3i(-6,0,0)})
|
||||
clock.advance_minutes(runtime.definition_registry.get_facility(&"reception").build_minutes)
|
||||
command(&"build_facility",{&"definition_id":&"premium_room",&"origin":Vector3i(-6,2,0)})
|
||||
clock.advance_minutes(7)
|
||||
for job: ConstructionJob in runtime.construction_service.get_jobs():
|
||||
if job.definition_id==&"premium_room" and not job.is_terminal():job_id=job.job_id
|
||||
expect(not job_id.is_empty(),"real paid old-size construction is in flight")
|
||||
for id: StringName in [&"patient",&"porter"]:
|
||||
command(&"register_staff",{&"staff_id":id,&"role_id":&"porter",&"options":{&"current_cell":Vector3i(3,0,1) if id==&"patient" else Vector3i(5,0,1),&"health":0 if id==&"patient" else 100,&"state":StaffRuntime.State.AVAILABLE,&"role_tags":[&"medic"],&"permitted_task_tags":[&"rescue"]}})
|
||||
var carrying:=false
|
||||
for minute: int in range(6):
|
||||
clock.advance_minutes(1)
|
||||
for task: StaffTask in runtime.staff_service.get_tasks():
|
||||
if task.task_type==&"rescue_transport" and task.state==StaffTask.State.MOVING:carrying=true
|
||||
if carrying:break
|
||||
expect(carrying,"actual rescue transport started without forced movement")
|
||||
if not carrying:runtime.free();clock.free();state.free();quit(1);return
|
||||
var patient: StaffRuntime=runtime.staff_service.get_staff(&"patient")
|
||||
var porter: StaffRuntime=runtime.staff_service.get_staff(&"porter")
|
||||
expect(patient.current_cell==porter.current_cell and patient.health==0,"actual carried patient shares porter cell without healing")
|
||||
var legacy: Dictionary=runtime.create_snapshot()
|
||||
var original_job: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(original_job[&"progress"]>0 and original_job[&"reserved_cells"].size()==6,"old-size job is partly paid and reserved")
|
||||
expect(SaveService.save_snapshot(slot,legacy)[&"ok"],"write actual formal source")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("legacy/formal"))
|
||||
write_proof("legacy.var",legacy);write_proof("original-job.var",original_job)
|
||||
paths.erase("res://tests/fixtures/legacy_premium_room.tres");paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"switch to current dimensions without fake graph changes")
|
||||
var preview: Dictionary=runtime.preview_facility_dimensions_at_path(slot)
|
||||
expect(preview.get(&"ok",false) and var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration preview preserves entire moving live world")
|
||||
var migrated: Dictionary=runtime.migrate_facility_dimensions_at_path(slot,&"",String(preview.get(&"source_digest","")))
|
||||
expect(migrated.get(&"ok",false) and migrated.get(&"backup_created",false),"formal migration makes verified original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(legacy),"migration never advances live guest or job")
|
||||
var backup:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(backup.get(&"ok",false) and var_to_bytes(backup.get(&"snapshot",{}))==var_to_bytes(legacy),"backup contains entire old moving state")
|
||||
copy_package(ProjectSettings.globalize_path(slot),PAIR_ROOT.path_join("migrated/formal"))
|
||||
copy_package(ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX),PAIR_ROOT.path_join("backup/formal"))
|
||||
write_proof("identity.var",{&"job_id":job_id,&"serial":serial})
|
||||
else:
|
||||
paths.append("res://data/facilities/expansion/premium_room.tres")
|
||||
expect(runtime.definition_registry.rebuild_from_paths(paths)[&"valid"],"reader current dimension registry")
|
||||
var identity: Dictionary=read_proof("identity.var");job_id=identity[&"job_id"];serial=identity[&"serial"]
|
||||
copy_package(PAIR_ROOT.path_join("backup/formal"),ProjectSettings.globalize_path(slot+SaveService.MIGRATION_BACKUP_SUFFIX))
|
||||
copy_package(PAIR_ROOT.path_join("migrated/formal"),ProjectSettings.globalize_path(slot))
|
||||
var old:=SaveService.load_snapshot(slot+SaveService.MIGRATION_BACKUP_SUFFIX)
|
||||
expect(old.get(&"ok",false) and runtime.restore_snapshot(old.get(&"snapshot",{})),"separate PID restores actual original backup")
|
||||
expect(var_to_bytes(runtime.create_snapshot())==var_to_bytes(read_proof("legacy.var")),"whole old guest/job backup replay is exact")
|
||||
var loaded:=SaveService.load_snapshot(slot)
|
||||
expect(loaded.get(&"ok",false) and runtime.restore_snapshot(loaded.get(&"snapshot",{})),"actual migrated formal package restores")
|
||||
var original: Dictionary=read_proof("original-job.var")
|
||||
var actual: Dictionary=runtime.construction_service.get_job(job_id).create_snapshot()
|
||||
expect(actual[&"reserved_cells"].size()==4 and actual[&"progress"]==original[&"progress"] and actual[&"construction_cost"]==original[&"construction_cost"] and actual[&"started_at"]==original[&"started_at"],"migration preserves actual paid work and changes footprint only")
|
||||
expect(not runtime.get_operations_report().get(&"enabled",false),"scope remains controlled Operations OFF")
|
||||
expect(runtime.domain_events.subscribe(&"*",&"p03.inflight.uncapped",Callable(self,"observe")),"subscribe whole uncapped continuation journal")
|
||||
capture("checkpoint")
|
||||
clock.advance_minutes(1);capture("next1")
|
||||
expect(runtime.staff_service.get_staff(&"patient").health==0,"first post-migration minute does not skip actual transport")
|
||||
clock.advance_minutes(1);capture("next2")
|
||||
clock.advance_minutes(8);capture("next10")
|
||||
clock.advance_minutes(150);capture("final160")
|
||||
var patient: StaffRuntime=runtime.staff_service.get_staff(&"patient")
|
||||
expect(patient.health==100 and patient.state==StaffRuntime.State.OFF_DUTY and patient.current_cell.x<0 and patient.current_cell.z==1,"actual carrier transport and treatment finish after migrated continuation")
|
||||
expect(runtime.staff_service.validate_invariants()[&"ok"],"rescue ownership invariants preserved")
|
||||
var completed: ConstructionJob=runtime.construction_service.get_job(job_id)
|
||||
expect(completed.state==ConstructionJob.State.COMPLETED and runtime.facility_service.get_instance(completed.facility_instance_id).occupied_cells.size()==4,"resized paid job completes exactly once in actual Runtime")
|
||||
expect(runtime.restore_snapshot(runtime.create_snapshot()),"final moving and construction world remains canonical")
|
||||
write_proof(MODE+"-events.var",journal)
|
||||
if MODE=="read":expect(var_to_bytes(journal)==var_to_bytes(read_proof("write-events.var")),"all uncapped continuation events match without deletion or remapping")
|
||||
write_proof(MODE+"-result.var",{&"pid":OS.get_process_id(),&"checks":checks,&"failures":failures,&"job_id":job_id,&"events":journal.size()})
|
||||
runtime.free();clock.free();state.free()
|
||||
print("Rescue dimension formal "+MODE+": %d checks, %d failures"%[checks,failures]);quit(failures)
|
||||
@@ -0,0 +1,68 @@
|
||||
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-rescue-dimension-prep-r01')
|
||||
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':'Rescue dimension formal write: <checks> checks, <failures> failures','required':True}
|
||||
contracts[READER]={'test':READER,'template':'Rescue dimension 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 migration with actual rescue transport, patient and carrier references plus paid old-size concurrent construction; whole separate-PID continuation and backup; controlled initial injury, Operations OFF, no Main OS, changed-clinic destination, logistics or whole 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())
|
||||
Reference in New Issue
Block a user