Record original-alignment implementation and traceability checkpoint

Capture current source, content data, tests, asset licenses, and original-specification traceability. Original implementation remains incomplete. The accepted matching UI generation passed 154 suites and 12,253 checks, with eight rendered staff-contract screens reviewed. Latest native Windows and full-original acceptance remain outstanding.
This commit is contained in:
Takeshi
2026-09-30 23:52:24 +09:00
parent 6077e02ebe
commit 5dde0c5ec2
490 changed files with 54051 additions and 809 deletions
+52
View File
@@ -21,6 +21,7 @@ func _run() -> void:
_test_batched_need_updates_match_individual_api()
_test_candidate_filtering()
_test_integer_utility_and_stable_tie_break()
_test_primary_need_priority()
_test_state_machine_and_loop_guard()
_test_atomic_queue_abandonment()
_test_service_interruption_is_idempotent()
@@ -776,3 +777,54 @@ func _expect(condition: bool, label: String) -> void:
return
_failures += 1
push_error(" ✗ %s" % label)
func _test_primary_need_priority() -> void:
var service := _service_with_definitions()
var guest := service.spawn_guest(&"need_priority", &"adventurer", 0, {
&"wallet_gold": 1000, &"planned_exit_at": 1000,
&"state": GuestRuntime.State.DECIDING,
&"needs": {&"hunger": 90, &"sleep": 70},
})
var food := _candidate(&"food", {&"need_relief": {&"hunger": 80}, &"expected_quality": 40})
var room := _candidate(&"room", {&"need_relief": {&"sleep": 90}, &"expected_quality": 100, &"preference": 100})
_expect(service.evaluate_candidate(guest.guest_id, room)[&"utility"] > service.evaluate_candidate(guest.guest_id, food)[&"utility"], "regression scenario has a tempting lower-need facility")
_expect(service.select_best_candidate(guest.guest_id, [room,food])[&"facility_id"] == &"food", "highest need precedes quality and preference bonuses")
var near_food := food.duplicate(true)
near_food[&"facility_id"] = &"near_food"
near_food[&"travel_minutes"] = 1
food[&"travel_minutes"] = 20
_expect(service.select_best_candidate(guest.guest_id, [food,near_food])[&"facility_id"] == &"near_food", "same need still compares distance")
for field: StringName in [&"wait_minutes", &"price_burden"]:
var costly := near_food.duplicate(true)
costly[&"facility_id"] = &"costly"
costly[field] = 100
_expect(service.select_best_candidate(guest.guest_id, [costly,near_food])[&"facility_id"] == &"near_food", "same need still compares queue or price")
var unavailable := food.duplicate(true)
unavailable[&"reachable"] = false
var accepted := service.extract_candidates(guest.guest_id, [unavailable,room])
_expect(service.select_best_candidate(guest.guest_id, accepted)[&"facility_id"] == &"room", "unreachable highest-need facility does not block a usable alternative")
unavailable[&"reachable"] = true
unavailable[&"price_gold"] = 100000
accepted = service.extract_candidates(guest.guest_id, [unavailable,room])
_expect(service.select_best_candidate(guest.guest_id, accepted)[&"facility_id"] == &"room", "highest need does not bypass affordability")
var unattractive := food.duplicate(true)
unattractive[&"travel_minutes"] = 10000
_expect(service.select_best_candidate(guest.guest_id, [unattractive,room])[&"facility_id"] == &"room", "below-threshold high-need candidate does not stop fallback search")
guest.needs[&"sleep"] = 90
_expect(service.select_best_candidate(guest.guest_id, [food,room])[&"facility_id"] == &"room", "equal highest needs use the existing utility comparison")
guest.needs[&"sleep"] = 70
var before := service.create_snapshot()
var observed := service.get_observation(guest.guest_id)
observed[&"needs"][&"hunger"] = 0
_expect(guest.needs[&"hunger"] == 90 and service.create_snapshot() == before, "observation is read-only and owns its dictionaries")
_expect(service.restore_snapshot(before), "pre-decision save restores")
var replay := service.decide(guest.guest_id, [room,food], 1)
_expect(replay[&"candidate"][&"facility_id"] == &"food", "restored runtime uses the same highest-need decision")
var after := service.create_snapshot()
_expect(service.restore_snapshot(before), "decision can be replayed from snapshot")
service.decide(guest.guest_id, [food,room], 1)
_expect(service.create_snapshot() == after, "candidate insertion order cannot change saved decision state")
_expect(service.restore_snapshot(before), "reservation retry starts at the same state")
var reserved := service.decide(guest.guest_id, [food,room], 1, {&"reserve_callback": func(_id: StringName, facility: StringName, _candidate: Dictionary) -> bool: return facility != &"food"})
_expect(reserved[&"candidate"][&"facility_id"] == &"room", "failed reservation tries the next usable candidate")