Skip to content

Split Floor into modules; execute one function per proposal kind - #84

Merged
shuv-amp merged 2 commits into
mainfrom
quality/c-floor-split
Oct 14, 2026
Merged

shuv-amp merged 2 commits into
mainfrom
quality/c-floor-split

Conversation

@shuv-amp

@shuv-amp shuv-amp commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

PR C of the code-quality plan. Floor was one 1,503-line lib.rs; it now mirrors the Vault's layout.

File Lines What
lib.rs 249 ids, constants, the dispatcher, account and argument helpers, the entrypoint
loader.rs 144 loader-v3 account checks, the snapshot comparison, the Upgrade/Close CPIs
guardians.rs 159 live guardian, signers, the set payload; heartbeat, eject, replace_recovery
register.rs 210 registration
stop.rs 317 stage, pin, abort, restore_snapshot, close_buffer
proposals.rs ~500 propose, veto, approve, execute, cancel

execute (242 lines) is now a short dispatcher over execute_code (upgrade, restore), execute_release and execute_config.

A move, not a rewrite. A mechanical check confirms every non-blank line of the old file appears in the new ones. The only exceptions:

  • signatures rustfmt re-wrapped;
  • the removed match-arm headers;
  • let mut c, now declared in the per-kind functions;
  • &schedule, now passed by reference.

Verification

  • check.sh and check-programs.sh pass: 45 Floor and 86 Vault tests, and the Floor program-vs-model differential at 24 seeds × 500 steps.
  • Compute is identical: stopping a 200 KB program costs 10,461 CU and restoring it 8,225 CU, on both main's build and this one.
  • floor.so grows by 560 bytes (74,024 → 74,584).
  • docs/06 §7's figures are refreshed (they dated from 8 Oct), and the doc references to lib.rs point to the new files.

The binary changes (Floor 508e5a99; Vault and Harbor unchanged). The devnet re-verification follows the audit-build freeze.

