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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Priority exploration experiment — evidence report (CEN-06)

Generated by `validation/report.py` from the immutable CEN-05
artifact `validation/report.json`. Regenerate and diff to review:

python3 -I validation/report.py

- Artifact schema: `pmo-offline-experiment/v1`
- Artifact SHA-256 (result digest): `818b94c4ab780d10399f6f160472c55b3f01f47cd3594afa482030173e87f006`
- Run ID: `MISSING — see Missing measurements`

## External source facts

Verbatim from the artifact; the writer adds nothing here.

- Fixture SHA-256 (provenance): `4dbab02808888bb399f87e427bf2d2187c7fdd939e575d707c8b20ebaaa79096`
- PRNG: SHA-256 counter, pmo-experiment-v1 domain separator, 53-bit uniform grid; algorithm independent of Python random module
- Limit: Design experiment only; no imports from Fleet and no production implementation tests.
- Limit: Synthetic fixtures do not establish production benefit, calibration, starvation bounds, or workload representativeness.
- Limit: The completion remote ledger is an idempotent fake; no universal exactly-once guarantee and no remote GitHub fence are modeled.
- Limit: No actual Fleet broker, Rust/TypeScript adapter, GitHub API, deployed service, or live completion behavior was tested.
- Limit: This is not formal proof, full PBT/MBT production coverage, or authorization to implement, migrate, schedule, or roll out.

## Measured model outputs

- Result: `pass`
- Seed: 9196; cases: 5000; draws: 50000
- Oracle checks recorded: 289539 across 54 named oracles
- Max error, exploration_first_draw_frequency: 0.004256898609982823
- Max error, exploration_tiny_inclusion_frequency: 0.0010684349096884427
- Max error, exploration_u_ref_invariance: 0.0
- Max error, float_vs_decimal_first_draw: 5.551115123125783e-17
- Preregistered tolerances (thresholds fixed before the run, not chosen post hoc):
- first_draw_frequency: per-category 6*sqrt(p*(1-p)/draws) + 1/draws
- float_vs_decimal_first_draw_abs: 2e-14
- probability_normalization_abs: 2e-15
- u_ref_normalized_probability_abs: 2e-15

## Inference

The synthetic reference model agreed with its independent oracles inside the preregistered tolerances above. That is evidence about the model's internal consistency only. This is a synthetic simulation: it is not a production result, and no production benefit is claimed from it.

## Recommendation

None for production. Do not enable exploration, choose production thresholds, or cite simulated benefit from this artifact alone; production adoption is a separately authorized stage with its own evidence.

## Missing measurements

- MISSING: run_id — the artifact does not carry it; this report marks it instead of inventing it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#!/usr/bin/env python3
"""CEN-06 — experiment report writer (#9436).

Translates the immutable CEN-05 experiment artifact (report.json,
produced by experiment.py) into a reviewable evidence report at
research/priority-exploration-experiment.md. The writer is separate
from the experiment on purpose: experiment code must not author its
own acceptance narrative.

The report separates, in order: external source facts (what the
artifact carries verbatim), measured model outputs (what the run
recorded), inference (what those outputs do and do not support), and
recommendation. A measurement the artifact does not carry is marked
missing by name — never filled in, never guessed. A synthetic
simulation is never called a production result, and no production
benefit is claimed.

Standard library only; deterministic output (no timestamps), so a
reviewer can regenerate the report from the immutable artifact and
diff it byte for byte.

Run: python3 -I report.py [--input report.json]
[--output ../research/priority-exploration-experiment.md]
"""

from __future__ import annotations

import argparse
import hashlib
import json
import sys
from pathlib import Path

HERE = Path(__file__).resolve().parent
DEFAULT_INPUT = HERE / "report.json"
DEFAULT_OUTPUT = HERE.parent / "research" / "priority-exploration-experiment.md"

