Skip to content

Pin G3's health bound at its edge with an exhaustive test - #141

Closed
shuv-amp wants to merge 1 commit into
auto/B/alert-message-cap-r2from
auto/A/g3-exhaustive-r3
Closed

shuv-amp wants to merge 1 commit into
auto/B/alert-message-cap-r2from
auto/A/g3-exhaustive-r3

Conversation

@shuv-amp

Copy link
Copy Markdown
Owner

Opened by the Bulkhead autopilot agents: one reviewed unit of work. Every commit was reviewed adversarially by the other agent, with mutants, and passes tools/claims.py on its own.
Stacked on #140: merge that first; this PR is then rebased onto main.
The agents never merge. The owner reviews and merges.

What changed

One new core test, g3_backed_amount_is_exact_on_small_ledgers (crates/bulkhead-core/tests/exhaustive.rs), and the counts and citations that follow from it in README, docs/03, docs/09 and docs/14. Tests and docs only: no program or core source line moves. One commit, ce3db42.

G3's health bound now fails a core test when moved by one. No core test caught backed_amount accepting health -1 (ledger.rs:246, t >= 0 -> t >= -1), which leaves a ledger 1 unit short. docs/09 said so in the ledger fuzz row; only the Python differential caught it. The property test g3_backed_amount_is_sound_and_maximal checks the same rule, but its random worlds seldom land on health exactly -1.

The new test enumerates two priced mints: other and own position in -6..=12 (0 is no position); per mint, (low, high) price in (1, 1), (2, 2), (3, 3), (1, 3), haircut 5,000 or 10,000, liability weight 10,000 or 15,000; request 0..=40. That is 3,789,056 cases. Each grant must equal the largest b <= request whose ledger owes nothing or has health >= 0, restated with collateral floored at its low price and haircut and debts ceiled at their high price and weight. In 764,280 cases some b is valid and one unit more leaves health at exactly -1; the test pins that count, and a Python restatement of the same domain prints 3789056 764280.

docs/09 §2 and §5.2, README and docs/14 now say 7 exhaustive tests over ~588M inputs (584.4M + 3.8M), and §5.2 says the exhaustive suite takes ~3 s in release, not ~6 s. docs/03 §4.6 cites the test for G3. The ledger fuzz row says a core test now catches the -1 bound.

Proof

Autopilot tasks/g3-exhaustive/ (mutants.sh applies each mutant to ledger.rs and runs the core suite):

  • mutants-r4.out: M5 t >= -1 KILLED by the new test, and the rest of the core suite (with the new test skipped) passes on it, rc 0. M6 t > 0, M7 collateral rounded up, M8 debt rounded down, M9 fast path without !others_liab, M11 collateral at the high price, M12 debt at the low price: KILLED. M10 (fast path after > 0) survives this test; g2_and_fail_closed_without_prices kills it.
  • Timing: new test 0.27 s release, 4.09 s debug; exhaustive suite 2.78 to 2.83 s release over three runs.
  • Agent B reviewed it: r2 at 5112383, APPROVE (REVIEWS/auto-A-g3-exhaustive-r2-5112383.md). r3 is the same commit rebased onto 1d5e7dd with no edit: range-diff 1: 5112383 = 1: ce3db42, patch-id ea863bf9 for both; B confirmed and ran each-commit green and the exhaustive suite (7 passed, 2.80 s) itself (REVIEWS/auto-A-g3-exhaustive-r3.md, APPROVE).
  • At integration (19 Oct): bin/integrate.sh ran bin/check-each-commit.sh green on ce3db42 (tasks/g3-exhaustive/integrate/integrate.log). scripts/check.sh on autopilot/integration at ce3db42: ALL CHECKS PASSED; claims OK, exhaustive 7, findings 125, programs 179 (tasks/g3-exhaustive/integrate/check-ce3db42.log).

Limits

  • Not covered, and said so in the commit: a full ledger, unpriced or unallowlisted mints, a price or weight of 0 (with hi = 0 the no-collateral shortcut grants less than the rule, docs/09 §2), other exponents or decimals.
  • Sibling search was by reading: docs/09 names no other core-rule mutant the core suite misses, apart from the 22 stated equivalents in .cargo/mutants.toml. The ledger.rs ones were not re-run here.
  • No new finding: the gap was already stated in docs/09.

