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:
@@ -0,0 +1,143 @@
|
||||
"""Accept the retained one-file transit guard against the 1396 source baseline.
|
||||
|
||||
Only disposable stages are changed. Whole-state/event oracle comparisons and
|
||||
transport regressions are new runs; full regression follows the merged changes.
|
||||
"""
|
||||
from datetime import datetime
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
import uuid
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[4]
|
||||
OUT = ROOT / "artifacts/original-completion-2026-10-02/p03-transit-guard"
|
||||
PACKET = ROOT / "artifacts/path-transit-snapshot-partial-success-guard-candidate-2026-10-01"
|
||||
PATH_TARGET = "scripts/world/path_service.gd"
|
||||
|
||||
|
||||
def sha(path):
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def write(path, data):
|
||||
path.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n")
|
||||
|
||||
|
||||
def main():
|
||||
global OUT
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--output", type=Path, default=OUT)
|
||||
args = parser.parse_args()
|
||||
OUT = args.output.resolve()
|
||||
OUT.mkdir(parents=True, exist_ok=False)
|
||||
baseline_map = json.loads((ROOT / "artifacts/facility-need-pricing-production-scale-adoption-2026-10-01-r01/after.json").read_text())
|
||||
pins = json.loads((PACKET / "source-pins.json").read_text())
|
||||
assert baseline_map[PATH_TARGET] == pins["target_base"][PATH_TARGET]
|
||||
assert sha(PACKET / "candidate" / PATH_TARGET) == pins["target_candidate"][PATH_TARGET]
|
||||
assert sha(ROOT / "scripts/world/facility_infrastructure_projector.gd") == pins["unchanged_projector_sha256"]
|
||||
run_id = uuid.uuid4().hex[:12]
|
||||
stage_root = Path("/private/tmp") / ("thetree-original-guard-" + run_id)
|
||||
stage_root.mkdir()
|
||||
assert shutil.disk_usage(stage_root).free > 3 * 1024**3
|
||||
info = {"source_head": subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=ROOT, text=True).strip(),
|
||||
"started_at_jst": datetime.now(ZoneInfo("Asia/Tokyo")).isoformat(),
|
||||
"baseline_files": len(baseline_map), "stages": {}, "rows": [], "production_applied": False}
|
||||
write(OUT / "source-baseline.json", baseline_map)
|
||||
for variant in ("reference", "candidate"):
|
||||
stage = stage_root / variant
|
||||
stage.mkdir()
|
||||
for name, expected in baseline_map.items():
|
||||
source = ROOT / name
|
||||
destination = stage / name
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
if source.is_file() and sha(source) == expected:
|
||||
shutil.copyfile(source, destination)
|
||||
else:
|
||||
# A parallel save fix may already change production; recover
|
||||
# only the exact committed baseline, never mix generations.
|
||||
payload = subprocess.check_output(["git", "show", "HEAD:" + name], cwd=ROOT)
|
||||
assert hashlib.sha256(payload).hexdigest() == expected, name
|
||||
destination.write_bytes(payload)
|
||||
profile_name = "TheTreeGoalGuard-" + run_id + "-" + variant
|
||||
profile = Path.home() / "Library/Application Support" / profile_name
|
||||
project = stage / "project.godot"
|
||||
config = project.read_text()
|
||||
project.write_text(config.replace("[application]", '[application]\nconfig/use_custom_user_dir=true\nconfig/custom_user_dir_name="' + profile_name + '"', 1))
|
||||
qa = stage / "tests/diagnostic/transit_snapshot_guard"
|
||||
qa.mkdir(parents=True)
|
||||
for name in ("frozen_full_snapshot_path.gd", "transit_snapshot_guard_boundary.gd"):
|
||||
shutil.copyfile(PACKET / "qa" / name, qa / name)
|
||||
shutil.copyfile(ROOT / "artifacts/path-snapshot-lazy-default-storage-budget-prep-2026-09-30/drivers/profile_current_whole.gd", qa / "whole.gd")
|
||||
if variant == "candidate":
|
||||
shutil.copyfile(PACKET / "candidate" / PATH_TARGET, stage / PATH_TARGET)
|
||||
info["stages"][variant] = {"path": str(stage), "profile": str(profile), "path_sha256": sha(stage / PATH_TARGET)}
|
||||
write(OUT / "execution.json", info)
|
||||
|
||||
def run(variant, label, script=None, extra=None):
|
||||
stage = Path(info["stages"][variant]["path"])
|
||||
env = dict(os.environ)
|
||||
env.update(THE_TREE_TRANSIT_SNAPSHOT_GUARD_STAGE=str(stage),
|
||||
THE_TREE_TRANSIT_SNAPSHOT_GUARD_PROFILE=info["stages"][variant]["profile"])
|
||||
if extra:
|
||||
env.update(extra)
|
||||
command = ["godot", "--headless", "--path", str(stage)]
|
||||
command += ["--script", "res://" + script] if script else ["--editor", "--import"]
|
||||
start = time.monotonic()
|
||||
log = OUT / (label + ".log")
|
||||
with log.open("w") as stream:
|
||||
try:
|
||||
code = subprocess.run(command, cwd=stage, env=env, stdout=stream,
|
||||
stderr=subprocess.STDOUT, timeout=1200).returncode
|
||||
except subprocess.TimeoutExpired:
|
||||
code = 124
|
||||
content = log.read_text()
|
||||
unicode_lines = [line for line in content.splitlines() if "Unicode parsing error" in line]
|
||||
passed = code == 0 and "Godot Engine v4.7.2" in content and not any(t in content for t in ("SCRIPT ERROR:", "\nERROR:"))
|
||||
# The historical importer emits two known NUL diagnostics. Retain and
|
||||
# expose them, while requiring clean script execution for this fix.
|
||||
if script and unicode_lines:
|
||||
passed = False
|
||||
row = {"variant": variant, "label": label, "script": script, "exit_code": code,
|
||||
"seconds": round(time.monotonic() - start, 3), "passed": passed,
|
||||
"unicode_diagnostics": unicode_lines, "diagnostics_clear": not unicode_lines,
|
||||
"log": log.name, "log_sha256": sha(log)}
|
||||
info["rows"].append(row)
|
||||
write(OUT / "execution.json", info)
|
||||
print(json.dumps(row), flush=True)
|
||||
assert passed, label
|
||||
return content
|
||||
|
||||
run("reference", "reference-import")
|
||||
run("candidate", "candidate-import")
|
||||
boundary = run("candidate", "boundary", "tests/diagnostic/transit_snapshot_guard/transit_snapshot_guard_boundary.gd")
|
||||
assert "failures=0" in boundary and boundary.count("TRANSIT_SNAPSHOT_GUARD checks=") == 1
|
||||
oracle = str(stage_root / "whole-oracle.var")
|
||||
for variant, mode in (("reference", "oracle"), ("candidate", "check")):
|
||||
report = OUT / (variant + "-whole.json")
|
||||
run(variant, variant + "-whole", "tests/diagnostic/transit_snapshot_guard/whole.gd",
|
||||
{"THE_TREE_WHOLE_MODE": mode, "THE_TREE_WHOLE_REPORT": str(report),
|
||||
"THE_TREE_WHOLE_ORACLE": oracle, "THE_TREE_PROFILE_VARIANT": variant,
|
||||
"THE_TREE_PROFILE_SOURCE_SHA": hashlib.sha256(json.dumps(baseline_map, sort_keys=True).encode()).hexdigest()})
|
||||
data = json.loads(report.read_text())
|
||||
assert data["failures"] == 0 and data["checked_ticks_including_midpoint_replay"] == 1200
|
||||
assert data["uncompared_delivered_event_count"] == 0
|
||||
for test in ("tests/s1/test_path_service.gd", "tests/s1/test_path_congestion.gd",
|
||||
"tests/transport/test_transport_save.gd", "tests/s1/test_runtime_infrastructure_integration.gd",
|
||||
"tests/s6/test_runtime_save_lifecycle.gd"):
|
||||
run("candidate", test.replace("/", "__"), test)
|
||||
info.update(finished_at_jst=datetime.now(ZoneInfo("Asia/Tokyo")).isoformat(),
|
||||
focused_acceptance_passed=True, full_merged_regression_pending=True,
|
||||
original_full_acceptance=False, performance_acceptance=False,
|
||||
unresolved_import_diagnostics=any(not r["diagnostics_clear"] for r in info["rows"]))
|
||||
write(OUT / "execution.json", info)
|
||||
print("Transit guard focused acceptance passed; merged full regression remains required.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user