feat(ha-heartbeat-committed-propagation): standby OP_nop consume branch + term-guard (task 2.2)

Append a committed-consume branch to the OP_nop handler (existing liveness/reply
byte-unchanged): ha_consume_heartbeat_committed applies the non-primary gate
(3.4) + stale-term guard (accept hb->term >= ha->term, 3.2), then delegates to
the monotonic ha_observe_heartbeat_committed (1.2). Absent body / zero / failed
gate are no-ops (4.2). No vote-floor edit — safety is the term-guard. 4 tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-06-20 12:02:15 +00:00
parent 8bfa861be2
commit 90e7179a89
5 changed files with 200 additions and 1 deletions

View file

@ -315,6 +315,15 @@ static int myreq_handler(vtask_t* task)
else if (role == CTRL_ELECTING)
ha_discover_primary(&c->ha, c);
}
/* ha-heartbeat-committed-propagation task 2.2: after the unchanged
* liveness/reply path above, a heartbeat that carries a HeartbeatMsg
* body lets a standby learn the primary's committed position. The
* consume helper applies the non-primary gate (Req 3.4) + term-guard
* (Req 3.2) and a NULL/zero no-op (Req 4.2); a bodyless nop skips it
* entirely. Purely additive — no existing OP_nop behaviour changes
* (Req 4.1). */
if (request.body_which == Request_body_heartbeatmsg)
ha_consume_heartbeat_committed(c, request.body.heartbeatmsg);
break;
}
case OPCode_join: