feat(ha-commit-engine): honest write-admission quorum accounting (task 4.2)

repl_active_standby_count: registry truth (ep != NULL && !in_catch_up)
under r->lock. ha_state_t gains repl back-pointer (wired at init by
task 5.3); ha_has_write_quorum uses registry truth when wired, exact
legacy fallback when NULL; formula unchanged. Test 29 (wired gate,
catch-up-only standby → NOT_READY, admits after clear) captured RED
pre-fix. 29/29 group tests; suite at the 3-failure baseline.
This commit is contained in:
Rongsong Shen 2026-06-11 22:28:44 +00:00
parent b2598823c0
commit c9154bd5cc
6 changed files with 92 additions and 11 deletions

View file

@ -47,7 +47,7 @@
- Observable completion: new cases FAIL (red) — current `ha_has_write_quorum` counts `standby_endpoints->count` including catch-up (grep ha.c for the current anchor near ha.c:1507)
- _Requirements: 3.1, 3.2, 3.3, 6.1, 6.2_
- [ ] 4.2 Implement the quorum-accounting fix to green
- [x] 4.2 Implement the quorum-accounting fix to green (incl. reviewer-mandated wired gate test 29; reviewed in main context — reviewer subagent unavailable)
- Add `repl_active_standby_count(replicator_t *r)` to repl.c (under `r->lock`); add `replicator_t *repl` back-pointer to `ha_state_t` (ha.h); `ha_has_write_quorum` uses the helper when the back-pointer is wired, falls back to the existing `standby_endpoints` count when NULL (legacy test contexts); quorum condition itself unchanged (`active >= n_peers / 2`, `n_peers <= 1 → true`)
- Observable completion: all task 4.1 tests PASS; existing dispatch-gate tests still green
- _Requirements: 3.1, 3.2, 3.3, 6.1, 6.2_