Files
MeltMind/tools/track_b_gino_paper_keyword_patch.py
T

50 lines
2.3 KiB
Python

"""Apply the two reviewed keyword names only to a verified temporary unpack."""
from pathlib import Path
from track_b_gino_shapenet_entry import BASE, checked, read, sha
from track_b_gino_shapenet_worker import extract_paper_code
EVIDENCE = BASE / "artifacts/track-b-paper-keyword-compatibility-2026-11-19"
PATCH_SHA = "7307ba49f83bfc46c5decf803a993a41ed602d987de65714958e738d2f52f077"
SEARCH_SHA = "77a897bf534a9a0e9e6a7c072b4f914168648eadc2af3493b70d63d0b715b3d0"
def patch_binding():
return dict(handoff="h-b8508140", identity="supplement code + 2-keyword patch",
patch_path=str(EVIDENCE / "two-keyword-patch.json"), patch_sha256=PATCH_SHA,
search_path=str(EVIDENCE / "keyword-search.json"), search_sha256=SEARCH_SHA)
def patch_identity(c):
pin = c["paper_compatibility"]
if pin != patch_binding():
raise PermissionError("The exact keyword patch and archive search are required")
patch = read(checked(pin["patch_path"], pin["patch_sha256"]))
search = read(checked(pin["search_path"], pin["search_sha256"]))
if (patch["nested_archive_sha256"] != c["paper_code_zip_sha256"]
or search["nested_archive_sha256"] != c["paper_code_zip_sha256"]
or search["neuraloperator_commit"] != c["environment"]["neuralop_commit"]
or search["status"] != "NO_ALTERNATE_INTERFACE"
or search["accepting_function_signatures"] or search["neuraloperator_matches"]):
raise ValueError("Alternative interface audit or source archive identity differs")
return patch
def extract_patched_paper_code(c, directory):
patch = patch_identity(c)
extract_paper_code(c, directory)
target = Path(directory) / patch["target"]
original = checked(target, patch["original_file_sha256"])
checked(target.with_name("neighbor_ops.py"), patch["neighbor_ops_file_sha256"])
source = original.read_bytes()
for before, after in patch["changes"]:
old, new = before.encode("ascii"), after.encode("ascii")
if source.count(old) != 1:
raise ValueError("The original keyword must occur exactly once")
source = source.replace(old, new)
original.write_bytes(source)
if sha(original) != patch["patched_file_sha256"]:
raise ValueError("Supplement decoder differs from the reviewed two-keyword patch")