# The measurements a reviewable evidence report requires, and where
# each must come from in the artifact. Anything absent is reported
# missing under its name here — this list is the contract the first
# oracle test (test_report.py) pins.
REQUIRED = ("run_id", "seed", "sample_count", "oracle",
"uncertainty", "fixture_provenance", "threshold")


def load_artifact(raw: bytes) -> dict:
doc = json.loads(raw.decode("utf-8"))
if not isinstance(doc, dict):
raise ValueError("experiment artifact must be a JSON object")
return doc


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


def missing_measurements(a: dict) -> list[str]:
"""Names of required measurements the artifact does not carry."""
inputs = a.get("inputs") or {}
missing = []
if not a.get("run_id"):
missing.append("run_id")
if inputs.get("seed") is None:
missing.append("seed")
if not (inputs.get("cases") and inputs.get("draws")):
missing.append("sample_count")
counts = (a.get("counts") or {}).get("by_oracle") or {}
if not (a.get("oracles") and counts):
missing.append("oracle")
stats = a.get("statistics") or {}
if not (stats.get("absolute_bounds") and a.get("max_errors")):
missing.append("uncertainty")
if not inputs.get("fixture_sha256"):
missing.append("fixture_provenance")
if not a.get("tolerances"):
missing.append("threshold")
return missing


def render_report(a: dict, digest: str) -> str:
inputs = a.get("inputs") or {}
counts = (a.get("counts") or {}).get("by_oracle") or {}
missing = missing_measurements(a)
lines = []
lines.append("# Priority exploration experiment — evidence report (CEN-06)")
lines.append("")
lines.append("Generated by `validation/report.py` from the immutable CEN-05")
lines.append("artifact `validation/report.json`. Regenerate and diff to review:")
lines.append("")
lines.append(" python3 -I validation/report.py")
lines.append("")
lines.append(f"- Artifact schema: `{a.get('schema', 'unknown')}`")
lines.append(f"- Artifact SHA-256 (result digest): `{digest}`")
lines.append(f"- Run ID: `{a.get('run_id', 'MISSING — see Missing measurements')}`")
lines.append("")
lines.append("## External source facts")
lines.append("")
lines.append("Verbatim from the artifact; the writer adds nothing here.")
lines.append("")
lines.append(f"- Fixture SHA-256 (provenance): `{inputs.get('fixture_sha256', 'MISSING')}`")
runtime = a.get("runtime") or {}
lines.append(f"- PRNG: {runtime.get('prng', 'MISSING')}")
for limit in a.get("limits") or []:
lines.append(f"- Limit: {limit}")
lines.append("")
lines.append("## Measured model outputs")
lines.append("")
lines.append(f"- Result: `{a.get('result', 'MISSING')}`")
lines.append(f"- Seed: {inputs.get('seed', 'MISSING')}; cases: "
f"{inputs.get('cases', 'MISSING')}; draws: {inputs.get('draws', 'MISSING')}")
lines.append(f"- Oracle checks recorded: {sum(counts.values())} "
f"across {len(counts)} named oracles")
for name, err in sorted((a.get("max_errors") or {}).items()):
lines.append(f"- Max error, {name}: {err}")
lines.append("- Preregistered tolerances (thresholds fixed before the run, "
"not chosen post hoc):")
for name, tol in sorted((a.get("tolerances") or {}).items()):
lines.append(f" - {name}: {tol}")
lines.append("")
lines.append("## Inference")
lines.append("")
lines.append("The synthetic reference model agreed with its independent "
"oracles inside the preregistered tolerances above. That is "
"evidence about the model's internal consistency only. This "
"is a synthetic simulation: it is not a production result, "
"and no production benefit is claimed from it.")
lines.append("")
lines.append("## Recommendation")
lines.append("")
lines.append("None for production. Do not enable exploration, choose "
"production thresholds, or cite simulated benefit from this "
"artifact alone; production adoption is a separately "
"authorized stage with its own evidence.")
lines.append("")
lines.append("## Missing measurements")
lines.append("")
if missing:
for name in missing:
lines.append(f"- MISSING: {name} — the artifact does not carry it; "
"this report marks it instead of inventing it.")
else:
lines.append("None — every required measurement is present in the artifact.")
lines.append("")
return "\n".join(lines)


