From f9db45388b1292d780479776388713d60f5dbca1 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sat, 24 Oct 2026 13:17:06 -0500 Subject: [PATCH 1/2] feat(prereg): SI Genesis E2 / Fusion E1 preregistration and validator (#39, #38) - manifests/prereg/si_genesis_e2.json: aien-bench-prereg/1 plan. Arms: rules, retrieval-only, frozen pretrained 0.8B/2B, 27B, 35B, multi-teacher verified, distilled Fusion student, experience-only scratch SI, SI+teacher, shuffled and revoked experience controls. Five seeded resettable environment families incl. interrupted-objective tasks. Judge-held sealed split with commit-before-reveal, single use and two fresh reserves. Exact McNemar power (Wolfram): E2 600 episodes / 50 tasks, effective n 387, power 0.9057; E1 99 objectives, power 0.8326. Turing profile B,D,G,P with T_ideal and T_real separate; T/J not allowed (energy NOT_MEASURED). Status SCOPED, all results NOT_RUN. - src/prereg.rs, src/bin/bench_verify_prereg.rs: offline validator. Refuses missing baseline_before_eval or phase order, missing/empty G background, advisers not declared in G, T/J without measured energy, unpinned G once FROZEN, inconsistent or underpowered sample sizes, unsealed held-out. - tests/prereg_manifest.rs: committed manifest passes; mutated copies are refused with exact defect lines. - src/evidence.rs: share helpers within the crate; README and PERF_INDEX. Assisted-by: omp agent BenchPrereg (Claude) Signed-off-by: Drake Stapleton --- README.md | 11 +- docs/PERF_INDEX.md | 2 + manifests/prereg/si_genesis_e2.json | 663 ++++++++++++++++++++++++++++ src/bin/bench_verify_prereg.rs | 57 +++ src/evidence.rs | 10 +- src/lib.rs | 1 + src/prereg.rs | 642 +++++++++++++++++++++++++++ tests/prereg_manifest.rs | 289 ++++++++++++ 8 files changed, 1668 insertions(+), 7 deletions(-) create mode 100644 manifests/prereg/si_genesis_e2.json create mode 100644 src/bin/bench_verify_prereg.rs create mode 100644 src/prereg.rs create mode 100644 tests/prereg_manifest.rs diff --git a/README.md b/README.md index b054dc6..165a63b 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,11 @@ The rules of the race (the frozen contract) are in [CONTRACT.md](prime-drag-race | Path | What it is | | :--- | :--- | | `prime-drag-race/` | Prime Drag Race suite runner (`prime_race`), contract, results and sealed evidence. A standalone Rust crate. | -| `src/` | The `aien-benchmarks` measurement harness and four helper programs: `bench_canonical_suite`, `bench_branching_neutral`, `bench_verify_records`, `bench_index`. | +| `src/` | The `aien-benchmarks` measurement harness and five helper programs: `bench_canonical_suite`, `bench_branching_neutral`, `bench_verify_records`, `bench_verify_prereg`, `bench_index`. | | `data/` | Datasets from the withdrawn 2026-09-19 sweep, kept as recorded. | | `artifacts/gb10_canonical_1789907893_4d762/` | One withdrawn GB10 run bundle with its `SHA256SUMS` file. | | `assets/` | SVG charts drawn from `data/`. | -| `manifests/` | Workload manifests read by `bench_branching_neutral` and `bench_canonical_suite`. | +| `manifests/` | Workload manifests read by `bench_branching_neutral` and `bench_canonical_suite`; `manifests/prereg/` holds preregistrations checked by `bench_verify_prereg`. | | `docs/` | [PIPELINE.md](docs/PIPELINE.md) (how pull requests are tested and merged), [PERF_INDEX.md](docs/PERF_INDEX.md) (generated index), [LIVE_PRESSURE_BENCHMARK.md](docs/LIVE_PRESSURE_BENCHMARK.md) (an older pressure benchmark write-up, not regenerated under the evidence standard). | | `tests/gates/` | The Spark test gates (see [How changes are tested](#how-changes-are-tested)). | | `tests/fixtures/records/` | Good and bad example records for the evidence check. | @@ -84,6 +84,9 @@ cargo run --release -- report # Check records and artifact bundles offline (one line per defect) cargo run --release --bin bench_verify_records -- records artifacts tests/fixtures/records/good +# Check preregistration manifests offline (one line per defect) +cargo run --release --bin bench_verify_prereg -- manifests/prereg + # Check that docs/PERF_INDEX.md matches the generator (drop --check to rewrite it) cargo run --release --bin bench_index -- --check @@ -177,6 +180,10 @@ Status words in a record (source: `src/evidence.rs`): - **FAIL**: the run happened and did not meet its acceptance check; kept as evidence. - **SUPERSEDED**: replaced by a newer record. +### Preregistration + +A campaign that compares learning arms is declared before any candidate is trained, in an `aien-bench-prereg/1` file under `manifests/prereg/`: arms, environments, the sealed held-out split and how non-access is enforced, metrics, sample sizes with their power calculation, stopping rules and the Turing profile `T(M;B,D,G,P)` with `T_ideal` and `T_real` kept apart. A preregistration is a plan and carries no measurements. `cargo run --release --bin bench_verify_prereg` (default path `manifests/prereg`) prints one `path: field: reason` line per defect. It refuses a file without `baseline_before_eval` (baselines run and frozen before any evaluation), without a non-empty `G` background naming every pretrained adviser and toolchain an arm uses, with T/J allowed while energy is not `MEASURED`, with unpinned background revisions once `FROZEN`, or with a sample size whose design effect, effective n or power does not add up (source: `src/prereg.rs`). [manifests/prereg/si_genesis_e2.json](manifests/prereg/si_genesis_e2.json) is the SI Genesis E2 and Fusion E1 plan for issues #39 and #38; its status is `SCOPED` and every result in it is `NOT_RUN`. + ## Hardware All measurements here come from one NVIDIA DGX Spark (`spark-b87b`), Grace Blackwell GB10, aarch64. The withdrawn dataset `data/benchmarks_latest.json` records kernel `7.0.0-1019-nvidia` and `rustc 1.98.1 (48a229cea 2026-09-01)`. On 2026-10-19 the Spark reported the same kernel and compiler, a 4096-byte page size (`getconf PAGESIZE`) and 121 GiB of memory (`free -g`). Nothing in this repository measures or tests any other platform. Work across other machines is planned in issues #31 and #32 and has no results yet. diff --git a/docs/PERF_INDEX.md b/docs/PERF_INDEX.md index fb366b2..1b78578 100644 --- a/docs/PERF_INDEX.md +++ b/docs/PERF_INDEX.md @@ -30,6 +30,7 @@ Scanned: `src/**/*.rs`, `prime-drag-race/src/**/*.rs`. The text is the first `// | `src/bin/bench_branching_neutral.rs` | Neutral out-of-process benchmark runner for agentic branching suites on NVIDIA DGX Spark GB10. | | `src/bin/bench_canonical_suite.rs` | Canonical Blackwell GB10 Inference Benchmark Suite | | `src/bin/bench_index.rs` | Writes (or with `--check`, compares) `docs/PERF_INDEX.md`, the generated discovery index. | +| `src/bin/bench_verify_prereg.rs` | Offline preregistration check: validates `aien-bench-prereg/1` manifests before any run. | | `src/bin/bench_verify_records.rs` | Offline evidence-integrity check: validates benchmark records and SHA256SUMS artifact bundles. | | `src/evidence.rs` | Offline evidence-integrity checks for benchmark records (`aien-bench-record/1`) and SHA256SUMS artifact bundles. | | `src/harness/http_bench.rs` | (no doc comment) | @@ -46,6 +47,7 @@ Scanned: `src/**/*.rs`, `prime-drag-race/src/**/*.rs`. The text is the first `// | `src/main.rs` | (item doc) Execute live measurement sweep, generate benchmark dataset, and render SVG charts | | `src/models.rs` | (item doc) Absent when too few observations exist for a real p95 (see llm_stream::P95_MIN_SAMPLES). | | `src/perf_index.rs` | Generator for `docs/PERF_INDEX.md`, the discovery index of records, artifacts, sources, studies and issues. | +| `src/prereg.rs` | Offline checks for benchmark preregistration manifests (`aien-bench-prereg/1`). | | `src/svg_chart.rs` | (no doc comment) | ## Performance studies diff --git a/manifests/prereg/si_genesis_e2.json b/manifests/prereg/si_genesis_e2.json new file mode 100644 index 0000000..68f0a7d --- /dev/null +++ b/manifests/prereg/si_genesis_e2.json @@ -0,0 +1,663 @@ +{ + "schema": "aien-bench-prereg/1", + "manifest_version": "1.0.0", + "benchmark_suite": "si-genesis-e2", + "prereg_id": "si-genesis-e2-prereg-2026-10-24", + "created_at": "2026-10-24T18:10:04Z", + "status": "SCOPED", + "results_status": "NOT_RUN", + "issues": [ + "aien-dev/benchmarks-mv#39", + "aien-dev/benchmarks-mv#38" + ], + "parent": "aien-dev/aien-architecture-mv#307", + "authority": { + "judge": "Existing independent signed Spark judge with spark-rsi-mv#67 adaptive holdout controls. This file declares the protocol; it is not a second judge or eval authority.", + "never_writable_by": "Any trained, tuned or teacher arm. No arm may write the sealed split, the scorer, this preregistration or the result table.", + "owners": { + "experience_records": "omega-mv#699 (World/Cortex, single authoritative store)", + "scratch_world_model_training": "aien-train#19", + "teacher_fusion_arm": "aien-train#18", + "training_lineage_and_withdrawal": "aien-train#20", + "revocation": "open-humanity#33", + "turing_instrument": "omega-mv#700", + "serving_27b_35b": "aien-sovereign-core-mv#737", + "microjob_wire_abi": "aien-protocols-mv#50" + }, + "freeze_rule": "status SCOPED may still change by reviewed commit. FROZEN requires every G revision pinned, the file digest signed by the judge and no candidate trained yet. After FROZEN any change is a new prereg_id; the old one is SUPERSEDED, never edited." + }, + "phases": [ + "preregistration_freeze", + "seal_commitment", + "baseline_run", + "candidate_training", + "prediction_commit", + "sealed_eval", + "analysis", + "report" + ], + "phase_definitions": { + "preregistration_freeze": "Judge signs the sha256 of this file with status FROZEN.", + "seal_commitment": "Judge draws the sealed seed and publishes only its commitment (see heldout.sealing).", + "baseline_run": "Every baseline arm runs on the calibration split; its predictions, scores and the B coder are signed and frozen before any candidate trains.", + "candidate_training": "Candidate and control arms learn only from the training split within the fixed budget in sample_size.training_budget.", + "prediction_commit": "Each arm receives sealed (prior_state, action) inputs from the judge once and returns predictions whose sha256 is signed before reveal.", + "sealed_eval": "Judge reveals actual next states and scores every committed prediction file once.", + "analysis": "Only the tests in metrics.confirmatory, with the Holm correction declared there.", + "report": "Separate status columns per claim in claims; negative and missing results are kept." + }, + "baseline_before_eval": { + "required": true, + "baseline_arms": [ + "rules_engine", + "retrieval_only", + "frozen_pretrained_small", + "teacher_27b", + "teacher_35b" + ], + "rule": "No candidate or control arm is trained or scored before every listed baseline has completed baseline_run and its signed calibration scores exist. A missing baseline makes every dependent comparison NOT_RUN, never PASS." + }, + "arms": [ + { + "id": "rules_engine", + "role": "baseline", + "kind": "rules", + "description": "Exact hand-written rule engine per environment family; no learning, no model. Also the #38 no-model deterministic operations arm.", + "pretrained": false, + "initialization": "none", + "learns_from": [], + "background_refs": [ + "rules_engine_spec" + ], + "requires_gpu": false, + "e1_label": "deterministic" + }, + { + "id": "retrieval_only", + "role": "baseline", + "kind": "retrieval", + "description": "Nearest checked procedure / stored verified transition from the training split, returned unchanged. No parameter update.", + "pretrained": false, + "initialization": "none", + "learns_from": [ + "training_split_verified_transitions" + ], + "background_refs": [ + "cortex_checked_procedure_snapshot" + ], + "requires_gpu": false + }, + { + "id": "frozen_pretrained_small", + "role": "baseline", + "kind": "frozen_pretrained", + "description": "Unchanged declared-pretrained 0.8B Reflex + 2B student, prompted with the same state/action encoding. Weights never updated.", + "pretrained": true, + "initialization": "pretrained_frozen", + "learns_from": [], + "background_refs": [ + "model_0p8b", + "model_2b" + ], + "requires_gpu": true, + "e1_label": "D" + }, + { + "id": "teacher_27b", + "role": "baseline", + "kind": "frozen_pretrained", + "description": "Unchanged Allen -> 27B route as currently qualified by Sovereign Core.", + "pretrained": true, + "initialization": "pretrained_frozen", + "learns_from": [], + "background_refs": [ + "model_27b" + ], + "requires_gpu": true, + "e1_label": "B" + }, + { + "id": "teacher_35b", + "role": "baseline", + "kind": "frozen_pretrained", + "description": "Unchanged Allen -> 35B route as currently qualified by Sovereign Core.", + "pretrained": true, + "initialization": "pretrained_frozen", + "learns_from": [], + "background_refs": [ + "model_35b" + ], + "requires_gpu": true, + "e1_label": "A" + }, + { + "id": "multi_teacher_verified", + "role": "candidate", + "kind": "fusion_selection", + "description": "Per-sample 27B/35B candidates; an answer counts only after the independent verifier accepts it; teacher output is a hypothesis until verified. Every candidate call is counted.", + "pretrained": true, + "initialization": "pretrained_frozen", + "learns_from": [], + "background_refs": [ + "model_27b", + "model_35b" + ], + "requires_gpu": true, + "e1_label": "C" + }, + { + "id": "fusion_distilled_student", + "role": "candidate", + "kind": "distilled_student", + "description": "#38 arm E: verified teacher-distilled SI student with Microforge. Distillation data are verified teacher outputs on the training split only.", + "pretrained": true, + "initialization": "pretrained_finetuned", + "learns_from": [ + "training_split_verified_teacher_outputs" + ], + "background_refs": [ + "model_2b", + "model_27b", + "model_35b", + "aien_train_engine" + ], + "requires_gpu": true, + "e1_label": "E" + }, + { + "id": "si_experience_only", + "role": "candidate", + "kind": "scratch_world_model", + "description": "PRIMARY. New world model initialized from a declared seed (no pretrained weights, no corpus) and trained only on verified training-split transitions {goal, prior_state_digest, action, predicted next state, actual next state, verification, cost, consent}. Saved verified skills must survive restart.", + "pretrained": false, + "initialization": "scratch_seeded", + "learns_from": [ + "training_split_verified_transitions" + ], + "background_refs": [ + "aien_train_engine", + "om_seeded_compiler" + ], + "requires_gpu": false + }, + { + "id": "si_plus_teacher", + "role": "candidate", + "kind": "scratch_world_model_with_advice", + "description": "Same scratch model and budget as si_experience_only, plus 27B/35B advice admitted only after independent verification (licensed use only).", + "pretrained": false, + "initialization": "scratch_seeded", + "learns_from": [ + "training_split_verified_transitions", + "training_split_verified_teacher_outputs" + ], + "background_refs": [ + "aien_train_engine", + "om_seeded_compiler", + "model_27b", + "model_35b" + ], + "uses_teacher": true, + "requires_gpu": true + }, + { + "id": "shuffled_experience_control", + "role": "control", + "kind": "scratch_world_model", + "description": "Same scratch model, seed and budget as si_experience_only, but next states permuted within (family, action type) so marginals stay and the transition signal is destroyed.", + "pretrained": false, + "initialization": "scratch_seeded", + "learns_from": [ + "training_split_shuffled_transitions" + ], + "background_refs": [ + "aien_train_engine", + "om_seeded_compiler" + ], + "requires_gpu": false + }, + { + "id": "revoked_experience_control", + "role": "control", + "kind": "scratch_world_model", + "description": "si_experience_only rebuilt from initialization after a signed revocation of a judge-chosen owner subset of training traces. Checks that revoked traces leave the training lineage and that performance on revoked-origin structure falls to the level of a model never given them.", + "pretrained": false, + "initialization": "scratch_seeded", + "learns_from": [ + "training_split_verified_transitions_minus_revoked" + ], + "background_refs": [ + "aien_train_engine", + "om_seeded_compiler" + ], + "requires_gpu": false + } + ], + "environments": [ + { + "id": "seeded_stochastic_world", + "family": "stochastic_transition", + "description": "Seeded resettable grid/graph world with stochastic action outcomes; the simulator holds the exact next-state distribution.", + "resettable": true, + "verifier": "Simulator recomputes the exact transition distribution from (seed, state, action); no model judges.", + "correct_if": "Total variation distance between predicted and exact next-state distribution <= 0.10.", + "transfer_splits": [ + "new_layouts", + "interventions_changed_transition_probabilities" + ], + "tasks_sealed": 10 + }, + { + "id": "math_transition_world", + "family": "numeric_physical_law", + "description": "Discrete-time dynamics with hidden constants (conservation, linear and nonlinear laws) in exact rational arithmetic.", + "resettable": true, + "verifier": "Exact rational recomputation of the next state.", + "correct_if": "Predicted next state equals the exact next state.", + "transfer_splits": [ + "unseen_constants", + "interventions_changed_law_term" + ], + "tasks_sealed": 10 + }, + { + "id": "om_compile_repair", + "family": "om_compiler_repair", + "description": "State = .om source digest plus diagnostics; action = typed edit; next state = pinned seeded compiler result.", + "resettable": true, + "verifier": "Pinned seeded handwritten .om compiler (om_seeded_compiler in G) run by the judge.", + "correct_if": "Predicted diagnostics/result digest equals the compiler output digest.", + "transfer_splits": [ + "unseen_programs", + "unseen_error_classes" + ], + "tasks_sealed": 10 + }, + { + "id": "constrained_orchestration", + "family": "constrained_orchestration", + "description": "Typed microjob DAG (aien-protocols-mv#50) under declared resource limits; action = admit/schedule/cancel.", + "resettable": true, + "verifier": "Deterministic DAG simulator applying the canonical microjob ABI.", + "correct_if": "Predicted next DAG state digest equals the simulator digest.", + "transfer_splits": [ + "new_dag_shapes", + "changed_resource_limits" + ], + "tasks_sealed": 10 + }, + { + "id": "interrupted_objective", + "family": "interrupted_objective", + "description": "Multi-step objectives killed at a judge-chosen step and restarted from durable state; tests saved verified skill reuse after restart and no duplicated effects.", + "resettable": true, + "verifier": "Judge compares final effect log with the reference effect set; any duplicated or missing effect is incorrect.", + "correct_if": "Objective completes with exactly the reference effects after restart.", + "transfer_splits": [ + "unseen_interruption_points" + ], + "tasks_sealed": 10 + } + ], + "heldout": { + "splits": { + "training": "Seeds under domain tag train; the only split any arm may learn from.", + "validation": "Seeds under domain tag validation; candidate early stopping and ICC estimation only.", + "calibration": "Seeds under domain tag calibration; baseline_run only.", + "sealed": "Seeds under domain tag sealed; scored once per arm.", + "reserve": "Two further sealed sets (reserve-1, reserve-2) of the sealed size, used only for a re-evaluation after any change.", + "sealed_family": "One extra environment family defined by the judge after freeze, disclosed only by hash commitment, for cross-family transfer (secondary)." + }, + "sealing": { + "mechanism": "Judge draws a 256-bit seed after preregistration_freeze, publishes only sha256(domain_tag || seed), and generates sealed episodes on judge-owned storage under a separate OS user on a separate process tree. Candidate processes have no filesystem or network route to that storage. Arms receive only (prior_state, action) inputs through the judge, once, and commit sha256 of their prediction file before the judge reveals next states. Every read of sealed material is logged by the judge; a read by anything other than the judge scorer is a breach.", + "hash_only_is_not_sealing": true, + "prediction_commit_before_reveal": true, + "judge_independent": true, + "single_use": true, + "collision_rule": "Episodes whose state digest appears in more than one split are removed from training, never from sealed.", + "breach_action": "Void the affected sealed set (INCONCLUSIVE), keep the record, regenerate from the next reserve." + } + }, + "metrics": { + "primary": { + "e2": { + "id": "transition_correct", + "unit": "sealed episode", + "definition": "Binary per sealed episode using the environment correct_if rule; paired across arms on identical episodes.", + "test": "Exact conditional McNemar (one-sided), stratified by family for reporting." + }, + "e1": { + "id": "objective_verified_complete", + "unit": "held-out objective", + "definition": "Binary per objective: completed, independently verified correct and authorized, with no silent context truncation.", + "test": "Exact conditional McNemar (one-sided)." + } + }, + "confirmatory": { + "correction": "Holm within each study; planning used Bonferroni (conservative).", + "hypotheses": [ + { + "id": "H1", + "study": "e2", + "claim": "si_experience_only > shuffled_experience_control" + }, + { + "id": "H2", + "study": "e2", + "claim": "si_experience_only > retrieval_only" + }, + { + "id": "H3", + "study": "e2", + "claim": "si_experience_only > frozen_pretrained_small" + }, + { + "id": "H4", + "study": "e2", + "claim": "si_plus_teacher > si_experience_only" + }, + { + "id": "H5", + "study": "e1", + "claim": "fusion_distilled_student > teacher_35b" + }, + { + "id": "H6", + "study": "e1", + "claim": "fusion_distilled_student > teacher_27b" + } + ] + }, + "secondary": [ + "log_loss_bits_per_transition", + "calibration_expected_calibration_error", + "retention_on_earlier_families_after_later_training", + "transfer_new_layouts_and_interventions", + "transfer_sealed_family", + "skill_reuse_after_restart", + "failed_attempts_count", + "revoked_trace_ids_absent_from_training_lineage", + "revoked_origin_performance_vs_never_given_model", + "rules_engine_vs_each_candidate", + "teacher_27b_vs_teacher_35b", + "multi_teacher_verified_vs_each_teacher" + ], + "safety_ceilings": { + "privacy_or_authorization_violations": 0, + "silent_context_truncations": 0, + "unverified_effects": 0 + }, + "cost_accounting": { + "counted": [ + "teacher_inference_and_mining", + "wrong_answers", + "retries", + "all_candidate_calls", + "tokenization_prefill_decode", + "queue_time", + "gpu_kernels_and_bytes", + "resident_and_peak_memory_bytes", + "verification", + "training_compute", + "checkpoint_io", + "cold_and_warm_setup", + "recovery_after_interruption" + ], + "throughput": "Independently verified objectives/sec with p50/p95 completion and TTFT; NOT_MEASURED unless instrumented on a scheduled uncontended run.", + "missing_counter_rule": "A counter that was not measured is NOT_MEASURED, never zero.", + "e1_job_profiles": [ + "64/16", + "128/32" + ], + "e1_batch_sizes": [ + 1, + 8, + 16, + 32, + 64, + 128 + ], + "reuse_break_even": "Immutable preparation reused n times wins only when (n-1)P > nH + V with P, H, V measured; otherwise NOT_MEASURED." + } + }, + "sample_size": { + "computed_with": "Wolfram Language evaluator 2026-10-24: approximate n by Connor (1987) normal formula, then exact power of the conditional binomial McNemar test, summed over the binomial number of discordant pairs, increasing n until power >= target.", + "studies": [ + { + "id": "e2", + "unit": "sealed episode", + "sided": "one", + "alpha_familywise": 0.05, + "confirmatory_contrasts": 4, + "alpha_per_contrast": 0.0125, + "power_target": 0.9, + "min_effect_discordant_difference": 0.1, + "assumed_discordant_proportion": 0.3, + "normal_approx_n": 368, + "exact_min_effective_n": 381, + "exact_power_at_min": 0.9006, + "families": 5, + "tasks_planned": 50, + "units_per_cluster": 12, + "icc_assumed": 0.05, + "design_effect": 1.55, + "units_planned": 600, + "effective_n_planned": 387, + "exact_power_at_planned": 0.9057, + "sensitivity": "At ICC 0.10 the design effect is 2.1, effective n 285 and exact power 0.7825; see stopping_rules icc_check." + }, + { + "id": "e1", + "unit": "held-out objective", + "sided": "one", + "alpha_familywise": 0.05, + "confirmatory_contrasts": 2, + "alpha_per_contrast": 0.025, + "power_target": 0.8, + "min_effect_discordant_difference": 0.15, + "assumed_discordant_proportion": 0.25, + "normal_approx_n": 85, + "exact_min_effective_n": 92, + "exact_power_at_min": 0.8014, + "families": 11, + "tasks_planned": 99, + "units_per_cluster": 1, + "icc_assumed": 0, + "design_effect": 1, + "units_planned": 99, + "effective_n_planned": 99, + "exact_power_at_planned": 0.8326, + "sensitivity": "The issue minimum of 30 objectives has exact power 0.2354 for this effect; 30 objectives is a pilot, not a confirmatory test.", + "categories": [ + "om_compilation", + "math", + "reduction", + "semantic_joining", + "code_repair", + "research_grounding", + "wrong_tool", + "null_route", + "privacy_refusal", + "interrupted_restarted_task", + "multi_turn_corrections" + ] + } + ], + "fresh_reserves": 2, + "training_budget": "Equal for every learning arm: the same training-split transitions, the same number of optimizer steps and the same parameter count for scratch arms; budget fixed at FROZEN from validation-split pilot only." + }, + "stopping_rules": [ + { + "id": "fixed_n", + "trigger": "Always.", + "action": "Scoring happens once, after all arms commit predictions. No interim efficacy or futility look at sealed data, no optional stopping, no adding episodes after reveal." + }, + { + "id": "icc_check", + "trigger": "Before FROZEN, the ICC estimated on the validation split exceeds the assumed value.", + "action": "Increase tasks_planned until effective_n_planned >= exact_min_effective_n, recompute in Wolfram, then freeze. Never after freeze." + }, + { + "id": "seal_breach", + "trigger": "Any non-judge access to sealed material, or a prediction commitment missing before reveal.", + "action": "Void that sealed set as INCONCLUSIVE, keep the record, continue only on the next reserve." + }, + { + "id": "reserve_exhausted", + "trigger": "Both reserves used.", + "action": "Campaign ends INCONCLUSIVE; a new campaign needs a new prereg_id." + }, + { + "id": "safety_ceiling", + "trigger": "An arm exceeds any metrics.safety_ceilings value.", + "action": "That arm is FAIL for promotion regardless of accuracy; scoring of the other arms continues." + }, + { + "id": "training_budget", + "trigger": "A learning arm reaches the fixed training budget.", + "action": "Training stops; early stopping may use the validation split only." + }, + { + "id": "hardware_not_granted", + "trigger": "An arm with requires_gpu true has no scheduled uncontended GPU window and signed receipt.", + "action": "That arm and every comparison using it are NOT_RUN or BLOCKED, never estimated." + } + ], + "turing_profile": { + "formula": "T(M;B,D,G,P) = [L(B|G) + L(D|B,G)] - [L(M|G) + L(D|M,G)]", + "source": "https://doi.org/10.5281/zenodo.23437498 (formal preprint v1.14)", + "unit": "bits", + "applies_to": "Learned predictive explanatory gain of candidate arms on D only; not service price, a single answer or a per-job metric.", + "B": { + "arm": "rules_engine", + "description": "Rules engine predictions coded under P; frozen at baseline_run." + }, + "D": { + "split": "sealed", + "blinded": true, + "description": "Sealed transitions of heldout.splits.sealed, coded under P after reveal." + }, + "G": { + "version": "si-genesis-e2-G/1", + "background": [ + { + "id": "rules_engine_spec", + "kind": "source", + "owner": "aien-dev/benchmarks-mv", + "revision": "PENDING_PIN" + }, + { + "id": "environment_generators_and_verifiers", + "kind": "source", + "owner": "aien-dev/benchmarks-mv", + "revision": "PENDING_PIN" + }, + { + "id": "om_seeded_compiler", + "kind": "toolchain", + "owner": "aien-dev/omega-mv", + "revision": "PENDING_PIN" + }, + { + "id": "aien_train_engine", + "kind": "toolchain", + "owner": "aien-dev/aien-train", + "revision": "PENDING_PIN" + }, + { + "id": "cortex_checked_procedure_snapshot", + "kind": "data", + "owner": "aien-dev/omega-mv", + "revision": "PENDING_PIN" + }, + { + "id": "model_0p8b", + "kind": "pretrained_adviser", + "owner": "aien-dev/omega-mv#694", + "revision": "PENDING_PIN" + }, + { + "id": "model_2b", + "kind": "pretrained_adviser", + "owner": "aien-dev/omega-mv#694", + "revision": "PENDING_PIN" + }, + { + "id": "model_27b", + "kind": "pretrained_adviser", + "owner": "aien-dev/aien-sovereign-core-mv#737", + "revision": "PENDING_PIN" + }, + { + "id": "model_35b", + "kind": "pretrained_adviser", + "owner": "aien-dev/aien-sovereign-core-mv#737", + "revision": "PENDING_PIN" + }, + { + "id": "reference_coder", + "kind": "toolchain", + "owner": "aien-dev/omega-mv#700", + "revision": "PENDING_PIN" + } + ] + }, + "P": { + "encoding": "Canonical state/action/next-state serialization of the environment family, arithmetic-coded by reference_coder with fixed 32-bit precision; L(M|G) is the reference-coded size of the model checkpoint plus its code given G.", + "baseline": "B as declared above.", + "sampling": "All sealed episodes, no subsampling; seeds as in heldout.", + "energy": "Joules only from an instrumented, reconciled measurement; otherwise NOT_MEASURED.", + "statistical_test": "Per-episode paired code-length differences; one-sided sign-flip permutation test with 100000 permutations at alpha 0.05, reported beside but separate from metrics.confirmatory." + }, + "T_ideal": { + "definition": "Code lengths as sum of -log2 of the probability each model assigns to the actual next state, plus ideal L(M|G).", + "status": "NOT_RUN" + }, + "T_real": { + "definition": "Actual reference_coder output bits for B and M, valid only after the H1 reference coder round-trip (decode reproduces the exact input bytes).", + "requires": [ + "H1_reference_coder_round_trip" + ], + "status": "NOT_RUN" + }, + "energy": { + "status": "NOT_MEASURED", + "instrument": "none declared", + "reconciliation": "Required before any T/J: measured joules reconciled against an independent meter for the same interval." + }, + "tj": { + "allowed": false, + "reason": "No energy instrument is declared and no joules are measured; T/J is not reported." + }, + "attribution": "One joint gain under one profile is counted once; it is never minted per contributor. Scientific T, measured utility and spendable credits are separate columns." + }, + "claims": [ + { + "id": "correctness_retention_safety", + "status": "NOT_RUN" + }, + { + "id": "performance_full_cost", + "status": "NOT_RUN" + }, + { + "id": "turing_scientific", + "status": "NOT_RUN" + }, + { + "id": "deployment_promotion", + "status": "NOT_RUN" + } + ], + "claim_rules": [ + "A scientific negative result is acceptable research but gives no performance or deployment promotion.", + "Never claim SI superiority without positive sealed quality and full-cost evidence.", + "Simulated time or energy is never reported as measured.", + "Hardware and two-real-owner results count only when separately consented and signed." + ], + "out_of_scope_here": [ + "Lattice vs serial compute (aien-architecture-mv#308, omega-mv#698): needs its own prereg.", + "Discovery Capsule transfer (aien-architecture-mv#310, open-humanity#34): needs its own prereg.", + "Two-owner network test-credit pilot (spark-connector#3, aien-sovereign-core-mv#738): needs its own prereg." + ] +} diff --git a/src/bin/bench_verify_prereg.rs b/src/bin/bench_verify_prereg.rs new file mode 100644 index 0000000..48355d1 --- /dev/null +++ b/src/bin/bench_verify_prereg.rs @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 Drake Stapleton (AIEN / aien-dev) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Offline preregistration check: validates `aien-bench-prereg/1` manifests before any run. +//! +//! Usage: `bench_verify_prereg [--root ] [PATH...]` (default path: `manifests/prereg`). +//! Prints one `path: field: reason` line per defect on stdout and exits 1 when there is any or +//! when no manifest was found; exits 0 when every manifest passes. Reads files only: no +//! network, no GPU, no live server. + +use aien_benchmarks::prereg::verify_prereg_paths; +use clap::Parser; +use std::path::PathBuf; + +#[derive(Parser)] +#[command(name = "bench_verify_prereg")] +#[command(about = "Validate aien-bench-prereg/1 preregistration manifests (offline)")] +struct Args { + /// Repository root that paths are relative to + #[arg(long, default_value = ".")] + root: PathBuf, + + /// Files or directories to check, relative to the root + #[arg(default_values_t = ["manifests/prereg".to_string()])] + paths: Vec, +} + +fn main() { + let args = Args::parse(); + let report = verify_prereg_paths(&args.root, &args.paths); + for note in &report.notes { + eprintln!("bench_verify_prereg: {note}"); + } + for d in &report.defects { + println!("{d}"); + } + eprintln!( + "bench_verify_prereg: {} manifests, {} defects", + report.manifests, + report.defects.len() + ); + if report.manifests == 0 || !report.defects.is_empty() { + std::process::exit(1); + } +} diff --git a/src/evidence.rs b/src/evidence.rs index 9f33dd8..1d3da00 100644 --- a/src/evidence.rs +++ b/src/evidence.rs @@ -617,7 +617,7 @@ fn claims_tokens(key: &str) -> bool { .any(|s| matches!(s, "tok" | "tokens" | "itl")) } -fn is_placeholder(s: &str) -> bool { +pub(crate) fn is_placeholder(s: &str) -> bool { PLACEHOLDERS.contains(&s.trim().to_ascii_lowercase().as_str()) } @@ -638,11 +638,11 @@ fn is_inside_relative(p: &str) -> bool { .all(|c| matches!(c, Component::Normal(_) | Component::CurDir)) } -fn get<'a>(v: &'a Value, dotted: &str) -> Option<&'a Value> { +pub(crate) fn get<'a>(v: &'a Value, dotted: &str) -> Option<&'a Value> { dotted.split('.').try_fold(v, |cur, k| cur.get(k)) } -fn collect_strings(v: &Value, prefix: String, out: &mut Vec<(String, String)>) { +pub(crate) fn collect_strings(v: &Value, prefix: String, out: &mut Vec<(String, String)>) { match v { Value::String(s) => out.push((prefix, s.clone())), Value::Array(a) => { @@ -664,7 +664,7 @@ fn collect_strings(v: &Value, prefix: String, out: &mut Vec<(String, String)>) { } } -fn walk(dir: &Path, out: &mut Vec) { +pub(crate) fn walk(dir: &Path, out: &mut Vec) { let Ok(entries) = fs::read_dir(dir) else { return; }; @@ -694,7 +694,7 @@ pub fn display_path(root: &Path, p: &Path) -> String { .join("/") } -fn push(out: &mut Vec, path: &str, field: &str, reason: String) { +pub(crate) fn push(out: &mut Vec, path: &str, field: &str, reason: String) { out.push(Defect { path: path.to_string(), field: field.to_string(), diff --git a/src/lib.rs b/src/lib.rs index 27edbb2..e6dd972 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,4 +17,5 @@ pub mod evidence; pub mod harness; pub mod models; pub mod perf_index; +pub mod prereg; pub mod svg_chart; diff --git a/src/prereg.rs b/src/prereg.rs new file mode 100644 index 0000000..1d89af6 --- /dev/null +++ b/src/prereg.rs @@ -0,0 +1,642 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 Drake Stapleton (AIEN / aien-dev) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Offline checks for benchmark preregistration manifests (`aien-bench-prereg/1`). +//! +//! A preregistration fixes arms, environments, the sealed split, metrics, sample sizes, +//! stopping rules and the Turing profile before any candidate is trained. It is a plan, not +//! evidence: it carries no measurements. Rules, one [`Defect`] per violation: +//! - `schema`, `prereg_id`, `status` ([`PREREG_STATUSES`]) and `results_status` +//! ([`RUN_STATUSES`]) are present; no string anywhere is a placeholder; +//! - `arms` have unique ids, a role in [`ARM_ROLES`], a boolean `pretrained`, and include at +//! least one baseline, one candidate and one control; +//! - `baseline_before_eval.required` is `true`, its `baseline_arms` are exactly the arms whose +//! role is `baseline`, and `phases` runs `preregistration_freeze` before `baseline_run` +//! before `sealed_eval` (with `candidate_training`, if present, after `baseline_run` and +//! before `sealed_eval`); +//! - `turing_profile.G.background` is a non-empty list of `{id, kind, owner, revision}`; +//! every arm that is pretrained or uses a teacher names its background, and every +//! `background_refs` entry is declared in `G`; [`PENDING_PIN`] revisions are allowed only +//! while `status` is `SCOPED`, otherwise a revision is a commit id or `sha256:<64 hex>`; +//! - `turing_profile` declares `B` (a baseline arm), a blinded `D`, all five `P` fields, +//! `T_ideal` and `T_real` separately, and `tj.allowed` is `true` only when +//! `energy.status == "MEASURED"`; +//! - `heldout.sealing` names a mechanism and sets `prediction_commit_before_reveal`, +//! `judge_independent` and `single_use` to `true`; +//! - every `sample_size.studies` entry is arithmetically consistent: `units_planned = +//! tasks_planned * units_per_cluster`, `design_effect = 1 + (units_per_cluster - 1) * icc`, +//! `effective_n_planned = floor(units_planned / design_effect)` and at least +//! `exact_min_effective_n`, `exact_power_at_planned >= power_target`, and +//! `alpha_per_contrast * confirmatory_contrasts <= alpha_familywise`; +//! - `stopping_rules` is a non-empty list of `{id, trigger, action}`; every `claims` status is +//! in [`RUN_STATUSES`]. + +use crate::evidence::Defect; +use crate::evidence::{collect_strings, display_path, get, is_commit, is_placeholder, push, walk}; +use serde_json::{Map, Value}; +use std::collections::BTreeSet; +use std::fs; +use std::path::Path; + +/// The preregistration contract this module validates. +pub const PREREG_SCHEMA: &str = "aien-bench-prereg/1"; + +/// Lifecycle of the preregistration itself. +pub const PREREG_STATUSES: [&str; 3] = ["SCOPED", "FROZEN", "SUPERSEDED"]; + +/// Status of the campaign and of each claim. +pub const RUN_STATUSES: [&str; 5] = ["NOT_RUN", "BLOCKED", "INCONCLUSIVE", "FAIL", "PASS"]; + +/// Arm roles. +pub const ARM_ROLES: [&str; 3] = ["baseline", "candidate", "control"]; + +/// A background revision not yet bound; allowed only while `status` is `SCOPED`. +pub const PENDING_PIN: &str = "PENDING_PIN"; + +const PHASE_FREEZE: &str = "preregistration_freeze"; +const PHASE_BASELINE: &str = "baseline_run"; +const PHASE_TRAINING: &str = "candidate_training"; +const PHASE_EVAL: &str = "sealed_eval"; + +const P_FIELDS: [&str; 5] = [ + "encoding", + "baseline", + "sampling", + "energy", + "statistical_test", +]; + +const STUDY_NUMBERS: [&str; 12] = [ + "alpha_familywise", + "confirmatory_contrasts", + "alpha_per_contrast", + "power_target", + "exact_min_effective_n", + "tasks_planned", + "units_per_cluster", + "icc_assumed", + "design_effect", + "units_planned", + "effective_n_planned", + "exact_power_at_planned", +]; + +const EPS: f64 = 1e-9; + +/// Result of a run over one or more paths. +#[derive(Debug, Default)] +pub struct PreregReport { + pub defects: Vec, + pub manifests: usize, + /// Informational lines (for example a target that does not exist). + pub notes: Vec, +} + +/// Validate every JSON file under each target (a file or directory relative to `root`). +pub fn verify_prereg_paths(root: &Path, targets: &[String]) -> PreregReport { + let mut report = PreregReport::default(); + for target in targets { + let clean = target.trim_end_matches('/'); + let full = root.join(clean); + if !full.exists() { + report + .notes + .push(format!("{clean}: skipped: not present under the root")); + continue; + } + let mut files = Vec::new(); + if full.is_dir() { + walk(&full, &mut files); + } else { + files.push(full.clone()); + } + files.sort(); + for file in files + .iter() + .filter(|f| f.extension().is_some_and(|e| e == "json")) + { + let display = display_path(root, file); + let value: Value = match fs::read_to_string(file) + .map_err(|e| format!("cannot read: {e}")) + .and_then(|t| serde_json::from_str(&t).map_err(|e| format!("invalid JSON: {e}"))) + { + Ok(v) => v, + Err(reason) => { + push(&mut report.defects, &display, "(file)", reason); + continue; + } + }; + report.manifests += 1; + let mut found = Vec::new(); + check_prereg(&display, &value, &mut found); + found.sort(); + found.dedup(); + report.defects.extend(found); + } + } + report +} + +/// Validate one parsed preregistration. `path` is only used for the defect lines. +pub fn check_prereg(path: &str, v: &Value, out: &mut Vec) { + let mut d = |field: &str, reason: String| push(out, path, field, reason); + let Some(top) = v.as_object() else { + d("(file)", "top level is not a JSON object".into()); + return; + }; + match top.get("schema").and_then(Value::as_str) { + None => d("schema", "missing".into()), + Some(s) if s != PREREG_SCHEMA => d("schema", format!("\"{s}\" is not {PREREG_SCHEMA}")), + Some(_) => {} + } + if top.get("prereg_id").and_then(Value::as_str).is_none() { + d("prereg_id", "missing".into()); + } + let status = enum_field(top, "status", &PREREG_STATUSES, &mut d); + enum_field(top, "results_status", &RUN_STATUSES, &mut d); + + let mut strings = Vec::new(); + collect_strings(v, String::new(), &mut strings); + for (field, s) in &strings { + if is_placeholder(s) { + d(field, format!("placeholder value \"{s}\"")); + } + } + + let arms = check_arms(top, &mut d); + check_baseline_before_eval(top, &arms, &mut d); + check_turing(top, status, &arms, &mut d); + check_sealing(top, &mut d); + check_sample_size(top, &mut d); + check_stopping_rules(top, &mut d); + if let Some(claims) = top.get("claims") { + match claims.as_array() { + Some(list) => { + for (i, c) in list.iter().enumerate() { + match c.get("status").and_then(Value::as_str) { + Some(s) if RUN_STATUSES.contains(&s) => {} + Some(s) => d( + &format!("claims[{i}].status"), + format!("\"{s}\" is not one of {}", RUN_STATUSES.join(", ")), + ), + None => d(&format!("claims[{i}].status"), "missing".into()), + } + } + } + None => d("claims", "must be an array".into()), + } + } +} + +/// One declared arm. +struct Arm { + id: String, + role: Option, + needs_background: bool, + refs: Vec, +} + +fn check_arms(top: &Map, d: &mut impl FnMut(&str, String)) -> Vec { + let Some(list) = top.get("arms").and_then(Value::as_array) else { + d("arms", "missing or not an array".into()); + return Vec::new(); + }; + if list.is_empty() { + d("arms", "must declare at least one arm".into()); + } + let mut arms = Vec::new(); + let mut seen = BTreeSet::new(); + for (i, a) in list.iter().enumerate() { + let at = |f: &str| format!("arms[{i}].{f}"); + let Some(id) = a.get("id").and_then(Value::as_str) else { + d(&at("id"), "missing".into()); + continue; + }; + if !seen.insert(id.to_string()) { + d(&at("id"), format!("duplicate arm id \"{id}\"")); + } + let role = match a.get("role").and_then(Value::as_str) { + Some(r) if ARM_ROLES.contains(&r) => Some(r.to_string()), + Some(r) => { + d( + &at("role"), + format!("\"{r}\" is not one of {}", ARM_ROLES.join(", ")), + ); + None + } + None => { + d(&at("role"), "missing".into()); + None + } + }; + let pretrained = match a.get("pretrained") { + Some(Value::Bool(b)) => *b, + Some(_) => { + d(&at("pretrained"), "must be true or false".into()); + false + } + None => { + d(&at("pretrained"), "missing".into()); + false + } + }; + let teacher = a.get("uses_teacher").and_then(Value::as_bool) == Some(true); + let refs = match a.get("background_refs") { + None => Vec::new(), + Some(Value::Array(r)) => r + .iter() + .filter_map(Value::as_str) + .map(str::to_string) + .collect(), + Some(_) => { + d(&at("background_refs"), "must be an array of strings".into()); + Vec::new() + } + }; + arms.push(Arm { + id: id.to_string(), + role, + needs_background: pretrained || teacher, + refs, + }); + } + for role in ARM_ROLES { + if !list.is_empty() && !arms.iter().any(|a| a.role.as_deref() == Some(role)) { + d("arms", format!("no arm has role {role}")); + } + } + arms +} + +fn check_baseline_before_eval( + top: &Map, + arms: &[Arm], + d: &mut impl FnMut(&str, String), +) { + match top.get("baseline_before_eval") { + None => d( + "baseline_before_eval", + "missing: baselines must be run and frozen before any evaluation".into(), + ), + Some(b) => { + if b.get("required").and_then(Value::as_bool) != Some(true) { + d("baseline_before_eval.required", "must be true".into()); + } + match b.get("baseline_arms").and_then(Value::as_array) { + Some(list) if !list.is_empty() => { + let named: BTreeSet<&str> = list.iter().filter_map(Value::as_str).collect(); + for (i, x) in list.iter().enumerate() { + let field = format!("baseline_before_eval.baseline_arms[{i}]"); + match x.as_str() { + None => d(&field, "must be a string".into()), + Some(id) => match arms.iter().find(|a| a.id == id) { + None => d(&field, format!("\"{id}\" is not a declared arm")), + Some(a) if a.role.as_deref() != Some("baseline") => { + d(&field, format!("arm \"{id}\" does not have role baseline")) + } + Some(_) => {} + }, + } + } + for a in arms { + if a.role.as_deref() == Some("baseline") && !named.contains(a.id.as_str()) { + d( + "baseline_before_eval.baseline_arms", + format!("baseline arm \"{}\" is not listed", a.id), + ); + } + } + } + _ => d( + "baseline_before_eval.baseline_arms", + "must be a non-empty array of arm ids".into(), + ), + } + } + } + let Some(phases) = top.get("phases").and_then(Value::as_array) else { + d("phases", "missing or not an array".into()); + return; + }; + let names: Vec<&str> = phases.iter().filter_map(Value::as_str).collect(); + let pos = |p: &str| names.iter().position(|n| *n == p); + let (freeze, baseline, eval) = (pos(PHASE_FREEZE), pos(PHASE_BASELINE), pos(PHASE_EVAL)); + for (p, at) in [ + (PHASE_FREEZE, freeze), + (PHASE_BASELINE, baseline), + (PHASE_EVAL, eval), + ] { + if at.is_none() { + d("phases", format!("missing {p}")); + } + } + if freeze.is_some_and(|f| f != 0) { + d("phases", format!("{PHASE_FREEZE} must be the first phase")); + } + if let (Some(b), Some(e)) = (baseline, eval) { + if b > e { + d( + "phases", + format!("{PHASE_BASELINE} must come before {PHASE_EVAL}"), + ); + } + } + if let Some(t) = pos(PHASE_TRAINING) { + if baseline.is_some_and(|b| t < b) { + d( + "phases", + format!("{PHASE_TRAINING} must come after {PHASE_BASELINE}"), + ); + } + if eval.is_some_and(|e| t > e) { + d( + "phases", + format!("{PHASE_TRAINING} must come before {PHASE_EVAL}"), + ); + } + } +} + +fn check_turing( + top: &Map, + status: Option<&str>, + arms: &[Arm], + d: &mut impl FnMut(&str, String), +) { + let Some(t) = top.get("turing_profile") else { + d("turing_profile", "missing".into()); + return; + }; + match get(t, "G.background") { + None => d( + "turing_profile.G.background", + "missing: G must declare every adviser, model and toolchain".into(), + ), + Some(Value::Array(bg)) if bg.is_empty() => d( + "turing_profile.G.background", + "empty: G must declare every adviser, model and toolchain".into(), + ), + Some(Value::Array(bg)) => { + let mut ids = BTreeSet::new(); + for (i, e) in bg.iter().enumerate() { + let at = |f: &str| format!("turing_profile.G.background[{i}].{f}"); + for f in ["id", "kind", "owner", "revision"] { + if e.get(f).and_then(Value::as_str).is_none() { + d(&at(f), "missing".into()); + } + } + if let Some(id) = e.get("id").and_then(Value::as_str) { + if !ids.insert(id.to_string()) { + d(&at("id"), format!("duplicate background id \"{id}\"")); + } + } + if let Some(r) = e.get("revision").and_then(Value::as_str) { + if r == PENDING_PIN { + if status != Some("SCOPED") { + d( + &at("revision"), + format!("{PENDING_PIN} is allowed only while status is SCOPED"), + ); + } + } else if !is_pinned(r) { + d( + &at("revision"), + format!("\"{r}\" is not a commit id or sha256:<64 hex>"), + ); + } + } + } + for (i, a) in arms.iter().enumerate() { + if a.needs_background && a.refs.is_empty() { + d( + &format!("arms[{i}].background_refs"), + format!( + "arm \"{}\" is pretrained or uses a teacher but declares no background", + a.id + ), + ); + } + for r in &a.refs { + if !ids.contains(r) { + d( + &format!("arms[{i}].background_refs"), + format!("\"{r}\" is not declared in turing_profile.G.background"), + ); + } + } + } + } + Some(_) => d("turing_profile.G.background", "must be an array".into()), + } + match get(t, "B.arm").and_then(Value::as_str) { + None => d("turing_profile.B.arm", "missing".into()), + Some(b) => { + if !arms + .iter() + .any(|a| a.id == b && a.role.as_deref() == Some("baseline")) + { + d( + "turing_profile.B.arm", + format!("\"{b}\" is not a declared baseline arm"), + ); + } + } + } + if get(t, "D.blinded").and_then(Value::as_bool) != Some(true) { + d("turing_profile.D.blinded", "must be true".into()); + } + for f in P_FIELDS { + if get(t, &format!("P.{f}")).and_then(Value::as_str).is_none() { + d(&format!("turing_profile.P.{f}"), "missing".into()); + } + } + for f in ["T_ideal", "T_real"] { + if get(t, &format!("{f}.definition")) + .and_then(Value::as_str) + .is_none() + { + d(&format!("turing_profile.{f}.definition"), "missing".into()); + } + } + match get(t, "tj.allowed") { + Some(Value::Bool(true)) => { + if get(t, "energy.status").and_then(Value::as_str) != Some("MEASURED") { + d( + "turing_profile.tj.allowed", + "T/J requires turing_profile.energy.status MEASURED".into(), + ); + } + } + Some(Value::Bool(false)) => {} + _ => d("turing_profile.tj.allowed", "must be true or false".into()), + } +} + +fn check_sealing(top: &Map, d: &mut impl FnMut(&str, String)) { + let Some(s) = top.get("heldout").and_then(|h| h.get("sealing")) else { + d("heldout.sealing", "missing".into()); + return; + }; + if s.get("mechanism").and_then(Value::as_str).is_none() { + d("heldout.sealing.mechanism", "missing".into()); + } + for f in [ + "prediction_commit_before_reveal", + "judge_independent", + "single_use", + ] { + if s.get(f).and_then(Value::as_bool) != Some(true) { + d(&format!("heldout.sealing.{f}"), "must be true".into()); + } + } +} + +fn check_sample_size(top: &Map, d: &mut impl FnMut(&str, String)) { + let Some(s) = top.get("sample_size") else { + d("sample_size", "missing".into()); + return; + }; + if s.get("computed_with").and_then(Value::as_str).is_none() { + d("sample_size.computed_with", "missing".into()); + } + let studies = match s.get("studies").and_then(Value::as_array) { + Some(l) if !l.is_empty() => l, + _ => { + d("sample_size.studies", "must be a non-empty array".into()); + return; + } + }; + for (i, st) in studies.iter().enumerate() { + let at = |f: &str| format!("sample_size.studies[{i}].{f}"); + let mut n = std::collections::BTreeMap::new(); + for f in STUDY_NUMBERS { + match st.get(f).and_then(Value::as_f64).filter(|x| x.is_finite()) { + Some(x) => { + n.insert(f, x); + } + None => d(&at(f), "missing or not a finite number".into()), + } + } + if n.len() != STUDY_NUMBERS.len() { + continue; + } + if (n["tasks_planned"] * n["units_per_cluster"] - n["units_planned"]).abs() > EPS { + d( + &at("units_planned"), + format!( + "{} != tasks_planned * units_per_cluster = {}", + n["units_planned"], + n["tasks_planned"] * n["units_per_cluster"] + ), + ); + } + let deff = 1.0 + (n["units_per_cluster"] - 1.0) * n["icc_assumed"]; + if (deff - n["design_effect"]).abs() > EPS { + d( + &at("design_effect"), + format!( + "{} != 1 + (units_per_cluster - 1) * icc_assumed = {deff}", + n["design_effect"] + ), + ); + } + let eff = (n["units_planned"] / deff).floor(); + if (eff - n["effective_n_planned"]).abs() > EPS { + d( + &at("effective_n_planned"), + format!( + "{} != floor(units_planned / design_effect) = {eff}", + n["effective_n_planned"] + ), + ); + } + if eff < n["exact_min_effective_n"] { + d( + &at("effective_n_planned"), + format!( + "underpowered: {eff} < exact_min_effective_n {}", + n["exact_min_effective_n"] + ), + ); + } + if n["exact_power_at_planned"] < n["power_target"] { + d( + &at("exact_power_at_planned"), + format!( + "{} < power_target {}", + n["exact_power_at_planned"], n["power_target"] + ), + ); + } + if n["alpha_per_contrast"] * n["confirmatory_contrasts"] > n["alpha_familywise"] + EPS { + d( + &at("alpha_per_contrast"), + format!( + "{} * {} contrasts exceeds alpha_familywise {}", + n["alpha_per_contrast"], n["confirmatory_contrasts"], n["alpha_familywise"] + ), + ); + } + } +} + +fn check_stopping_rules(top: &Map, d: &mut impl FnMut(&str, String)) { + match top.get("stopping_rules").and_then(Value::as_array) { + Some(list) if !list.is_empty() => { + for (i, r) in list.iter().enumerate() { + for f in ["id", "trigger", "action"] { + if r.get(f).and_then(Value::as_str).is_none() { + d(&format!("stopping_rules[{i}].{f}"), "missing".into()); + } + } + } + } + _ => d("stopping_rules", "must be a non-empty array".into()), + } +} + +fn enum_field<'a>( + top: &'a Map, + field: &str, + allowed: &[&str], + d: &mut impl FnMut(&str, String), +) -> Option<&'a str> { + match top.get(field) { + None => { + d(field, "missing".into()); + None + } + Some(Value::String(s)) if allowed.contains(&s.as_str()) => Some(s.as_str()), + Some(Value::String(s)) => { + d( + field, + format!("\"{s}\" is not one of {}", allowed.join(", ")), + ); + None + } + Some(_) => { + d(field, "must be a string".into()); + None + } + } +} + +/// A 40-character commit id or `sha256:` followed by 64 lowercase hex characters. +fn is_pinned(r: &str) -> bool { + is_commit(r) + || r.strip_prefix("sha256:").is_some_and(|h| { + h.len() == 64 && h.bytes().all(|b| matches!(b, b'0'..=b'9' | b'a'..=b'f')) + }) +} diff --git a/tests/prereg_manifest.rs b/tests/prereg_manifest.rs new file mode 100644 index 0000000..009f774 --- /dev/null +++ b/tests/prereg_manifest.rs @@ -0,0 +1,289 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 Drake Stapleton (AIEN / aien-dev) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! The committed preregistration passes `bench_verify_prereg`; mutated copies of it are refused with exact defect lines. + +use aien_benchmarks::prereg::check_prereg; +use serde_json::{json, Value}; +use std::fs; +use std::path::Path; +use std::process::Command; + +const ROOT: &str = env!("CARGO_MANIFEST_DIR"); +const MANIFEST: &str = "manifests/prereg/si_genesis_e2.json"; + +fn committed() -> Value { + let text = fs::read_to_string(Path::new(ROOT).join(MANIFEST)).expect("read prereg manifest"); + serde_json::from_str(&text).expect("prereg manifest is JSON") +} + +fn defects(v: &Value) -> Vec { + let mut out = Vec::new(); + check_prereg("m.json", v, &mut out); + out.sort(); + out.dedup(); + out.iter().map(ToString::to_string).collect() +} + +fn expect(v: &Value, want: &[&str]) { + let want: Vec = want.iter().map(|l| format!("m.json: {l}")).collect(); + assert_eq!(defects(v), want); +} + +fn arm_index(v: &Value, id: &str) -> usize { + v["arms"] + .as_array() + .unwrap() + .iter() + .position(|a| a["id"] == id) + .unwrap() +} + +fn run_bin(root: &Path, args: &[&str]) -> (i32, Vec) { + let out = Command::new(env!("CARGO_BIN_EXE_bench_verify_prereg")) + .arg("--root") + .arg(root) + .args(args) + .output() + .expect("run bench_verify_prereg"); + let lines = String::from_utf8(out.stdout) + .expect("utf-8 output") + .lines() + .map(str::to_string) + .collect(); + (out.status.code().expect("exit code"), lines) +} + +#[test] +fn committed_prereg_passes() { + assert_eq!(defects(&committed()), Vec::::new()); + let (code, lines) = run_bin(Path::new(ROOT), &[]); + assert_eq!(lines, Vec::::new()); + assert_eq!(code, 0); +} + +#[test] +fn refuses_missing_baseline_before_eval() { + let mut v = committed(); + v.as_object_mut().unwrap().remove("baseline_before_eval"); + expect( + &v, + &["baseline_before_eval: missing: baselines must be run and frozen before any evaluation"], + ); +} + +#[test] +fn refuses_baseline_not_required_or_incomplete() { + let mut v = committed(); + v["baseline_before_eval"]["required"] = json!(false); + v["baseline_before_eval"]["baseline_arms"] = json!(["rules_engine", "si_experience_only"]); + expect( + &v, + &[ + "baseline_before_eval.baseline_arms: baseline arm \"frozen_pretrained_small\" is not listed", + "baseline_before_eval.baseline_arms: baseline arm \"retrieval_only\" is not listed", + "baseline_before_eval.baseline_arms: baseline arm \"teacher_27b\" is not listed", + "baseline_before_eval.baseline_arms: baseline arm \"teacher_35b\" is not listed", + "baseline_before_eval.baseline_arms[1]: arm \"si_experience_only\" does not have role baseline", + "baseline_before_eval.required: must be true", + ], + ); +} + +#[test] +fn refuses_eval_or_training_before_baseline() { + let mut v = committed(); + v["phases"] = json!([ + "preregistration_freeze", + "candidate_training", + "sealed_eval", + "baseline_run" + ]); + expect( + &v, + &[ + "phases: baseline_run must come before sealed_eval", + "phases: candidate_training must come after baseline_run", + ], + ); + v["phases"] = json!(["preregistration_freeze", "sealed_eval"]); + expect(&v, &["phases: missing baseline_run"]); +} + +#[test] +fn refuses_missing_or_empty_g_background() { + let mut v = committed(); + v["turing_profile"]["G"] + .as_object_mut() + .unwrap() + .remove("background"); + expect( + &v, + &["turing_profile.G.background: missing: G must declare every adviser, model and toolchain"], + ); + v["turing_profile"].as_object_mut().unwrap().remove("G"); + expect( + &v, + &["turing_profile.G.background: missing: G must declare every adviser, model and toolchain"], + ); + v["turing_profile"]["G"] = json!({"version": "g/1", "background": []}); + expect( + &v, + &["turing_profile.G.background: empty: G must declare every adviser, model and toolchain"], + ); +} + +#[test] +fn refuses_adviser_missing_from_g() { + let mut v = committed(); + let bg = v["turing_profile"]["G"]["background"] + .as_array_mut() + .unwrap(); + bg.retain(|e| e["id"] != "model_35b"); + let mut want: Vec = [ + "teacher_35b", + "multi_teacher_verified", + "fusion_distilled_student", + "si_plus_teacher", + ] + .iter() + .map(|id| { + format!( + "arms[{}].background_refs: \"model_35b\" is not declared in turing_profile.G.background", + arm_index(&v, id) + ) + }) + .collect(); + want.sort(); + let want: Vec<&str> = want.iter().map(String::as_str).collect(); + expect(&v, &want); + + let mut v = committed(); + let i = arm_index(&v, "teacher_27b"); + v["arms"][i]["background_refs"] = json!([]); + let line = format!( + "arms[{i}].background_refs: arm \"teacher_27b\" is pretrained or uses a teacher but declares no background" + ); + expect(&v, &[line.as_str()]); +} + +#[test] +fn refuses_tj_without_measured_energy() { + let mut v = committed(); + v["turing_profile"]["tj"]["allowed"] = json!(true); + expect( + &v, + &["turing_profile.tj.allowed: T/J requires turing_profile.energy.status MEASURED"], + ); + v["turing_profile"]["energy"]["status"] = json!("MEASURED"); + expect(&v, &[]); +} + +#[test] +fn frozen_prereg_needs_pinned_background() { + let mut v = committed(); + v["status"] = json!("FROZEN"); + let n = v["turing_profile"]["G"]["background"] + .as_array() + .unwrap() + .len(); + let lines: Vec = (0..n) + .map(|i| { + format!( + "turing_profile.G.background[{i}].revision: PENDING_PIN is allowed only while status is SCOPED" + ) + }) + .collect(); + let want: Vec<&str> = lines.iter().map(String::as_str).collect(); + expect(&v, &want); + for e in v["turing_profile"]["G"]["background"] + .as_array_mut() + .unwrap() + { + e["revision"] = json!(format!("sha256:{}", "0".repeat(64))); + } + expect(&v, &[]); +} + +#[test] +fn refuses_underpowered_or_inconsistent_sample_size() { + let mut v = committed(); + let s = &mut v["sample_size"]["studies"][0]; + s["tasks_planned"] = json!(40); + s["units_planned"] = json!(480); + s["effective_n_planned"] = json!(309); + expect( + &v, + &["sample_size.studies[0].effective_n_planned: underpowered: 309 < exact_min_effective_n 381"], + ); + let s = &mut v["sample_size"]["studies"][0]; + s["design_effect"] = json!(1.0); + s["alpha_per_contrast"] = json!(0.05); + expect( + &v, + &[ + "sample_size.studies[0].alpha_per_contrast: 0.05 * 4 contrasts exceeds alpha_familywise 0.05", + "sample_size.studies[0].design_effect: 1 != 1 + (units_per_cluster - 1) * icc_assumed = 1.55", + "sample_size.studies[0].effective_n_planned: underpowered: 309 < exact_min_effective_n 381", + ], + ); +} + +#[test] +fn refuses_unsealed_heldout_and_placeholders() { + let mut v = committed(); + v["heldout"]["sealing"]["prediction_commit_before_reveal"] = json!(false); + v["stopping_rules"] = json!([]); + v["arms"][0]["description"] = json!("TBD"); + expect( + &v, + &[ + "arms[0].description: placeholder value \"TBD\"", + "heldout.sealing.prediction_commit_before_reveal: must be true", + "stopping_rules: must be a non-empty array", + ], + ); +} + +#[test] +fn binary_refuses_bad_manifest_file() { + let dir = std::env::temp_dir().join(format!("bench_verify_prereg_{}", std::process::id())); + fs::create_dir_all(&dir).unwrap(); + let mut v = committed(); + v.as_object_mut().unwrap().remove("baseline_before_eval"); + v["turing_profile"]["G"]["background"] = json!([]); + fs::write(dir.join("bad.json"), serde_json::to_string(&v).unwrap()).unwrap(); + let (code, lines) = run_bin(&dir, &["bad.json"]); + fs::remove_dir_all(&dir).unwrap(); + assert_eq!( + lines, + vec![ + "bad.json: baseline_before_eval: missing: baselines must be run and frozen before any evaluation", + "bad.json: turing_profile.G.background: empty: G must declare every adviser, model and toolchain", + ] + ); + assert_eq!(code, 1); +} + +#[test] +fn binary_refuses_empty_target() { + let dir = + std::env::temp_dir().join(format!("bench_verify_prereg_empty_{}", std::process::id())); + fs::create_dir_all(&dir).unwrap(); + let (code, lines) = run_bin(&dir, &["."]); + fs::remove_dir_all(&dir).unwrap(); + assert_eq!(lines, Vec::::new()); + assert_eq!(code, 1, "no manifest checked is not a pass"); +} From b541b190db086fb6e6048e70f377c9776890a615 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sat, 24 Oct 2026 13:20:09 -0500 Subject: [PATCH 2/2] prereg(si-genesis-e2): pin locally verified G entries - om_seeded_compiler: aien-dev/omega-mv main 3eff14f02a31abf18498ae9dbcd27cf22d4d8003 - aien_train_engine: aien-dev/aien-train main ed8b6ea2562efdda7913234ca8f34b443714a987 - model_0p8b, model_27b, model_35b: sha256 of model.safetensors.index.json, with model_dir and config.json sha256 (names from aien-sovereign-core-mv#737 audit); weight shard bytes not hashed - model_2b, rules_engine_spec, environment generators, Cortex snapshot and reference_coder stay PENDING_PIN (not present or not implemented) - test: FROZEN check now targets only the remaining PENDING_PIN entries and refuses a non-digest revision Assisted-by: omp agent BenchPrereg (Claude) Signed-off-by: Drake Stapleton --- manifests/prereg/si_genesis_e2.json | 24 +++++++++++++++++++----- tests/prereg_manifest.rs | 28 ++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/manifests/prereg/si_genesis_e2.json b/manifests/prereg/si_genesis_e2.json index 68f0a7d..3d23cd1 100644 --- a/manifests/prereg/si_genesis_e2.json +++ b/manifests/prereg/si_genesis_e2.json @@ -556,13 +556,15 @@ "id": "om_seeded_compiler", "kind": "toolchain", "owner": "aien-dev/omega-mv", - "revision": "PENDING_PIN" + "revision": "3eff14f02a31abf18498ae9dbcd27cf22d4d8003", + "pin_basis": "aien-dev/omega-mv main HEAD on 2026-10-24 (merge of PR #701), contains seed/; verified with git ls-remote and a local checkout. Re-pin before FROZEN if the compiler changes." }, { "id": "aien_train_engine", "kind": "toolchain", "owner": "aien-dev/aien-train", - "revision": "PENDING_PIN" + "revision": "ed8b6ea2562efdda7913234ca8f34b443714a987", + "pin_basis": "aien-dev/aien-train main HEAD on 2026-10-24 (skeleton, plan, thesis); verified with git ls-remote and a local checkout. The T2 learner (aien-train#19) is not on main yet; re-pin before FROZEN." }, { "id": "cortex_checked_procedure_snapshot", @@ -574,7 +576,11 @@ "id": "model_0p8b", "kind": "pretrained_adviser", "owner": "aien-dev/omega-mv#694", - "revision": "PENDING_PIN" + "revision": "sha256:d8a08838a613b025eb7952ed9db11696213e57e76a375661ef5c12f9dd5dcf4e", + "model_id": "qwen3.5-0.8b", + "model_dir": "~/models/qwen3.5-0.8b-2fc06364", + "config_sha256": "b90b86f35c8e6925ef74ee04d0e758f0a845c83a42089ad82bbaa948de9b4204", + "pin_basis": "revision is sha256 of model.safetensors.index.json; config.json hashed separately; weight shard bytes not hashed. Read locally 2026-10-24." }, { "id": "model_2b", @@ -586,13 +592,21 @@ "id": "model_27b", "kind": "pretrained_adviser", "owner": "aien-dev/aien-sovereign-core-mv#737", - "revision": "PENDING_PIN" + "revision": "sha256:f0838c766951bdfe76d6afbdb2771a8f67aaa2231dedb3d33cebd817729843a2", + "model_id": "qwen3.8-27b-fp8-017b9c7a", + "model_dir": "~/models/qwen3.8-27b-fp8-017b9c7a", + "config_sha256": "74227dd615bf1ea975aa676bdf355a0379858c12f394b5365cd9dfa5fc2c70bc", + "pin_basis": "On-disk 27B per aien-sovereign-core-mv#737 audit (not serving). revision is sha256 of model.safetensors.index.json; config.json hashed separately; 64 layer shard bytes not hashed. Read locally 2026-10-24." }, { "id": "model_35b", "kind": "pretrained_adviser", "owner": "aien-dev/aien-sovereign-core-mv#737", - "revision": "PENDING_PIN" + "revision": "sha256:6f176f344e41d35b17af12904e33401da5ebff3b49fccb8bfa0185bc2d50f9d6", + "model_id": "qwen3.6-35b-a3b-fp8-95a723d0", + "model_dir": "~/models/qwen3.6-35b-a3b-fp8-95a723d0", + "config_sha256": "570ef7ea45a7e1d3de2b1d3c70c4ac3562d0e768acdc195778cb4f4d95025845", + "pin_basis": "Live 35B seat per aien-sovereign-core-mv#737 audit. revision is sha256 of model.safetensors.index.json; config.json hashed separately; 40 layer shard bytes not hashed (read-only, no load on the live service). Read locally 2026-10-24." }, { "id": "reference_coder", diff --git a/tests/prereg_manifest.rs b/tests/prereg_manifest.rs index 009f774..33af332 100644 --- a/tests/prereg_manifest.rs +++ b/tests/prereg_manifest.rs @@ -195,11 +195,20 @@ fn refuses_tj_without_measured_energy() { fn frozen_prereg_needs_pinned_background() { let mut v = committed(); v["status"] = json!("FROZEN"); - let n = v["turing_profile"]["G"]["background"] + let pending: Vec = v["turing_profile"]["G"]["background"] .as_array() .unwrap() - .len(); - let lines: Vec = (0..n) + .iter() + .enumerate() + .filter(|(_, e)| e["revision"] == "PENDING_PIN") + .map(|(i, _)| i) + .collect(); + assert!( + !pending.is_empty(), + "the SCOPED manifest still has unpinned entries" + ); + let lines: Vec = pending + .iter() .map(|i| { format!( "turing_profile.G.background[{i}].revision: PENDING_PIN is allowed only while status is SCOPED" @@ -208,13 +217,16 @@ fn frozen_prereg_needs_pinned_background() { .collect(); let want: Vec<&str> = lines.iter().map(String::as_str).collect(); expect(&v, &want); - for e in v["turing_profile"]["G"]["background"] - .as_array_mut() - .unwrap() - { - e["revision"] = json!(format!("sha256:{}", "0".repeat(64))); + for i in &pending { + v["turing_profile"]["G"]["background"][*i]["revision"] = + json!(format!("sha256:{}", "0".repeat(64))); } expect(&v, &[]); + v["turing_profile"]["G"]["background"][0]["revision"] = json!("main"); + expect( + &v, + &["turing_profile.G.background[0].revision: \"main\" is not a commit id or sha256:<64 hex>"], + ); } #[test]