extends "/Users/korizatou114/Projects/とりにく工房ゲーム制作部/artifacts/original-completion-2026-10-02/p23-02-build-preview-monitor-compressed-r06.gd" class CustomFacility: extends FacilityInstance class CustomDefinition: extends FacilityDefinition class CustomElevator: extends ElevatorService class CustomGuest: extends GuestRuntime const CASES := ["ordinary", "stairs150", "stairs149", "foreign150", "elevator151", "integer_wrap", "clamp_low", "geometry_wrap", "inputs_unavailable", "staff_only", "custom_facility", "custom_definition", "custom_elevator", "custom_guest", "path_observer"] var records: Array = [] var core: Variant var calls := 0 func observed(_duration: int) -> void: calls += 1 func setup(label: String) -> void: var p := PathService.new() var start := Vector3i.ZERO var target := Vector3i(0,1,0) if label in ["stairs150","stairs149","foreign150","elevator151"] else Vector3i(2,0,0) if label == "geometry_wrap": start=Vector3i(-2147483648,0,0);target=start var cells: Array[Vector3i] = [start,target] if target.y==0 and label!="geometry_wrap": cells.insert(1,Vector3i(1,0,0)) check(p.rebuild_graph(cells),label+" finite public graph") if target.y!=0: check(p.set_vertical_walk_requires_connector(true),label+" actual connector-only vertical route") runtime.path_service=p p.path_query_measured.connect(Callable(runtime,"_on_path_query_measured")) var e: ElevatorService = CustomElevator.new() if label=="custom_elevator" else ElevatorService.new() e.configure(p);runtime.elevators=e if label=="elevator151": check(bool(e.synchronize([{&"shaft_id":&"transport.shaft.finite", &"module_ids":[&"finite.module"], &"stops":[start,target], &"width":2, &"capacity":4, &"travel_minutes_per_floor":10, &"access_id":&""}],646).get(&"ok",false)),label+" actual owned shaft") var id: StringName=e._connector_configs(e.get_report()[&"shafts"][0][&"config"])[0][&"id"] check(p.configure_connector(id,start,target,151,true,&"",true,{&"movement_type":PathService.MOVEMENT_ELEVATOR, &"cabin_capacity":4, &"queue_capacity":16, &"travel_minutes_per_floor":10}),label+" owned elevator cost151") elif target.y!=0: var id: StringName = &"foreign" if label=="foreign150" else &"infra.connector:finite" check(p.configure_connector(id,start,target,149 if label=="stairs149" else 150),label+" public connector") var f: FacilityInstance = CustomFacility.new() if label=="custom_facility" else FacilityInstance.new() f.instance_id=&"finite.facility";f.definition_id=&"finite.definition";f.origin=target f.occupied_cells=[];f.base_price=0;f.base_quality=101;f.capacity=4;f.base_service_minutes=7 f.queue_entries=[&"q1",&"q2",&"q3"] if label=="integer_wrap": f.base_service_minutes=9223372036854775807;f.capacity=-9223372036854775808 if label=="clamp_low": f.base_quality=-9223372036854775808;f.capacity=0 if label=="geometry_wrap": f.origin=Vector3i(2147483647,0,0);f.occupied_cells=[f.origin] runtime.facility_service._instances={f.instance_id:f} var d: FacilityDefinition = CustomDefinition.new() if label=="custom_definition" else FacilityDefinition.new() d.id=f.definition_id;d.tags=[&"rest"] if label=="inputs_unavailable": d.inventory_inputs={&"finite.missing":1} if label=="staff_only": d.tags=[&"staff_only"] runtime.definition_registry._facilities_by_id[f.definition_id]=d var g: GuestRuntime = CustomGuest.new() if label=="custom_guest" else GuestRuntime.new() g.guest_id=&"finite.guest";g.current_cell=start runtime.guest_service._guests={g.guest_id:g};runtime.guest_service._guest_order_dirty=true calls=0 if label=="path_observer":p.path_query_measured.connect(observed) func state() -> Array: var p=runtime.path_service return [runtime.create_snapshot(),p.last_error,p.last_no_route_reason,p.last_path_cost,p.cache_hits,p.cache_misses,p._path_cache,p._query_batch,p._guest_step_connector_memo,calls] func project() -> Dictionary: return core.project_guest_candidates(runtime,&"finite.guest",FacilityInstance.State.OPEN,FacilityInstance.State.DEGRADED,runtime.MOVEMENT_CREDIT_SCALE,runtime.STAIR_MOVEMENT_CREDIT,PathService.ORTHOGONAL_MOVE_COST,Callable(Time,"get_ticks_usec")) const ROUTE_CASES := ["ordinary", "goal_only", "cycle_limit", "negative_terminal", "readonly_cells", "readonly_indices", "untyped_cells", "noncompact"] var route_records: Array = [] func route_setup(label: String) -> Dictionary: setup("ordinary") var p=runtime.path_service var goal := Vector3i.ZERO if label == "goal_only" else Vector3i(2,0,0) var goals: Array=[goal] p.begin_guest_path_query_batch(Vector3i.ZERO,goals) var layers: Array[int]=[0,1] var access: Array[StringName]=[] var tree: Dictionary=p._build_guest_query_tree_compact(Vector3i.ZERO,p._query_batch[&"targets"],layers,access) if label == "cycle_limit": var parents: PackedInt64Array=tree[&"parent_indices"] parents[1]=2;parents[2]=1;tree[&"parent_indices"]=parents elif label == "negative_terminal": var parents: PackedInt64Array=tree[&"parent_indices"] parents[2]=-99;tree[&"parent_indices"]=parents elif label == "readonly_cells": tree[&"cells"].make_read_only() elif label == "readonly_indices": tree[&"indices"].make_read_only() elif label == "untyped_cells": var cells: Array=[];cells.append_array(tree[&"cells"]);tree[&"cells"]=cells elif label == "noncompact": tree[&"compact"]=false tree[&"parents"]={Vector3i(1,0,0):Vector3i.ZERO,Vector3i(2,0,0):Vector3i(1,0,0)} tree[&"costs"]={Vector3i.ZERO:0,Vector3i(1,0,0):100,Vector3i(2,0,0):200} p._query_batch[&"tree"]=tree;p._query_batch[&"ready"]=true;p._query_batch[&"arithmetic_wrapped"]=false return {"path":p,"goal":goal,"goals":goals,"layers":layers,"access":access,"tree":tree} func route_case(label: String) -> void: var input: Dictionary=route_setup(label) var p=input["path"] var before: PackedByteArray=var_to_bytes(input["tree"]) var actual: Dictionary=core.nearest_guest_access(p,Vector3i.ZERO,input["goals"],input["goal"],input["layers"],input["access"],Callable(Time,"get_ticks_usec")) check(bool(actual.get(&"supported",false)),label+" ready route actual native selected") check(var_to_bytes(input["tree"])==before and (label!="readonly_cells" or input["tree"][&"cells"].is_read_only()) and (label!="readonly_indices" or input["tree"][&"indices"].is_read_only()),label+" ready route original tree and readonly unchanged") var got_bytes: PackedByteArray=var_to_bytes(actual) var after: PackedByteArray=var_to_bytes(state()) var route: Array=actual[&"path"] var key: String=p._cache_key(Vector3i.ZERO,input["goal"],input["layers"],input["access"]) var cached: Array=p._path_cache[key] check(route.is_typed() and route.get_typed_builtin()==TYPE_VECTOR3I and not route.is_read_only() and cached.is_typed() and cached.get_typed_builtin()==TYPE_VECTOR3I and not cached.is_read_only() and not is_same(route,cached),label+" fresh writable typed path and separate cache copy") var cache_before: PackedByteArray=var_to_bytes(p._path_cache) route[0]=Vector3i(99,99,0) check(var_to_bytes(p._path_cache)==cache_before,label+" returned path mutation leaves cache unchanged") var returned_before: PackedByteArray=var_to_bytes(route) cached[0]=Vector3i(77,77,0) check(var_to_bytes(route)==returned_before,label+" cache copy mutation leaves returned path unchanged") input=route_setup(label);p=input["path"];before=var_to_bytes(input["tree"]) var expected: Dictionary=p._query_nearest_guest_access_without_native(Vector3i.ZERO,input["goals"],input["goal"]) check(var_to_bytes(expected)==got_bytes,label+" full original ordered typed ready-route result") check(var_to_bytes(state())==after,label+" full Runtime cache counters errors and signals equal") check(var_to_bytes(input["tree"])==before,label+" original fallback tree unchanged") route_records.append({"case":label,"expected":expected,"actual":bytes_to_var(got_bytes)}) func run() -> void: output=OS.get_environment("THE_TREE_RUNTIME_MONITOR_OUTPUT") runtime=root.get_node("SimulationRuntime");clock=root.get_node("GameClock") var raw := FileAccess.get_file_as_bytes(OS.get_environment("THE_TREE_REPLAY_SNAPSHOT")).decompress(11411840,FileAccess.COMPRESSION_ZSTD) var initial: Dictionary=bytes_to_var(raw) runtime.initialize(clock,root.get_node("GameState"),int(initial[&"systems"][&"runtime"][&"world_seed"])) check(runtime.restore_snapshot(initial),"fixed646 original seed/context restore") core=ClassDB.instantiate(&"TheTreeNumericCore") for label: String in CASES: setup(label) var before := var_to_bytes(state()) var selected := project() var fallback := label.begins_with("custom_") or label=="path_observer" check(bool(selected.get(&"supported",false))==not fallback,label+" actual native domain") if fallback:check(var_to_bytes(state())==before,label+" rejection has no public effects") var got: Array=runtime._project_guest_candidates(&"finite.guest") if fallback else selected[&"candidates"] var after := var_to_bytes(state()) var got_bytes := var_to_bytes(got) check(runtime.path_service._query_batch.is_empty(),label+" derived batch released") setup(label) check(var_to_bytes(state())==before,label+" same complete starting state") var expected: Array=runtime._project_guest_candidates_without_native(&"finite.guest") check(var_to_bytes(expected)==got_bytes,label+" complete ordered typed candidates") check(var_to_bytes(state())==after,label+" complete Runtime Path cache errors counters callback count") if label=="stairs150":check(int(got[0][&"travel_minutes"])==2,label+" stairs ceil150/100") elif label=="elevator151":check(int(got[0][&"travel_minutes"])==12,label+" elevator ceil((151+1floor*10minutes*100)/100)") elif label in ["stairs149","foreign150"]:check(int(got[0][&"travel_minutes"])==1,label+" ordinary movement retained") if label=="integer_wrap":check(int(got[0][&"expected_wait"])==9223372036854775805 and int(got[0][&"group_fit"])==-9223372036854775808,label+" signed multiplication wrap") if label=="clamp_low":check(got[0][&"expected_quality"]==0 and got[0][&"group_fit"]==0,label+" zero divisor guard and quality lower clamp") if label=="ordinary": check(got[0][&"expected_quality"]==100,label+" quality upper clamp") var protected_bytes := var_to_bytes(expected) got[0][&"facility_tags"].append(&"mutated");got[0][&"need_relief"].clear();got[0][&"path_handle"].clear() check(var_to_bytes(expected)==protected_bytes and runtime.definition_registry.get_facility(&"finite.definition").tags==[&"rest"],label+" owned returned tags relief and handle") records.append({"case":label,"native_supported":not fallback,"candidates":expected,"observer_calls":calls}) for label: String in ROUTE_CASES: route_case(label) var route_payload := typed("ready-route-fixtures",route_records) core=null var report := {"passed":failures.is_empty(),"checks":checks,"failures":failures,"pid":OS.get_process_id(),"case_count":CASES.size(),"ready_route_cases":ROUTE_CASES.size(),"ready_route_fixtures":route_payload,"fixtures":typed("fixtures",records),"unit_accepted":false,"performance_accepted":false,"Windows_accepted":false} report["passed"]=failures.is_empty();report["checks"]=checks;report["failures"]=failures var file := FileAccess.open(output.path_join("report.json"),FileAccess.WRITE) if file==null:quit(98);return file.store_string(JSON.stringify(report,"\t"));file.close() print("Ready route local: %d checks, %d failures"%[checks,failures.size()]);quit(0 if failures.is_empty() else 1)