Preserve complete P08 review materials and retry binary-safe preparation

This commit is contained in:
Takeshi
2026-10-14 09:49:47 +09:00
parent 96006c60eb
commit e65d6b8c49
4 changed files with 965 additions and 1 deletions
@@ -72,7 +72,32 @@ def packet_with_actual_evidence(self, task_id, role, sha=None):
spec.loader.exec_module(module)
packet = module.packet(self, task_id, sha or self.task(task_id)["submitted"], original_packet)
else:
packet = original_packet(self, task_id, role, sha)
if role == 'reviewer' and self.config['project'] == 'the-tree-p08-03-code' and task_id == 'P08-03':
import runner.core as packet_core
import subprocess, hashlib
actual_git = packet_core.git
def binary_safe_git(repo, *argv, **kwargs):
if len(argv) == 2 and argv[0] == 'show' and ':' in argv[1]:
raw = subprocess.check_output(['git', '-C', str(repo), *argv])
try:
value = raw.decode('utf-8')
if '\x00' not in value:
return value.strip()
except UnicodeDecodeError:
pass
revision, path = argv[1].split(':', 1)
return json.dumps({'source_kind':'binary', 'path':path, 'bytes':len(raw),
'sha256':hashlib.sha256(raw).hexdigest(),
'git_blob':actual_git(repo, 'rev-parse', argv[1]),
'full_bytes_available':'unchanged committed file in frozen reviewer checkout; use Read for images or inspect raw file'}, ensure_ascii=False)
return actual_git(repo, *argv, **kwargs)
packet_core.git = binary_safe_git
try:
packet = original_packet(self, task_id, role, sha)
finally:
packet_core.git = actual_git
else:
packet = original_packet(self, task_id, role, sha)
extra = os.environ.get('OWNER_REVIEW_SUPPLEMENT')
if role == 'reviewer' and extra:
prefix, data = packet.split('\nDATA:\n', 1)
@@ -150,5 +175,38 @@ if p08_read_adapter:
adapter_spec.loader.exec_module(adapter_module)
adapter_module.install(p08_core)
# Reuse the fully prepared frozen review after the known text-decoding failure.
prepared_review = os.environ.get("OWNER_P08_PREPARED_REVIEW")
if prepared_review:
import hashlib
frozen = Path("/Users/korizatou114/Projects/TheTree-managed-worktrees/p08-03-code/P08-03-review-d137e8d8")
require(Path(prepared_review).resolve() == frozen.resolve(), "exact prepared P08 review")
pinned = "7dde98ccb749cbd1c1b82e066b59350e73191400"
detached_original, materials_original = Runner.detached, Runner.review_materials
def reused_detached(self, name, revision):
if self.config["project"] == "the-tree-p08-03-code" and name.startswith("P08-03-review-"):
require(revision == pinned and git(frozen, "rev-parse", "HEAD") == pinned, "frozen review candidate")
require(not git(frozen, "diff", "HEAD", "--name-only"), "unchanged tracked review sources")
return frozen
return detached_original(self, name, revision)
def reused_materials(self, task_id, worktree, revision):
if self.config["project"] != "the-tree-p08-03-code" or task_id != "P08-03":
return materials_original(self, task_id, worktree, revision)
require(Path(worktree) == frozen and revision == pinned, "exact P08 reuse binding")
manifest = read_json(frozen / ".review-material/manifest.json")
require(manifest["candidate"] == pinned and manifest["task_id"] == task_id and manifest["complete_nonsecret_registered_validation_material"], "complete frozen manifest")
for row in manifest["files"]:
path = frozen / row["path"]
require(path.resolve().is_relative_to(frozen.resolve()) and not path.is_symlink() and path.is_file(), "ordinary frozen proof")
digest = hashlib.sha256()
with path.open("rb") as stream:
for block in iter(lambda: stream.read(1048576), b""):
digest.update(block)
require(path.stat().st_size == row["bytes"] and digest.hexdigest() == row["sha256"], "frozen full proof bytes")
self.event(task_id, "owner_prepared_review_reuse", {"candidate": revision, "files_verified": len(manifest["files"]), "path": str(frozen), "reason": "Reuse complete frozen preparation after binary UTF-8 error; no source or acceptance changes"})
return {"path": ".review-material/manifest.json", "file_count": len(manifest["files"]), "byte_limit": None}
Runner.detached, Runner.review_materials = reused_detached, reused_materials
from runner.cli import main
main()