Save The Tree implementation and acceptance work in progress

Preserve production code, regression fixtures, audio assets and provenance, test infrastructure, and the original-completion plan and progress ledger. Final game and Windows acceptance remain pending; excluded local artifacts and native experiments are not part of this snapshot.
This commit is contained in:
Takeshi
2026-10-11 15:58:00 +09:00
parent 39f6068461
commit b84bade045
235 changed files with 495831 additions and 312 deletions
+5
View File
@@ -199,11 +199,16 @@ func _test_queue_release_is_atomic() -> void:
func _facilities() -> FacilityService:
var dining_cells: Array[Vector3i] = [Vector3i(0, 0, 0), Vector3i(1, 0, 0), Vector3i(2, 0, 0), Vector3i(3, 0, 0), Vector3i(0, 1, 0), Vector3i(1, 1, 0), Vector3i(2, 1, 0), Vector3i(3, 1, 0)]
var kitchen_cells: Array[Vector3i] = [Vector3i(0, 0, 1), Vector3i(1, 0, 1), Vector3i(2, 0, 1), Vector3i(3, 0, 1), Vector3i(0, 1, 1), Vector3i(1, 1, 1), Vector3i(2, 1, 1), Vector3i(3, 1, 1)]
var facilities := Facilities.new()
facilities.register_instance(Facility.new().configure(&"inn", &"cafeteria", {
&"occupied_cells": dining_cells,
&"capacity": 1, &"queue_capacity": 8, &"base_price": 25,
&"base_quality": 50, &"base_service_minutes": 4,
}))
facilities.register_instance(Facility.new().configure(&"kitchen", &"kitchen", {&"origin": Vector3i(0, 0, WorldService.LAYER_BACK), &"occupied_cells": kitchen_cells}))
_expect(facilities.set_operational_status(&"inn", {&"related_facility_id": &"kitchen"}).is_success(), "isolated pricing Service uses explicit BACK kitchen; quote calculations unchanged")
return facilities
+17
View File
@@ -21,6 +21,7 @@ func _run() -> void:
_test_interruption_and_recovery()
_test_determinism()
_test_snapshot_round_trip_is_atomic()
_test_deferred_queue_clock_contract()
if _failures == 0:
print("PASS: %d checks" % _checks)
else:
@@ -311,3 +312,19 @@ func _expect(condition: bool, label: String) -> void:
return
_failures += 1
push_error(" ✗ %s" % label)
func _test_deferred_queue_clock_contract() -> void:
var service := FacilityService.new()
var facility := FacilityInstance.new().configure(&"clock_contract", &"test_facility", {&"capacity": 1, &"queue_capacity": 8, &"staff_min": 0, &"staff_max": 2, &"base_service_minutes": 2, &"base_quality": 75, &"base_price": 100})
_expect(service.register_instance(facility).is_success(), "standalone fixture registers")
var request := service.create_request(&"default", facility.instance_id, [&"guest"], &"meal", 100)
_expect(service.enqueue_request(request, 100).is_success() and service.current_minute == 100 and request.enqueued_at == 100, "existing default API advances committed minute")
for minute: int in [-1, 99, 100, 102]:
var before := var_to_bytes(service.create_snapshot())
var invalid := service.create_request(StringName("invalid_%d" % minute), facility.instance_id, [&"guest"], &"meal", maxi(0, minute))
_expect(not service.enqueue_request(invalid, minute, false).is_success() and before == var_to_bytes(service.create_snapshot()), "deferred invalid minute %d is rejected without state mutation" % minute)
var deferred := service.create_request(&"deferred", facility.instance_id, [&"guest"], &"meal", 101)
_expect(service.enqueue_request(deferred, 101, false).is_success() and service.current_minute == 100 and deferred.created_at == 101 and deferred.enqueued_at == 101, "deferred registration preserves effective time without advancing committed time")
var before_duplicate := var_to_bytes(service.create_snapshot())
_expect(not service.enqueue_request(deferred, 101, false).is_success() and before_duplicate == var_to_bytes(service.create_snapshot()), "duplicate deferred registration is rejected atomically")
+9 -4
View File
@@ -7,6 +7,7 @@ var _state: Variant
var _runtime: Variant
var _facility_id: StringName
var _facility_inventory_id: StringName
var _kitchen_fixture_gold := 0
func _initialize() -> void:
@@ -52,6 +53,7 @@ func _cleanup() -> void:
_runtime = null
_clock = null
_state = null
_kitchen_fixture_gold = 0
func _build_operational_cafeteria() -> void:
@@ -71,6 +73,9 @@ func _build_operational_cafeteria() -> void:
_expect(_runtime.economy_service.has_account(StringName("FACILITY_REVENUE:%s" % _facility_id)), "facility receives a dedicated revenue account")
_expect(not _runtime.mana_network_service.get_node(_facility_id).is_empty(), "Mana demand is registered for the completed facility")
_facility_inventory_id = operational.local_inventory_id
var kitchen_setup: Dictionary = load("res://tests/fixtures/required_kitchen_setup.gd").ensure(_runtime, _clock, _facility_id, false)
_expect(bool(kitchen_setup.get(&"ok", false)), "public paid kitchen setup/link for logical-attendance S2 fixture")
_kitchen_fixture_gold = int(kitchen_setup.get(&"gold_cost", -1))
var staffing = _runtime.submit_command(
&"set_facility_conditions",
{&"facility_id": _facility_id, &"conditions": {&"active_staff_ids": [&"cook_1", &"server_1"]}},
@@ -78,8 +83,8 @@ func _build_operational_cafeteria() -> void:
)
_expect(staffing.is_success(), "two active staff can be assigned through a command")
_expect(operational.state == FacilityInstance.State.OPEN, "staffed and powered cafeteria becomes operational")
_expect(_state.get_resource(&"gold") == 4200, "construction Gold is paid once through the authoritative ledger")
_expect(_runtime.economy_service.get_balance(&"CONSTRUCTION_EXPENSE") == 800, "construction counter-account retains the capital flow")
_expect(_state.get_resource(&"gold") == 4200 - _kitchen_fixture_gold, "construction Gold is paid once through the authoritative ledger")
_expect(_runtime.economy_service.get_balance(&"CONSTRUCTION_EXPENSE") == 800 + _kitchen_fixture_gold, "construction counter-account retains the capital flow")
func _deliver_inputs_through_logistics() -> void:
@@ -193,8 +198,8 @@ func _run_service_sale_with_round_trip() -> void:
_expect(completed != null and completed.state == ServiceInstance.State.COMPLETED, "three active minutes complete the service")
_expect(_runtime.inventory_service.total_quantity(_facility_inventory_id, &"ingredient/basic_meal") == 1, "completion consumes exactly one reserved ingredient")
_expect(_runtime.economy_service.get_balance(&"GUEST_WALLET:guest_1") == 75, "guest pays the immutable quoted price")
_expect(_runtime.economy_service.get_balance(&"PLAYER_CASH") == 4225, "service cash sweep increases player Gold")
_expect(_state.get_resource(&"gold") == 4225, "UI Gold mirror follows the ledger transaction")
_expect(_runtime.economy_service.get_balance(&"PLAYER_CASH") == 4225 - _kitchen_fixture_gold, "service cash sweep increases player Gold")
_expect(_state.get_resource(&"gold") == 4225 - _kitchen_fixture_gold, "UI Gold mirror follows the ledger transaction")
_expect(_runtime.economy_service.validate_ledger()[&"ok"], "service sale remains double-entry balanced")
var saw_completion := false
for event in _runtime.domain_events.recent_events():