diff --git a/docs/plans/original-completion-2026-10-02/execution/completion_marker_contracts.json b/docs/plans/original-completion-2026-10-02/execution/completion_marker_contracts.json index 1158482..fce033f 100644 --- a/docs/plans/original-completion-2026-10-02/execution/completion_marker_contracts.json +++ b/docs/plans/original-completion-2026-10-02/execution/completion_marker_contracts.json @@ -3784,7 +3784,7 @@ "template": "Peeping room runtime: checks, failures", "required": true, "fixed_check_count_used": false, - "source_sha256_at_schema_audit": "30ed2fe11cc6b0353e9a3a6d995cf8690d322858d2c3dbb38ef32fd941072d2d", + "source_sha256_at_schema_audit": "924efd34414c12a325a1b700f799aef0396de9f15441fd88a3608292ff221657", "authority": { "path": "docs/plans/original-completion-2026-10-02/execution/p13-02/CODE1_TASK_SPEC.json", "scope": "new backend suite marker; native execution pending" diff --git a/tests/special/test_peeping_room_runtime.gd b/tests/special/test_peeping_room_runtime.gd index 34a6510..06ef0ea 100644 --- a/tests/special/test_peeping_room_runtime.gd +++ b/tests/special/test_peeping_room_runtime.gd @@ -12,10 +12,43 @@ func _run() -> void: expect(before == var_to_bytes(runtime.create_snapshot()), "validator changes no whole Runtime bytes") var public_validation: CommandResult = runtime.submit_command(&"peeping_room_validate", validation.payload) expect(public_validation.is_success(), "registered validation command runs through real queue") - var domain_before := [runtime.world_service.create_snapshot(), runtime.economy_service.create_snapshot(), runtime.id_generator.create_snapshot(), runtime.peeping_room_service.create_snapshot()] + var placement := SimulationCommand.new() + placement.command_type = &"peeping_room_place" + placement.payload = validation.payload.duplicate(true) + var placement_before := var_to_bytes(runtime.create_snapshot()) + var direct_unavailable: CommandResult = runtime._execute_peeping_room(placement) + expect(not direct_unavailable.is_success() and direct_unavailable.details[&"reason"] == &"BUILD_DEFINITION_PENDING_D04", "direct production placement unavailable with precise reason") + expect(placement_before == var_to_bytes(runtime.create_snapshot()), "direct placement adds no room, occupancy, cost or ID in whole typed Runtime") + var domain_before := var_to_bytes([runtime.world_service.create_snapshot(), runtime.economy_service.create_snapshot(), runtime.peeping_room_service.create_snapshot()]) + var ids_before: Dictionary = runtime.id_generator.create_snapshot() + var counters_before: Dictionary = ids_before["counters"] + var event_counter_before: int = counters_before.get("domain_event", 0) + var event_ids_before := {} + for event: SimulationDomainEvent in runtime.domain_events.recent_events(): + event_ids_before[event.event_id] = true var unavailable: CommandResult = runtime.submit_command(&"peeping_room_place", validation.payload) expect(not unavailable.is_success() and unavailable.details[&"reason"] == &"BUILD_DEFINITION_PENDING_D04", "production placement unavailable with precise reason") - expect(var_to_bytes(domain_before) == var_to_bytes([runtime.world_service.create_snapshot(), runtime.economy_service.create_snapshot(), runtime.id_generator.create_snapshot(), runtime.peeping_room_service.create_snapshot()]), "placement adds no room, occupancy, cost or ID (normal queue receipt only)") + expect(domain_before == var_to_bytes([runtime.world_service.create_snapshot(), runtime.economy_service.create_snapshot(), runtime.peeping_room_service.create_snapshot()]), "queued placement adds no room, occupancy or cost") + var ids_after: Dictionary = runtime.id_generator.create_snapshot() + var counters_after: Dictionary = ids_after["counters"] + expect(ids_before["version"] == ids_after["version"], "queued placement preserves ID generator version") + for prefix: Variant in counters_before: + if prefix != "domain_event": + expect(counters_after.has(prefix) and counters_after.get(prefix) == counters_before[prefix], "queued placement consumes no non-event ID or removes prefix: %s" % prefix) + for prefix: Variant in counters_after: + if prefix != "domain_event": + expect(counters_before.has(prefix), "queued placement adds no non-event ID prefix: %s" % prefix) + expect(counters_after.has("domain_event") and counters_after["domain_event"] == event_counter_before + 1, "queued placement allocates exactly one normal receipt event ID") + var new_events: Array[SimulationDomainEvent] = [] + for event: SimulationDomainEvent in runtime.domain_events.recent_events(): + if not event_ids_before.has(event.event_id): + new_events.append(event) + expect(new_events.size() == 1, "queued placement publishes exactly one new receipt event") + if new_events.size() == 1: + var receipt: SimulationDomainEvent = new_events[0] + expect(receipt.event_id == StringName("domain_event.%012d" % (event_counter_before + 1)), "placement receipt uses the next domain event ID") + expect(receipt.event_type == &"COMMAND_FAILED", "unavailable placement receipt is COMMAND_FAILED") + expect(receipt.causation_command_id == unavailable.command_id, "placement receipt causation matches rejected command") var room := place(f) enable_fixture(f, room) var blocked: CommandResult = runtime.submit_command(&"peeping_room_record_evidence", {&"room_id": room, &"source_event_key": &"fixture.command"})