Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions evals/unsafe-rust/runs/2026-07-31-v3-targeted/events.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"details": {"lock_sha256": "9aeeaa4987227f5ac4761349d0979ef6b425cb724fb54d1fe21b89f9cb62e678"}, "event": "freeze_locked", "phase": "freeze", "previous_event_sha256": null, "schema_version": 1, "sequence": 1, "sha256": "2a036052cd3def40582bbe6c3fa7f81ff0bb4afbc82b86f249885076ae7974b3", "time_utc": "2026-08-01T03:19:38.915424Z"}
219 changes: 219 additions & 0 deletions evals/unsafe-rust/runs/2026-07-31-v3-targeted/fetch_authority.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
#!/usr/bin/env python3
"""Fetch or verify the exact official-document pages allowed by this run."""

from __future__ import annotations

import argparse
import csv
import hashlib
import html
import io
import re
import urllib.parse
import urllib.request
from datetime import datetime, timezone
from pathlib import Path


RUN = Path(__file__).resolve().parent
ALLOWLISTS = RUN / "freeze" / "allowlists"
MANIFEST = RUN / "freeze" / "authority-manifest.tsv"
MODES = ("S", "C", "X", "Q", "W", "M", "R", "K")
FIELDS = (
"mode",
"requested_url",
"fetch_url",
"final_url",
"status",
"content_type",
"bytes",
"sha256",
"fragment_found",
"retrieved_utc",
)


