feat(raft-log-replication): raft_log_append leader client-entry append (tasks 3.1, 3.2)

Leader-only (-EPERM for follower/candidate, no mutation/callback); index=
log_len+1, term=currentTerm (raft.tla ClientRequest:246, Req 2.1-2.4);
persist-before-act: on_persist_entry called once BEFORE log_len advances,
non-zero return propagated with no phantom entry (Req 2.5); no commit-index
advance, no transport I/O. Spy-based tests for all four branches. ASAN green.
This commit is contained in:
Rongsong Shen 2026-06-21 15:50:33 +00:00
parent fc87a662cd
commit e5b9b83955
3 changed files with 212 additions and 2 deletions

View file

@ -49,14 +49,14 @@
## 3. ClientRequest — raft_log_append (raft.tla:246)
- [ ] 3.1 RED: append tests (leader stamps term, follower rejected)
- [x] 3.1 RED: append tests (leader stamps term, follower rejected)
- Test: leader `raft_log_append` assigns index `log_len+1`, stamps `currentTerm`, calls `on_persist_entry` exactly once with `(index, term, entry)`, returns the index; follower call returns `-EPERM` with no log change and no callback
- Observable completion: tests compile and FAIL (no implementation yet)
- _Requirements: 2.1, 2.2, 2.3, 2.4_
- _Boundary: test_raft.c_
- _Depends: 2.2_
- [ ] 3.2 GREEN: implement `raft_log_append`
- [x] 3.2 GREEN: implement `raft_log_append`
- Role guard (`-EPERM` if not leader); persist-before-act (`on_persist_entry` before incrementing `log_len`); set `*out_index`; do NOT advance any commit index
- Observable completion: 3.1 tests pass; `log_len` only advances on a successful persist (no phantom entry on persist failure)
- _Requirements: 2.1, 2.2, 2.3, 2.4, 2.5_