"""Archive only explicitly selected completed receipts; execute no project code.""" import hashlib import io import json from pathlib import Path import zipfile ROOT = Path(__file__).resolve().parents[2] OUT = Path(__file__).resolve().parent PREFIX = "source-rename-completed-evidence/" RUNS = ["attempt-6", "clipping-negative-1", "clipping-positive-diagnostic-1", "nested-sync-diagnostic-1", "editor-patch-check-1"] payload = {} originals = {} checks = [] def sha(data): return hashlib.sha256(data).hexdigest() def encoded(value): return (json.dumps(value, ensure_ascii=True, indent=2) + "\n").encode() def add(source, target): path = ROOT / source data = path.read_bytes() assert target not in payload assert path.suffix.lower() not in {".exe", ".dll", ".pyc"} payload[target] = data originals[str(path)] = data for run in RUNS: directory = ROOT / ".local/source-rename-integration-20260912" / run names = ["inputs.zip", "inputs.json", "environment.json"] phases = ["clippy", "tests", "timing", "gui"] if run == "attempt-6" else [""] if run == "attempt-6": names.append("complete.json") complete = json.loads((directory / "complete.json").read_bytes()) assert complete["inputsUnchanged"] and complete["gates"] == phases for phase in phases: receipt_name = phase + "-result.json" if phase else "result.json" receipt = json.loads((directory / receipt_name).read_bytes()) assert receipt["finished"] and receipt["inputsUnchanged"] assert receipt["exitCode"] == (101 if run == "clipping-negative-1" else 0) names.append(receipt_name) for stream in ["stdout", "stderr"]: log = (phase + "-" if phase else "") + stream + ".log" assert sha((directory / log).read_bytes()) == receipt[stream + "Sha256"] names.append(log) checks.append({"run": run, "phase": phase or "command", "exitCode": receipt["exitCode"], "finished": receipt["finished"], "command": receipt["command"]}) manifest = json.loads((directory / "inputs.json").read_bytes()) raw = (directory / "inputs.zip").read_bytes() assert sha(raw) == manifest["archiveSha256"] with zipfile.ZipFile(io.BytesIO(raw)) as inner: expected = {entry["path"]: entry for entry in manifest["files"]} assert len(inner.namelist()) == len(set(inner.namelist())) == len(expected) assert set(inner.namelist()) == set(expected) and inner.testzip() is None for name, entry in expected.items(): assert not Path(name).is_absolute() and ".." not in Path(name).parts assert Path(name).suffix.lower() not in {".exe", ".dll", ".pyc"} data = inner.read(name) assert len(data) == entry["bytes"] and sha(data) == entry["sha256"] checks.append({"run": run, "inputArchiveSha256": sha(raw), "inputMembers": len(expected), "allInputBytesAndCrcVerified": True}) for name in names: add(directory.relative_to(ROOT) / name, "runs/" + run + "/" + name) diagnosis = ".local/source-rename-latency-diagnosis-20260912/" notes = ["notes.md", "read-bindings.json", "nested-summary.json", "summarize.py", "editor-initialization-candidates.md", "editor-initialization-bindings.json", "same-line-patch-assessment.md", "editor-patch-independent-review.md", "editor-patch-review-bindings.json", "prepare-instrumentation.ps1", "candidate/editor_patch.rs", "candidate/README.md"] for name in notes: add(diagnosis + name, "diagnosis/" + name) for path in sorted((ROOT / diagnosis / "instrumentation").rglob("*")): if path.is_file(): add(path.relative_to(ROOT), "diagnosis/instrumentation/" + path.relative_to(ROOT / diagnosis / "instrumentation").as_posix()) for name in ["README.md", "source_rename.rs", "controller-tests.rs", "preview_glyph_tests.rs", "base-hashes.json", "staged-hashes.json"]: add(".local/source-rename-preview-clipping-20260912/" + name, "clipping-stage/" + name) for name in ["native-preview-clipping-review.md", "native-preview-clipping-bindings.json", "staged-clipping-review.md", "staged-clipping-review-bindings.json"]: add(".local/source-rename-controller-independent-review-20260912/" + name, "reviews/" + name) for name in ["gate.py", "focused.py"]: add(".local/source-rename-integration-20260912/" + name, "helpers-current-readback/" + name) assert sha(payload["diagnosis/candidate/editor_patch.rs"]) == "f301b8a043916b69dccb176da527a50ee85124b7e8b1da18921e4a0374a5153b" # Bind the corrected helper from the completed check snapshot, never moving live source. with zipfile.ZipFile(io.BytesIO(payload["runs/editor-patch-check-1/inputs.zip"])) as inner: corrected = inner.read("crates/oa-desktop/src/app/source_rename/editor_patch.rs") assert sha(corrected) == "049c9774c1ca28cda01f9a8e024604bef282366aa52c53c17c1918dbd09c3441" negative = payload["runs/clipping-negative-1/stderr.log"].decode() assert "source glyph under scrollbar" in negative and "cluster=92..93" in negative native_path = "harness/experiments/source-alias-rename-native-20260912/source-rename-native-attempt-6-20260912.zip" native = (ROOT / native_path).read_bytes() assert sha(native) == "77adda5a33eb1def6dab23352ca0ab172300ea65fc21d2c215d545d7fcce0d08" gui = json.loads(payload["runs/attempt-6/gui-result.json"])["binary"] summary = {"scope": "Completed source gates and bounded experiments only; not candidate acceptance or native paint.", "checks": checks, "externalBindings": [{"path": native_path, "sha256": sha(native), "bytes": len(native), "included": False}, {"path": ".local/source-rename-integration-20260912/attempt-6/arcadia-studio.exe", "sha256": gui["sha256"], "bytes": gui["bytes"], "included": False}], "correctedHelperFromCheckInputSha256": sha(corrected), "excluded": ["editor-patch-tests-1", "next-layout evaluator", "executable/DLL bytes", "private profiles", "caches", "duplicate native trial archive"]} payload["SUMMARY.json"] = encoded(summary) payload["INDEX.md"] = b"""# Completed alias source gates and bounded experiments This private archive preserves five completed runs only. It is not a release or acceptance of an editor-reuse candidate. Native trial evidence is separately versioned and SHA-bound in SUMMARY.json, without duplicate payload. | Run | Meaning | | --- | --- | | attempt-6 | Four successful Windows source gates: Clippy, tests, existing full Confirm timing, GUI executable build. The GUI JSON records the external binary; building it is not native acceptance. | | clipping-negative-1 | Expected test failure (101): original layout allows actual shaped declaration glyph cluster92..93 beneath the scrollbar. | | clipping-positive-diagnostic-1 | Successful focused rename tests with corrected preview layout and temporary timing instrumentation in source. This is an experimental capture, not clean production acceptance. | | nested-sync-diagnostic-1 | Successful ignored real-Confirm timing experiment with nested instrumentation. Inclusive phase levels must not be added together; no GPU, first-paint or native responsiveness claim. | | editor-patch-check-1 | Successful cargo check of corrected reuse helper integration only. It does not execute helper behavior, later layout timing or native rendering. | Every run has its exact inputs.zip, complete membership/hash manifest, environment, commands/receipts and raw logs. All eight command receipt log hashes and all five nested ZIP memberships/member bytes/CRCs were independently checked during construction. Inputs manifests bind historical uncommitted snapshots; baseCommit alone is not their source identity. diagnosis/instrumentation preserves removed diagnostic baseline/modified files, exact patch, bindings and generator. Historical notes retain their original time-scoped claims; later receipts qualify earlier hypotheses. diagnosis/candidate/editor_patch.rs is frozen f301b8a0 and has the known after-only LFCR counterexample documented in editor-patch-independent-review.md. Its original README's broad fallback claim is superseded by that review. Corrected helper049c9774 is preserved inside editor-patch-check-1/inputs.zip. The review is static, not proof of executed correctness. clipping-stage and reviews preserve the earlier proposed repair/evaluator and source review; the exact executed evaluator is in each run's inputs.zip. helpers-current-readback are archive-time helper source snapshots, not independently proven historical executed versions. Historical absolute paths are evidence, not portable execution instructions. Reproduce with the recorded Windows compiler/dependencies and exact source snapshot; do not run relocated helpers blindly. No current editor-patch-tests-1 or subsequent layout evaluation is included. No executables, DLLs, caches or private profiles are included, and no native trial payload is duplicated. PAYLOAD-MANIFEST.json covers all members except itself; external archive-result.json binds the entire archive. """ add(Path(__file__).relative_to(ROOT), "archive-tools/build_archive.py") payload["READBACK-SOURCES.json"] = encoded([{"path": str(Path(path).relative_to(ROOT)), "sha256": sha(data), "bytes": len(data)} for path, data in originals.items()]) payload["PAYLOAD-MANIFEST.json"] = encoded({"selfExcluded": "PAYLOAD-MANIFEST.json", "members": [{"path": name, "bytes": len(data), "sha256": sha(data)} for name, data in sorted(payload.items())]}) archive = OUT / "source-rename-completed-evidence-20260912.zip" with zipfile.ZipFile(archive, "x", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zipped: for name, data in sorted(payload.items()): info = zipfile.ZipInfo(PREFIX + name, date_time=(2026, 9, 12, 0, 0, 0)) info.compress_type = zipfile.ZIP_DEFLATED zipped.writestr(info, data) with zipfile.ZipFile(archive) as zipped: assert zipped.testzip() is None and set(zipped.namelist()) == {PREFIX + n for n in payload} for name, data in payload.items(): assert zipped.read(PREFIX + name) == data for path, data in originals.items(): assert Path(path).read_bytes() == data, "Source changed during archive: " + path receipt = {"archive": archive.name, "sha256": sha(archive.read_bytes()), "bytes": archive.stat().st_size, "members": len(payload), "payloadBytes": sum(map(len, payload.values())), "completedRuns": RUNS, "commandReceipts": 8, "inputArchivesVerified": 5, "sourceReadbacks": len(originals), "allMemberBytesAndCrcVerified": True, "scope": summary["scope"]} with (OUT / "archive-result.json").open("x", encoding="utf-8") as stream: json.dump(receipt, stream, indent=2) print(json.dumps(receipt))