Files
OBLITERATUS/docs/REGRESSION_LIBRARY.md
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

134 lines
6.8 KiB
Markdown

# Regression library and monitoring
The regression library turns a run's confirmed cases, failures and interaction
surprises into versioned suites, marks evidence stale when something it depends
on changes, and records re-runs next to the historical evidence. It is stored
beside an observation run as `<run>/regression/`.
```bash
obliteratus experiments regression build --run ./observations/<digest>
obliteratus experiments regression observe snapshot.json --run ./observations/<digest>
obliteratus experiments regression status --run ./observations/<digest>
obliteratus experiments regression revalidate --run ./observations/<digest>
obliteratus experiments regression run --run ./observations/<digest> --case sha256:<case>
obliteratus experiments regression run --run ./observations/<digest> --plan sha256:<plan>
```
```python
from obliteratus.experiments import regression
from obliteratus.experiments.regression_status import status
regression.build(run)
regression.observe(run, regression.model_snapshot(model, tokenizer, "org/model"))
report = status(run)
plan = regression.revalidate(run)
regression.run_case(run, plan["cases"][0]["case"])
```
## Cases
`build` reads the run's evidence through each feature's own loader and
recomputes its outcome:
| Kind | Source | Measured value |
| --- | --- | --- |
| `confirmation`, `replication` | unlocked registry results (verdict recomputed) | intended minus baseline target success at the decision dose |
| `verification` | persistent-candidate reload verifications | candidate target success rate |
| `qualification` | backend qualification attempts (evaluation digest checked) | backend target success rate |
| `interaction` | interaction results (statistics recomputed) | interaction or order-sensitivity estimate |
Supported, passed and qualified evidence goes to the `confirmed` suite; negative
results and failed verifications or qualifications to `failures`; detected
interactions and order sensitivities to `surprises`.
A case references its evidence as `{path, sha256, pointer}` and copies no score
other than its expectation: the outcome and the value at the pointer, with a
tolerance (the evidence's declared `target_rate` when it has one, otherwise
0.05 or `--tolerance`). It records what is needed to reproduce it: model id,
revision, sampled weight fingerprint and tokenizer vocabulary digest; dataset
pack, revision, role and rows digest; scorer ids and versions; backend label,
runtime and descriptor; and the recipe (spec digest, registration, candidate,
dataset and tolerances). Its id is the canonical SHA-256 of the whole case.
Each build that changes the cases writes `suites/NNNN.json` once, with the
previous version's id. An unchanged build writes nothing. Results recorded by
`run` never become new historical cases.
## Dependencies and staleness
Every case depends on edges `{kind, key, value}`:
| Kind | Key | Value | Current value from |
| --- | --- | --- | --- |
| `model` | model id | sampled weight fingerprint | snapshot `models` |
| `tokenizer` | model id | vocabulary digest | snapshot `models[...].tokenizer_vocab_sha256` or `tokenizers` |
| `dataset` | pack reference | dataset revision | snapshot `datasets` |
| `scorer` | scorer id | version | installed scorers, or snapshot `scorers` |
| `backend` | backend label | runtime (`unrecorded` if none was kept) | snapshot `backends` |
| `direction` | target | edited vector digest | snapshot `directions` |
| `feature` | feature report or direction artifact path | file SHA-256 | the file |
| `artifact` | candidate id | artifact digest | the candidate store |
`observe` appends a snapshot to `dependencies.jsonl`; later snapshots replace
earlier values key by key. Evidence is `stale` when any edge now has a different
value. Staleness is computed when status is read; nothing in the evidence or the
suite changes. A dependency without a current value is listed under
`unobserved`, not treated as changed. Evidence that did not record its backend
runtime becomes stale as soon as a runtime is observed for its backend label.
A model is matched by weight fingerprint, never by name. When a snapshot gives a
model id new weights, every case on the old weights is stale and the dashboard
adds an `untested` row for each affected condition on the new weights.
## Status
Per case, the latest validation is the newest re-run, or the historical evidence
when there is none:
* `invalid`: the case's evidence, or its latest re-run, no longer has its SHA-256;
* `regressed`: the latest re-run's outcome differs, or its value is outside the
tolerance;
* `stale`: a dependency changed since the latest validation;
* `current`: otherwise.
`status` (schema `obliteratus.regression-status`, version 1) returns:
* `cases`: status, reasons, expectation, latest observation and full re-run history;
* `conditions`: per intervention, one row per condition (task, domain, backend,
model with fingerprint), with expected and observed values, validation and
regression counts. Conditions are never pooled into one score;
* `dashboard`: rows of intervention by condition with status (`current`,
`stale`, `regressed`, `invalid`, `untested`) and capability (`works`, `fails`,
`surprise`, `mixed`, `unknown`), plus counts. Backends listed in a snapshot's
`declared_backends` without a qualification attempt are `untested` rows;
* `graph`: the evidence-to-dependency graph.
A `fails` row whose status is `current` means the recorded failure still holds.
## Revalidation and re-runs
`revalidate` writes `plans/<id>.json` once: the suites and cases that are stale,
regressed or invalid, each with the command that re-runs it.
`run` re-runs a case through its feature's harness (or takes `--result`, a result
already produced by that harness) and measures the new result with the same
extractor as the case. The result must come from the same recipe (spec digest,
registration, candidate, backend and dataset) and must not be the historical
evidence. It is appended to `results.jsonl` with its own evidence digest,
observation, dependencies and a link to the case (`suite_file` and JSON
pointer). Every log line carries the SHA-256 of the previous line, so an edited,
removed or reordered line is refused. The command exits 1 when a re-run regressed.
The harness rules still apply: a re-run verification that fails marks its
candidate failed, a re-run qualification adds an attempt to the support matrix,
a re-run confirmation records an exposure, and a model whose identity no longer
matches the dossier is refused before a forward pass.
## Limits
Sequences and recovered candidates are not yet collected as cases. A re-run on
new weights is usually refused by the harness, because dossiers bind a model
identity; new weights need new evidence, which then appears as new cases on a
later build. Snapshots are declared by the operator, except installed scorer
versions and file-backed dependencies, which are read directly.