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
+171
View File
@@ -0,0 +1,171 @@
extends SceneTree
# Actual 53-key recurrence plus text edge cases. No environment variables required.
# Full Runtime state/event/suffix equivalence remains a separate required gate.
const CommandType = preload("res://scripts/core/command.gd")
const QueueType = preload("res://scripts/core/command_queue.gd")
const ResultType = preload("res://scripts/core/command_result.gd")
const OBSERVED_KEYS: Array[String] = [
"guest.auto_queue.guest-auto-00000023.692",
"pixel_view.command.0044",
"pixel_view.command.0043",
"pixel_view.command.0042",
"pixel_view.command.0041",
"pixel_view.command.0013",
"pixel_view.command.0012",
"pixel_view.command.0011",
"pixel_view.command.0010",
"pixel_view.command.0009",
"pixel_view.command.0008",
"pixel_view.command.0004",
"pixel_view.command.0006",
"pixel_view.command.0007",
"pixel_view.command.0040",
"pixel_view.command.0039",
"pixel_view.command.0037",
"pixel_view.command.0036",
"pixel_view.command.0035",
"pixel_view.command.0034",
"pixel_view.command.0033",
"pixel_view.command.0029",
"pixel_view.command.0028",
"pixel_view.command.0027",
"pixel_view.command.0025",
"pixel_view.command.0024",
"pixel_view.command.0023",
"pixel_view.command.0022",
"pixel_view.command.0021",
"pixel_view.command.0020",
"pixel_view.command.0019",
"pixel_view.command.0017",
"pixel_view.command.0018",
"pixel_view.command.0016",
"pixel_view.command.0014",
"pixel_view.command.0015",
"pixel_view.command.0026",
"guest.auto_queue.guest-auto-00000024.692",
"guest.auto_queue.guest-auto-00000019.697",
"pixel_view.command.0005",
"guest.auto_queue.guest-auto-00000021.662",
"guest.auto_queue.guest-auto-00000026.722",
"guest.auto_queue.guest-auto-00000022.726",
"guest.auto_queue.guest-auto-00000022.662",
"pixel_view.command.0032",
"pixel_view.command.0031",
"pixel_view.command.0030",
"pixel_view.command.0001",
"pixel_view.command.0038",
"pixel_view.command.0002",
"guest.auto_queue.guest-auto-00000019.632",
"guest.auto_queue.guest-auto-00000020.632",
"pixel_view.command.0003",
]
var checks := 0
var failures := 0
func _initialize() -> void:
call_deferred("_run")
func _run() -> void:
print("Command Queue snapshot key-order regression")
var input: Array[String] = OBSERVED_KEYS.duplicate()
input.append_array(["A", "a", "a10", "a2", "alpha", "Alpha", "あ", "🌳"])
var sorted_text: Array[String] = input.duplicate()
sorted_text.sort()
var reference := PackedByteArray()
var reference_final := PackedByteArray()
for iteration: int in range(2):
var insertion: Array[String] = input.duplicate()
if iteration == 1:
insertion.reverse()
var queue := QueueType.new()
for key: String in insertion:
var identity := sorted_text.find(key) + 1
_expect(queue.enqueue(_command(identity, identity % 3, identity % 4, key)).is_success(), "accept unique actual/text fixture key")
var initially_ready := queue.drain_ready(0)
for index: int in range(initially_ready.size()):
if index % 2 == 0:
var command: SimulationCommand = initially_ready[index]
_expect(queue.complete(command.command_id, _result(command.command_id)).is_success(), "retain processed fixture result")
var snapshot := queue.create_snapshot()
var snapshot_bytes := var_to_bytes(snapshot)
_expect(not snapshot["pending"].is_empty() and not snapshot["in_flight"].is_empty() and not snapshot["processed"].is_empty(),
"fixture simultaneously covers pending, in-flight and retained results")
_assert_text_snapshot(snapshot, sorted_text)
if iteration == 0:
reference = snapshot_bytes
_expect(snapshot_bytes == reference, "complete typed snapshot ignores keyed command insertion order")
_expect(var_to_bytes(queue.create_snapshot()) == snapshot_bytes, "snapshot query is stable and read-only")
var reversed_source := snapshot.duplicate(true)
var reverse_keys: Array[String] = sorted_text.duplicate()
reverse_keys.reverse()
var raw_map: Dictionary = {}
for index: int in range(reverse_keys.size()):
var key: String = reverse_keys[index]
var raw_key: Variant = StringName(key) if index % 2 == 0 else key
raw_map[raw_key] = snapshot["idempotency"][key]
reversed_source["idempotency"] = raw_map
var restored := QueueType.new()
_expect(restored.restore_snapshot(reversed_source), "valid reordered mixed String/StringName saved map restores")
var restored_snapshot := restored.create_snapshot()
_assert_text_snapshot(restored_snapshot, sorted_text)
_expect(var_to_bytes(restored_snapshot) == snapshot_bytes, "all saved fields and map output bytes agree after restore")
for key: String in sorted_text:
_expect(queue.has_idempotency_key(StringName(key)) and restored.has_idempotency_key(StringName(key)), "every actual/text key remains available")
var before := queue.get_result_by_idempotency_key(StringName(key))
var after := restored.get_result_by_idempotency_key(StringName(key))
if before == null:
_expect(after == null, "unprocessed key does not invent a result")
else:
_expect(after != null and var_to_bytes(before.to_dictionary()) == var_to_bytes(after.to_dictionary()), "retained replay result agrees completely")
var duplicate := restored.enqueue(_command(10000 + sorted_text.find(key), 10, 0, key))
_expect(duplicate.code == ResultType.Code.DUPLICATE_IDEMPOTENCY_KEY and int(duplicate.details.get("original_command_id", 0)) == sorted_text.find(key) + 1,
"restored mapping rejects duplicates with the original command ID")
_expect(var_to_bytes(restored.create_snapshot()) == snapshot_bytes, "rejected duplicate lookups preserve every saved field")
var owned := queue.create_snapshot()
owned["idempotency"].clear()
owned["accepted"].clear()
_expect(var_to_bytes(queue.create_snapshot()) == snapshot_bytes, "returned containers cannot corrupt accepted/idempotency state")
var original_drained := _finish(queue, snapshot)
var restored_drained := _finish(restored, restored_snapshot)
_expect(var_to_bytes(original_drained) == var_to_bytes(restored_drained), "restored queue executes every pending command in the same tick/priority/ID order")
var final_bytes := var_to_bytes(queue.create_snapshot())
_expect(final_bytes == var_to_bytes(restored.create_snapshot()), "all final retained result/accepted/idempotency bytes agree")
if iteration == 0:
reference_final = final_bytes
_expect(final_bytes == reference_final, "both insertion orders preserve complete processed history")
print("Command Queue snapshot key-order regression: %d checks, %d failures" % [checks, failures])
quit(0 if failures == 0 else 1)
func _assert_text_snapshot(snapshot: Dictionary, sorted_text: Array[String]) -> void:
var converted: Array[String] = []
for raw_key: Variant in snapshot["idempotency"]:
_expect(typeof(raw_key) == TYPE_STRING, "saved idempotency key remains String")
_expect(typeof(snapshot["idempotency"][raw_key]) == TYPE_INT and int(snapshot["idempotency"][raw_key]) == sorted_text.find(String(raw_key)) + 1,
"saved idempotency value retains int type and original command ID")
converted.append(String(raw_key))
_expect(var_to_bytes(converted) == var_to_bytes(sorted_text), "saved key text matches ordinary String lexical order")
_expect(int(snapshot["version"]) == QueueType.SNAPSHOT_VERSION, "snapshot version remains unchanged")
func _command(identity: int, tick: int, priority: int, text: String) -> SimulationCommand:
return CommandType.new(identity, 0, tick, priority, &"Test", &"actor", &"target",
{"original_key": text, "nested": {"fixture": &"preserve", "value": identity}}, StringName(text))
func _result(identity: int) -> CommandResult:
return ResultType.succeeded(identity, {"number": identity, "nested": {"fixture": &"preserve"}})
func _finish(queue: CommandQueue, snapshot: Dictionary) -> Array[Dictionary]:
for saved: Dictionary in snapshot["in_flight"]:
var identity := int(saved["command_id"])
_expect(queue.complete(identity, _result(identity)).is_success(), "complete saved in-flight command with unchanged result")
var drained: Array[Dictionary] = []
for command: SimulationCommand in queue.drain_ready(10):
drained.append(command.to_dictionary())
_expect(queue.complete(command.command_id, _result(command.command_id)).is_success(), "complete ready command exactly once")
return drained
func _expect(condition: bool, label: String) -> void:
checks += 1
if not condition:
failures += 1
push_error(label)
@@ -0,0 +1 @@
uid://b5tv71yuw2fg4
+12
View File
@@ -13,6 +13,7 @@ func _initialize() -> void:
func _run() -> void:
_test_catalog_references()
_test_normal_catalog_lookup()
_test_expansion_catalog()
_test_default_registry()
_test_detailed_definition_schema()
@@ -83,6 +84,16 @@ func _test_catalog_references() -> void:
_expect(FacilityCatalogScript.by_id(&"not_a_facility") == null, "catalog by_id rejects an unknown reference")
func _test_normal_catalog_lookup() -> void:
# Every normal-build registration must also resolve through the public catalog.
var paths: Array[String] = FacilityCatalogScript.FACILITY_PATHS + FacilityCatalogScript.INFRASTRUCTURE_FACILITY_PATHS + FacilityCatalogScript.RESCUE_FACILITY_PATHS + FacilityCatalogScript.ORIGINAL_FACILITY_PATHS
for path: String in paths:
var registered := load(path) as FacilityDefinition
_expect(registered != null, "normal catalog resource loads: %s" % path)
if registered != null:
_expect(FacilityCatalogScript.by_id(registered.id) == registered, "normal registration resolves to identical definition: %s" % registered.id)
func _test_detailed_definition_schema() -> void:
var registry = DefinitionRegistryScript.new()
registry.rebuild()
@@ -204,6 +215,7 @@ func _test_queries() -> void:
&"service_elevator",
&"staff_door",
&"staff_waiting_room",
&"standard_room",
&"tavern",
&"warehouse",
]
+23
View File
@@ -8,6 +8,7 @@ func _initialize() -> void:
func _run() -> void:
print("S0: domain events")
_test_snapshot_id_cache()
_test_single_publish_and_snapshot()
_test_atomic_batch_and_reentrant_delivery()
_test_batch_rejection_is_atomic()
@@ -119,3 +120,25 @@ func _expect(condition: bool, label: String) -> void:
return
_failures += 1
push_error(" ✗ %s" % label)
func _test_snapshot_id_cache() -> void:
var stream := DomainEventStream.new()
var ids: Array[String] = ["z", "a", "A", "a10", "a2", String.chr(0x1f333), String.chr(0x3042)]
_expect(stream.restore_snapshot({"version":1,"published_ids":ids,"recent_events":[]}), "restore unsorted history fixture")
var expected := ids.duplicate()
expected.sort_custom(func(a: String,b: String):return a < b)
var first := stream.create_snapshot()
_expect(first["published_ids"] == expected, "native string sort preserves reference order including Unicode")
first["published_ids"].clear()
_expect(stream.create_snapshot()["published_ids"] == expected, "returned ID array cannot corrupt cached history")
var event := SimulationDomainEvent.new(&"new_id", &"TEST", 360, &"test", [], {}, 1)
_expect(stream.publish(event), "publish invalidates cached IDs")
expected.append("new_id");expected.sort()
_expect(stream.create_snapshot()["published_ids"] == expected, "new ID appears once after cached snapshot")
_expect(not stream.publish(event) and stream.create_snapshot()["published_ids"] == expected, "rejected duplicate preserves cached state")
_expect(stream.restore_snapshot({"version":1,"published_ids":["replacement"],"recent_events":[]}), "replace history through restore")
_expect(stream.create_snapshot()["published_ids"] == ["replacement"], "restore invalidates old sorted cache")
var valid := stream.create_snapshot()
_expect(not stream.restore_snapshot({"version":1,"published_ids":["duplicate","duplicate"],"recent_events":[]}), "invalid restore rejected")
_expect(stream.create_snapshot() == valid, "failed restore preserves canonical snapshot")
+2 -1
View File
@@ -66,7 +66,8 @@ func _test_tick_command_execution() -> void:
func _test_starter_world_layers() -> void:
_reset_runtime()
_expect(_runtime.definition_registry.facility_count() == 18, "Runtime loads baseline sixteen plus two required stair definitions")
_expect(_runtime.definition_registry.facility_count() == 23, "Runtime loads baseline sixteen plus stairs, the infirmary and premium room/dormitory and chapel")
_expect(_runtime.definition_registry.has_facility(&"chapel"), "Runtime exposes the original chapel definition")
var front_start := Vector3i(-2, 0, WorldService.LAYER_FRONT)
var back_goal := Vector3i(2, 0, WorldService.LAYER_BACK)
var guest_path: Array[Vector3i] = _runtime.path_service.find_path(