feat(raft-sim-conformance): bag push/deliver routes vote+AE RPCs through library handlers (task 2.1)
This commit is contained in:
parent
631854303c
commit
ae4495104a
4 changed files with 249 additions and 2 deletions
|
|
@ -522,6 +522,10 @@ typedef struct {
|
|||
raft_sim_msg_kind_t kind;
|
||||
int src, dst;
|
||||
uint64_t term; /* RPC term (all kinds) */
|
||||
/* vote request: candidate's advertised last-log tuple at SEND time, feeding the
|
||||
* (lastLogTerm, lastLogIndex) freshness gate at delivery (mirrors
|
||||
* raft_sim_rpc_t.last_log_*). Sourced from the candidate's own log at send. */
|
||||
uint64_t last_log_term, last_log_index;
|
||||
/* AE request */
|
||||
uint64_t prev_log_index, prev_log_term, leader_commit;
|
||||
uint64_t entry_term, entry_value; /* one entry per AE (raft.tla "<=1 entry") */
|
||||
|
|
@ -668,6 +672,29 @@ int raft_sim_conformance_init(raft_sim_cluster_t *c, int n_nodes,
|
|||
*/
|
||||
uint64_t raft_sim_prng_next(raft_sim_cluster_t *c);
|
||||
|
||||
/*
|
||||
* raft_sim_bag_push: append one message to the unified cluster bag[] (mirrors
|
||||
* raft.tla `messages`). Fails loud (returns -1) on overflow rather than silently
|
||||
* truncating; returns 0 on success. Exposed so tests (and later scheduler tasks)
|
||||
* can seed the bag directly.
|
||||
*/
|
||||
int raft_sim_bag_push(raft_sim_cluster_t *c, const raft_sim_msg_t *msg);
|
||||
|
||||
/*
|
||||
* raft_sim_bag_deliver: route the bag message at index `i` to its matching library
|
||||
* handler (vote/AE request or response) and push any handler reply back onto the
|
||||
* bag as a *_RSP message (src/dst swapped). Mirrors raft.tla Receive: delivering a
|
||||
* request consumes it (swap-with-last removal, so bag indices stay compact for the
|
||||
* Drop/Duplicate/Reorder actions in task 2.2) and produces a response member.
|
||||
* UpdateTerm higher-term adoption and the stale-response drop live INSIDE the
|
||||
* handlers (R2.4) — this only routes. Delivery honors node.partition: if either
|
||||
* endpoint is partitioned the message is NOT delivered (no removal, no reply),
|
||||
* mirroring a dropped network edge.
|
||||
* Returns 0 on a delivered message, -1 on an out-of-range index, -2 when the
|
||||
* endpoint is partitioned (distinct non-zero status, message left in the bag).
|
||||
*/
|
||||
int raft_sim_bag_deliver(raft_sim_cluster_t *c, int i);
|
||||
|
||||
/*
|
||||
* raft_sim_dump_log: print trace logs for all nodes to fp.
|
||||
* If RAFT_SIM_VERBOSE env var is set, always prints.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue