Skip to content

feat(format): encoder-roundtrip-v1 + gateway-contract-v1 7-gate PARTIAL discharge#1398

Open
noahgift wants to merge 1 commit intomainfrom
feat/rt-gw-001-007-partial-discharge
Open

feat(format): encoder-roundtrip-v1 + gateway-contract-v1 7-gate PARTIAL discharge#1398
noahgift wants to merge 1 commit intomainfrom
feat/rt-gw-001-007-partial-discharge

Conversation

@noahgift
Copy link
Copy Markdown
Contributor

@noahgift noahgift commented May 2, 2026

Summary

Bundles two sister contracts:

  • encoder-roundtrip-v1 (FALSIFY-RT-001..003): APR F32 bit-exact, GGUF shape preservation, SafeTensors metadata
  • gateway-contract-v1 (FALSIFY-GW-001..004): MQS zeroing, two-phase, G4 25% threshold, 5 gateway types

29 unit tests including a 32-case 5-gate truth table + 6-bucket threshold sweep.
Algorithm-level coverage advances by 7 gates; runtime ship % unchanged.

Gates bound

Gate ID Rule
RT-001 APR F32 roundtrip bit-exact
RT-002 GGUF export→import preserves names + ranks + dims
RT-003 SafeTensors metadata HashMap roundtrip
GW-001 Any gateway failure → MQS == 0
GW-002 G0 sub-gates complete before scenarios
GW-003 G4 passes iff garbage ≤ evidence/4
GW-004 check_gateways returns exactly 5 items

Five Whys

See commit message — captures bit-exact for RT-001, exhaustive 32-case truth table for GW-001, and fail-on-zero-evidence for GW-003.

Test plan

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

🤖 Generated with Claude Code

…AL discharge

Bundles two sister contracts in one verdict module:

encoder-roundtrip-v1 (FALSIFY-RT-001..003):
- RT-001: APR write→read F32 preserves bits exactly
- RT-002: GGUF export→import preserves names + ranks + dims
- RT-003: SafeTensors save→load preserves metadata HashMap

gateway-contract-v1 (FALSIFY-GW-001..004):
- GW-001: any gateway failure zeros MQS (no partial credit)
- GW-002: G0 sub-gates complete before scenarios run
- GW-003: G4 passes iff garbage_count ≤ evidence_count / 4
- GW-004: check_gateways always returns exactly 5 items

## Five Whys

1. Why bundle these two contracts? Both peripheral, span the
   format-roundtrip + scoring-gateway coverage band; one verdict
   module captures both without provenance pin overhead.
2. Why does this block ship? Coverage % cannot move while these
   peripheral contracts are unbound at PARTIAL_ALGORITHM_LEVEL.
3. Why bit-exact (`to_bits()`) for RT-001 (not f32-tolerant)? The
   spec says "byte-level buffer equality." Round-trip through APR
   is a memory-layout op, not a float arithmetic op — even one ULP
   of drift indicates corrupt serialization (wrong endianness,
   stale bytes, off-by-one offset).
4. Why a 5-gate truth table for GW-001 (32 cases)? The contract's
   "any failure zeros MQS" predicate is binary across 5 dimensions.
   Sweeping all 32 (false/true)^5 combinations exhaustively proves
   the AND-aggregate logic and catches every single-bit mutation
   that would let a partial-credit bug slip through.
5. Why fail-on-zero-evidence for GW-003? Vacuous Pass when
   `evidence_count == 0` would mask the regression class
   "evidence collection broke and produced empty output." Per the
   contract's intent, an empty evidence set means the gate didn't
   actually run, not that it passed by default.

Adds 29 unit tests including a 32-case 5-gate truth table for GW-001
and a 6-bucket 25% threshold sweep for GW-003. Realistic-healthy
walks the canonical post-roundtrip + all-pass-gateway state; pre-fix
walks 7 simultaneous regressions.

No runtime % shift; algorithm-level coverage advances by 7 gates.
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