P08-03-RTPREVIEW: P08-03を閉じるための共有配置プレビュー判定

This commit is contained in:
Agent Control Runner
2026-10-14 19:49:04 +09:00
parent 8d52b20d40
commit 12f04d6e8b
+31 -10
View File
@@ -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_stairs", cell, 999, "STAIR_LANDING_MISSING", "先に階段の一つ下の階に通路を作ってください。")
_failure_case(&"guest_corridor", cell, 999, "INVALID_PAYLOAD", "The selected rotation is not allowed.") _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. # origin INVALID_PAYLOAD cannot be reached through preview's Vector3i API.
# Diagnostic landing path from the seed; existing reception provides support. _reset()
var walkable: Array[Vector3i] = _runtime.world_service.get_walkable_cells() var lower_stairs := _command(&"guest_stairs", Vector3i(4, 1, 0), 0)
walkable.append(Vector3i(-8, 1, 0)) check(lower_stairs.is_success(), "build real lower stairs: %s" % lower_stairs.message)
check(_runtime.path_service.rebuild_graph(walkable), "diagnostic landing path") _clock.advance_minutes(_runtime.definition_registry.get_facility(&"guest_stairs").build_minutes)
var report := _pure_preview(&"guest_stairs", cell, 0) var lower_exists := false
var accepted: Variant = _command(&"guest_stairs", cell, 0) 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") check(report[&"can_build"] and accepted.is_success(), "positive landing preview and command agree")
_reset() _reset()
check(_command(&"guest_elevator", Vector3i.ZERO, 0).is_success(), "build real elevator") 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 processed_before: int = _runtime.command_queue.processed_count()
var events_before: int = _runtime.domain_events.recent_events().size() var events_before: int = _runtime.domain_events.recent_events().size()
var report: Dictionary = _runtime.preview_build_facility(id, cell, rotation) var report: Dictionary = _runtime.preview_build_facility(id, cell, rotation)
check(before == var_to_bytes(_runtime.create_snapshot()), "preview preserves typed snapshot bytes") var after := var_to_bytes(_runtime.create_snapshot())
check(log_before == var_to_bytes(_runtime.command_queue.create_snapshot()), "preview preserves command log bytes") var log_after := var_to_bytes(_runtime.command_queue.create_snapshot())
check(commands_before == _runtime.command_queue.get_accepted_command_metadata().size() and processed_before == _runtime.command_queue.processed_count(), "preview preserves command counts") var commands_after: int = _runtime.command_queue.get_accepted_command_metadata().size()
check(events_before == _runtime.domain_events.recent_events().size(), "preview preserves event count") 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 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: func _failure_case(id: StringName, cell: Vector3i, rotation: int, code: String, message: String) -> void:
var report := _pure_preview(id, cell, rotation) var report := _pure_preview(id, cell, rotation)
check(not report[&"can_build"] and report[&"error_codes"][0] == code, "preview first code: " + code) check(not report[&"can_build"] and report[&"error_codes"][0] == code, "preview first code: " + code)