sigil-node · governance_durable
Source declarations, signatures and documentation for governance_durable.
Source: sigil/node/sigil-node/src/governance_durable.rs. SHA-256: 6d95456dd9e8a4b65404307b5dfa4152ce7b921caf1b6db9c461bc6cc704d838.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
governance_durable::DurableGovernanceStore
Durable governance store backed by AkashaKV.
Persists proposals, votes, voting tallies, and the execution timelock queue.
All multi-write operations must use [GovernanceWriteBatch] +
[DurableGovernanceStore::commit_batch] for crash safety.
pub struct DurableGovernanceStore {
}Source line: 208.
governance_durable::DurableGovernanceStore::open
Open (or create) the store at path. The directory becomes the
AkashaKV data root for the governance subsystem. Fatal on failure.
pub fn open(path: &Path) -> Result<Self, NodeError>;Source line: 216.
governance_durable::DurableGovernanceStore::get_proposal
Fetch a proposal by ID. Returns None if not found.
pub fn get_proposal(&self, proposal_id: &str) -> Result<Option<Proposal>, NodeError>;Source line: 291.
governance_durable::DurableGovernanceStore::put_proposal
Insert or replace a proposal.
pub fn put_proposal(&self, proposal: &Proposal) -> Result<(), NodeError>;Source line: 299.
governance_durable::DurableGovernanceStore::list_all_proposals
Return all proposals in the store (order is lexicographic by id bytes).
pub fn list_all_proposals(&self) -> Result<Vec<Proposal>, NodeError>;Source line: 305.
governance_durable::DurableGovernanceStore::list_active_proposals
Return proposals that are in an active (non-terminal) state.
pub fn list_active_proposals(&self) -> Result<Vec<Proposal>, NodeError>;Source line: 314.
governance_durable::DurableGovernanceStore::get_vote
Fetch the full [Vote] record cast by voter_did on proposal_id.
Returns None if no vote has been recorded.
pub fn get_vote(&self, proposal_id: &str, voter_did: &str) -> Result<Option<Vote>, NodeError>;Source line: 323.
governance_durable::DurableGovernanceStore::put_vote
Store a vote record for (proposal_id, voter_did).
pub fn put_vote(&self, vote: &Vote) -> Result<(), NodeError>;Source line: 331.
governance_durable::DurableGovernanceStore::list_proposal_votes
Return all votes cast on a proposal, in lexicographic voter_did order.
pub fn list_proposal_votes(&self, proposal_id: &str) -> Result<Vec<Vote>, NodeError>;Source line: 338.
governance_durable::DurableGovernanceStore::has_voted
Returns true if voter_did has already voted on proposal_id.
Uses the lightweight voted-marker key (no full deserialisation).
pub fn has_voted(&self, proposal_id: &str, voter_did: &str) -> Result<bool, NodeError>;Source line: 346.
governance_durable::DurableGovernanceStore::mark_voted
Record the voted marker for (proposal_id, voter_did). Must be
committed atomically with the corresponding vote write; use
[GovernanceWriteBatch] for this.
pub fn mark_voted(&self, proposal_id: &str, voter_did: &str) -> Result<(), NodeError>;Source line: 353.
governance_durable::DurableGovernanceStore::get_tally
Fetch the current [VotingTally] for proposal_id.
Returns None if no votes have been tallied yet.
pub fn get_tally(&self, proposal_id: &str) -> Result<Option<VotingTally>, NodeError>;Source line: 361.
governance_durable::DurableGovernanceStore::put_tally
Store the current [VotingTally] for a proposal.
pub fn put_tally(&self, tally: &VotingTally) -> Result<(), NodeError>;Source line: 369.
governance_durable::DurableGovernanceStore::enqueue_timelock
Enqueue a timelock entry. Keyed by (execution_epoch, proposal_id) so
lexicographic scan == chronological execution order.
pub fn enqueue_timelock(&self, entry: &TimelockEntry) -> Result<(), NodeError>;Source line: 379.
governance_durable::DurableGovernanceStore::dequeue_timelock
Mark a timelock entry as executed (soft-delete).
Updates the entry's status to [TimelockStatus::Executed] in-place
rather than performing a hard delete. This preserves the audit trail
and sidesteps the AkashaKV memtable-scan tombstone limitation: the
delete API writes a tombstone to the active memtable, but the memtable
iterator returns entries in timestamp-ascending order (earliest first),
so the tombstone is deduplicated away before the engine-level scan can
promote it. The overwrite approach produces a new version with a higher
timestamp that IS returned first by the iterator.
list_due_timelocks and list_all_timelocks both filter out entries
whose status is Executed or Cancelled.
pub fn dequeue_timelock(
&self,
execution_epoch: u64,
proposal_id: &str,
) -> Result<(), NodeError>;Source line: 398.
governance_durable::DurableGovernanceStore::list_due_timelocks
Return all timelock entries whose execution_epoch <= current_epoch
and whose status is Pending, ordered by epoch ascending
(ready-first), then by proposal_id within the same epoch (lexicographic).
pub fn list_due_timelocks(&self, current_epoch: u64) -> Result<Vec<TimelockEntry>, NodeError>;Source line: 418.
governance_durable::DurableGovernanceStore::list_all_timelocks
Return all pending timelock entries in the store (any epoch).
Entries whose status is Executed or Cancelled are excluded.
pub fn list_all_timelocks(&self) -> Result<Vec<TimelockEntry>, NodeError>;Source line: 446.
governance_durable::DurableGovernanceStore::set_executor_proposal
Persist the executor-internal [crate::executor::Proposal] under its
u64 ID. These records are stored separately from the
sigil_governance::Proposal records so the two data models do not
interfere with each other.
pub fn set_executor_proposal(
&self,
proposal: &crate::executor::Proposal,
) -> Result<(), NodeError>;Source line: 467.
governance_durable::DurableGovernanceStore::get_executor_proposal
Return the executor-internal proposal for id, or None if absent.
pub fn get_executor_proposal(
&self,
id: u64,
) -> Result<Option<crate::executor::Proposal>, NodeError>;Source line: 477.
governance_durable::DurableGovernanceStore::list_executor_proposals
Return all executor-internal proposals ordered by numeric ID.
pub fn list_executor_proposals(&self) -> Result<Vec<crate::executor::Proposal>, NodeError>;Source line: 488.
governance_durable::DurableGovernanceStore::list_executor_votes
Return all executor voted markers as (proposal_id, voter_did).
pub fn list_executor_votes(&self) -> Result<Vec<(u64, String)>, NodeError>;Source line: 499.
governance_durable::DurableGovernanceStore::record_executor_vote
Record that voter_did has voted on proposal_id.
pub fn record_executor_vote(&self, proposal_id: u64, voter_did: &str) -> Result<(), NodeError>;Source line: 521.
governance_durable::DurableGovernanceStore::has_executor_voted
Return true if voter_did has already voted on proposal_id.
pub fn has_executor_voted(&self, proposal_id: u64, voter_did: &str) -> Result<bool, NodeError>;Source line: 526.
governance_durable::DurableGovernanceStore::flush
Force a flush of AkashaKV memtables to SSTables. Useful in tests.
pub fn flush(&self) -> Result<(), NodeError>;Source line: 535.
governance_durable::DurableGovernanceStore::close
Graceful shutdown — flushes memtables and stops background tasks.
pub fn close(&self) -> Result<(), NodeError>;Source line: 542.
governance_durable::DurableGovernanceStore::commit_batch
Apply all operations in batch atomically via a single AkashaKV MVCC
transaction.
Atomicity guarantee: if any individual operation fails the transaction
is dropped (auto-aborted via Drop) before commit, leaving zero partial
state visible. Either every operation in the batch lands or none do.
pub fn commit_batch(&self, batch: &GovernanceWriteBatch) -> Result<(), NodeError>;Source line: 556.
governance_durable::DurableGovernanceStore::namespace_prefix
Test helper: return the root namespace prefix for governance keys.
pub fn namespace_prefix() -> &'static [u8];Source line: 615.
governance_durable::ArcGovernanceStore
Convenience type alias for a shared durable governance store.
pub type ArcGovernanceStore = Arc<DurableGovernanceStore>;Source line: 621.
governance_durable::GovernanceBatchOp
An individual operation inside a [GovernanceWriteBatch].
#[derive(Clone)]
pub enum GovernanceBatchOp {
/// Insert or replace a governance proposal.
PutProposal(Proposal),
/// Record a full vote payload.
PutVote(Vote),
/// Set the lightweight voted-marker for `(proposal_id, voter_did)`.
MarkVoted {
proposal_id: String,
voter_did: String,
},
/// Store the current voting tally for a proposal.
PutTally(VotingTally),
/// Enqueue a timelock entry for execution.
EnqueueTimelock(TimelockEntry),
/// Insert or replace an executor-internal [`crate::executor::Proposal`].
///
/// Stored in the `gov/exec/proposal/` keyspace so it does not collide
/// with `sigil_governance::Proposal` records in `gov/proposal/`.
SetExecutorProposal(Box<crate::executor::Proposal>),
/// Record that `voter_did` has voted on `proposal_id` (u64 key).
///
/// Stored in the `gov/exec/voted/` keyspace.
RecordExecutorVote { proposal_id: u64, voter_did: String },
}Source line: 629.
governance_durable::GovernanceWriteBatch
Write batch accumulating all mutations for a single governance transition.
Build the batch inside the transaction handler, then pass it to
[crate::executor::ExecutionState::commit_governance_tx]. A crash before
commit_governance_tx returns leaves zero partial state on disk.
#[derive(Default)]
pub struct GovernanceWriteBatch {
}Source line: 660.
governance_durable::GovernanceWriteBatch::new
Create an empty write batch.
pub fn new() -> Self;Source line: 666.
governance_durable::GovernanceWriteBatch::put_proposal
Queue a proposal write.
pub fn put_proposal(&mut self, proposal: Proposal);Source line: 671.
governance_durable::GovernanceWriteBatch::put_vote
Queue a full vote record write.
pub fn put_vote(&mut self, vote: Vote);Source line: 676.
governance_durable::GovernanceWriteBatch::mark_voted
Queue a voted-marker write for (proposal_id, voter_did).
pub fn mark_voted(&mut self, proposal_id: impl Into<String>, voter_did: impl Into<String>);Source line: 681.
governance_durable::GovernanceWriteBatch::put_tally
Queue a tally write.
pub fn put_tally(&mut self, tally: VotingTally);Source line: 689.
governance_durable::GovernanceWriteBatch::enqueue_timelock
Queue a timelock enqueue operation.
pub fn enqueue_timelock(&mut self, entry: TimelockEntry);Source line: 694.
governance_durable::GovernanceWriteBatch::set_executor_proposal
Queue an executor-internal proposal write.
Use this (not put_proposal) when the proposal is represented by
[crate::executor::Proposal] rather than [sigil_governance::Proposal].
pub fn set_executor_proposal(&mut self, proposal: crate::executor::Proposal);Source line: 702.
governance_durable::GovernanceWriteBatch::record_executor_vote
Queue an executor voted-marker write for (proposal_id: u64, voter_did).
pub fn record_executor_vote(&mut self, proposal_id: u64, voter_did: impl Into<String>);Source line: 708.
governance_durable::GovernanceWriteBatch::len
Number of operations queued.
pub fn len(&self) -> usize;Source line: 716.
governance_durable::GovernanceWriteBatch::is_empty
Returns true if no operations have been queued.
pub fn is_empty(&self) -> bool;Source line: 721.
governance_durable::GovernanceWriteBatch::into_ops
Consume the batch and return the inner op list.
pub fn into_ops(self) -> Vec<GovernanceBatchOp>;Source line: 726.