feat(controller-status): add election-time schema fields + ha_state_t (task 7.1)

Adds CtrlStatus.electedAtMs@14 and HeartbeatMsg.electedAtMs@4 to the
capnp schema, their hand-authored typemap.h counterparts, and a new
ha_state_t.last_known_elected_at_ms field alongside last_known_committed_lsn.
Schema/state plumbing only -- nothing stamps or consumes these fields yet
(tasks 7.2-7.5). Codec round-trip tests confirm both new fields survive
encode/decode unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
Rongsong Shen 2026-09-16 04:21:02 +00:00
parent 7556856e5c
commit cae1039ed7
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
6 changed files with 184 additions and 1 deletions

View file

@ -551,6 +551,9 @@ struct CtrlStatus $C.mapname("xce_ctrlstatus_t") {
peers @11: List(CtrlPeer) $C.mapname("peers.list") $C.maplistcount("peers.count");
peerCount @12: UInt32;
responderTimeMs @13: UInt64 $C.mapname("responder_time_ms"); # responder's wall-clock at sample time (epoch milliseconds)
electedAtMs @14: UInt64 $C.mapname("elected_at_ms");
# epoch millis of the current primary's election, learned off-primary via
# heartbeat; 0/unset when no primary is known (gated together with primaryName)
}
struct ClusterConf $C.mapname("xce_clusterconf_t") {
@ -909,6 +912,8 @@ struct HeartbeatMsg $C.mapname("heartbeat_msg_t") {
term @1: UInt64 $C.mapname("term");
committedLsn @2: UInt64 $C.mapname("committed_lsn");
committedConfigTag @3: UInt64 $C.mapname("committed_config_tag");
electedAtMs @4: UInt64 $C.mapname("elected_at_ms");
# primary's own last_known_elected_at_ms, echoed on every heartbeat (Req 12.2)
}
# ── Config replication message structs ──────────────────────────────