def main(argv=None) -> int:
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--input", type=Path, default=DEFAULT_INPUT)
parser.add_argument("--output", type=Path, default=DEFAULT_OUTPUT)
args = parser.parse_args(argv)
raw = args.input.read_bytes()
text = render_report(load_artifact(raw), artifact_digest(raw))
args.output.write_text(text, encoding="utf-8")
print(f"wrote {args.output}")
return 0


if __name__ == "__main__":
sys.exit(main())
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env python3
"""CEN-06 — experiment report writer tests (#9436).

Oracles are independent of the writer's internals: the required
measurement names come from the CEN-06 slice text, the digest oracle
is hashlib applied to the raw artifact bytes in this file, and the
no-production-benefit oracle is a text property of the rendered
report. The committed CEN-05 artifact is read as data, never imported.

Run: python3 -m unittest -v test_report
python3 test_report.py
"""

from __future__ import annotations

import hashlib
import importlib.util
import json
import sys
import unittest
from pathlib import Path

HERE = Path(__file__).resolve().parent
spec = importlib.util.spec_from_file_location("cen06_report", HERE / "report.py")
report = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = report
spec.loader.exec_module(report)

REQUIRED = ["run_id", "seed", "sample_count", "oracle",
"uncertainty", "fixture_provenance", "threshold"]


class TestMissingMeasurements(unittest.TestCase):
def test_report_marks_missing_measurement_and_does_not_claim_production_benefit(self):
# An artifact carrying nothing: every required measurement is
# marked missing by name, and the rendered report still refuses
# to call a synthetic simulation a production result.
artifact = {}
self.assertEqual(report.missing_measurements(artifact), REQUIRED)
text = report.render_report(artifact, "0" * 64)
for name in REQUIRED:
self.assertIn(f"MISSING: {name}", text)
self.assertIn("not a production result", text)
self.assertIn("no production benefit is claimed", text)
self.assertNotIn("production benefit of", text)

def test_partial_artifact_marks_only_what_is_absent(self):
artifact = {"inputs": {"seed": 9196, "fixture_sha256": "abc"}}
missing = report.missing_measurements(artifact)
self.assertNotIn("seed", missing)
self.assertNotIn("fixture_provenance", missing)
self.assertIn("run_id", missing)
self.assertIn("oracle", missing)


class TestCommittedArtifact(unittest.TestCase):
def setUp(self):
self.raw = (HERE / "report.json").read_bytes()
self.artifact = report.load_artifact(self.raw)

def test_report_reproduces_input_result_digest(self):
digest = report.artifact_digest(self.raw)
self.assertEqual(digest, hashlib.sha256(self.raw).hexdigest())
text = report.render_report(self.artifact, digest)
self.assertIn(digest, text)
self.assertIn("9196", text) # the recorded seed, verbatim

def test_committed_artifact_missing_only_run_id(self):
# The CEN-05 artifact predates the run_id requirement: the
# writer marks exactly that one measurement missing and
# invents nothing else.
self.assertEqual(report.missing_measurements(self.artifact), ["run_id"])

def test_report_separates_facts_outputs_inference_recommendation(self):
text = report.render_report(self.artifact, report.artifact_digest(self.raw))
for header in ("## External source facts", "## Measured model outputs",
"## Inference", "## Recommendation"):
self.assertIn(header, text)

def test_report_is_deterministic(self):
digest = report.artifact_digest(self.raw)
self.assertEqual(report.render_report(self.artifact, digest),
report.render_report(self.artifact, digest))


if __name__ == "__main__":
unittest.main()