Skip to content

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

Closed
noahgift wants to merge 2 commits into
mainfrom
feat/rt-gw-001-007-partial-discharge
Closed

feat(format): encoder-roundtrip-v1 + gateway-contract-v1 7-gate PARTIAL discharge#1398
noahgift wants to merge 2 commits into
mainfrom
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.
@noahgift noahgift force-pushed the feat/rt-gw-001-007-partial-discharge branch from 4ab91b7 to 3c4a33c Compare May 11, 2026 15:21
@noahgift noahgift enabled auto-merge (squash) May 11, 2026 15:21
@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:20

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