mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-05 18:44:41 +01:00
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>
78 lines
4.4 KiB
Python
78 lines
4.4 KiB
Python
"""``obliteratus experiments regression build|observe|status|revalidate|run``."""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
|
|
def add_regression(commands):
|
|
parser = commands.add_parser(
|
|
"regression", help="Regression library: versioned suites of confirmed cases, failures "
|
|
"and interaction surprises, dependency staleness and re-runs")
|
|
sub = parser.add_subparsers(dest="regression_command", required=True)
|
|
build = sub.add_parser("build", help="Write a new suite version from a run's evidence")
|
|
observe = sub.add_parser("observe", help="Record current dependency values (snapshot JSON)")
|
|
observe.add_argument("snapshot", help="Snapshot JSON file (models, tokenizers, datasets, "
|
|
"scorers, backends, directions, declared_backends)")
|
|
status = sub.add_parser("status", help="Current, stale, regressed and untested evidence")
|
|
revalidate = sub.add_parser("revalidate", help="Write the plan of cases to re-run")
|
|
run = sub.add_parser("run", help="Re-run one case (or every case of a plan) and append "
|
|
"the new result")
|
|
target = run.add_mutually_exclusive_group(required=True)
|
|
target.add_argument("--case", help="Case id (sha256:...)")
|
|
target.add_argument("--plan", help="Plan id (sha256:...) from revalidate")
|
|
run.add_argument("--result", help="An already produced result file for --case")
|
|
for command in (build, observe, status, revalidate, run):
|
|
command.add_argument("--run", required=True, help="Observation run directory")
|
|
command.add_argument("--library", help="Library directory (default <run>/regression)")
|
|
build.add_argument("--tolerance", type=float, default=None,
|
|
help="Tolerance of cases whose evidence declares none (default 0.05)")
|
|
for command in (status, revalidate):
|
|
command.add_argument("--snapshot", help="Evaluate against this snapshot JSON instead of "
|
|
"the observed ones")
|
|
for command in (build, observe, run):
|
|
command.add_argument("--actor", help="Who acts (default: the login name)")
|
|
|
|
|
|
def _json(path):
|
|
return json.loads(Path(path).read_text(encoding="utf-8")) if path else None
|
|
|
|
|
|
def run_regression_command(args):
|
|
from obliteratus.experiments import regression as reg
|
|
command = args.regression_command
|
|
if command == "build":
|
|
from obliteratus.experiments.regression_cases import DEFAULT_TOLERANCE
|
|
tolerance = DEFAULT_TOLERANCE if args.tolerance is None else args.tolerance
|
|
found = reg.build(args.run, library=args.library, tolerance=tolerance, actor=args.actor)
|
|
return {"version": found["version"], "id": found["id"], "unchanged": found["unchanged"],
|
|
"suites": {n: {"id": s["id"], "cases": len(s["cases"])}
|
|
for n, s in found["suites"].items()},
|
|
"skipped": found["skipped"]}
|
|
if command == "observe":
|
|
return reg.observe(args.run, _json(args.snapshot), library=args.library, actor=args.actor)
|
|
if command == "status":
|
|
from obliteratus.experiments.regression_status import status
|
|
return status(args.run, library=args.library, snapshot=_json(args.snapshot))
|
|
if command == "revalidate":
|
|
return reg.revalidate(args.run, library=args.library, snapshot=_json(args.snapshot))
|
|
from obliteratus.experiments.regression_store import Library
|
|
from obliteratus.experiments.inputs import default_pack_resolver
|
|
if args.plan:
|
|
plan_file = Library(args.run, args.library).path / "plans" / \
|
|
f"{args.plan.removeprefix('sha256:')}.json"
|
|
cases = [c["case"] for c in _json(plan_file)["cases"]]
|
|
else:
|
|
cases = [args.case]
|
|
if args.result and len(cases) != 1:
|
|
raise ValueError("--result names the new result of exactly one --case")
|
|
recorded = [reg.run_case(args.run, case, result=args.result, library=args.library,
|
|
actor=args.actor, pack_resolver=default_pack_resolver)
|
|
for case in cases]
|
|
return {"results": [{k: r[k] for k in ("seq", "id", "case", "status", "reasons",
|
|
"observed", "expected", "evidence", "case_link")}
|
|
for r in recorded],
|
|
"regressions": sum(r["status"] == "regression" for r in recorded)}
|
|
|
|
|
|
__all__ = ["add_regression", "run_regression_command"]
|