borderland-rl / tools /export_native_probe.py
FatUnc6969's picture
Publish reviewed Borderland recovery research artifact
a8aea51 verified
Raw History Blame Contribute Delete
28.1 kB
"""Verify frozen public first-filing receipts without engine or provider imports."""
import argparse
from dataclasses import dataclass
import hashlib
import json
from pathlib import Path, PurePosixPath
import re
import zipfile
MANIFESTS = {
"public-native-probe-receipts": "c6491c2edf9eb094ad495e8d32d9d2c98293f9ab50aee90f4eb83826ce1b4812",
"public-engine-verification": "cdf81037e2e66145e4629a0f248e09778cac7148a87e3207b73edb42276b6559",
}
CASES = tuple(f"g{g}-t{t}-{c}" for g in range(2) for t in range(2) for c in ("correct", "erased", "foil"))
FORBIDDEN = {"reasoning", "reasoning_content", "raw_reasoning", "assistant_content", "api_key", "authorization", "credentials", "root", "roots", "root_id", "operator_root", "operator_roots", "world_recipe", "world_config", "world_seed", "generation_seed", "native_tool_ids", "provider_response_id"}
PRIVATE_PATH = re.compile(r"/Users/|/home/|/private/|[A-Za-z]:\\Users\\")
def require(condition, message):
if not condition:
raise ValueError(message)
def canonical(value):
return json.dumps(value, sort_keys=True, separators=(",", ":"), ensure_ascii=False, allow_nan=False).encode()
def sha(data):
return hashlib.sha256(data).hexdigest()
def unique_object(pairs):
result = {}
for key, value in pairs:
require(key not in result, "Duplicate JSON key.")
result[key] = value
return result
def strict_json(data):
def reject_constant(value):
raise ValueError("Non-finite JSON number.")
return json.loads(data, object_pairs_hook=unique_object, parse_constant=reject_constant)
def check_privacy(value):
if isinstance(value, dict):
for key, child in value.items():
require(key.lower() not in FORBIDDEN, "Private field in public receipt.")
check_privacy(child)
elif isinstance(value, list):
for child in value:
check_privacy(child)
elif isinstance(value, str):
require(not PRIVATE_PATH.search(value), "Private path in public receipt.")
if value.lstrip().startswith(("{", "[")):
try:
child = strict_json(value)
except ValueError:
return
check_privacy(child)
@dataclass(frozen=True)
class PublicBundle:
name: str
manifest: bytes
contents: dict
@classmethod
def open(cls, directory, name):
directory = Path(directory)
require(name in MANIFESTS and directory.is_dir() and not directory.is_symlink(), "Invalid public bundle.")
manifest_path = directory / "manifest.json"
require(manifest_path.is_file() and not manifest_path.is_symlink(), "Missing regular manifest.")
manifest = manifest_path.read_bytes()
require(sha(manifest) == MANIFESTS[name], "Frozen manifest mismatch.")
files = strict_json(manifest)
contents = {}
for member, expected in files.items():
relative = PurePosixPath(member)
require(not relative.is_absolute() and all(p not in ("", ".", "..") for p in member.split("/")), "Unsafe manifest path.")
require(relative.suffix in (".json", ".jsonl") and member != "manifest.json", "Unexpected receipt type.")
require(all(not directory.joinpath(*relative.parts[:i]).is_symlink() for i in range(1, len(relative.parts) + 1)), "Symlink in receipt path.")
target = directory / relative
require(target.is_file(), "Missing receipt.")
data = target.read_bytes()
require(sha(data) == expected, "Receipt hash mismatch.")
contents[member] = data
require(not any(p.is_symlink() for p in directory.rglob("*")), "Symlink in bundle.")
actual = {p.relative_to(directory).as_posix() for p in directory.rglob("*") if p.is_file()}
require(actual == set(contents) | {"manifest.json"}, "Manifest does not cover entire bundle.")
bundle = cls(name, manifest, contents)
for member in contents:
check_privacy(bundle.read(member))
return bundle
def read(self, member):
data = self.contents[member].decode("utf-8")
return [strict_json(line) for line in data.splitlines()] if member.endswith(".jsonl") else strict_json(data)
def decode(envelope):
require(set(envelope) == {"case_id", "choices", "model", "omitted_fields", "raw_response_sha256", "usage"}, "Unexpected response envelope.")
require(envelope["omitted_fields"] == ["assistant_content", "reasoning_content", "provider_response_id", "native_tool_ids"], "Response omission scope changed.")
require(envelope["model"] == "reflection/Beam-1.0", "Reported model changed.")
require(len(envelope["choices"]) == 1, "Expected one response choice.")
choice = envelope["choices"][0]
require(set(choice) == {"index", "message", "finish_reason"} and choice["index"] == 0 and choice["finish_reason"] == "tool_calls", "Unexpected finish or choice.")
message = choice["message"]
require(set(message) == {"role", "tool_calls"} and message["role"] == "assistant" and len(message["tool_calls"]) == 1, "Expected one native function call without assistant text.")
call = message["tool_calls"][0]
require(set(call) == {"function", "id_sha256", "type"} and call["type"] == "function", "Unexpected native call shape.")
require(re.fullmatch(r"[0-9a-f]{64}", call["id_sha256"]) is not None, "Invalid public native ID hash.")
require(set(call["function"]) == {"name", "arguments"} and call["function"]["name"] == "execute_action", "Unexpected function.")
raw = call["function"]["arguments"]
require(isinstance(raw, str), "Native arguments must be a string.")
try:
command = strict_json(raw)
except ValueError:
return None, raw, call["id_sha256"]
require(isinstance(command, dict) and set(command) == {"tag", "arguments"}, "Invalid native command shape.")
require(command["tag"] == "file_record" and isinstance(command["arguments"], dict) and set(command["arguments"]) == {"record_id"}, "Expected first filing command.")
require(isinstance(command["arguments"]["record_id"], str), "Invalid record ID.")
return command, raw, call["id_sha256"]
def packet_semantics(request):
require(set(request) == {"max_tokens", "messages", "model", "parallel_tool_calls", "reasoning_effort", "tool_choice", "tools"}, "Unexpected request fields.")
require(request["model"] == "reflection/Beam-1.0-501B-A23B:baseten" and request["max_tokens"] == 8192 and request["reasoning_effort"] == "medium" and request["tool_choice"] == "auto" and request["parallel_tool_calls"] is False, "Inference configuration changed.")
require(len(request["tools"]) == 1 and request["tools"][0]["function"]["name"] == "execute_action", "Unexpected request tools.")
require([m["role"] for m in request["messages"]] == ["system", "user"] and all(set(m) == {"role", "content"} for m in request["messages"]), "Unexpected request turns.")
packet = strict_json(request["messages"][1]["content"])
require(set(packet) == {"current", "supplied_public_archive_packets", "task"}, "Unexpected actor packet labels.")
current = packet["current"]
require(set(current) == {"context_reset", "error", "legal_actions", "observation", "outcome", "reward", "terminated", "truncated"}, "Incomplete actor view.")
require(current["observation"]["phase"] == 3 and current["error"] is None and current["observation"]["board"]["filed"] == {}, "Expected first-filing checkpoint.")
require(packet["task"]["operation"] == "file_one_conditional_amendment", "Unexpected task.")
records = packet["supplied_public_archive_packets"]
require(len(records) == len({r["id"] for r in records}) == 24, "Expected 24 unique supplied public records.")
require(all(r["authenticated"] is True and r["seal"] == "civic" and strict_json(r["statement"]) == r["body"] for r in records), "Invalid authenticated public record.")
target = packet["task"]["target_service"]
candidates = [r for r in records if r["subject"] == target]
require(len(candidates) == 3, "Expected three target records.")
base = [r for r in candidates if r["supersedes"] is None]
amendments = [r for r in candidates if r["supersedes"] is not None]
require(len(base) == 1 and len(amendments) == 2 and {r["supersedes"] for r in amendments} == {base[0]["id"]} and {r["applies_bit"] for r in amendments} == {0, 1}, "Unexpected amendment chain.")
channels = {r["applies_channel"] for r in amendments}
require(len(channels) == 1 and all(r["issued_at"] > base[0]["issued_at"] for r in amendments), "Invalid applicability channel or order.")
channel = next(iter(channels))
notebook = strict_json(current["observation"]["notebook"]["text"])
matches = [m for m in notebook["m"] if m[0] == channel]
require(len(matches) == 1 and matches[0][1] in ("0", "1", "?"), "Missing supplied public bit.")
bit = matches[0][1]
choices = {str(r["applies_bit"]): r["id"] for r in amendments}
return packet, target, channel, bit, choices, candidates
def verify_journal(bundle, rows, summary):
journal = bundle.read("journal.jsonl")
require(len(journal) == 38, "Incomplete journal lifecycle.")
previous = "0" * 64
for entry in journal:
require(set(entry) == {"event", "previous_sha256", "sha256"} and entry["previous_sha256"] == previous, "Journal predecessor mismatch.")
require(sha(canonical({"event": entry["event"], "previous_sha256": previous})) == entry["sha256"], "Journal hash mismatch.")
previous = entry["sha256"]
require(previous == summary["journal_terminal_sha256"], "Journal terminal mismatch.")
reserve = journal[0]["event"]
require(reserve["type"] == "batch_reserved" and reserve["manifest_sha256"] == summary["original_manifest_sha256"] and reserve["reservation_nano_usd"] == 452198400 <= summary["authorized_cap_nano_usd"], "Batch reservation mismatch.")
order = []
for index in range(12):
intent, response, settled = [e["event"] for e in journal[1 + index * 3:4 + index * 3]]
case = intent["case_id"]
require(case not in order and case in rows, "Repeated or unknown journal attempt.")
order.append(case)
row = rows[case]
require(intent["type"] == "intent" and intent["payload_sha256"] == row["request_sha256"] and intent["reservation_nano_usd"] == 37683200, "Journal intent mismatch.")
require(response["type"] == "response_received" and response["case_id"] == case and response["response_sha256"] == row["response_sha256"] and response["http_status"] == 200, "Journal response mismatch.")
require(settled["type"] == "settled" and settled["case_id"] == case and settled["status"] == row["status"] and settled["finish_reason"] == row["finish_reason"] and all(settled[k] == v for k, v in row["usage"].items()), "Journal settlement mismatch.")
require(journal[-1]["event"] == {"type": "batch_complete", "requests": 12}, "Missing batch completion.")
require(order == [r["case_id"] for r in summary["rows"]], "Summary attempt order mismatch.")
return order
def verify_witness(events, engine_row, row):
index = engine_row["choice_index"]
require(len(events) == engine_row["command_count"] + 1 and [e["index"] for e in events] == list(range(len(events))), "Witness event indices mismatch.")
require(events[0]["kind"] == "reset" and events[0]["input"] is None and 0 < index < len(events), "Invalid witness reset or choice index.")
require(events[index - 1]["public"] == row["request_packet"]["current"], "Witness current differs from actual request.")
require(events[index]["kind"] == "action" and events[index]["input"] == row["command"] == engine_row["native_action"], "Witness replaced actual model choice.")
require(row["command"] in events[index - 1]["public"]["legal_actions"] and events[index]["public"]["error"] is None, "Model action was not legally accepted.")
target = row["target_service"]
choice = row["actual_choice"]
require(events[index]["public"]["observation"]["board"]["filed"] == {target: choice}, "First filing receipt differs.")
target_selections = [e for e in events if e["kind"] == "action" and e["input"]["tag"] == "file_record" and e["input"]["arguments"]["record_id"] in row["candidate_ids"]]
require(len(target_selections) == 1 and target_selections[0]["index"] == index, "Target model selection repeated or replaced.")
require(all(e["public"]["error"] is None and e["public"]["outcome"] == "running" and e["public"]["terminated"] is False and e["public"]["truncated"] is False for e in events), "Unexpected witness ending or rejection.")
for before, after in zip(events, events[1:]):
require(set(after) == {"index", "input", "kind", "public"} and after["kind"] in ("note", "action"), "Unexpected witness event.")
if after["kind"] == "action":
action = after["input"]
legal = before["public"]["legal_actions"]
if action["tag"] == "compare_seal":
require(any(a["tag"] == "compare_seal" and set(a["arguments"].values()) == set(action["arguments"].values()) for a in legal), "Illegal scripted comparison.")
else:
require(action in legal, "Illegal witness action.")
else:
require(isinstance(after["input"], str) and after["public"]["observation"]["notebook"]["text"] == after["input"], "Witness note mismatch.")
final = events[-1]
observation = final["public"]["observation"]
require(final["input"]["tag"] == "bind_docket" and final["input"]["arguments"]["record_ids"].count(choice) == 1, "Missing actual model selection at bind.")
require(sum(e["kind"] == "action" and e["input"]["tag"] == "file_record" for e in events) == 8, "Expected model filing plus seven scripted selections.")
require(observation["phase"] == engine_row["final_phase"] == (4 if row["correct"] else 3) and observation["charge"] == engine_row["final_charge"], "Final phase or charge mismatch.")
require(engine_row["archive_exit"] is row["correct"] and engine_row["expected_correct"] is row["correct"] and engine_row["choice_accepted"] is True and engine_row["exact_request_current_matched"] is True, "Engine summary disagrees with public witness.")
require(len(events) - index == engine_row["suffix_commands"] == 17, "Scripted continuation count mismatch.")
verification = engine_row["replay_verification"]
require(verification == {"episode_complete": False, "events": len(events), "mismatches": [], "outcome": "running", "verified": True, "view_only": False}, "Origin replay attestation changed.")
return {
"choice_index": index, "command_count": len(events) - 1,
"final_phase": observation["phase"], "final_charge": observation["charge"],
"bind_success": engine_row["archive_exit"], "origin_replay_verification": verification,
"recovery": engine_row.get("recovery"),
"current": events[index - 1]["public"], "actual_choice_event": events[index], "final_event": final,
"scripted_prefix": [{k: e[k] for k in ("index", "kind", "input")} for e in events[:index]],
"scripted_continuation": [{k: e[k] for k in ("index", "kind", "input")} for e in events[index + 1:]],
}
def export(probe, engine):
expected_probe = {"analysis-freeze.json", "journal.jsonl", "scoring.json", "summary.json"} | {f"{kind}/{case}.json" for case in CASES for kind in ("requests", "results", "response-envelopes")}
require(set(probe.contents) == expected_probe, "Unexpected probe member set.")
require(set(engine.contents) == {"summary.json"} | {f"witnesses/{case}.json" for case in CASES if case != "g1-t1-erased"}, "Unexpected engine member set.")
summary = probe.read("summary.json")
scoring = probe.read("scoring.json")
require(len(scoring) == 12 and {r["case_id"] for r in scoring} == set(CASES), "Scoring coverage changed.")
score_by_case = {r["case_id"]: r for r in scoring}
require(len(summary["rows"]) == 12 and {r["case_id"] for r in summary["rows"]} == set(CASES), "Summary coverage changed.")
source_rows = {r["case_id"]: r for r in summary["rows"]}
freeze = probe.read("analysis-freeze.json")
require(freeze["manifest_sha256"] == summary["original_manifest_sha256"] and freeze["scoring_sha256"] == sha(probe.contents["scoring.json"]) and freeze["invalid_cells"] == "retained_not_counted_as_wrong_play" and freeze["population_claim"] is False, "Analysis commitment mismatch.")
rows = {}
ids = set()
for case in CASES:
group, twin, condition = case.split("-")
request = probe.read(f"requests/{case}.json")
packet, target, channel, bit, choices, candidates = packet_semantics(request)
envelope = probe.read(f"response-envelopes/{case}.json")
result = probe.read(f"results/{case}.json")
command, raw, identity = decode(envelope)
valid = command is not None
require(identity not in ids, "Repeated native tool ID hash.")
ids.add(identity)
require(envelope["case_id"] == result["case_id"] == case and result["engine_applied"] is False and result.get("command") == command and result["finish_reason"] == "tool_calls", "Decoded result mismatch.")
require(not valid or result["tool_call_id_sha256"] == identity, "Native ID hash mismatch.")
status = "valid_native_command" if valid else "invalid_native_reply"
require(result["status"] == status and result.get("reason") == (None if valid else "malformed_reply"), "Validity changed.")
if not valid:
require(case == "g1-t1-erased" and strict_json(raw + "}") == {"arguments": {"record_id": "r14"}, "tag": "file_record"}, "Expected preserved missing closing brace.")
else:
require(command in packet["current"]["legal_actions"] and command["arguments"]["record_id"] in {r["id"] for r in candidates}, "Selected record is not a legal target choice.")
usage = result["usage"]
require(set(usage) == {"completion_tokens", "cost_nano_usd", "prompt_tokens", "total_tokens"} and all(type(v) is int and v >= 0 for v in usage.values()), "Invalid token accounting.")
require(all(usage[k] == envelope["usage"][k] for k in ("prompt_tokens", "completion_tokens", "total_tokens")) and usage["total_tokens"] == usage["prompt_tokens"] + usage["completion_tokens"] and usage["cost_nano_usd"] == usage["prompt_tokens"] * 400 + usage["completion_tokens"] * 1200, "Usage estimate mismatch.")
score = score_by_case[case]
require(score["group"] == group and score["twin"] == twin and score["condition"] == ("?" if condition == "erased" else condition) and score["target_service"] == target and score["candidate_ids"] == [r["id"] for r in candidates], "Scoring packet mismatch.")
require(score["payload_bytes"] == len(probe.contents[f"requests/{case}.json"]), "Request byte length mismatch.")
actual = command["arguments"]["record_id"] if valid else None
row = {
"case_id": case, "group": group, "twin": twin, "condition": condition,
"channel": channel, "note_bit": bit, "target_service": target,
"candidate_ids": [r["id"] for r in candidates], "target_records": candidates,
"note_expected_choice": choices.get(bit), "actual_choice": actual, "command": command,
"valid": valid, "status": status, "invalid_reason": None if valid else "malformed_reply",
"finish_reason": "tool_calls", "raw_function_arguments": raw, "tool_id_sha256": identity,
"request_model": request["model"], "reported_model": envelope["model"], "usage": usage,
"request_sha256": sha(probe.contents[f"requests/{case}.json"]), "response_sha256": envelope["raw_response_sha256"],
"request_packet": packet, "system_instruction": request["messages"][0]["content"],
"source_actor_packet_commitment": {"sha256": score["actor_packet_sha256"], "scope": "Original prepared current-plus-history packet. Not reconstructible from the public request subset; origin-only source commitment."},
}
rows[case] = row
for row in rows.values():
correct = rows[f"{row['group']}-{row['twin']}-correct"]
counterpart = rows[f"{row['group']}-{'t1' if row['twin'] == 't0' else 't0'}-correct"]
require(correct["note_bit"] in ("0", "1") and counterpart["note_bit"] != correct["note_bit"], "Correct-note twins must differ.")
true_choice = correct["note_expected_choice"]
other_choice = counterpart["note_expected_choice"]
require(row["note_bit"] == ("?" if row["condition"] == "erased" else correct["note_bit"] if row["condition"] == "correct" else counterpart["note_bit"]), "Treatment bit mismatch.")
row.update(true_expected_choice=true_choice, counterpart_choice=other_choice, correct=row["actual_choice"] == true_choice if row["valid"] else None, follows_counterpart=row["actual_choice"] == other_choice if row["valid"] else None)
score = score_by_case[row["case_id"]]
source = source_rows[row["case_id"]]
require(score["expected_true_record"] == true_choice and score["expected_counterpart_record"] == other_choice, "Public semantic derivation differs from scoring.")
require(all(source[k] == row[k] for k in ("command", "correct", "follows_counterpart", "finish_reason", "request_sha256", "response_sha256", "status", "usage")), "Public summary differs from decoded evidence.")
pairs = []
for group in ("g0", "g1"):
normalized = []
for row in rows.values():
if row["group"] == group:
packet = strict_json(canonical(row["request_packet"]))
note = strict_json(packet["current"]["observation"]["notebook"]["text"])
for item in note["m"]:
if item[0] == row["channel"]:
item[1] = "?"
packet["current"]["observation"]["notebook"]["text"] = canonical(note).decode()
normalized.append(packet)
require(all(p == normalized[0] for p in normalized), "Group differs outside supplied notebook bit.")
for a, b in ((f"{group}-t0-erased", f"{group}-t1-erased"), (f"{group}-t0-correct", f"{group}-t1-foil"), (f"{group}-t1-correct", f"{group}-t0-foil")):
require(probe.contents[f"requests/{a}.json"] == probe.contents[f"requests/{b}.json"], "Paired request bytes differ.")
pairs.append({"cases": [a, b], "request_sha256": rows[a]["request_sha256"], "choices": [rows[a]["actual_choice"], rows[b]["actual_choice"]], "validities": [rows[a]["valid"], rows[b]["valid"]]})
conditions = {}
for condition in ("correct", "erased", "foil"):
arm = [r for r in rows.values() if r["condition"] == condition]
conditions[condition] = {"attempted": len(arm), "valid": sum(r["valid"] for r in arm), "correct": sum(r["correct"] is True for r in arm), "invalid": sum(not r["valid"] for r in arm), "follows_counterpart": sum(r["follows_counterpart"] is True for r in arm)}
expected = summary["conditions"]["?" if condition == "erased" else condition]
require(all(expected[k] == v for k, v in conditions[condition].items()), "Condition denominator mismatch.")
require([(conditions[c]["correct"], conditions[c]["valid"], conditions[c]["invalid"]) for c in conditions] == [(4, 4, 0), (0, 3, 1), (1, 4, 0)], "Frozen result changed.")
totals = {k: sum(r["usage"][k] for r in rows.values()) for k in ("prompt_tokens", "completion_tokens", "total_tokens", "cost_nano_usd")}
require(totals == {"prompt_tokens": 66666, "completion_tokens": 24360, "total_tokens": 91026, "cost_nano_usd": 55898400}, "Frozen usage total changed.")
require(summary["requests"] == summary["planned"] == summary["settled"] == summary["actual_native_ids"] == summary["unique_native_ids"] == 12 and summary["retries"] == summary["holds"] == summary["commands_applied_to_engine"] == summary["cash_cap_nano_usd"] == 0 and summary["authorized_cap_nano_usd"] == 500000000, "Batch scope mismatch.")
require(summary["prompt_tokens"] == totals["prompt_tokens"] and summary["completion_tokens"] == totals["completion_tokens"] and summary["estimated_cost_nano_usd"] == totals["cost_nano_usd"], "Summary usage mismatch.")
order = verify_journal(probe, rows, summary)
engine_summary = engine.read("summary.json")
require(engine_summary["actual_model_requests"] == engine_summary["new_policy_training"] == engine_summary["newly_sampled_roots"] == 0 and engine_summary["valid_actions_verified"] == 11 and engine_summary["invalid_not_applied"] == 1, "Engine verification scope mismatch.")
require(len(engine_summary["rows"]) == 12 and {r["case_id"] for r in engine_summary["rows"]} == set(CASES), "Engine summary coverage mismatch.")
for e in engine_summary["rows"]:
row = rows[e["case_id"]]
require(e["model_requests"] == 0, "Engine verification made a model request.")
require(e["condition"] == ("?" if row["condition"] == "erased" else row["condition"]), "Engine condition label mismatch.")
if not row["valid"]:
require(e["status"] == "invalid_reply_not_applied" and e["reason"] == "malformed_reply", "Invalid reply was applied.")
row["engine"] = None
else:
require(e["status"] == "verified_recorded_choice", "Missing verified choice.")
member = f"witnesses/{row['case_id']}.json"
row["engine"] = verify_witness(engine.read(member), e, row)
row["engine"]["witness_sha256"] = sha(engine.contents[member])
row["engine"]["witness_member"] = engine.name + "/" + member
flips = sum(rows[f"{g}-t0-correct"]["actual_choice"] != rows[f"{g}-t1-correct"]["actual_choice"] for g in ("g0", "g1"))
require(flips == 2, "Correct-note action flip mismatch.")
return {"format": "borderland-native-archive-probe-v1", "rows": list(rows.values()), "conditions": conditions,
"identical_inputs": pairs, "correct_note_twins_flipped": flips, "attempt_order": order,
"totals": totals, "authorized_cap_nano_usd": 500000000, "cash_cap_nano_usd": 0,
"manifest_sha256": {b.name: sha(b.manifest) for b in (probe, engine)},
"zip_members": sum(len(b.contents) + 1 for b in (probe, engine)),
"engine": {"valid_actions_accepted": 11, "bind_successes": 5, "bind_rejections": 6, "invalid_not_applied": 1, "new_model_requests": 0}}
def write_zip(path, bundles):
with zipfile.ZipFile(path, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as archive:
for bundle in bundles:
for member, data in sorted({**bundle.contents, "manifest.json": bundle.manifest}.items()):
info = zipfile.ZipInfo(bundle.name + "/" + member, (1980, 1, 1, 0, 0, 0))
info.compress_type = zipfile.ZIP_DEFLATED
info.create_system = 3
info.external_attr = 0o100644 << 16
archive.writestr(info, data, compresslevel=9)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--probe", type=Path, required=True, help="Sanitized public probe bundle directory")
parser.add_argument("--engine", type=Path, required=True, help="Sanitized public engine bundle directory")
parser.add_argument("--output", type=Path, required=True)
parser.add_argument("--zip-output", type=Path)
args = parser.parse_args()
probe = PublicBundle.open(args.probe, "public-native-probe-receipts")
engine = PublicBundle.open(args.engine, "public-engine-verification")
result = export(probe, engine)
args.output.write_bytes(json.dumps(result, indent=2, sort_keys=True, ensure_ascii=False, allow_nan=False).encode() + b"\n")
if args.zip_output:
write_zip(args.zip_output, (probe, engine))
print(f"Verified 12 attempts, 11 public engine witnesses, {result['zip_members']} ZIP members.")
if __name__ == "__main__":
main()