#!/usr/bin/env python3 """Build and validate the frozen DeepResearch-9K frontier-v1 release. The internal builder creates a thin release whose multi-gigabyte SQLite corpus is a relative symlink. The validator also accepts the standalone Hub layout, where that same database is an embedded regular file excluded from the small artifact checksum list and pinned separately in ``manifest.json``. Keeping the complete corpus preserves FTS/BM25 ranks; extracting only answer-bearing pages would make the benchmark a different (and much easier) retrieval task. """ from __future__ import annotations import argparse import hashlib import json import os import shutil import sqlite3 import tempfile from collections import Counter, defaultdict from datetime import datetime, timezone from pathlib import Path from typing import Any, Iterable try: from .common import read_jsonl from .corpus_db import fts_counts, search_docids, status_counts except ImportError: # direct script execution from common import read_jsonl from corpus_db import fts_counts, search_docids, status_counts RELEASE_NAME = "deepresearch9k-frontier-v1" DATABASE_RELEASE_PATH = Path("search/corpus.sqlite3") CHECKSUMS_PATH = Path("checksums.sha256") MANIFEST_PATH = Path("manifest.json") PROBE_QUERIES = ( "research history university film", "Eye Of The Eagle Italian beach comedy filmmaker", ) def sha256_file(path: Path) -> str: digest = hashlib.sha256() with path.open("rb") as handle: for chunk in iter(lambda: handle.read(8 * 1024 * 1024), b""): digest.update(chunk) return digest.hexdigest() def load_json(path: Path) -> dict[str, Any]: value = json.loads(path.read_text(encoding="utf-8")) if not isinstance(value, dict): raise ValueError(f"expected a JSON object: {path}") return value def write_json(path: Path, value: Any) -> None: path.write_text( json.dumps(value, ensure_ascii=False, indent=2, sort_keys=True) + "\n", encoding="utf-8", ) def require(condition: bool, message: str) -> None: if not condition: raise ValueError(message) def relative_artifact(path: str | Path) -> Path: result = Path(path) require(not result.is_absolute(), f"release artifact path must be relative: {result}") require(".." not in result.parts, f"release artifact path escapes release: {result}") return result def benchmark_inventory(rows: Iterable[dict[str, Any]]) -> dict[str, Any]: rows = list(rows) require(bool(rows), "benchmark has no questions") qids: list[str] = [] indexes: list[int] = [] composition: dict[str, Counter[str]] = defaultdict(Counter) difficulties: Counter[str] = Counter() teacher_correct: Counter[str] = Counter() provenance_docids: set[str] = set() for position, row in enumerate(rows): metadata = row.get("metadata") or {} benchmark = metadata.get("benchmark") or {} qid = str(metadata.get("qid") or "") index = benchmark.get("index") require(qid != "", f"question {position} has no qid") require(metadata.get("manifest_qid") == qid, f"question {position} manifest_qid mismatch") require(index == position, f"question {position} has benchmark index {index!r}") require(benchmark.get("name") == RELEASE_NAME, f"question {position} benchmark name mismatch") require(str(row.get("label") or "").strip() != "", f"question {position} has an empty label") require(isinstance(row.get("prompt"), list) and row["prompt"], f"question {position} has no prompt") tier = str(benchmark.get("calibration_tier") or "") bucket = str(benchmark.get("selection_bucket") or "") require(tier in {"frontier", "challenge"}, f"question {position} has invalid tier {tier!r}") require(bucket in {"hard_open", "reformulate"}, f"question {position} has invalid bucket {bucket!r}") docids = benchmark.get("clean_provenance_answer_docids") or [] require(bool(docids), f"question {position} has no clean provenance answer document") require(all(isinstance(docid, str) and docid for docid in docids), f"question {position} has invalid docids") qids.append(qid) indexes.append(int(index)) composition[tier][bucket] += 1 difficulties[str(metadata.get("difficulty"))] += 1 teacher_correct[str(bool(metadata.get("teacher_correct"))).lower()] += 1 provenance_docids.update(docids) require(len(set(qids)) == len(qids), "benchmark contains duplicate qids") require(indexes == list(range(len(rows))), "benchmark indexes are not contiguous") return { "questions": len(rows), "unique_qids": len(set(qids)), "index_range": [0, len(rows) - 1], "composition": { tier: dict(sorted(buckets.items())) for tier, buckets in sorted(composition.items()) }, "difficulty": dict(sorted(difficulties.items())), "teacher_correct": dict(sorted(teacher_correct.items())), "clean_provenance_answer_documents": len(provenance_docids), } def result_inventory( rows: Iterable[dict[str, Any]], questions: list[dict[str, Any]], *, seed_base: int, ) -> dict[str, Any]: rows = list(rows) require(len(rows) == len(questions), f"result has {len(rows)} rows, expected {len(questions)}") expected = { int(question["metadata"]["benchmark"]["index"]): question["metadata"]["qid"] for question in questions } seen: set[int] = set() judge_correct = 0.0 local_em_correct = 0.0 turns = 0 searches = 0 opens = 0 empty_answers = 0 stop_reasons: Counter[str] = Counter() by_stratum: dict[str, Counter[str]] = defaultdict(Counter) for row in rows: index = int(row["index"]) require(index not in seen, f"duplicate result index {index}") require(expected.get(index) == row.get("qid"), f"result qid mismatch at index {index}") require(row.get("sampling_seed") == seed_base + index, f"sampling seed mismatch at index {index}") seen.add(index) judge_score = float(row.get("judge_score", 0) or 0) local_em = float(row.get("local_em", 0) or 0) require(judge_score in {0.0, 1.0}, f"invalid judge score at index {index}") require(local_em in {0.0, 1.0}, f"invalid local EM at index {index}") judge_correct += judge_score local_em_correct += local_em turns += int(row.get("num_turns", 0) or 0) tool_stats = row.get("tool_stats") or {} searches += int(tool_stats.get("search", 0) or 0) opens += int(tool_stats.get("open_page", 0) or 0) empty_answers += int(not str(row.get("predicted") or "").strip()) stop_reasons[str(row.get("stop_reason") or "unknown")] += 1 benchmark = row.get("benchmark") or {} stratum = f"{benchmark.get('calibration_tier')}/{benchmark.get('selection_bucket')}" by_stratum[stratum]["questions"] += 1 by_stratum[stratum]["judge_correct"] += int(judge_score) by_stratum[stratum]["local_em_correct"] += int(local_em) require(seen == set(expected), "result indexes do not exactly cover the benchmark") count = len(rows) return { "questions": count, "sampling_seed_base": seed_base, "sampling_seed_range": [seed_base, seed_base + count - 1], "judge_correct": int(judge_correct), "judge_accuracy": judge_correct / count, "local_em_correct": int(local_em_correct), "local_em_accuracy": local_em_correct / count, "mean_turns": turns / count, "search_calls": searches, "open_page_calls": opens, "empty_answers": empty_answers, "stop_reasons": dict(sorted(stop_reasons.items())), "by_stratum": { stratum: dict(sorted(values.items())) for stratum, values in sorted(by_stratum.items()) }, } def connect_immutable(path: Path) -> sqlite3.Connection: connection = sqlite3.connect( f"file:{path.resolve()}?mode=ro&immutable=1", uri=True, check_same_thread=False, ) connection.row_factory = sqlite3.Row return connection def database_inventory(path: Path) -> dict[str, Any]: connection = connect_immutable(path) try: statuses = status_counts(connection) indexed = fts_counts(connection) return { "sqlite_version": sqlite3.sqlite_version, "page_size": int(connection.execute("PRAGMA page_size").fetchone()[0]), "page_count": int(connection.execute("PRAGMA page_count").fetchone()[0]), "freelist_count": int(connection.execute("PRAGMA freelist_count").fetchone()[0]), "documents": int(connection.execute("SELECT count(*) FROM documents").fetchone()[0]), "fetch_status": dict(sorted(statuses.items())), "url_aliases": int(connection.execute("SELECT count(*) FROM url_aliases").fetchone()[0]), "qid_links": int(connection.execute("SELECT count(*) FROM document_qids").fetchone()[0]), "distinct_qids": int( connection.execute("SELECT count(DISTINCT qid) FROM document_qids").fetchone()[0] ), "domains": int(connection.execute("SELECT count(DISTINCT domain) FROM documents").fetchone()[0]), "fts_documents": indexed["documents"], "fts_chunks": indexed["chunks"], } finally: connection.close() def search_probe_inventory(path: Path, blocked: frozenset[str]) -> list[dict[str, Any]]: connection = connect_immutable(path) try: return [ { "query": query, "k": 5, "docids": search_docids(connection, query, 5, excluded_docids=blocked), } for query in PROBE_QUERIES ] finally: connection.close() def copied_source_layout(data_root: Path, base_results_dir: Path, rl_results_dir: Path) -> dict[Path, Path]: frontier = data_root / "benchmarks/frontier_v1" candidates = data_root / "benchmarks/frontier_candidates_v1" pilot_results = data_root / "eval/frontier_base_pilot_v1_20260810_2202_merged" return { Path("benchmark/questions.jsonl"): frontier / "questions.jsonl", Path("benchmark/blocked_docids.txt"): frontier / "blocked_docids.txt", Path("benchmark/summary.json"): frontier / "summary.json", Path("selection/pilot_audit.jsonl"): frontier / "pilot_audit.jsonl", Path("selection/pilot_supply.json"): frontier / "pilot_supply.json", Path("selection/candidates.jsonl"): candidates / "candidates.jsonl", Path("selection/pilot_data.jsonl"): candidates / "base_pilot.jsonl", Path("selection/candidate_summary.json"): candidates / "summary.json", Path("selection/blocked_documents.jsonl"): candidates / "blocked_documents.jsonl", Path("selection/pilot_results.jsonl"): pilot_results / "final_results.jsonl", Path("baselines/qwen3-8b/final_results.jsonl"): base_results_dir / "final_results.jsonl", Path("baselines/qwen3-8b/summary.json"): base_results_dir / "final_results.summary.json", Path("baselines/browsecomp-rl-iter199/final_results.jsonl"): rl_results_dir / "final_results.jsonl", Path("baselines/browsecomp-rl-iter199/summary.json"): rl_results_dir / "final_results.summary.json", Path("search/coverage_summary.json"): data_root / "coverage_full_hq/summary.json", Path("search/source_manifest_summary.json"): data_root / "train_manifest_final/summary.json", } def regular_release_files(release_dir: Path) -> list[Path]: return sorted( path.relative_to(release_dir) for path in release_dir.rglob("*") if path.is_file() and not path.is_symlink() and path.relative_to(release_dir) not in { CHECKSUMS_PATH, DATABASE_RELEASE_PATH, } and not ( {".cache", "__pycache__"} & set(path.relative_to(release_dir).parts) ) ) def write_checksums(release_dir: Path) -> None: lines = [ "# Regular release artifacts. The 3.5 GB database is pinned in manifest.json", "# and is hashed by: frontier_release.py validate --deep", ] for relative in regular_release_files(release_dir): lines.append(f"{sha256_file(release_dir / relative)} {relative.as_posix()}") (release_dir / CHECKSUMS_PATH).write_text("\n".join(lines) + "\n", encoding="utf-8") def checksums_from_file(path: Path) -> dict[Path, str]: result: dict[Path, str] = {} for line_number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), start=1): if not line or line.startswith("#"): continue parts = line.split(None, 1) require(len(parts) == 2, f"invalid checksum line {line_number}") digest, filename = parts relative = relative_artifact(filename.strip()) require(len(digest) == 64, f"invalid SHA-256 on checksum line {line_number}") require(relative not in result, f"duplicate checksum entry: {relative}") result[relative] = digest return result def release_readme(manifest: dict[str, Any]) -> str: database = manifest["database"] base = manifest["baselines"]["qwen3-8b"]["metrics"] rl = manifest["baselines"]["browsecomp-rl-iter199"]["metrics"] return f"""# DeepResearch-9K frontier-v1 frozen diagnostic release This directory binds one evaluation set to the exact offline-search snapshot, selection audit, and paired reference runs used with it. It is an **internal, train-provenance diagnostic**, not a clean held-out DeepResearch-9K score. Do not replace `search/corpus.sqlite3` with a database containing only the answer pages. The release uses the complete {database['inventory']['documents']:,}-URL snapshot because removing distractors changes FTS/BM25 ranks and task difficulty. The database file is a relative symlink to the canonical {database['size_bytes'] / 2**30:.2f} GiB snapshot and is pinned by SHA-256 in `manifest.json`. ## Contents - `benchmark/`: 256 frozen questions, 28 blocked dataset/dump documents, and the final selection summary. - `selection/`: complete 672-question candidate/pilot audit needed to explain why each final question was admitted. - `search/`: the corpus link plus crawl/coverage summaries. - `baselines/`: fresh, paired Qwen3-8B and BrowseComp-RL iter199 results. - `manifest.json`: machine-readable composition, hashes, corpus statistics, retrieval probes, sampling protocol, and baseline metrics. The paired semantic scores are {base['judge_correct']}/256 ({base['judge_accuracy']:.1%}) for Qwen3-8B and {rl['judge_correct']}/256 ({rl['judge_accuracy']:.1%}) for BrowseComp-RL iter199. These are reference runs, not outputs used to select the final 256 questions. ## Validate From the Miles repository root: ```bash python examples/deepresearch9k/frontier_release.py validate \ --release-dir {manifest['release']['canonical_path']} ``` The default validates all small-file hashes, benchmark/result alignment, blocked and answer-bearing document membership, SQLite metadata, and frozen search probes. Use `--deep` before publishing or moving the package; it also hashes the 3.5 GB database and runs SQLite `PRAGMA quick_check`. ## Serve local search ```bash release={manifest['release']['canonical_path']} export DEEPRESEARCH9K_BLOCKED_DOCIDS_FILE="$release/benchmark/blocked_docids.txt" python examples/deepresearch9k/search_server.py \ --database "$release/search/corpus.sqlite3" --host 127.0.0.1 --port 8011 ``` ## Launch a matched evaluation ```bash release={manifest['release']['canonical_path']} DR9K_DATABASE="$release/search/corpus.sqlite3" \ DR9K_EVAL_DATA="$release/benchmark/questions.jsonl" \ DR9K_BLOCKED_DOCIDS_FILE="$release/benchmark/blocked_docids.txt" \ DR9K_MODEL=/path/to/checkpoint \ DR9K_RUN_PREFIX=frontier_v1_my_checkpoint \ EVAL_SEED_BASE=20260811 \ SHARD_SIZE=64 \ sbatch --array=0-3%4 examples/deepresearch9k/run_local_eval_gb300.sbatch ``` Keep temperature `0.6`, top-p `0.95`, top-k `20`, maximum 20 turns, and the same per-index seed when making a paired comparison. New random seeds should be stored as new result runs; do not mutate this release in place. """ def build_release(args: argparse.Namespace) -> Path: data_root = args.data_root.resolve() database = (args.database or data_root / "train_corpus_full_hq.sqlite3").resolve() base_results_dir = ( args.base_results_dir or data_root / "eval/frontier_v1_base_qwen3_8b_seed20260811_2215_merged" ).resolve() rl_results_dir = ( args.rl_results_dir or data_root / "eval/frontier_v1_iter199_seed20260811_2219_merged" ).resolve() output = (args.output_dir or data_root / "releases/frontier_v1").resolve() require(not output.exists(), f"refusing to overwrite existing release: {output}") require(database.is_file(), f"database does not exist: {database}") wal_path = Path(str(database) + "-wal") require(not wal_path.exists() or wal_path.stat().st_size == 0, f"database WAL is not empty: {wal_path}") sources = copied_source_layout(data_root, base_results_dir, rl_results_dir) missing = [str(source) for source in sources.values() if not source.is_file()] require(not missing, "missing source artifacts:\n" + "\n".join(missing)) output.parent.mkdir(parents=True, exist_ok=True) staging = Path(tempfile.mkdtemp(prefix=f".{output.name}.", dir=output.parent)) try: artifact_manifest: dict[str, dict[str, Any]] = {} for relative, source in sources.items(): destination = staging / relative destination.parent.mkdir(parents=True, exist_ok=True) shutil.copy2(source, destination) artifact_manifest[relative.as_posix()] = { "sha256": sha256_file(destination), "size_bytes": destination.stat().st_size, } link_path = staging / DATABASE_RELEASE_PATH link_path.parent.mkdir(parents=True, exist_ok=True) link_target = os.path.relpath(database, start=link_path.parent) link_path.symlink_to(link_target) questions = list(read_jsonl(staging / "benchmark/questions.jsonl")) blocked = frozenset( line.strip() for line in (staging / "benchmark/blocked_docids.txt").read_text(encoding="utf-8").splitlines() if line.strip() ) benchmark = benchmark_inventory(questions) require(len(blocked) == 28, f"expected 28 blocked documents, found {len(blocked)}") candidate_summary = load_json(staging / "selection/candidate_summary.json") database_sha256 = sha256_file(database) require( candidate_summary.get("database_sha256") == database_sha256, "database no longer matches the snapshot used to build frontier candidates", ) inventory = database_inventory(database) probes = search_probe_inventory(database, blocked) baseline_specs = { "qwen3-8b": ("baselines/qwen3-8b/final_results.jsonl", "baselines/qwen3-8b/summary.json"), "browsecomp-rl-iter199": ( "baselines/browsecomp-rl-iter199/final_results.jsonl", "baselines/browsecomp-rl-iter199/summary.json", ), } baselines: dict[str, dict[str, Any]] = {} for name, (results_path, summary_path) in baseline_specs.items(): summary = load_json(staging / summary_path) results = list(read_jsonl(staging / results_path)) metrics = result_inventory(results, questions, seed_base=args.seed_base) require(summary.get("questions") == len(questions), f"{name} summary question count mismatch") require( summary.get("output_sha256") == artifact_manifest[results_path]["sha256"], f"{name} summary result hash mismatch", ) require( int(summary["judge_score"]["correct"]) == metrics["judge_correct"], f"{name} summary judge score mismatch", ) baselines[name] = { "model_label": summary.get("model_label"), "results": results_path, "summary": summary_path, "metrics": metrics, } manifest = { "schema_version": 1, "release": { "name": RELEASE_NAME, "canonical_path": str(output), "created_at_utc": datetime.now(timezone.utc).isoformat(), "classification": "internal_train_provenance_model_calibrated_diagnostic", "held_out_claim_allowed": False, }, "benchmark": { "questions": "benchmark/questions.jsonl", "blocked_docids": "benchmark/blocked_docids.txt", "inventory": benchmark, "blocked_documents": len(blocked), }, "selection": { "candidate_questions": 672, "pilot_episodes": 2016, "pilot_replicas_per_qid": 3, "selection_seed": 20260810, "warning": "Base pilot outputs selected the final qids; only fresh baseline results are scores.", }, "sampling_protocol": { "temperature": 0.6, "top_p": 0.95, "top_k": 20, "maximum_agent_turns": 20, "seed_base": args.seed_base, "per_question_seed": "seed_base + benchmark index", }, "database": { "path": DATABASE_RELEASE_PATH.as_posix(), "storage": "relative_symlink_to_canonical_snapshot", "link_target": link_target, "sha256": database_sha256, "size_bytes": database.stat().st_size, "hash_scope": "main SQLite file; build requires an absent or empty WAL", "retrieval": "SQLite FTS5 unicode61, 800-word chunks, 100-word overlap, BM25", "inventory": inventory, "search_probes": probes, }, "baselines": baselines, "artifacts": artifact_manifest, } write_json(staging / MANIFEST_PATH, manifest) (staging / "README.md").write_text(release_readme(manifest), encoding="utf-8") write_checksums(staging) validate_release(staging, deep=False) staging.rename(output) except Exception: shutil.rmtree(staging, ignore_errors=True) raise return output def validate_database_membership( database: Path, questions: list[dict[str, Any]], blocked: frozenset[str], ) -> dict[str, int]: provenance = { docid for question in questions for docid in question["metadata"]["benchmark"]["clean_provenance_answer_docids"] } requested = sorted(provenance | set(blocked)) connection = connect_immutable(database) try: found: dict[str, sqlite3.Row] = {} for start in range(0, len(requested), 500): chunk = requested[start : start + 500] placeholders = ",".join("?" for _ in chunk) for row in connection.execute( f"SELECT url_id,status,length(trim(text)) AS text_length FROM documents WHERE url_id IN ({placeholders})", chunk, ): found[str(row["url_id"])] = row missing_provenance = provenance - set(found) require(not missing_provenance, f"missing provenance documents: {sorted(missing_provenance)[:5]}") bad_provenance = [ docid for docid in provenance if found[docid]["status"] != "success" or int(found[docid]["text_length"] or 0) == 0 ] require(not bad_provenance, f"unusable provenance documents: {sorted(bad_provenance)[:5]}") require(not (provenance & blocked), "answer-bearing provenance overlaps blocked documents") missing_blocked = blocked - set(found) require(not missing_blocked, f"blocked docids absent from database: {sorted(missing_blocked)[:5]}") indexed = fts_counts(connection) return { "provenance_documents": len(provenance), "blocked_documents": len(blocked), "fts_documents": indexed["documents"], "fts_chunks": indexed["chunks"], } finally: connection.close() def validate_release(release_dir: Path, *, deep: bool) -> dict[str, Any]: release_dir = release_dir.resolve() require((release_dir / MANIFEST_PATH).is_file(), f"missing {MANIFEST_PATH}") require((release_dir / CHECKSUMS_PATH).is_file(), f"missing {CHECKSUMS_PATH}") manifest = load_json(release_dir / MANIFEST_PATH) require(manifest.get("schema_version") == 1, "unsupported release schema") require(manifest.get("release", {}).get("name") == RELEASE_NAME, "release name mismatch") checksums = checksums_from_file(release_dir / CHECKSUMS_PATH) expected_regular = set(regular_release_files(release_dir)) require(set(checksums) == expected_regular, "checksums.sha256 does not exactly cover regular release files") for relative, expected_digest in checksums.items(): path = release_dir / relative require(path.is_file() and not path.is_symlink(), f"missing regular artifact: {relative}") require(sha256_file(path) == expected_digest, f"checksum mismatch: {relative}") for filename, metadata in manifest.get("artifacts", {}).items(): relative = relative_artifact(filename) path = release_dir / relative require(path.is_file(), f"missing manifest artifact: {relative}") require(path.stat().st_size == metadata["size_bytes"], f"size mismatch: {relative}") require(checksums.get(relative) == metadata["sha256"], f"manifest hash mismatch: {relative}") questions_path = release_dir / manifest["benchmark"]["questions"] blocked_path = release_dir / manifest["benchmark"]["blocked_docids"] questions = list(read_jsonl(questions_path)) blocked = frozenset( line.strip() for line in blocked_path.read_text(encoding="utf-8").splitlines() if line.strip() ) benchmark = benchmark_inventory(questions) require(benchmark == manifest["benchmark"]["inventory"], "benchmark inventory mismatch") require(len(blocked) == manifest["benchmark"]["blocked_documents"], "blocked count mismatch") database_metadata = manifest["database"] database = release_dir / relative_artifact(database_metadata["path"]) require(database.is_file(), f"missing database target: {database}") require(database.stat().st_size == database_metadata["size_bytes"], "database size mismatch") membership = validate_database_membership(database, questions, blocked) require( membership["fts_documents"] == database_metadata["inventory"]["fts_documents"], "FTS document count mismatch", ) require( membership["fts_chunks"] == database_metadata["inventory"]["fts_chunks"], "FTS chunk count mismatch", ) probes = search_probe_inventory(database, blocked) require(probes == database_metadata["search_probes"], "frozen search probe results changed") seed_base = int(manifest["sampling_protocol"]["seed_base"]) baseline_metrics: dict[str, dict[str, Any]] = {} for name, baseline in manifest["baselines"].items(): rows = list(read_jsonl(release_dir / relative_artifact(baseline["results"]))) metrics = result_inventory(rows, questions, seed_base=seed_base) require(metrics == baseline["metrics"], f"baseline metrics mismatch: {name}") baseline_metrics[name] = metrics deep_checks: dict[str, Any] | None = None if deep: database_sha256 = sha256_file(database) require(database_sha256 == database_metadata["sha256"], "database SHA-256 mismatch") connection = connect_immutable(database) try: quick_check = [str(row[0]) for row in connection.execute("PRAGMA quick_check")] finally: connection.close() require(quick_check == ["ok"], f"SQLite quick_check failed: {quick_check[:5]}") deep_checks = {"database_sha256": database_sha256, "sqlite_quick_check": "ok"} return { "release": RELEASE_NAME, "release_dir": str(release_dir), "questions": len(questions), "blocked_documents": len(blocked), "database_membership": membership, "search_probes": len(probes), "baselines": { name: { "judge_correct": metrics["judge_correct"], "judge_accuracy": metrics["judge_accuracy"], } for name, metrics in baseline_metrics.items() }, "deep_checks": deep_checks, "status": "ok", } def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser(description=__doc__) subparsers = parser.add_subparsers(dest="command", required=True) build = subparsers.add_parser("build", help="create a new frozen thin release") build.add_argument("--data-root", type=Path, required=True) build.add_argument("--database", type=Path) build.add_argument("--base-results-dir", type=Path) build.add_argument("--rl-results-dir", type=Path) build.add_argument("--output-dir", type=Path) build.add_argument("--seed-base", type=int, default=20260811) validate = subparsers.add_parser("validate", help="validate an existing release") validate.add_argument("--release-dir", type=Path, required=True) validate.add_argument( "--deep", action="store_true", help="also hash the multi-gigabyte database and run SQLite quick_check", ) return parser.parse_args() def main() -> None: args = parse_args() if args.command == "build": output = build_release(args) result = validate_release(output, deep=False) result["created"] = str(output) else: result = validate_release(args.release_dir, deep=args.deep) print(json.dumps(result, ensure_ascii=False, indent=2, sort_keys=True)) if __name__ == "__main__": main()