Skip to content

feat(format): drift-detection-v1 4-gate PARTIAL discharge#1374

Closed
noahgift wants to merge 2 commits into
mainfrom
feat/drift-001-004-partial-discharge
Closed

feat(format): drift-detection-v1 4-gate PARTIAL discharge#1374
noahgift wants to merge 2 commits into
mainfrom
feat/drift-001-004-partial-discharge

Conversation

@noahgift
Copy link
Copy Markdown
Contributor

@noahgift noahgift commented May 2, 2026

Summary

  • Binds FALSIFY-DRIFT-001..004 from drift-detection-v1 at PARTIAL_ALGORITHM_LEVEL via 4 verdict functions + in-module reference classifier.
  • 29 unit tests including a 81-pair monotonicity sweep (DRIFT-002).
  • Algorithm-level coverage advances by 4 gates; runtime ship % unchanged.

Gates bound

Gate ID Rule
DRIFT-001 drift_score >= 0 AND is_finite() for all inputs
DRIFT-002 s_lo <= s_histatus(s_lo) <= status(s_hi) (monotone)
DRIFT-003 |data| < min_samplesstatus == NoDrift (fail-closed)
DRIFT-004 mu_ref == mu_curscore == 0 AND status == NoDrift

Reference impl

univariate_drift_score(mu_ref, mu_cur, sigma_ref) = |mu_ref - mu_cur| / sigma_ref (NaN on sigma_ref <= 0).
classify_drift(score, warn, drift) — fail-closed NoDrift on invalid thresholds.

Five Whys

See commit message — captures why fail-closed on invalid thresholds (Gama 2004 reasoning) and why the reference classifier ships in-module rather than coupling to a downstream impl.

Test plan

  • cargo test -p aprender-core --lib drift_001_004 — 29 passed
  • PMAT pre-commit gates green
  • CI green

🤖 Generated with Claude Code

Binds FALSIFY-DRIFT-001..004 from drift-detection-v1 at
PARTIAL_ALGORITHM_LEVEL via 4 verdict functions plus a pure-Rust
reference classifier (univariate_drift_score + classify_drift).

- DRIFT-001: drift_score >= 0 for all inputs
- DRIFT-002: higher score → equal-or-higher severity (monotone)
- DRIFT-003: |data| < min_samples → NoDrift
- DRIFT-004: identical reference == current → score=0 → NoDrift

## Five Whys

1. Why does drift-detection-v1 list 4 falsification IDs without
   algorithm-level discharge? PMAT lints flagged FALSIFY-DRIFT-001..004
   as unbound at PARTIAL_ALGORITHM_LEVEL.
2. Why does that block ship? Coverage % cannot move while peripheral
   ML monitoring contracts have no algorithm-level verdict module.
3. Why bind both verdicts AND a reference classifier? The
   monotone-classification gate (DRIFT-002) requires a deterministic
   threshold predicate; the identical-distribution gate (DRIFT-004)
   requires that mu_ref == mu_cur ⇒ score == 0. Both need the
   classifier in-module to avoid coupling the verdict to a specific
   downstream impl.
4. Why fail-closed (NoDrift) on invalid thresholds? Per Gama 2004,
   alarming on insufficient or malformed input is a worse failure
   mode than missing real drift; the spec lists `min_samples_guard`
   as an invariant for this reason.
5. Why a 7-section mutation-survey layout? The score-sweep over 81
   pairs (9×9 probes around the threshold band) catches AND→OR
   classification mutations and off-by-epsilon boundary regressions
   that single-fixture tests would miss.

Adds 29 unit tests. Realistic-healthy vector covers a passing
production scenario; pre-fix vector encodes the 4 regression classes
(sign-bug, inverted-threshold, premature-alarm, invalid-sigma).

No runtime % shift; algorithm-level coverage advances by 4 gates.
@noahgift noahgift force-pushed the feat/drift-001-004-partial-discharge branch from 066f46d to a098426 Compare May 11, 2026 15:45
@noahgift noahgift enabled auto-merge (squash) May 11, 2026 15:45
@noahgift
Copy link
Copy Markdown
Contributor Author

Superseded by #1637 (135-PR squash). The commit content is included verbatim in that PR's diff. Closing now to release runner slots; this PR would have auto-closed when #1637 merges.

@noahgift noahgift closed this May 12, 2026
auto-merge was automatically disabled May 12, 2026 09:21

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant