Files
OBLITERATUS/tests/conditional/test_numeric_geometry_pretrained.py
Joseph MaglyandClaude Opus 5.5 101cfa7c88 feat(analysis): opt-in numeric geometry preservation evaluation
Add a bounded evaluation of whether shifting a known predictive mean
preserves a known non-target spread (#511), producing reproducible
evidence and negative results rather than a universal steering claim.

- Whole sequences are split into fit, calibration and held-out
  partitions per seed block before any activation is collected.
  Geometry is fitted on fit rows only, matched-mean scales are found on
  calibration rows only, and the preregistration (tolerances, arm
  choices, scales) is frozen by digest before any held-out pass.
- Seven arms with exposed choices and reversible, restoration-checked
  hooks; matched-displacement and matched-mean comparisons are reported
  separately, and PCA-plane proximity can never establish preservation.
- Paired intervals over seed blocks, separate AdamW and L-BFGS probe
  fits (optimizer-dependent outcomes flagged conditional), explicit
  zero handling, separate costs, and exploratory labels for
  extrapolated cells. Curvature stays null.
- Golden synthetic arc fixtures with known answers: a spread-preserving
  variant and a radius-dependent variant the chord arm distorts.
- Every attempted cell, arm and comparison is logged; synthetic runs are
  rated hypothesis and never claim pretrained reproduction. The opt-in
  pretrained campaign refuses until both model revisions are pinned and
  runs only behind an explicit environment flag.
- `obliteratus experiments numeric-geometry`, catalog rows and a new
  documentation section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 22:09:11 -05:00

48 lines
2.4 KiB
Python

"""Operator-gated pretrained numeric geometry preservation campaign (issue #511).
Kept out of the hosted ``model-download-runtime`` gate: that gate rejects any
skipped test and is credential-free, while this run needs gated-model access,
pinned revisions and an accelerator sized for the declared budget. It asserts
that the run produced a complete, frozen, restored and honestly labelled
record; it never asserts that preservation succeeded.
"""
from __future__ import annotations
import json
import os
from pathlib import Path
import pytest
pytestmark = [pytest.mark.network, pytest.mark.download, pytest.mark.gpu]
OPT_IN = "OBLITERATUS_NUMERIC_GEOMETRY_E2E"
def test_pinned_pretrained_campaign_produces_a_complete_record(tmp_path):
if os.environ.get(OPT_IN) != "1":
pytest.skip(f"set {OPT_IN}=1 with OBLITERATUS_NUMERIC_GEOMETRY_CAMPAIGN and "
"OBLITERATUS_NUMERIC_GEOMETRY_PREREGISTRATION on an operator runner")
from obliteratus.analysis import numeric_geometry_dossier as dossier
from obliteratus.analysis import numeric_geometry_spec as spec
from obliteratus.analysis.numeric_geometry_adapter import load_pretrained
from obliteratus.analysis.numeric_geometry_eval import run_campaign
campaign = json.loads(Path(os.environ["OBLITERATUS_NUMERIC_GEOMETRY_CAMPAIGN"]).read_text())
prereg = json.loads(
Path(os.environ["OBLITERATUS_NUMERIC_GEOMETRY_PREREGISTRATION"]).read_text())
out = Path(os.environ.get("OBLITERATUS_NUMERIC_GEOMETRY_OUT", tmp_path))
result = run_campaign(campaign, prereg, load_pretrained(campaign), pretrained=True)
dossier.write_result(result, out / "numeric-geometry-result.json")
(out / "numeric-geometry-dossier.md").write_text(dossier.render_dossier(result))
assert result["source"]["kind"] == "pretrained"
assert result["source"]["revision"] == campaign["model"]["revision"]
assert spec.verify_frozen(result["preregistration"]) == result["preregistration_sha256"]
assert result["restoration"] == {"hooks_restored": True, "hook_free_logits_identical": True}
statuses = {r["status"] for r in result["rows"]}
assert statuses <= {"evaluated", "missing", "not_applicable", "unrun"}
assert result["reproduction_claim"]["status"] in {"not_claimed",
"supported_in_source_regime"}
assert result["curvature"] is None