Concord.StateMachine (Concord v2.0.0)

Copy Markdown View Source

The Raft state machine for Concord (Version 3).

Implements the :ra_machine behavior to provide a replicated key-value store with TTL support and secondary indexes.

Correctness Guarantees

All state mutations go through apply/3 which is a pure function of (meta, command, state) → (new_state, result, effects). Time is derived from meta.system_time (leader-assigned, replicated in the log), ensuring deterministic replay across all nodes.

State Shape

{:concord_kv, %{
  indexes: %{name => extractor_spec},
  command_count: non_neg_integer()
}}

ETS tables are materialized views rebuilt from the authoritative state on snapshot install. They are never the source of truth.

Summary

Functions

apply_command(meta, command, arg3)

query(query_cmd, arg2)

ra_query(query_term, state)