Skip to content

Commit 31502d5

Browse files
committed
Validate final routing policies and harden artifact loading
Reserve independent final-policy data, validate required OOD artifacts and stage artifact publication with rollback on exceptions. Update API documentation, examples and diagnostic reports to match serving behavior.
1 parent 169edf8 commit 31502d5

31 files changed

Lines changed: 1821 additions & 988 deletions

‎AGENTS.md‎

Lines changed: 146 additions & 156 deletions
Large diffs are not rendered by default.

‎CHANGELOG.md‎

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,29 @@ versioning.
55

66
## Unreleased
77

8+
These entries describe repository source. They do not announce a new PyPI or
9+
npm release; check the installed package version before relying on them.
10+
11+
### Documentation
12+
- Document direct student predictions, teacher deferral and the OOD guard.
13+
- Add an [overview](docs/system1.md) covering the teacher/student contract,
14+
meaningful quality and cost measurements, free self-hosting, and the boundary
15+
between this library and the hosted application's managed features.
16+
- Clarify that OSS OOD rejection is currently reported as `deferred`, that
17+
acceptance scores are not certified per-request probabilities, and that
18+
fixed-label fitting does not train a general zero-shot model or its encoder.
19+
- Correct stale integration examples and unsupported latency, savings and
20+
monotonic-coverage claims. Keep historical paper results identified as such.
21+
822
### Fixed
23+
- Make direct `fit()` transactional as well as `update()`: partial reports,
24+
indexes, or manifests cannot replace a previously working generation.
25+
- Fail loading when a present or required OOD guard is unreadable or missing;
26+
preserve legacy unguarded artifacts without inventing a certificate.
27+
- Reserve final certification rows before fitting, label discovery or balancing.
28+
Check the selected serving policy, including its development-only OOD guard,
29+
once using a one-sided agreement lower bound; never retry other candidates
30+
using these outcomes. Zero accepted examples cannot certify a policy.
931
- Preserve the previous artifact generation when an update fails validation,
1032
fitting, or publication. Honor explicit update configuration without mutating
1133
the caller, retain saved configuration by default, and increment the fit count.
@@ -26,6 +48,15 @@ versioning.
2648
- Correct update examples to use `new_embeddings=`.
2749

2850
### Changed (breaking)
51+
- New fits reserve 20% of rows by default (`certification_fraction`) and use
52+
`certification_alpha=0.10`. Small or uncertain fits may now decline deployment.
53+
`manifest.certification` records the result; legacy-named `coverage_cal` and
54+
`teacher_agreement_cal` now measure this final partition for new artifacts.
55+
The confidence statement requires independent representative examples and
56+
does not cover distribution shift, correlated sessions, or adaptive reuse.
57+
- Persist `ood_reference.npy` separately from all embeddings used for updates.
58+
Existing artifacts keep their previous behavior unless their guard is broken.
59+
- Remove unsupported universal coverage, savings and monotonic-growth claims.
2960
- The prediction server binds to `127.0.0.1` by default and no longer sends a
3061
wildcard CORS header. Explicitly configure a remote bind address when needed;
3162
browser deployments should configure CORS at their authenticated proxy.
@@ -85,6 +116,10 @@ versioning.
85116

86117
## 0.2.0 (2026-06)
87118

119+
Historical release notes. The scan remains a diagnostic; the calibration
120+
procedure described here is superseded by the independent final-policy check
121+
in Unreleased. These entries do not establish current deployment guarantees.
122+
88123
### Added
89124
- `tracer.scan()`: a fast, conservative day-one read of a traces file, before any
90125
training. It groups traffic by similarity and measures, on a held-out slice it
@@ -106,11 +141,11 @@ versioning.
106141
`embeddings=`, or select a local sentence-transformers model with `model=`.
107142

108143
### Changed
109-
- The parity gate now certifies on an exact held-out lower bound instead of an
110-
in-sample point estimate, so a policy cannot clear the target by in-sample luck
111-
and then break the contract on real traffic. Coverage is now monotonic in the
112-
target, and a hybrid select-then-verify procedure recovers coverage at strict
113-
targets that a plain held-out split discarded.
144+
- The parity gate introduced held-out lower-bound checks and a hybrid
145+
select-then-verify procedure. Later review found that selection and final
146+
certification must use separate data; see Unreleased. This historical
147+
procedure does not guarantee agreement on future traffic or monotonic
148+
coverage across targets.
114149
- The HTML report is restyled to the light Tracer theme, and the word "audit" is
115150
dropped across the report and docs.
116151

‎CONTRIBUTING.md‎

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
Thank you for your interest in contributing.
44

5-
TRACER is a routing library with formal parity guarantees, and those guarantees
6-
only mean something if they hold up under measurement. So for anything that can
7-
change routing behavior, the most useful thing you can bring is evidence. The
8-
standards below exist to keep contributions focused and to make the best use of
9-
your time and ours. None of this is meant to gatekeep good ideas. it's meant to
10-
help us evaluate them fairly.
5+
TRACER builds task-specific classifiers: classical or
6+
shallow neural classifiers make direct fixed-label decisions, while a learned
7+
policy leaves other requests to the caller's teacher. The final check bounds
8+
teacher agreement under stated sampling assumptions. It does not guarantee
9+
ground-truth accuracy, per-request correctness or robustness to distribution
10+
shift. Contributions should preserve those distinctions and provide evidence
11+
for changes in behavior.
1112