def sha256(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()


def read_pinned(path: Path) -> bytes:
data = path.read_bytes()
if (RUN / "freeze" / "LOCK.json").exists():
import protocol

if sha256(data) != protocol.frozen_file_digest(path):
raise ValueError(f"frozen authority input changed while being read: {path}")
return data


def load_urls() -> list[tuple[str, str]]:
rows: list[tuple[str, str]] = []
for mode in MODES:
path = ALLOWLISTS / f"{mode}.txt"
for url in read_pinned(path).decode().splitlines():
if not re.fullmatch(r"https://doc\.rust-lang\.org/\S+", url):
raise ValueError(f"invalid allowlisted URL: {url!r}")
rows.append((mode, url))
return rows


def without_fragment(url: str) -> str:
parts = urllib.parse.urlsplit(url)
return urllib.parse.urlunsplit((parts.scheme, parts.netloc, parts.path, parts.query, ""))


def fragment_present(requested_url: str, body: bytes) -> bool:
fragment = urllib.parse.unquote(urllib.parse.urlsplit(requested_url).fragment)
if not fragment:
return True
text = body.decode("utf-8", errors="replace")
escaped = html.escape(fragment, quote=True)
patterns = (
rf'\bid=["\']{re.escape(fragment)}["\']',
rf'\bid=["\']{re.escape(escaped)}["\']',
rf'\bname=["\']{re.escape(fragment)}["\']',
)
return any(re.search(pattern, text) for pattern in patterns)


def fetch(url: str) -> dict[str, object]:
request = urllib.request.Request(
url,
headers={"User-Agent": "unsafe-rust-skill-evaluation/1 authority-freeze"},
)
with urllib.request.urlopen(request, timeout=60) as response:
body = response.read()
return {
"final_url": response.geturl(),
"status": response.status,
"content_type": response.headers.get_content_type(),
"bytes": len(body),
"sha256": sha256(body),
"body": body,
"retrieved_utc": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
}


def build_rows() -> list[dict[str, str]]:
requested = load_urls()
fetched: dict[str, dict[str, object]] = {}
for _mode, requested_url in requested:
fetch_url = without_fragment(requested_url)
if fetch_url not in fetched:
fetched[fetch_url] = fetch(fetch_url)

rows: list[dict[str, str]] = []
for mode, requested_url in requested:
fetch_url = without_fragment(requested_url)
result = fetched[fetch_url]
found = fragment_present(requested_url, result["body"])
if not found:
raise ValueError(f"fragment not present in retrieved page: {requested_url}")
rows.append(
{
"mode": mode,
"requested_url": requested_url,
"fetch_url": fetch_url,
"final_url": str(result["final_url"]),
"status": str(result["status"]),
"content_type": str(result["content_type"]),
"bytes": str(result["bytes"]),
"sha256": str(result["sha256"]),
"fragment_found": "true",
"retrieved_utc": str(result["retrieved_utc"]),
}
)
return rows


def render(rows: list[dict[str, str]]) -> str:
output = io.StringIO(newline="")
writer = csv.DictWriter(output, fieldnames=FIELDS, dialect="excel-tab", lineterminator="\n")
writer.writeheader()
writer.writerows(rows)
return output.getvalue()


def read_manifest() -> list[dict[str, str]]:
rows = list(
csv.DictReader(io.StringIO(read_pinned(MANIFEST).decode()), dialect="excel-tab")
)
if not rows or tuple(rows[0]) != FIELDS:
raise ValueError("authority manifest has unexpected columns")
return rows


def verify() -> None:
rows = read_manifest()
expected_pairs = load_urls()
actual_pairs = [(row["mode"], row["requested_url"]) for row in rows]
if actual_pairs != expected_pairs:
raise ValueError("authority manifest does not match allowlist ordering")

fetched: dict[str, dict[str, object]] = {}
for row in rows:
fetch_url = row["fetch_url"]
if fetch_url != without_fragment(row["requested_url"]):
raise ValueError(f"incorrect fetch URL for {row['requested_url']}")
if fetch_url not in fetched:
fetched[fetch_url] = fetch(fetch_url)
result = fetched[fetch_url]
checks = {
"final_url": str(result["final_url"]),
"status": str(result["status"]),
"content_type": str(result["content_type"]),
"bytes": str(result["bytes"]),
"sha256": str(result["sha256"]),
}
for field, actual in checks.items():
if row[field] != actual:
raise ValueError(
f"authority drift for {row['requested_url']}: "
f"{field} frozen={row[field]!r} live={actual!r}"
)
if row["fragment_found"] != "true" or not fragment_present(
row["requested_url"], result["body"]
):
raise ValueError(f"fragment missing for {row['requested_url']}")
print(f"verified {len(rows)} allowlist entries across {len(fetched)} pages")


def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--write", action="store_true", help="retrieve and write the frozen manifest")
parser.add_argument(
"--record-wave",
type=int,
choices=range(1, 6),
help="verify live bytes and append a successful verification event for this collection wave",
)
args = parser.parse_args()
if args.write and args.record_wave is not None:
raise SystemExit("--write and --record-wave are mutually exclusive")
if args.write:
if (RUN / "freeze" / "LOCK.json").exists():
raise SystemExit("refusing to rewrite authority manifest after freeze lock")
MANIFEST.write_text(render(build_rows()))
print(f"wrote {MANIFEST.relative_to(RUN)}")
else:
operation_lock_handle = None
if args.record_wave is not None:
import protocol

operation_lock_handle = protocol.acquire_operation_lock()
protocol.validate_static(require_lock=True, announce=False)
protocol.assert_freeze_locked()
protocol.assert_authority_verification_allowed(args.record_wave)
verify()
if args.record_wave is not None:
protocol.append_event(
"collection",
"authority_verified",
digest=protocol.frozen_file_digest(MANIFEST),
details={"wave": args.record_wave, "entries": len(read_manifest())},
)


if __name__ == "__main__":
main()
23 changes: 23 additions & 0 deletions evals/unsafe-rust/runs/2026-07-31-v3-targeted/freeze/LOCK.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"schema_version": 1,
"status": "FROZEN",
"file_manifest_sha256": "2a036052cd3def40582bbe6c3fa7f81ff0bb4afbc82b86f249885076ae7974b3",
"review_signoffs": [
{
"reviewer_id": "codex-analyze-n-overall",
"verdict": "PASS/FREEZE",
"file_manifest_sha256": "2a036052cd3def40582bbe6c3fa7f81ff0bb4afbc82b86f249885076ae7974b3",
"scope": "Independent authentication and holistic review of all 47 manifest-listed bytes: protocol.py, prepare.py, fetch_authority.py, frozen plan/manifest/policies/prompts/schemas/randomization/allowlists/authority manifest/oracles/rubrics, sealed maps/seeds, V3 and V2 package identities, all eight target identities and source-oracle claims, and zero-report precollection state.",
"reviewed_utc": "2026-08-01T03:16:47Z"
},
{
"reviewer_id": "v3-fixtures-domain-audit",
"verdict": "PASS/FREEZE",
"file_manifest_sha256": "2a036052cd3def40582bbe6c3fa7f81ff0bb4afbc82b86f249885076ae7974b3",
"scope": "Independent byte authentication of all 47 manifest-listed files; complete review of protocol lifecycle, freeze and failure semantics, policies, prompts, schemas, randomization and sealed maps, blinding, authority allowlists and oracle/rubric semantics, V3 and V2 package identities, all eight fixture and target identities, and zero-report precollection state. The 76 allowlist entries across 46 live official pages were also reverified against frozen hashes without recording an event.",
"reviewed_utc": "2026-08-01T03:18:56Z"
}
],
"reports_collected_before_lock": 0,
"locked_utc": "2026-08-01T03:19:11Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
https://doc.rust-lang.org/1.84.0/std/option/enum.Option.html#method.is_none
https://doc.rust-lang.org/1.84.0/std/option/enum.Option.html#method.unwrap_unchecked
https://doc.rust-lang.org/1.84.0/std/option/enum.Option.html#method.unwrap_or
https://doc.rust-lang.org/1.85.0/std/option/enum.Option.html#method.is_none
https://doc.rust-lang.org/1.85.0/std/option/enum.Option.html#method.unwrap_unchecked
https://doc.rust-lang.org/1.85.0/std/option/enum.Option.html#method.unwrap_or
https://doc.rust-lang.org/1.86.0/std/option/enum.Option.html#method.is_none
https://doc.rust-lang.org/1.86.0/std/option/enum.Option.html#method.unwrap_unchecked
https://doc.rust-lang.org/1.86.0/std/option/enum.Option.html#method.unwrap_or
https://doc.rust-lang.org/1.84.0/reference/conditional-compilation.html#conditional-compilation
https://doc.rust-lang.org/1.84.0/reference/conditional-compilation.html#the-cfg-attribute
https://doc.rust-lang.org/1.84.0/std/macro.compile_error.html
https://doc.rust-lang.org/1.85.0/reference/conditional-compilation.html#conditional-compilation
https://doc.rust-lang.org/1.85.0/reference/conditional-compilation.html#the-cfg-attribute
https://doc.rust-lang.org/1.85.0/std/macro.compile_error.html
https://doc.rust-lang.org/1.86.0/reference/conditional-compilation.html#conditional-compilation
https://doc.rust-lang.org/1.86.0/reference/conditional-compilation.html#the-cfg-attribute
https://doc.rust-lang.org/1.86.0/std/macro.compile_error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
https://doc.rust-lang.org/1.82.0/std/primitive.slice.html#method.get_unchecked
https://doc.rust-lang.org/1.82.0/std/primitive.slice.html#method.get_unchecked_mut
https://doc.rust-lang.org/1.82.0/std/primitive.slice.html#method.len
https://doc.rust-lang.org/1.82.0/std/primitive.slice.html#method.is_empty
https://doc.rust-lang.org/1.82.0/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators
https://doc.rust-lang.org/1.82.0/reference/types/numeric.html#integer-types
https://doc.rust-lang.org/1.82.0/reference/items/traits.html#unsafe-traits
https://doc.rust-lang.org/1.82.0/reference/unsafe-keyword.html#unsafe-traits-unsafe-trait
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
https://doc.rust-lang.org/1.80.0/std/ptr/fn.write.html
https://doc.rust-lang.org/1.81.0/std/ptr/fn.write.html
https://doc.rust-lang.org/1.80.0/std/ptr/fn.copy_nonoverlapping.html
https://doc.rust-lang.org/1.80.0/reference/type-layout.html#primitive-data-layout
https://doc.rust-lang.org/1.80.0/std/primitive.u8.html#impl-Copy-for-u8
https://doc.rust-lang.org/1.80.0/std/marker/trait.Copy.html
https://doc.rust-lang.org/1.80.0/std/ptr/fn.read.html
https://doc.rust-lang.org/1.80.0/std/primitive.u32.html#impl-Copy-for-u32
https://doc.rust-lang.org/1.82.0/std/ptr/fn.read.html
https://doc.rust-lang.org/1.82.0/std/primitive.u32.html#impl-Copy-for-u32
https://doc.rust-lang.org/1.82.0/std/marker/trait.Copy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://doc.rust-lang.org/1.80.0/std/hint/fn.unreachable_unchecked.html#safety
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://doc.rust-lang.org/1.82.0/std/primitive.slice.html#method.get_unchecked_mut
https://doc.rust-lang.org/1.82.0/std/primitive.u32.html#method.wrapping_add
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
https://doc.rust-lang.org/1.84.0/std/option/enum.Option.html#method.is_none
https://doc.rust-lang.org/1.84.0/std/option/enum.Option.html#method.unwrap_unchecked
https://doc.rust-lang.org/1.84.1/std/option/enum.Option.html#method.is_none
https://doc.rust-lang.org/1.84.1/std/option/enum.Option.html#method.unwrap_unchecked
https://doc.rust-lang.org/1.85.0/std/option/enum.Option.html#method.is_none
https://doc.rust-lang.org/1.85.0/std/option/enum.Option.html#method.unwrap_unchecked
https://doc.rust-lang.org/1.85.1/std/option/enum.Option.html#method.is_none
https://doc.rust-lang.org/1.85.1/std/option/enum.Option.html#method.unwrap_unchecked
https://doc.rust-lang.org/1.86.0/std/option/enum.Option.html#method.is_none
https://doc.rust-lang.org/1.86.0/std/option/enum.Option.html#method.unwrap_unchecked
https://doc.rust-lang.org/1.86.0/releases.html#version-1841-2025-01-30
https://doc.rust-lang.org/1.86.0/releases.html#version-1851-2025-03-18
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://doc.rust-lang.org/1.80.0/std/hint/fn.unreachable_unchecked.html#safety
https://doc.rust-lang.org/1.80.0/reference/behavior-considered-undefined.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
https://doc.rust-lang.org/1.85.1/std/num/struct.NonZero.html#method.new_unchecked
https://doc.rust-lang.org/1.85.1/reference/expressions/operator-expr.html#comparison-operators
https://doc.rust-lang.org/1.85.1/reference/expressions/if-expr.html
https://doc.rust-lang.org/1.85.1/std/macro.panic.html
https://doc.rust-lang.org/1.85.1/std/env/fn.var.html
https://doc.rust-lang.org/1.85.1/std/string/struct.String.html#method.as_str
https://doc.rust-lang.org/1.85.1/std/primitive.str.html#impl-ToOwned-for-str
https://doc.rust-lang.org/1.85.1/std/fmt/index.html#syntax
https://doc.rust-lang.org/1.85.1/reference/expressions/block-expr.html
https://doc.rust-lang.org/1.85.1/reference/expressions/match-expr.html
https://doc.rust-lang.org/1.85.1/reference/patterns.html#literal-patterns
https://doc.rust-lang.org/1.85.1/reference/patterns.html#or-patterns
https://doc.rust-lang.org/1.85.1/reference/patterns.html#wildcard-pattern
https://doc.rust-lang.org/1.85.1/std/macro.println.html
https://doc.rust-lang.org/1.85.1/reference/conditional-compilation.html#conditional-compilation
https://doc.rust-lang.org/1.85.1/reference/conditional-compilation.html#the-cfg-attribute
https://doc.rust-lang.org/1.85.1/std/macro.compile_error.html
https://doc.rust-lang.org/1.85.1/cargo/reference/build-scripts.html#rustc-cfg
https://doc.rust-lang.org/1.85.1/cargo/reference/build-scripts.html#rustc-check-cfg
https://doc.rust-lang.org/1.85.1/cargo/reference/build-scripts.html#rerun-if-env-changed
https://doc.rust-lang.org/1.85.1/cargo/reference/build-scripts.html#life-cycle-of-a-build-script
https://doc.rust-lang.org/1.85.1/cargo/reference/features.html
Loading