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
+46
View File
@@ -12,6 +12,7 @@ func _initialize() -> void:
func _run() -> void:
print("S5: deterministic wave-by-wave Raid defense")
_test_threat_summary()
_test_definition_and_registration_validation()
_test_scores_penalties_and_stable_order()
_test_layered_assets_and_breach()
@@ -22,6 +23,7 @@ func _run() -> void:
_test_rng_transaction_retry_stability()
_test_retreat_policies_and_manual_retreat_replay()
_test_cancel_transaction_and_reconciliation()
_test_cancel_incomplete_preparation()
_test_resolution_operation_namespace_and_legacy_v1()
_test_multiple_waves_require_explicit_transition()
_test_raid_duration_and_wave_round_limits()
@@ -39,6 +41,22 @@ func _run() -> void:
quit(_failures)
func _test_threat_summary() -> void:
var service := DefenseServiceType.new()
_expect(service.get_threat_summary()[&"total"] == 0, "empty defense has no HUD threat")
_must(service.create_raid(&"preparing", 0, _definition()), "HUD preparing raid created")
_prepare_basic(service, &"active")
var before := service.create_snapshot()
var summary := service.get_threat_summary()
_expect(summary == {&"preparing": 1, &"active": 1, &"between_waves": 0, &"total": 2}, "HUD counts preparing and active raids separately")
summary[&"total"] = 99
_expect(service.get_threat_summary()[&"total"] == 2 and service.create_snapshot() == before, "HUD projection is owned and read only")
_must(service.cancel_raid(&"preparing", 0), "HUD incomplete preparation can be cancelled")
_expect(service.get_threat_summary()[&"preparing"] == 0 and service.get_threat_summary()[&"total"] == 1, "cancelled history is not an ongoing threat")
var restored := DefenseServiceType.new()
_expect(restored.restore_snapshot(service.create_snapshot()) and restored.get_threat_summary() == service.get_threat_summary(), "HUD projection follows restored authoritative state")
func _test_definition_and_registration_validation() -> void:
var service := DefenseServiceType.new()
_expect(not service.create_raid(&"", 0, _definition()).is_success(), "Raid ID is required")
@@ -505,6 +523,7 @@ func _test_multiple_waves_require_explicit_transition() -> void:
_must(service.start_raid(&"multi", 0), "multi-wave Raid starts")
var wave_one = service.resolve_next_round(&"multi", &"wave_one_round", 5)
_expect(wave_one.is_success() and wave_one.details[&"state"] == &"BETWEEN_WAVES", "first max-round wave ends BETWEEN_WAVES")
_expect(service.get_threat_summary()[&"between_waves"] == 1 and service.get_threat_summary()[&"active"] == 0, "HUD distinguishes waiting for next wave from combat")
var between_snapshot := service.create_snapshot()
_expect(not service.resolve_next_round(&"multi", &"illegal_between_round", 6).is_success(), "round cannot resolve while waiting between waves")
_expect(service.create_snapshot() == between_snapshot, "failed between-wave round is atomic")
@@ -515,6 +534,7 @@ func _test_multiple_waves_require_explicit_transition() -> void:
_expect(not service.begin_next_wave(&"multi", 7).is_success(), "active wave cannot be skipped")
var wave_two = service.resolve_next_round(&"multi", &"wave_two_round", 12)
_expect(wave_two.is_success() and wave_two.details[&"state"] == &"DEFENDED", "last wave completion defends the Raid")
_expect(service.get_threat_summary()[&"total"] == 0, "defended raid is removed from ongoing HUD threats")
var raid := service.get_raid(&"multi")
_expect(raid[&"current_round"] == 2 and raid[&"elapsed_minutes"] == 10, "round and elapsed counters span all waves")
_expect(raid[&"waves"][0][&"state"] == &"RESOLVED" and raid[&"waves"][1][&"state"] == &"RESOLVED", "each completed wave retains its own state")
@@ -968,3 +988,29 @@ func _expect(condition: bool, message: String) -> bool:
_failures += 1
push_error(" CHECK FAILED: %s" % message)
return false
func _test_cancel_incomplete_preparation() -> void:
for partial: bool in [false, true]:
var service := DefenseServiceType.new()
_must(service.create_raid(&"unprepared", 0, _definition({&"objective_ids": [&"core", &"annex"]})), "create raid with incomplete objective registration")
if partial:
_must(service.register_asset(&"unprepared", &"core", &"OBJECTIVE", 1000, 0), "register only one of two objectives")
var before := service.create_snapshot()
_expect(not service.start_raid(&"unprepared", 0).is_success() and service.create_snapshot() == before, "incomplete preparation still cannot start combat")
var cancelled = service.cancel_raid(&"unprepared", 1, &"PLAYER_ABORT", &"cancel_unprepared")
_expect(cancelled.is_success(), "incomplete preparation can be cancelled")
if not cancelled.is_success():
continue
var raid := service.get_raid(&"unprepared")
_expect(raid[&"state"] == DefenseServiceType.RaidState.CANCELLED and raid[&"started_at"] == -1 and raid[&"current_round"] == 0, "preparation cancellation does not invent combat")
_expect(raid[&"assets"].size() == (1 if partial else 0), "cancellation does not invent unregistered assets")
var saved := service.create_snapshot()
var restored := DefenseServiceType.new()
_expect(restored.restore_snapshot(JSON.parse_string(JSON.stringify(saved))), "cancelled preparation survives JSON save transport")
var replay = restored.cancel_raid(&"unprepared", 99, &"DIFFERENT", &"cancel_unprepared")
_expect(replay.is_success() and replay.is_replay and restored.create_snapshot() == saved, "cancel replay after restore preserves state")
var corrupt := saved.duplicate(true)
corrupt[&"raids"][0][&"started_at"] = 0
_expect(not restored.restore_snapshot(corrupt) and restored.create_snapshot() == saved, "started cancelled raid still requires all objective assets and rejects corruption atomically")
_expect(restored.validate_invariants()[&"ok"], "cancelled incomplete preparation remains valid")