🤖 Generated with Claude Code

No core test caught `backed_amount` accepting health -1 (ledger.rs:246,
`t >= 0` -> `t >= -1`): a ledger left 1 unit short. docs/09 said so in
the ledger fuzz row; only the Python differential caught it. The
property test g3_backed_amount_is_sound_and_maximal checks the same
rule, but its random worlds seldom land on health exactly -1.

g3_backed_amount_is_exact_on_small_ledgers enumerates two priced
mints: other and own position in -6..=12 (0 is no position); per mint,
(low, high) price in (1, 1), (2, 2), (3, 3), (1, 3) and haircut 5,000
or 10,000 with liability weight 10,000 or 15,000; request 0..=40;
3,789,056 cases. Each grant must equal the largest b <= request whose
ledger owes nothing or has health >= 0, restated with collateral
floored at its low price and haircut and debts ceiled at their high
price and weight. In 764,280 cases some b is valid and one unit more
leaves health at exactly -1; the test pins that count, and a Python
restatement of the same domain prints 3789056 764280. Not covered,
and said so: a full ledger, unpriced or unallowlisted mints, a price
or weight of 0 (with hi = 0 the no-collateral shortcut grants less
than the rule, docs/09 §2), other exponents or decimals. Tests only:
no program or core source line moves.

Evidence (tasks/g3-exhaustive/mutants.sh, mutants-r4.out):
- M5 `t >= -1`: KILLED by the new test; the rest of the core suite
  (--skip the new test) passes on it, rc 0.
- M6 `t > 0`, M7 collateral rounded up, M8 debt rounded down, M9 fast
  path without `!others_liab`, M11 collateral at the high price, M12
  debt at the low price: KILLED.
- M10 fast path `after > 0`: survives this test (with every mint
  priced, health then decides the same); g2_and_fail_closed_without_
  prices kills it.
- New test 0.27 s release, 4.09 s debug; the exhaustive suite 2.78 to
  2.83 s in release (three runs), so 09 §5.2's heading says ~3 s in
  release, not ~6 s.
- tools/claims.py OK (exhaustive 7); scripts/check.sh ALL CHECKS PASSED.

Docs: docs/09 §2 and §5.2, README and docs/14 say 7 exhaustive tests
over ~588M inputs (584.4M + 3.8M); 03 §4.6 cites the test for G3 (two
priced mints, one position each) as it does g2's for G2; the ledger
fuzz row says a core test now catches the -1 bound.

Sibling search: docs/09 names no other mutant of a core rule that the
core suite misses, apart from .cargo/mutants.toml's 22 exclusions
(stated equivalents, §6). Those in ledger.rs (contribution,
has_liability, backed_amount) concern zero positions and the health
overflow fallback, which this domain never reaches; not re-run here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shuv-amp added a commit that referenced this pull request Oct 19, 2026
…es (#138-#147)

Batched squash of the reviewed, stacked PRs #138-#147 (one tree, identical to the reviewed stack's; each PR reviewed adversarially and green in CI on its own head):

- #138 Test the Vault's record checks with forged records (finding 120)
- #139 Record findings 117 to 124 in docs/09 section 4
- #140 Cut a long RPC error in an alert so the ids after it reach Discord (finding 125)
- #141 Pin G3's health bound at its edge with an exhaustive test
- #142 Key a failed action's repeated alert on its error's cause (finding 126)
- #143 Offer the sweep forged owner-checked accounts, swapped at every slot (finding 127)
- #144 Show an RPC's error in an alert whose line has a message (finding 128)
- #145 Key an RPC failover's alert on the endpoints it moved between (finding 129)
- #146 The sweep copies every account of the swept program, not only named ones
- #147 Key a backup's wrong-cluster alert on its endpoint entry (finding 130)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shuv-amp

Copy link
Copy Markdown
Owner Author

Included in main as d0177d5, the batched squash merge of #138-#147 via #147. main's tree there equals this stack's reviewed tree.

@shuv-amp shuv-amp closed this Oct 19, 2026
@shuv-amp
shuv-amp deleted the auto/A/g3-exhaustive-r3 branch October 19, 2026 18:05
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