feat(format): encoder-roundtrip-v1 + gateway-contract-v1 7-gate PARTIAL discharge#1398
Open
feat(format): encoder-roundtrip-v1 + gateway-contract-v1 7-gate PARTIAL discharge#1398
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bundles two sister contracts:
encoder-roundtrip-v1(FALSIFY-RT-001..003): APR F32 bit-exact, GGUF shape preservation, SafeTensors metadatagateway-contract-v1(FALSIFY-GW-001..004): MQS zeroing, two-phase, G4 25% threshold, 5 gateway types29 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
garbage ≤ evidence/4check_gatewaysreturns exactly 5 itemsFive 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🤖 Generated with Claude Code