From 12f04d6e8bfdba59e44d81e8e34c57b67efbefeb Mon Sep 17 00:00:00 2001 From: Agent Control Runner Date: Wed, 14 Oct 2026 19:49:04 +0900 Subject: [PATCH] =?UTF-8?q?P08-03-RTPREVIEW:=20P08-03=E3=82=92=E9=96=89?= =?UTF-8?q?=E3=81=98=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AE=E5=85=B1=E6=9C=89?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E3=83=97=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/transport/test_runtime_build_preview.gd | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/tests/transport/test_runtime_build_preview.gd b/tests/transport/test_runtime_build_preview.gd index 1ac6fdd..259afb2 100644 --- a/tests/transport/test_runtime_build_preview.gd +++ b/tests/transport/test_runtime_build_preview.gd @@ -58,12 +58,21 @@ func _facility_definition_is_unsupported_vertical_proxy(definition: Variant) -> _failure_case(&"guest_stairs", cell, 999, "STAIR_LANDING_MISSING", "先に階段の一つ下の階に通路を作ってください。") _failure_case(&"guest_corridor", cell, 999, "INVALID_PAYLOAD", "The selected rotation is not allowed.") # origin INVALID_PAYLOAD cannot be reached through preview's Vector3i API. - # Diagnostic landing path from the seed; existing reception provides support. - var walkable: Array[Vector3i] = _runtime.world_service.get_walkable_cells() - walkable.append(Vector3i(-8, 1, 0)) - check(_runtime.path_service.rebuild_graph(walkable), "diagnostic landing path") - var report := _pure_preview(&"guest_stairs", cell, 0) - var accepted: Variant = _command(&"guest_stairs", cell, 0) + _reset() + var lower_stairs := _command(&"guest_stairs", Vector3i(4, 1, 0), 0) + check(lower_stairs.is_success(), "build real lower stairs: %s" % lower_stairs.message) + _clock.advance_minutes(_runtime.definition_registry.get_facility(&"guest_stairs").build_minutes) + var lower_exists := false + for facility: Dictionary in _runtime.construction_service.get_facilities(): + if facility[&"origin"] == Vector3i(4, 1, 0): + lower_exists = true + check(lower_exists, "real lower stairs construction completes") + var report := _pure_preview(&"guest_stairs", Vector3i(4, 2, 0), 0) + var accepted: Variant = _command(&"guest_stairs", Vector3i(4, 2, 0), 0) + if not (report[&"can_build"] and accepted.is_success()): + var first_reason: Dictionary = report[&"reasons"][0] if not report[&"reasons"].is_empty() else {} + var command_code := String(accepted.details.get(&"reason", CommandResult.Code.keys()[accepted.code])) + print("Runtime preview positive: can_build=%s error_codes=%s first_code=%s first_message=%s command_code=%s command_message=%s" % [report[&"can_build"], JSON.stringify(report[&"error_codes"]).left(256), JSON.stringify(first_reason.get(&"code", "none")).left(256), JSON.stringify(first_reason.get(&"message", "none")).left(512), JSON.stringify(command_code).left(256), JSON.stringify(accepted.message).left(512)]) check(report[&"can_build"] and accepted.is_success(), "positive landing preview and command agree") _reset() check(_command(&"guest_elevator", Vector3i.ZERO, 0).is_success(), "build real elevator") @@ -96,12 +105,24 @@ func _pure_preview(id: StringName, cell: Vector3i, rotation: int) -> Dictionary: var processed_before: int = _runtime.command_queue.processed_count() var events_before: int = _runtime.domain_events.recent_events().size() var report: Dictionary = _runtime.preview_build_facility(id, cell, rotation) - check(before == var_to_bytes(_runtime.create_snapshot()), "preview preserves typed snapshot bytes") - check(log_before == var_to_bytes(_runtime.command_queue.create_snapshot()), "preview preserves command log bytes") - check(commands_before == _runtime.command_queue.get_accepted_command_metadata().size() and processed_before == _runtime.command_queue.processed_count(), "preview preserves command counts") - check(events_before == _runtime.domain_events.recent_events().size(), "preview preserves event count") + var after := var_to_bytes(_runtime.create_snapshot()) + var log_after := var_to_bytes(_runtime.command_queue.create_snapshot()) + var commands_after: int = _runtime.command_queue.get_accepted_command_metadata().size() + var processed_after: int = _runtime.command_queue.processed_count() + var events_after: int = _runtime.domain_events.recent_events().size() + print("Runtime preview proof: case=%s cell=%s rotation=%d snapshot_before=%s snapshot_after=%s queue_before=%s queue_after=%s accepted_before=%d accepted_after=%d processed_before=%d processed_after=%d events_before=%d events_after=%d can_build=%s error_codes=%s" % [JSON.stringify(String(id)).left(256), cell, rotation, _sha256(before), _sha256(after), _sha256(log_before), _sha256(log_after), commands_before, commands_after, processed_before, processed_after, events_before, events_after, report[&"can_build"], JSON.stringify(report[&"error_codes"]).left(256)]) + check(before == after, "preview preserves typed snapshot bytes") + check(log_before == log_after, "preview preserves command log bytes") + check(commands_before == commands_after and processed_before == processed_after, "preview preserves command counts") + check(events_before == events_after, "preview preserves event count") return report +func _sha256(bytes: PackedByteArray) -> String: + var context := HashingContext.new() + context.start(HashingContext.HASH_SHA256) + context.update(bytes) + return context.finish().hex_encode() + func _failure_case(id: StringName, cell: Vector3i, rotation: int, code: String, message: String) -> void: var report := _pure_preview(id, cell, rotation) check(not report[&"can_build"] and report[&"error_codes"][0] == code, "preview first code: " + code)