bankai/cluster

Clustered command admission for Bankai.

Mnesia remains the materialized task/version store. This module admits a cluster-visible mutation before Mnesia applies it idempotently by command ID. Local mode deliberately never calls this surface.

Types

pub type Admission {
  Admission(
    fence: Int,
    commit_index: Int,
    idempotent: Bool,
    command_id: String,
  )
}

Constructors

  • Admission(
      fence: Int,
      commit_index: Int,
      idempotent: Bool,
      command_id: String,
    )
pub type Mode {
  Local
  Cluster(cluster_id: String, node_id: String)
}

Constructors

  • Local
  • Cluster(cluster_id: String, node_id: String)
pub type Status {
  Status(
    mode: Mode,
    leader: String,
    commit_index: Int,
    read_index: Int,
    quorum: String,
    lease_count: Int,
  )
}

Constructors

  • Status(
      mode: Mode,
      leader: String,
      commit_index: Int,
      read_index: Int,
      quorum: String,
      lease_count: Int,
    )

Values

pub fn claim(
  workspace: String,
  task_id: String,
  holder: String,
  expected_hash: String,
  replacement_hash: String,
  now: Int,
) -> Result(Admission, String)

Quorum-admit a conditional claim and lease acquire. The Mnesia task CAS uses the returned command ID exactly once; retried requests receive this admission rather than a second lease or task write.

pub fn force_no_quorum_for_test(
  workspace: String,
) -> Result(Nil, String)
pub fn mode(workspace: String) -> Result(Mode, String)
pub fn reset_for_test(workspace: String) -> Result(Nil, String)
pub fn status(workspace: String) -> Result(Status, String)

A clustered status includes a ReadIndex confirmation. Callers can distinguish a leader-confirmed read from local-mode Mnesia reads without inspecting logs.

pub fn status_json(status: Status) -> json.Json
pub fn transition(
  workspace: String,
  task_id: String,
  expected_hash: String,
  replacement_hash: String,
  fence: Int,
  now: Int,
) -> Result(Admission, String)

Quorum-admit a claimant-owned transition. It validates the current lease fence before Mnesia performs the expected-head CAS under the command ID.

pub fn validate_fence(
  workspace: String,
  task_id: String,
  fence: Int,
) -> Result(Nil, String)
Search Document