Files
TheTree_mock/docs/plans/original-completion-2026-10-02/execution/review_audio_geometry.py
T
Takeshi b84bade045 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.
2026-10-11 15:58:00 +09:00

71 lines
5.3 KiB
Python

# -*- coding: utf-8 -*-
"""Independent raw review of the preserved Staff failure/geometry contrast."""
from pathlib import Path
import hashlib
import json
import re
import subprocess
ROOT = Path(__file__).resolve().parents[4]
ART = ROOT / "artifacts/original-completion-2026-10-02"
BASE = ART / "ui-audio-staff-repeat-r01/run-r01"
FIX = ART / "ui-audio-staff-geometry-repeat-prep-r01/run-r01"
OUT = ART / "ui-audio-staff-geometry-root-review-r01.json"
def require(ok, message):
if not ok:
raise AssertionError(message)
def sha(p):
return hashlib.sha256(p.read_bytes()).hexdigest()
def read(p):
return json.loads(p.read_text(encoding="utf-8"))
def main():
require(not OUT.exists(), "Fresh root review")
counts = {}; rows = []; all_pids = []
for name, folder, failure in (("baseline", BASE, 1), ("geometry", FIX, 0)):
receipt = read(folder / "execution.json")
require(receipt["source_changes"] == receipt["input_changes"] == [] and receipt["engine_unchanged"] and receipt["source_files"] == 1246, "Same isolated stage input")
require(receipt["original_expectations_unchanged"] and receipt["observer_added"] is False and receipt["formal_acceptance"] is False, "Limited unchanged expectations")
require(len(receipt["rows"]) == 3 and receipt["actual_checks"] == 393 and receipt["strict_pass"] is (failure == 0), "Honest contrast result")
total = 0
for row in receipt["rows"]:
n = row["repeat"]
raw = folder / "logs" / ("repeat-%d.log" % n)
text = raw.read_text(encoding="utf-8")
profile = folder / ("profile-%d.json" % n)
require(sha(raw) == row["log_sha256"] and sha(profile) == row["profile_report_sha256"], "Actual raw/profile pins")
require(re.findall(r"^Staff management UI: (\d+) checks, (\d+) failures$", text, re.M) == [("131", str(failure))], "Unique raw actual marker")
require("Godot Engine v4.7.2.stable.official.ed1daf0bf" in text and "SCRIPT ERROR" not in text and "Parse Error" not in text and "resources still in use" not in text and "leaked at exit" not in text, "Actual engine/no script/resource errors")
errors = [line for line in text.splitlines() if line.startswith("ERROR:")]
require(errors == (["ERROR: unreachable drag preserves staff and explains route failure"] if failure else []), "Only exact preserved baseline failure")
guard = read(profile)
require(guard == row["actual_profile"] and guard["verified"] and guard["conditions"] == [True]*5 and guard["conditions_checked"] == 5 and guard["fresh_before_parent_initialize"] and guard["profile_writes_before_guard"] == 0, "Actual five private guards")
require(row["checks"] == 131 and row["failures"] == failure and row["exit_code"] == failure and row["engine_ended"], "Actual process/count/exit binding")
all_pids.append(row["owned_engine_pid"]); total += 131
rows.append({"case": name, "pid": row["owned_engine_pid"], "checks": 131, "failures": failure, "raw_sha256": sha(raw), "profile_sha256": sha(profile)})
counts[name] = {"checks": total, "failures": failure*3, "execution_sha256": sha(folder / "execution.json")}
require(len(set(all_pids)) == 6, "Six actual distinct owned processes")
status = subprocess.run(["ps", "-p", ",".join(map(str,all_pids)), "-o", "pid=,comm="], capture_output=True, text=True)
require(status.returncode == 1 and status.stdout == status.stderr == "", "All six owned PIDs ended")
source = ROOT / "tests/ui/test_staff_management.gd"
geometry = ART / "ui-audio-and-presentation-candidate-r07/candidate/tests/ui/test_staff_management.gd"
original = source.read_text(encoding="utf-8")
token = "func _drag_staff_to(target: Vector2, cell: Variant = null, before_release := Callable()) -> void:\n"
require(original.count(token) == 1 and geometry.read_text(encoding="utf-8") == original.replace(token, token + "\t# Let restored roster layout finish before reading the card to press.\n\tawait process_frame\n"), "Only layout-frame synchronization before reading geometry")
require(sha(source) == "6bd701cf3ac2386768db34b59d6298bed3f59a3aed0795e0854134051cdcf2e0" and sha(geometry) == "42595c39a933bfceffaab54d5169bbacfaca1d593cc3bcd099e72a354b77c428", "Source/script pins")
historical = ART / "ui-audio-and-presentation-candidate-r06/focused-run-r01/execution.json"
require(sha(historical) == "cb8ace997b3e22fff39a5fdb62cbd5f75a1c6a097b180486edbdcdebb1216011", "r06 failed execution retained")
OUT.write_text(json.dumps({"passed": True, "scope": "Limited QA geometry contrast; no production adoption/full9/game acceptance", "cases": counts, "rows": rows, "all_owned_PIDs_ended": True, "source_expectations_and_input_API_unchanged": True, "geometry_difference": "one process_frame before card/start geometry is read", "detailed_deferred_layout_cause_confirmed": False, "r06_failed_execution_SHA_retained": sha(historical), "production_game_changes": [], "engine_runs_by_root_review": 0, "full9_focused_accepted": False, "whole_P03_accepted": False, "normal_human_play_accepted": False, "native_Windows_accepted": False}, ensure_ascii=False, indent=2)+"\n", encoding="utf-8")
print("Root geometry contrast PASS: original393/3 retained, synchronized393/0;all6PIDs ended;input/expectations unchanged")
if __name__ == "__main__":
main()