mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-05 10:34:23 +01:00
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>
91 lines
4.5 KiB
Python
91 lines
4.5 KiB
Python
"""``obliteratus experiments numeric-geometry template|synthetic|pretrained|dossier`` (issue #511).
|
|
|
|
``synthetic`` runs the golden CPU fixture. ``pretrained`` loads the pinned
|
|
checkpoint and is refused unless ``OBLITERATUS_NUMERIC_GEOMETRY_E2E=1`` is set
|
|
and the campaign pins both revisions; default CI never runs it.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
OPT_IN = "OBLITERATUS_NUMERIC_GEOMETRY_E2E"
|
|
|
|
|
|
def add_numeric_geometry(commands):
|
|
parser = commands.add_parser(
|
|
"numeric-geometry", help="Bounded numeric geometry preservation: does a declared mean "
|
|
"shift keep the non-target spread (preregistered, opt-in "
|
|
"pretrained)")
|
|
sub = parser.add_subparsers(dest="numeric_geometry_command", required=True)
|
|
template = sub.add_parser("template", help="Write the campaign and preregistration "
|
|
"templates")
|
|
template.add_argument("--out", required=True, help="Directory for the two JSON files")
|
|
for name, text in (("synthetic", "Run the golden synthetic fixture"),
|
|
("pretrained", f"Run the pinned pretrained campaign ({OPT_IN}=1)")):
|
|
run = sub.add_parser(name, help=text)
|
|
run.add_argument("--campaign", help="Campaign JSON (default: built-in template)",
|
|
required=name == "pretrained")
|
|
run.add_argument("--preregistration", help="Unfrozen preregistration JSON "
|
|
"(default: built-in template)",
|
|
required=name == "pretrained")
|
|
run.add_argument("--out", required=True, help="Result JSON path")
|
|
run.add_argument("--dossier", help="Also write the Markdown result dossier here")
|
|
if name == "synthetic":
|
|
run.add_argument("--variant", choices=("preserving", "distorting"),
|
|
default="preserving")
|
|
dossier = sub.add_parser("dossier", help="Render the Markdown dossier of a result")
|
|
dossier.add_argument("result", help="Result JSON")
|
|
dossier.add_argument("--out", required=True, help="Markdown path")
|
|
|
|
|
|
def _load(path, default):
|
|
return json.loads(Path(path).read_text(encoding="utf-8")) if path else default()
|
|
|
|
|
|
def _write_json(path, value):
|
|
path = Path(path)
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text(json.dumps(value, sort_keys=True, indent=1) + "\n")
|
|
return str(path)
|
|
|
|
|
|
def run_numeric_geometry_command(args):
|
|
from obliteratus.analysis import numeric_geometry_dossier as dossier
|
|
from obliteratus.analysis import numeric_geometry_spec as spec
|
|
command = args.numeric_geometry_command
|
|
if command == "template":
|
|
out = Path(args.out)
|
|
return {"campaign": _write_json(out / "campaign.json", spec.default_campaign()),
|
|
"preregistration": _write_json(out / "preregistration.json",
|
|
spec.preregistration_template())}
|
|
if command == "dossier":
|
|
result = json.loads(Path(args.result).read_text(encoding="utf-8"))
|
|
path = Path(args.out)
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text(dossier.render_dossier(result))
|
|
return {"dossier": str(path)}
|
|
from obliteratus.analysis.numeric_geometry_eval import run_campaign
|
|
campaign = _load(args.campaign, spec.default_campaign)
|
|
prereg = _load(args.preregistration, spec.preregistration_template)
|
|
if command == "pretrained":
|
|
if os.environ.get(OPT_IN) != "1":
|
|
raise ValueError(f"Pretrained campaign is opt-in: set {OPT_IN}=1")
|
|
from obliteratus.analysis.numeric_geometry_adapter import load_pretrained
|
|
model = load_pretrained(campaign)
|
|
result = run_campaign(campaign, prereg, model, pretrained=True)
|
|
else:
|
|
from obliteratus.analysis.numeric_geometry_synthetic import synthetic_model
|
|
result = run_campaign(campaign, prereg, synthetic_model(args.variant))
|
|
path = dossier.write_result(result, args.out)
|
|
if args.dossier:
|
|
Path(args.dossier).write_text(dossier.render_dossier(result))
|
|
return {"result": str(path), "dossier": args.dossier, "rows": len(result["rows"]),
|
|
"missing": len(result["missing"]),
|
|
"scientific_evidence": result["scientific_evidence"]["level"],
|
|
"reproduction_claim": result["reproduction_claim"]["status"],
|
|
"coverage": {k: v["fraction"] for k, v in result["coverage"].items()}}
|
|
|
|
|
|
__all__ = ["OPT_IN", "add_numeric_geometry", "run_numeric_geometry_command"]
|