feat(raft-sim-conformance): Figure-8 commit-safety scenario + restore dropped 5.3 impl (task 5.4)

Adds raft_sim_scenario_figure8: a previous-term entry on a quorum under a
new-term leader is NOT committed until a current-term entry commits (library-
gated by raft_advance_commit; verified by a mutation test). Also restores the
raft_sim_scenario_drop_dup_reorder implementation that commit e445404 (task 5.3)
silently dropped from raft_sim.c (a stray git checkout reverted the uncommitted
impl), which had left the lib build broken with an undefined reference.

Build green: test_sim_5_3_drop_dup_reorder + test_sim_5_4_figure8 both PASS.
This commit is contained in:
Rongsong Shen 2026-06-24 15:38:01 +00:00
parent e445404439
commit b1f289d2cb
4 changed files with 521 additions and 1 deletions

View file

@ -152,7 +152,7 @@
- _Boundary: raft_sim.c, test_raft.c_
- _Depends: 4.2_
- [ ] 5.4 Figure-8 scenario
- [x] 5.4 Figure-8 scenario
- Implement `raft_sim_scenario_figure8`: a previous-term entry on a quorum, a leader change; assert the entry is NOT reported committed until a current-term entry commits (Leader Completeness / State Machine Safety preserved)
- Observable completion: the previous-term entry's `commit_index` does not cover it until a current-term commit
- _Requirements: 4.4_
@ -263,3 +263,13 @@
current-term entry commits) — driven by `raft_advance_commit` on the leader, which works.
applied[]/SM-Safety is exercised across leader CHANGES (each node accumulates applied[]
while it is leader). This SUPERSEDES the follower-commit-propagation guidance above.
- **PROCESS FIX (task 5.3 commit e445404 was BROKEN).** That commit captured the
drop_dup_reorder decl (raft.h) + test (test_raft.c) but NOT its implementation in
raft_sim.c — a stray `git checkout` (a reviewer cleaning up the `src/build` symlink)
reverted the uncommitted impl between review and commit, so the lib build was broken
(undefined reference) from e445404 onward. Detected during task 5.4. The exact
implementation was recovered (byte-identical) and re-inserted into raft_sim.c; it is
committed together with task 5.4. LESSON: after every task commit, verify `git show
--stat` includes every expected source file (raft_sim.c was silently absent from
e445404's stat). Reviewers must use targeted `git checkout <path>` (never `git checkout .`
/ `git stash`) so uncommitted impl is never reverted.