How production Rust in this tree should read. Principles 7–9
(CONTRIBUTING.md) still own comments, tests, and
RAM/CPU. This file owns control flow, types, naming, and composition.
Named extracts that applied these rules: quality.md Q-61
(Completed). Residual god-file peels: R-10.
Confirm stage IO, leftover union, and store roles stay in
invariants.md / concurrency.md —
do not restate them here.
-
Early return. Reject,
continue, and?first. Do not nest four levels ofif/match/forto reach the work. -
Session state is a type. More than a handful of related
mutparameters is a struct (PeerFollowState,ElectrumConn). Do not thread twelve booleans and maps through a dispatch function. -
Dispatch is a table.
match method/match NetworkMessagearms call named handlers. Help text, method lists, and dispatch share one catalog so they cannot drift. -
Boolean products become enums or methods.
IndexModemethods, not five independent flags at every call site.PendingSendCmpct::{None, Lb, Hb}, notAtomicU80/1/2. Fourbools in one orchestrator is an enum. -
Composition, not a 30-field god struct.
ChainHubhas held bodies and mining knobs;Queryhas SH write-behind. Keep façade methods on the outer type so callers do not churn. -
One owner per algorithm. Display-order 32-byte hex lives in
rbitcoin-primitives. A mempool admit walk used by accept and test-accept is one helper. Do not copy reverse-then-hex or pin-view forks into each crate. -
Names say the pick rule.
resolve_txid_tipversusresolve_txid_tip_then_any. In one crate,hubis not bothChainHubandPeerHubwithout a qualifier (chain/peers). -
Do not split to beat
wc -l. Bitcoin script's opcodematch, io_uring machines, and MPHF construction stay dense on purpose. A peel needs a named seam (two stages, two protocols, two roles) — see R-10. -
One path. A change that replaces a behavior deletes the old branch in the same change. Do not leave the old way behind a flag, a thread-local, a test-only wrapper, or a second function that does the same job. Confirm-stage IO has the same rule in
invariants.md.
Behavior-preserving moves still follow Red → Green → Refactor
(how-we-plan.md). This is a move, not a second
implementation:
- Find the existing production implementations and every caller.
- Choose the crate that owns the concept (rule 6).
- If an arm has no observable assert, add one before moving the code.
- Green is the extract only — no new branches. Wrap the old API, switch one
caller at a time, keep
--libcompiling. - Delete the old path, the unused flag, and restating comments.
Do not invent a failing test for a pure move that is already pinned. Do not copy the helper into a test-friendly crate and leave the original (Miri peels included).
CI is cargo clippy --workspace --all-targets -- -D warnings.
Goal: no [workspace.lints.clippy] = "allow". A lint that is wrong
for one item is #[allow(clippy::lint)] on that item, with a one-line
reason (Core-faithful opcode loop, wire layout, dispatch bag,
result_large_err on a public error enum, …). Do not add a new workspace
or crate-wide allow. Do not peel R-10, flatten an io_uring machine, or
split interpreter.rs to silence a lint.
Complexity still drops because the types got better, not because clippy
denied a Core-faithful loop. That is a site allow on that function, not
a standing workspace cognitive_complexity allow.
The workspace allow list is empty. cognitive_complexity is workspace
warn (nursery opt-in). A leftover Core-faithful loop or dense surface
test is a site allow — do not peel R-10, flatten io_uring, or
split interpreter.rs to silence it. Do not turn ast-grep into a second
clippy (quality.md Won't-fix).
- Not a second quality backlog (that is
quality.md; Q-61 is Completed). - Not confirm stage IO (that is
invariants.md). - Not a license to flatten uring,
idx_body_pipeline, or the IBD confirm OS pipeline.