1213
## Contribution standards (read first)
1314

@@ -24,8 +25,8 @@ for us to act on when they come with numbers. Three guidelines follow from that.
2425

2526
2. **Changing a core parameter, threshold, or gate: bring an ablation.** The
2627
acceptor threshold, the parity gate, the calibration logic, the default
27-
`FitConfig` values, and the split strategy are load-bearing for the parity
28-
guarantee. A change to any of them is much easier to accept with before/after
28+
`FitConfig` values, and the split strategy determine the statistical contract.
29+
A change to any of them is much easier to accept with before/after
2930
numbers on the eval showing the frontier does not regress (and, ideally,
3031
improves). If you think a parameter should be user-tunable, the most
3132
convincing case is one where a different value measurably wins.
@@ -45,14 +46,23 @@ Run against a fixed, public eval so results are reproducible by a maintainer:
4546
- Use a known dataset (the repo's test fixtures, or a public set such as
4647
Banking77) and a fixed `seed`.
4748
- Report the metric that matters: **coverage at the target teacher agreement**
48-
(how much traffic the surrogate can take while holding parity), plus the
49-
realized teacher agreement on a held-out split (not the calibration split).
49+
together with accepted counts, realized agreement, the final lower bound and
50+
confidence level. Use an untouched evaluation split, not the examples used
51+
for classifier/threshold selection. Where ground truth exists, report its
52+
accuracy separately, including per-class or worst-group behavior.
53+
- Measure full-path latency and cost when claiming efficiency: embeddings,
54+
student inference, teacher deferrals and relevant serving overhead. A gate's
55+
score is not a calibrated per-request correctness probability.
56+
- Separate sessions/workflows/time where the dataset permits; random row splits
57+
do not establish independence. Preserve historical benchmark results and label
58+
new results with their exact implementation and evaluation protocol.
5059
- Compare against the current behavior on `main`, so the delta is clear.
5160
- Include the exact command and config you ran so the numbers can be checked.
5261

53-
If a change does not move the frontier (or regresses it), we'll usually hold
54-
off on merging even when the code itself is clean, since the numbers are what
55-
we're optimizing for.
62+
Performance proposals should show their tradeoff. Correctness fixes, truthful
63+
contracts and reproducible failure handling are valuable even when they reduce
64+
previously overstated coverage; they do not need an invented benchmark win.
65+
Never retune a policy against its final certification outcomes to make it pass.
5666

5767
## Setup
5868

@@ -68,6 +78,8 @@ pip install -e ".[dev]"
6878
## Running tests
6979

7080
```bash
81+
TOKENIZERS_PARALLELISM=false RAYON_NUM_THREADS=1 OMP_NUM_THREADS=1 \
82+
OPENBLAS_NUM_THREADS=1 MKL_NUM_THREADS=1 VECLIB_MAXIMUM_THREADS=1 \
7183
pytest tests/ -v
7284
```
7385

@@ -97,6 +109,8 @@ src/tracer/
97109
types.py <- TraceRecord, QualitativeReport, ArtifactManifest, ...
98110
fit/
99111
pipeline.py <- global / L2D / RSB pipeline construction + calibration
112+
certification.py <- untouched final-policy teacher-agreement check
113+
ood.py <- distance guard, included in final serving check
100114
surrogate.py <- model zoo (LogReg, SGD, MLP, RF, ET, DT, GBT, XGB) + selection
101115
analysis/
102116
qualitative.py <- XAI report: slices, boundary pairs, examples, deltas
@@ -134,17 +148,30 @@ further. It's usually quick to run, and it's the thing that lets us say yes.
134148

135149
## Changing the gate, calibration, or default config
136150

137-
These are the parts that back the parity guarantee. A PR here must include an
138-
ablation: the frontier on `main` versus the frontier with your change, on the
139-
same eval and seed. State clearly which guarantee you are strengthening and
140-
show it does not regress coverage or realized agreement.
151+
These parts define selection and final certification. Performance changes need
152+
an ablation on the same external evaluation and seed. Contract/correctness fixes
153+
need focused regressions that demonstrate the broken behavior and its repair.
154+
Verify that no final outcomes influence training, threshold selection, OOD
155+
fitting or retries. Keep no-policy results, exceptions and legacy-artifact
156+
behavior explicit; a completed failed check and a failed write are different.
141157

142158
## Adding a new pipeline family
143159

144160
Implement a `build_<name>(split, target_ta) -> dict` function in
145161
`src/tracer/fit/pipeline.py` following the same structure as `build_global`,
146162
`build_l2d`, and `build_rsb`. Register it in the `builders` dict inside
147-
`fit_frontier`. Include a benchmark showing where the new family wins.
163+
`fit_frontier`, preserving the builders' keyword options. Include a benchmark
164+
showing where the new family wins. The full selected policy, including residual
165+
stages and OOD checks, must receive the final check and match runtime behavior.
166+
167+
## Documentation and integration boundaries
168+
169+
Check examples against current function signatures and saved artifact fields.
170+
The bundled HTTP server takes vectors and does not call teachers. Generic
171+
embedding/export adapters do not imply a turnkey provider integration or
172+
standards-compliant OTLP transport. The current package exposes Python APIs,
173+
not a packaged CLI; hosted catalogs, credentials and Echo wallets are separate.
174+
Document proposed features as proposals rather than existing OSS capabilities.
148175

149176
## Submitting a PR
150177

0 commit comments

Comments
 (0)