Files
OBLITERATUS/obliteratus/experiments/regression_exec.py
Joseph MaglyandClaude Opus 5.5 189311e5d0 feat(experiments): regression library and dependency-triggered revalidation
Add F22: versioned regression suites built from confirmed cases,
failures and interaction surprises, with computed staleness when a
dependency changes and append-only re-run history.

- Cases point at the original evidence by path, digest and pointer
  (never copying scores) and record what reproduces them: model and
  weight fingerprint, tokenizer, dataset revision and rows digest,
  scorer versions, backend descriptor and recipe, plus the expected
  outcome with tolerance. Suite versions are write-once and chained.
- A dependency graph covers weights, tokenizer, dataset, scorer,
  backend runtime, directions, report files and artifacts. Staleness is
  computed on read; models match by weight fingerprint, so a same-name
  model with new weights inherits no qualification.
- Re-runs go through each feature's own run function and append to a
  hash-chained results log; regressions link to their case, and history
  stays byte-identical.
- Status and the conditions table report per intervention and condition
  (task, domain, backend, model), with no single aggregate.
- `obliteratus experiments regression build|observe|status|revalidate|run`.

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

71 lines
3.1 KiB
Python

"""Re-run a regression case's recorded recipe through its own feature's harness.
Each executor returns the path of the new evidence file; the harness writes it
as a new attempt next to the historical ones (a controlled intervention or
interaction runs with ``rerun=True``, a verification or qualification adds an
attempt). Its own rules still apply: a verification that fails marks the
candidate failed, and a model whose identity no longer matches the dossier is
refused before any forward pass.
Harness options (``model_factory``, ``model_io``, ``pack_resolver``) pass through.
"""
from __future__ import annotations
import json
from obliteratus.analysis import dossier_refs as refs
def _intervention(run_dir, case, *, model_factory=None, pack_resolver=None, **_):
from obliteratus.experiments.intervention_runner import run_intervention
from obliteratus.experiments.registry_store import Registry
document = Registry(run_dir).get(case["reproduce"]["recipe"]["registration"])
result = run_intervention(document["frozen"]["recipe"]["spec"], run_dir, rerun=True,
model_factory=model_factory, pack_resolver=pack_resolver)
return result["location"]["result"]
def _interaction(run_dir, case, *, model_factory=None, pack_resolver=None, **_):
from obliteratus.experiments.interaction_runner import run_interaction
stored = refs.resolve_path(case["evidence"]["path"], run_dir)
spec = json.loads(stored.read_text(encoding="utf-8"))["spec"]
result = run_interaction(spec, run_dir, rerun=True, model_factory=model_factory,
pack_resolver=pack_resolver)
return result["location"]["result"]
def _verification(run_dir, case, *, model_io=None, pack_resolver=None, **_):
from obliteratus.experiments import candidate as cand
from obliteratus.experiments.candidate_verify import verify_candidate
recipe = case["reproduce"]["recipe"]
record = verify_candidate(run_dir, recipe["candidate"], recipe["dataset"],
model_io=model_io, pack_resolver=pack_resolver)
return str(cand.candidate_path(run_dir, recipe["candidate"]) / cand.VERIFICATIONS
/ f"{record['attempt']:04d}" / "verification.json")
def _qualification(run_dir, case, *, model_io=None, pack_resolver=None, **_):
from pathlib import Path
from obliteratus.experiments.backend_qualify import qualify
recipe = case["reproduce"]["recipe"]
descriptor = case["reproduce"]["backend"]["descriptor"]
record = qualify(run_dir, recipe["candidate"], descriptor, recipe["dataset"],
model_io=model_io, pack_resolver=pack_resolver,
tolerances_override=recipe.get("tolerances"))
return str(Path(record["location"]) / "qualification.json")
EXECUTORS = {"confirmation": _intervention, "replication": _intervention,
"interaction": _interaction, "verification": _verification,
"qualification": _qualification}
def execute(run_dir, case, **harness):
"""Path of a new result for ``case`` produced by its feature's harness."""
return EXECUTORS[case["kind"]](run_dir, case, **harness)
__all__ = ["EXECUTORS", "execute"]