Files
TheTree_mock/docs/plans/original-completion-2026-10-02/execution/review_day_boundary.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

75 lines
7.2 KiB
Python

# -*- coding: utf-8 -*-
"""Recheck immutable rendered day-boundary paired-save subset evidence."""
from pathlib import Path
import importlib.util
import json
import re
import struct
import sys
sys.dont_write_bytecode = True
ROOT = Path(__file__).resolve().parents[4]
ART = ROOT / "artifacts/original-completion-2026-10-02"
P = ART / "p03-cleaning-day-boundary-paired-r02"
OUT = ART / "p03-day-boundary-root-review-r01.json"
spec = importlib.util.spec_from_file_location("day_boundary_source_guard", ROOT / "docs/plans/original-completion-2026-10-02/execution/review_rescue_scale_checkpoint.py")
guard = importlib.util.module_from_spec(spec)
spec.loader.exec_module(guard)
sha, read, require = guard.sha, guard.read, guard.require
def main():
require(not OUT.exists(), "Fresh review required")
seal = read(P / "evidence-seal.json")
require(len(seal["nonstage_files"]) == 131 and all(sha(P / n) == h for n,h in seal["nonstage_files"].items()), "All131 immutable raw proof pins")
receipt = read(P / "acceptance-subset-receipt.json")
pins = read(P / "supplied-source-map.json")
require(len(pins) == 1224 and pins == read(P / "input-source-before.json") == read(P / "input-source-end.json") == guard.source() and read(P / "input-source-change.json") == [], "Actual current adopted source exact before/end")
summary = read(P / "summary.json")
counts = {}
require(summary["error"] is None and len(summary["phases"]) == 6 and len({r["pid"] for r in summary["phases"]}) == 6, "Actual six distinct phases")
for row in summary["phases"]:
log = P / "phases" / row["name"] / "raw.log"
text = log.read_text()
require(sha(log) == row["raw_log_sha256"] and row["passed"] and row["exit_code"] == 0 and not any(s in text for s in ("SCRIPT ERROR", "Parse Error", "ERROR:")), "Actual raw/clean exit")
role = row["name"].removeprefix("day_boundary-")
if role in ("write", "read"):
markers = re.findall(r"^P03_MIDPOINT_COMPLETE scenario=day_boundary phase=" + role + r" nonce=([^ ]+) checks=(\d+) failures=(\d+)$", text, re.M)
require(len(markers) == 1 and markers[0][2] == "0" and int(markers[0][1]) == row["checks"], "Unique actual completion count")
profile = read(P / ("evidence/day_boundary/" + role + "-profile-before-parent.json"))
require(profile["pid"] == row["pid"] and profile["nonce"] == markers[0][0] and profile["verified"] and profile["conditions"] == [True]*6 and profile["conditions_checked"] == 6 and profile["phase"] == role, "Actual private6 conditions before parent")
result = read(P / ("evidence/day_boundary/" + role + "-result.json"))
counts[role] = row["checks"]
require(counts == {"write": 83, "read": 100}, "Actual183/0 counts")
comparisons = read(P / "whole-typed-comparisons.json")
require(comparisons["actual_pairs"] == 12 and comparisons["all_passed"] and len(comparisons["pairs"]) == 12, "Twelve full typed pairs")
for pair in comparisons["pairs"]:
left, right = P / pair["left"], P / pair["right"]
require(left.read_bytes() == right.read_bytes() and sha(left) == pair["left_sha256"] and sha(right) == pair["right_sha256"] and pair["field_exclusions"] == [] and pair["event_deletion_count"] == 0, "Independent entire typed bytes, no exclusions/deletions")
if "writer_raw_event" in pair:
w,r = pair["writer_raw_event"], pair["reader_raw_event"]
require({k:v for k,v in w.items() if k not in ("event_type", "payload")} == {k:v for k,v in r.items() if k not in ("event_type", "payload")}, "Exact IO identity/envelope")
require(pair["writer_event_replaced_count"] == pair["reader_event_count"] == 1 and w["event_type"] == "SAVE_CHECKPOINT_SUCCEEDED" and r["event_type"] == "SAVE_RECOVERY_LOADED", "One actual manual save to normal UI formal recovery IO")
require(w["absolute_minute"] == r["absolute_minute"] == 2879 and w["payload"]["save_id"] == r["payload"]["save_id"] == "manual" and w["payload"]["save_path"] == r["payload"]["save_path"], "Bound actual checkpoint and save")
require(r["payload"]["selected_candidate_id"] == r["payload"]["selected_candidate_kind"] == "formal" and r["payload"]["selected_generation"] == -1 and r["payload"]["operation"] == "recovery" and r["payload"]["ok"] is True, "Formal chosen by actual normal recovery")
package = Path(receipt["formal_package_retained_path"])
require({f.relative_to(package).as_posix():sha(f) for f in package.rglob("*") if f.is_file()} == receipt["formal_4files_SHA_unchanged"] and len(receipt["formal_4files_SHA_unchanged"]) == 4, "Live original formal4 entries unchanged at root review")
evidence = P / "evidence/day_boundary"
require(read(evidence / "write-package-end.json") == read(evidence / "read-package-end.json"), "Writer/reader formal proof equality")
pngs = []
direct = {"write-checkpoint.png", "read-checkpoint.png", "read-final.png", "read-followup.png"}
for name,h in receipt["rendered_PNG"].items():
path = P / name
require(sha(path) == h and path.read_bytes()[:8] == b"\x89PNG\r\n\x1a\n" and struct.unpack(">II",path.read_bytes()[16:24]) == (1280,720), "Actual1280x720 pinned PNG")
pngs.append({"path": path.relative_to(ROOT).as_posix(), "sha256": h, "review": "direct_pixels" if path.name in direct else "same_bytes_as_reviewed_reader"})
require(sha(evidence / "write-final.png") == sha(evidence / "read-final.png") and sha(evidence / "write-followup.png") == sha(evidence / "read-followup.png"), "Other2 captures exactly reviewed pixels")
settled = read(evidence / "read-boundary-summary.json")
require(settled["closed_at"] == 2880 and settled["day"] == 2 and settled["category_totals"]["maintenance"] == 2 and settled["reconciliation_difference"] == 0 and settled["net_profit"] == -2 and settled["balanced"], "Actual full day2G settlement reconciles")
require(guard.source() == pins, "Source unchanged at review end")
guard.write(OUT, {"passed": True, "scope": "Normal Main Save/Load handlers and rendered closed-cleaning day boundary, public construction/resources fixture; not whole normal play", "actual_checks": 183, "failures": 0, "source_files": 1224, "source_changes": [], "evidence_seal_sha256": sha(P / "evidence-seal.json"), "raw131_pins_rechecked": True, "whole_typed_pairs": comparisons["pairs"], "formal4_entries": receipt["formal_4files_SHA_unchanged"], "actual_IO": "SAVE_CHECKPOINT_SUCCEEDED to SAVE_RECOVERY_LOADED/formal; event_type/payload only, same identity/envelope/save_id", "uncapped_branch_events_each": 15, "same_process_future_events_each": 6, "pngs": pngs, "visual_review": {"direct": 4, "same_bytes": 2, "ledger_values": "23:59 gold4649/prior1G;00:00 gold4647/maintenance2G;00:01 same gold4647", "labels": "closed cleaning/no customer fees; ledger balance/no arrears displayed", "read_checkpoint_vs_write": "reader ledger selected by scenario; writer business panel", "finished_art_accepted": False}, "root_rendered_review_pending": False, "whole_P03_accepted": False, "whole_A05_accepted": False, "whole_normal_UI_accepted": False, "native_Windows_accepted": False, "performance_accepted": False, "engine_runs_by_review": 0})
print("Root183/0 review PASS:131 pins,12typed pairs,formal4 unchanged,6PNG reviewed4direct+2same")
if __name__ == "__main__":
main()