Skip to content

refactor(consensus)!: typed AdvanceOutOfRange variant end-to-end#569

Merged
SebastianThiebaud merged 1 commit into
mainfrom
refactor/advance-out-of-range-variant
May 27, 2026
Merged

refactor(consensus)!: typed AdvanceOutOfRange variant end-to-end#569
SebastianThiebaud merged 1 commit into
mainfrom
refactor/advance-out-of-range-variant

Conversation

@SebastianThiebaud
Copy link
Copy Markdown
Contributor

Summary

Promote the out-of-range high-water advance from a Box<dyn Error>-erased ConsensusError::PermanentDriver source to a first-class ConsensusError::AdvanceOutOfRange(u64) variant. The offending value is carried structurally from the propose-time guard, through the server's disposition layer, into both consumers — no downcasting, no re-boxing in classify.

  • Breaking surface (the !): the public AdvanceOutOfRange struct and its pub use re-export are removed from tsoracle-consensus. The only downcaster in the tree was the crate's own test; no external consumer is affected.
  • Disposition layer carries the value structurally: PersistDisposition::OutOfRange(u64) instead of Permanent(Box::new(...)). This follows the disposition module's stated design philosophy — "a fifth ConsensusError variant becomes one edit here plus a compiler-forced arm at each site" — and lets the fence path reconstruct ConsensusError::AdvanceOutOfRange(n) faithfully instead of laundering it back into PermanentDriver. service.rs reuses the variant's Display so the message text stays pinned to one source of truth.
  • Test strengthening: three driver tests that previously asserted matches!(_, PermanentDriver(_)) on the OOR path now assert the new variant and the carried u64. The unrelated PermanentDriver(_) assertions (storage I/O failpoints, Raft Fatal, paxos PendingReconfig, watch-task death) are untouched.

Blast radius (9 files, +92/−30): the new variant + simplified guard in tsoracle-consensus, the new disposition arm + two compiler-forced consumer arms in tsoracle-server, and three updated test assertions across the file/paxos/openraft drivers.

Test plan

  • cargo test --workspace --all-features — 1158 passed, 0 failed, 21 ignored across 135 test result blocks
  • cargo clippy --workspace --all-features --all-targets -- -D warnings — clean
  • scripts/check-ts-header.py — 270 files OK
  • Pre-commit cargo fmt --check + cargo clippy passed
  • New unit tests:
    • consensus::advance::tests::reject_out_of_range_advance_rejects_above_the_cap_as_variant
    • consensus::error::tests::consensus_error_display_text (now covers AdvanceOutOfRange)
    • server::persist_disposition::tests::advance_out_of_range_carries_the_offending_value_structurally

@coveralls
Copy link
Copy Markdown

coveralls commented May 27, 2026

Coverage Report for CI Build 26494250958

Coverage decreased (-0.06%) to 94.848%

Details

  • Coverage decreased (-0.06%) from the base build.
  • Patch coverage: 13 uncovered changes across 6 files (23 of 36 lines covered, 63.89%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
crates/tsoracle-server/src/service.rs 5 0 0.0%
crates/tsoracle-server/src/fence.rs 4 0 0.0%
crates/tsoracle-consensus/src/advance.rs 4 3 75.0%
crates/tsoracle-driver-openraft/src/driver.rs 2 1 50.0%
crates/tsoracle-driver-paxos/src/driver.rs 2 1 50.0%
crates/tsoracle-server/src/persist_disposition.rs 10 9 90.0%
Total (8 files) 36 23 63.89%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 14966
Covered Lines: 14195
Line Coverage: 94.85%
Coverage Strength: 357048.18 hits per line

💛 - Coveralls

Promote the rejected-out-of-range advance from a `Box<dyn Error>`-erased
`PermanentDriver` source to a first-class `ConsensusError::AdvanceOutOfRange(u64)`
variant. The offending value is now carried structurally from the propose-time
guard, through the server's disposition layer, into both consumers — no
downcasting, no re-boxing in `classify`.

The breaking change is the removal of the public `AdvanceOutOfRange` struct
and its `pub use` re-export from `tsoracle-consensus`. The only downcaster in
the tree was the crate's own test; no external consumer is affected.

`PersistDisposition::OutOfRange(u64)` carries the value end-to-end at the
server layer rather than collapsing into `Permanent(Box::new(...))`. This
follows the disposition module's stated design philosophy — "a new
ConsensusError variant becomes one edit here plus a compiler-forced arm at
each site" — and lets the fence path reconstruct
`ConsensusError::AdvanceOutOfRange(n)` faithfully instead of laundering it
back into `PermanentDriver`. `service.rs` reuses the variant's `Display` so
the message text stays pinned to a single source of truth in `ConsensusError`.

Three driver tests that previously asserted `matches!(_, PermanentDriver(_))`
on the OOR path are strengthened to assert the new variant carries the
expected `u64`; the unrelated `PermanentDriver(_)` assertions (storage I/O,
Raft fatal, paxos pending-reconfig, watch-task death) are unchanged.

Verified `cargo test --workspace --all-features` (1158 passed, 0 failed),
`cargo clippy --workspace --all-features --all-targets -- -D warnings`
(clean), and the license-header script.

Signed-off-by: Sebastian Thiebaud <sebastian@prismarisk.com>
@SebastianThiebaud SebastianThiebaud force-pushed the refactor/advance-out-of-range-variant branch from f0a0bd7 to 919e627 Compare May 27, 2026 06:13
@SebastianThiebaud SebastianThiebaud merged commit 1535b94 into main May 27, 2026
40 checks passed
@SebastianThiebaud SebastianThiebaud deleted the refactor/advance-out-of-range-variant branch May 27, 2026 06:22
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.

2 participants