fix: falsification-audit hardening — exact conservation, -O guard, empty-index join (C-67/C-68/C-69)#194
Merged
Conversation
…pty-index join (C-67/C-68/C-69) The 2026-07-02 four-axis audit's falsification phase found one hard and three soft violations of the safety claim; fix all four (bug fixes, identical contract): - C-68 (HARD): reconcile_proportional's torch-port `+ 1e-8` denominator epsilon was a float32 no-op for draw sums >~ 0.1 but SILENTLY deflated the scale factor for tiny nonzero sums (draw sum 1e-8: country total 100 reconciled to 50, no error; the package's own assert_reconcile_contract rejected its own output). Replace it with an explicit all-zero-draw guard: exact division for any nonzero sum; all-zero draws stay zero exactly as before. Bit-identical on all realistic data — torch-oracle parity unchanged and green. Also (F8): negative country totals now raise ValueError instead of silently clamping to a zero output. - C-67: the three published conformance suites were bare asserts — a silent no-op under python -O. Entry points now call _require_assertions(), raising RuntimeError under optimized bytecode instead of reporting green while dead. - C-69: searchsorted from an empty index crashed with an obscure IndexError (the np.clip(pos, 0, -1) corner); now returns all -1, the documented not-found value. Regression pins: tests/test_falsification_safety_audit_2026_07.py (written first as failing stubs, turned green by these fixes). Reconcile.md §6 + proportional.py docstring document the behaviors. Register: C-67/C-68/C-69 registered-and-resolved, C-70 (the audit's docs/tests polish bundle) opened; counts 63->67 total, 13 open, 54 resolved; /review-rr triage CLEAN. Gate: ruff / mypy (3.10+3.11) / pytest 398 passing at 100% line+branch / validate_docs all green; /review-diff CLEAN. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes all four findings of the 2026-07-02 four-axis audit's falsification phase (1 hard, 3 soft).
Bug fixes with an identical contract — the code now honors what the docs already promised. No
public-surface change;
CONFORMANCE_FLOORstays1.0.0.The hard finding — C-68
reconcile_proportional's torch-port+ 1e-8denominator epsilon was a float32 no-op for drawsums ≳ 0.1 (why no oracle/parity test ever saw it) but silently deflated the scale factor for
tiny nonzero sums: at draw-sum 1e-8 a country total of 100 reconciled to 50, no error — violating
the Reconcile.md §3 sum-to-country guarantee in-domain; the package's own
assert_reconcile_contractrejected its own output. Fix: explicit all-zero-draw guard + exact division — conservation now
exact for any nonzero sum; all-zero draws stay zero exactly as before; bit-identical on all
realistic data (torch-oracle parity green, unchanged). Also: negative country totals now raise
ValueErrorinstead of silently clamping to a zero output (F8).The soft findings
asserts) silently no-op'd underpython -O— a verified float64 non-conformer passed. Now:_require_assertions()on everyentry point →
RuntimeErrorunder optimized bytecode (refuse-to-run beats report-green-while-dead).searchsortedcrashed with an obscureIndexError(theclip(0,−1)corner) → now returns all
-1, the documented not-found value.Ritual
tests/test_falsification_safety_audit_2026_07.py(written as failing stubsduring the audit, turned green by these fixes; the F3 pin runs a
python -Osubprocess).Reconcile.md§6 +proportional.pymodule docstring (records the deliberate,parity-preserving deviation from the torch original). CHANGELOG
[Unreleased]entry.bundle); counts 63→67 total / 13 open / 54 resolved.
/review-rr triageCLEAN./review-diffCLEAN.🤖 Generated with Claude Code