Review (code-review, high): no logic change found. Its fixes are in the second commit: an explicit SetDelay arm in execute_config and three comments. Declined, with reasons in the commit: the compute concern (measured identical), the import style (it is the Vault's pattern), and the authority-seed helper (pre-existing duplication, which would touch the CPI signing path).

🤖 Generated with Claude Code

shuv-amp and others added 2 commits October 14, 2026 11:05
PR C of the code-quality plan. Floor was one 1,503-line lib.rs; it now
mirrors the Vault's layout:

- lib.rs (249 lines): ids, constants, the dispatcher, account and
  argument helpers, the entrypoint.
- loader.rs: the loader-v3 account checks, the snapshot comparison, the
  Upgrade and Close CPIs.
- guardians.rs: live guardian, signers, the set payload; heartbeat,
  eject, replace_recovery.
- register.rs; stop.rs (stage, pin, abort, restore_snapshot,
  close_buffer); proposals.rs (propose, veto, approve, execute, cancel).
- execute (242 lines) is a short dispatcher over execute_code (upgrade,
  restore), execute_release and execute_config.

A move, not a rewrite: every non-blank line of the old file is in the
new ones (checked mechanically), except signatures rustfmt re-wrapped,
the arm headers, `let mut c` now in the per-kind functions, and
`&schedule` passed by reference. Compute is identical (stop of a 200 KB
program 10,461 CU and restore 8,225 CU, on main's build and this one);
floor.so grows by 560 bytes (74,024 -> 74,584). docs/06 §7's figures are
refreshed (they were from 8 Oct), and the references to lib.rs point to
the new files.

Binary: Floor af54a2ef (Vault and Harbor unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of this PR (code-review, high): every moved function matches
main; no logic change.

- execute_config matches SET_DELAY explicitly and refuses any other kind
  (WrongProposalKind), instead of treating everything else as a delay; it
  no longer depends on its caller to filter. Same behaviour today.
- Comments: restore_snapshot points to execute_code; the execute account
  list includes SetRecovery (a gap carried over from lib.rs); the sim
  test names the files each Floor event comes from.

Not changed, with reasons: the compute concern is measured away (main's
build and this one both cost 10,461 CU to stop and 8,225 to restore; the
older docs/06 figures moved with earlier PRs); lib.rs's imports for the
modules' `use crate::*` follow the Vault's pattern; the authority-PDA
seeds built in three places were duplicated before the split too, and a
shared helper on the CPI signing path is its own change.

Binary: Floor 508e5a99.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shuv-amp
shuv-amp merged commit 54decc4 into main Oct 14, 2026
11 checks passed
@shuv-amp
shuv-amp deleted the quality/c-floor-split branch October 14, 2026 05:35
shuv-amp added a commit that referenced this pull request Oct 17, 2026
16 §6 says every on-chain change since the reviewed commit (`9aae0c4`)
belongs in the independent audit's scope, and lists 87–95. It stopped
there: the on-chain fixes for 96–99, 101 and 103, the guardian margin
of 107, and the Floor split were missing, so an auditor scoping from §6
would not see them. Its rows for 93 and 95 also pointed at `lib.rs`
`execute`, which PR #84 split into `proposals.rs` `execute_release`,
and row 91 left out `genesis.rs` `create_vault`, which c65068f changed
to start the exit proposer.

Fix: one row per change, each from its 09 §4 row and the commit that
made it, with the functions and files where the rule now is, by the
names they have today (row 87–89 still points to 09 §4, as before, and
now names the core it also changed). For 96/107 the rule is in the core
and the programs' parsers; the call sites are named as such. 96 and 107
share a row (the same check, `guardian_set_ok`); it says, as 09's 107
row does, that a stored set is not checked again, that an ejection may
shrink one below the margin, and that 107 is not on devnet yet. PR #82
(entrypoint behind `no-entrypoint`) and PR #84 (Floor split into
modules, `execute` into three functions) are meant to change no rule and
share the last row; their evidence is in the PRs. The intro said each
test "fails with its rule deleted"; 09 §4 says that for some fixes,
"fails on the previous build" for others (96–99, 101), and gives a
differential case for 103, so it now points to each row's evidence in 09
§4 instead. The questions for the auditors: the release question said
trailing accounts can only close buffers, but since 99 a live copy among
them stands in for the pin; and one is added for 98 (any other signature
that could pass as a borrower's consent) and one for 107 (any path but
registration and SetGuardians that installs or keeps a set below the
margin, as a stored set and an ejection can).

Evidence:
- git log 9aae0c4..autopilot/integration -- programs/{floor,vault,
  harbor}/src crates/bulkhead-core/src: 13 commits. Each is now in §6
  except 2165134 (views.rs comment, line-neutral) and a47d0cb's tests
  part; its program part is PR #82's row.
- Every function named exists: grep finds guardian_set_ok,
  GuardianSet::parse, guardian_alive, guardian_index, alive_mask,
  signer_bits (core governance.rs:137, :188, :103, :233, :239, :259),
  Floor guardian_signers and replace_recovery (guardians.rs:25, :126),
  no-entrypoint (both Cargo.toml:15), parse_guardian_set in Floor
  guardians.rs:39 and Vault lib.rs:420, called from Floor
  register.rs:27, proposals.rs:91 and :471, Vault genesis.rs:70 and
  governance.rs:52 (parse at propose :254 and execute :478),
  may_charge_transfer_fee and transfer_fee_possible (token.rs:154,
  :161), FeeBearingMint in lifeboat.rs move_in (:74), the caller check
  in custody.rs release (:336), execute_release (proposals.rs:325, the
  live-copy rule at :352), reset_backlog's max(t, ref_updated_s)
  (brakes.rs:252).
- python3 -I tools/claims.py: claims OK, findings 107.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shuv-amp added a commit that referenced this pull request Oct 17, 2026
16 §6 says every on-chain change since the reviewed commit (`9aae0c4`)
belongs in the independent audit's scope, and lists 87–95. It stopped
there: the on-chain fixes for 96–99, 101 and 103, the guardian margin
of 107, and the Floor split were missing, so an auditor scoping from §6
would not see them. Its rows for 93 and 95 also pointed at `lib.rs`
`execute`, which PR #84 split into `proposals.rs` `execute_release`,
and row 91 left out `genesis.rs` `create_vault`, which c65068f changed
to start the exit proposer.

Fix: one row per change, each from its 09 §4 row and the commit that
made it, with the functions and files where the rule now is, by the
names they have today (row 87–89 still points to 09 §4, as before, and
now names the core it also changed). For 96/107 the rule is in the core
and the programs' parsers; the call sites are named as such. 96 and 107
share a row (the same check, `guardian_set_ok`); it says, as 09's 107
row does, that a stored set is not checked again, that an ejection may
shrink one below the margin, and that 107 is not on devnet yet. PR #82
(entrypoint behind `no-entrypoint`) and PR #84 (Floor split into
modules, `execute` into three functions) are meant to change no rule and
share the last row; their evidence is in the PRs. The intro said each
test "fails with its rule deleted"; 09 §4 says that for some fixes,
"fails on the previous build" for others (96–99, 101), and gives a
differential case for 103, so it now points to each row's evidence in 09
§4 instead. The questions for the auditors: the release question said
trailing accounts can only close buffers, but since 99 a live copy among
them stands in for the pin; and one is added for 98 (any other signature
that could pass as a borrower's consent) and one for 107 (any path but
registration and SetGuardians that installs or keeps a set below the
margin, as a stored set and an ejection can).

Evidence:
- git log 9aae0c4..autopilot/integration -- programs/{floor,vault,
  harbor}/src crates/bulkhead-core/src: 13 commits. Each is now in §6
  except 2165134 (views.rs comment, line-neutral) and a47d0cb's tests
  part; its program part is PR #82's row.
- Every function named exists: grep finds guardian_set_ok,
  GuardianSet::parse, guardian_alive, guardian_index, alive_mask,
  signer_bits (core governance.rs:137, :188, :103, :233, :239, :259),
  Floor guardian_signers and replace_recovery (guardians.rs:25, :126),
  no-entrypoint (both Cargo.toml:15), parse_guardian_set in Floor
  guardians.rs:39 and Vault lib.rs:420, called from Floor
  register.rs:27, proposals.rs:91 and :471, Vault genesis.rs:70 and
  governance.rs:52 (parse at propose :254 and execute :478),
  may_charge_transfer_fee and transfer_fee_possible (token.rs:154,
  :161), FeeBearingMint in lifeboat.rs move_in (:74), the caller check
  in custody.rs release (:336), execute_release (proposals.rs:325, the
  live-copy rule at :352), reset_backlog's max(t, ref_updated_s)
  (brakes.rs:252).
- python3 -I tools/claims.py: claims OK, findings 107.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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