sigil-node · labor_durable
Source declarations, signatures and documentation for labor_durable.
Source: sigil/node/sigil-node/src/labor_durable.rs. SHA-256: 20cb878ad0c83c6bfb6dd421a1a63e3ff4d14302123ae2d2a0b79f795c5153e0.
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.
labor_durable::LaborEvent
A lightweight audit event appended to the labor event log on every state-changing labor transaction.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct LaborEvent {
/// Block at which the event was emitted.
pub block_height: u64,
/// Sequence number within the block (for ordering).
pub seq: u64,
/// Contract ID this event relates to.
pub contract_id: String,
/// Kind of event (e.g. `"contract_created"`, `"milestone_released"`).
pub kind: String,
/// Free-form JSON payload (actor DIDs, amounts, etc.).
pub payload: serde_json::Value
}Source line: 335.
labor_durable::DurableLaborStore
Durable labor marketplace store backed by AkashaKV.
Persists [LaborContract] records, per-milestone state, worker assignment
indexes, and an append-only audit event log. All multi-write operations
must use [LaborWriteBatch] + [DurableLaborStore::commit_batch] for
crash safety.
pub struct DurableLaborStore {
}Source line: 358.
labor_durable::DurableLaborStore::open
Open (or create) the store at path. The directory becomes the
AkashaKV data root for the labor subsystem. Fatal on failure.
pub fn open(path: &Path) -> Result<Self, NodeError>;Source line: 366.
labor_durable::DurableLaborStore::get_contract
Fetch a labor contract by ID. Returns None if not found.
pub fn get_contract(&self, contract_id: &str) -> Result<Option<LaborContract>, NodeError>;Source line: 435.
labor_durable::DurableLaborStore::put_contract
Insert or replace a labor contract (top-level record only, without
persisting individual milestones separately). Prefer
commit_batch for multi-write atomicity.
pub fn put_contract(&self, contract: &LaborContract) -> Result<(), NodeError>;Source line: 445.
labor_durable::DurableLaborStore::list_all_contracts
Return all contracts in the store.
pub fn list_all_contracts(&self) -> Result<Vec<LaborContract>, NodeError>;Source line: 451.
labor_durable::DurableLaborStore::list_contracts_by_state
Return all contracts in a given state.
pub fn list_contracts_by_state(
&self,
state: ContractState,
) -> Result<Vec<LaborContract>, NodeError>;Source line: 460.
labor_durable::DurableLaborStore::get_job
Fetch a labor job posting by ID. Returns None if not found.
pub fn get_job(&self, job_id: &str) -> Result<Option<LaborJob>, NodeError>;Source line: 471.
labor_durable::DurableLaborStore::put_job
Insert or replace a job record.
pub fn put_job(&self, job: &LaborJob) -> Result<(), NodeError>;Source line: 479.
labor_durable::DurableLaborStore::list_all_jobs
Return all job postings in the store.
pub fn list_all_jobs(&self) -> Result<Vec<LaborJob>, NodeError>;Source line: 485.
labor_durable::DurableLaborStore::get_bid
Fetch a labor bid by ID. Returns None if not found.
pub fn get_bid(&self, bid_id: &str) -> Result<Option<LaborBid>, NodeError>;Source line: 496.
labor_durable::DurableLaborStore::put_bid
Insert or replace a bid record.
pub fn put_bid(&self, bid: &LaborBid) -> Result<(), NodeError>;Source line: 504.
labor_durable::DurableLaborStore::list_all_bids
Return all bids in the store.
pub fn list_all_bids(&self) -> Result<Vec<LaborBid>, NodeError>;Source line: 510.
labor_durable::DurableLaborStore::list_job_bids
Return all bid IDs for a given job.
pub fn list_job_bids(&self, job_id: &str) -> Result<Vec<String>, NodeError>;Source line: 519.
labor_durable::DurableLaborStore::get_milestone
Fetch a single milestone by contract + index.
pub fn get_milestone(
&self,
contract_id: &str,
milestone_index: u32,
) -> Result<Option<Milestone>, NodeError>;Source line: 542.
labor_durable::DurableLaborStore::put_milestone
Store a milestone record.
pub fn put_milestone(&self, contract_id: &str, milestone: &Milestone) -> Result<(), NodeError>;Source line: 555.
labor_durable::DurableLaborStore::list_milestones
Return all milestones for a contract, ordered by index (ascending via big-endian key ordering).
pub fn list_milestones(&self, contract_id: &str) -> Result<Vec<Milestone>, NodeError>;Source line: 563.
labor_durable::DurableLaborStore::list_milestones_by_state
Return all milestones for a contract that are in a given state.
pub fn list_milestones_by_state(
&self,
contract_id: &str,
state: MilestoneState,
) -> Result<Vec<Milestone>, NodeError>;Source line: 573.
labor_durable::DurableLaborStore::index_worker_contract
Record that worker_did is a party to contract_id. Value is
presence-only (b"1"); use commit_batch to write
this atomically with the contract record.
pub fn index_worker_contract(
&self,
worker_did: &str,
contract_id: &str,
) -> Result<(), NodeError>;Source line: 587.
labor_durable::DurableLaborStore::list_worker_contracts
Return all contract IDs for which worker_did has an index entry.
pub fn list_worker_contracts(&self, worker_did: &str) -> Result<Vec<String>, NodeError>;Source line: 597.
labor_durable::DurableLaborStore::put_dispute_index
Write a dispute_id → contract_id mapping to the dispute index. Called atomically when a dispute is raised.
pub fn put_dispute_index(&self, dispute_id: &str, contract_id: &str) -> Result<(), NodeError>;Source line: 624.
labor_durable::DurableLaborStore::get_dispute_contract_id
Look up the contract_id for a given dispute_id.
pub fn get_dispute_contract_id(&self, dispute_id: &str) -> Result<Option<String>, NodeError>;Source line: 630.
labor_durable::DurableLaborStore::get_dispute
Fetch the full durable dispute record.
pub fn get_dispute(&self, dispute_id: &str) -> Result<Option<Dispute>, NodeError>;Source line: 641.
labor_durable::DurableLaborStore::put_dispute
Insert or replace a durable dispute record.
pub fn put_dispute(&self, dispute: &Dispute) -> Result<(), NodeError>;Source line: 649.
labor_durable::DurableLaborStore::list_disputes
Return all disputes, optionally filtered by state.
pub fn list_disputes(&self, state: Option<DisputeState>) -> Result<Vec<Dispute>, NodeError>;Source line: 655.
labor_durable::DurableLaborStore::get_escrow
Fetch exact labor escrow accounting for a contract.
pub fn get_escrow(&self, contract_id: &str) -> Result<Option<LaborEscrow>, NodeError>;Source line: 670.
labor_durable::DurableLaborStore::put_escrow
Insert or replace a labor escrow accounting record.
pub fn put_escrow(&self, escrow: &LaborEscrow) -> Result<(), NodeError>;Source line: 678.
labor_durable::DurableLaborStore::list_all_escrows
Return all labor escrow records.
pub fn list_all_escrows(&self) -> Result<Vec<LaborEscrow>, NodeError>;Source line: 684.
labor_durable::DurableLaborStore::append_event
Append an audit event to the event log. Events are immutable once written; there is no delete.
pub fn append_event(&self, event: &LaborEvent) -> Result<(), NodeError>;Source line: 696.
labor_durable::DurableLaborStore::list_events_in_range
Return events in [from_height, to_height] (inclusive), ordered
chronologically (block height ascending, then seq ascending).
pub fn list_events_in_range(
&self,
from_height: u64,
to_height: u64,
) -> Result<Vec<LaborEvent>, NodeError>;Source line: 704.
labor_durable::DurableLaborStore::get_offer
Fetch an open bounty offer by ID.
pub fn get_offer(&self, offer_id: &str) -> Result<Option<BountyOffer>, NodeError>;Source line: 729.
labor_durable::DurableLaborStore::put_offer
Insert or replace a bounty offer record.
pub fn put_offer(&self, offer: &BountyOffer) -> Result<(), NodeError>;Source line: 737.
labor_durable::DurableLaborStore::list_offers
Return bounty offers, optionally filtered by state.
pub fn list_offers(&self, state: Option<BountyState>) -> Result<Vec<BountyOffer>, NodeError>;Source line: 743.
labor_durable::DurableLaborStore::get_claim
Fetch a bounty claim by ID.
pub fn get_claim(&self, claim_id: &str) -> Result<Option<BountyClaim>, NodeError>;Source line: 756.
labor_durable::DurableLaborStore::put_claim
Insert or replace a bounty claim.
pub fn put_claim(&self, claim: &BountyClaim) -> Result<(), NodeError>;Source line: 764.
labor_durable::DurableLaborStore::list_claims
Return bounty claims, optionally filtered by offer and claimant.
pub fn list_claims(
&self,
offer_id: Option<&str>,
claimant_did: Option<&str>,
) -> Result<Vec<BountyClaim>, NodeError>;Source line: 770.
labor_durable::DurableLaborStore::get_claim_index
Lookup the replay/equivocation guard index for claimant deliverables.
pub fn get_claim_index(
&self,
offer_id: &str,
claimant_did: &str,
deliverable_hash: &str,
) -> Result<Option<String>, NodeError>;Source line: 806.
labor_durable::DurableLaborStore::get_claim_attestation
Fetch a claim attestation by ID.
pub fn get_claim_attestation(
&self,
attestation_id: &str,
) -> Result<Option<ClaimAttestation>, NodeError>;Source line: 825.
labor_durable::DurableLaborStore::put_claim_attestation
Insert or replace a claim attestation.
pub fn put_claim_attestation(&self, attestation: &ClaimAttestation) -> Result<(), NodeError>;Source line: 836.
labor_durable::DurableLaborStore::list_claim_attestations
List attestations for one claim in deterministic ID order.
pub fn list_claim_attestations(
&self,
claim_id: &str,
) -> Result<Vec<ClaimAttestation>, NodeError>;Source line: 842.
labor_durable::DurableLaborStore::flush
Force a flush of AkashaKV memtables to SSTables. Useful in tests.
pub fn flush(&self) -> Result<(), NodeError>;Source line: 866.
labor_durable::DurableLaborStore::close
Graceful shutdown — flushes memtables and stops background tasks.
pub fn close(&self) -> Result<(), NodeError>;Source line: 873.
labor_durable::DurableLaborStore::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) before commit, leaving zero partial state. Either every operation in the batch lands or none do.
pub fn commit_batch(&self, batch: &LaborWriteBatch) -> Result<(), NodeError>;Source line: 887.
labor_durable::DurableLaborStore::namespace_prefix
Test helper: return the root namespace prefix for labor keys.
pub fn namespace_prefix() -> &'static [u8];Source line: 1007.
labor_durable::ArcLaborStore
Convenience type alias for a shared durable labor store.
pub type ArcLaborStore = Arc<DurableLaborStore>;Source line: 1013.
labor_durable::LaborBatchOp
An individual operation inside a [LaborWriteBatch].
#[derive(Clone)]
pub enum LaborBatchOp {
/// Insert or replace a labor job posting.
///
/// Boxed to reduce enum variant size — `LaborJob` is large.
PutJob(Box<LaborJob>),
/// Insert or replace a labor bid.
///
/// Boxed to reduce enum variant size — `LaborBid` is large.
PutBid(Box<LaborBid>),
/// Write a job→bid index entry (presence marker).
IndexJobBid { job_id: String, bid_id: String },
/// Insert or replace a labor contract record.
///
/// Boxed to reduce enum variant size — `LaborContract` is large.
PutContract(Box<LaborContract>),
/// Insert or replace a single milestone for a contract.
PutMilestone {
contract_id: String,
milestone: Milestone,
},
/// Write a worker→contract index entry (presence marker).
IndexWorker {
worker_did: String,
contract_id: String,
},
/// Write a dispute_id → contract_id index entry.
IndexDispute {
dispute_id: String,
contract_id: String,
},
/// Insert or replace a full dispute record.
PutDispute(Box<Dispute>),
/// Insert or replace exact escrow accounting for a contract.
PutEscrow(Box<LaborEscrow>),
/// Append an immutable audit event.
AppendEvent(LaborEvent),
/// Insert or replace an open bounty offer.
PutOffer(Box<BountyOffer>),
/// Insert or replace an open bounty claim.
PutClaim(Box<BountyClaim>),
/// Write the claimant+deliverable replay guard for a claim.
IndexClaim {
offer_id: String,
claimant_did: String,
deliverable_hash: String,
claim_id: String,
},
/// Write deterministic per-offer claim ordering.
IndexOfferClaim {
offer_id: String,
claim_sequence: u32,
claim_id: String,
},
/// Insert or replace a claim attestation and its claim index.
PutClaimAttestation(Box<ClaimAttestation>),
}Source line: 1021.
labor_durable::LaborWriteBatch
Write batch accumulating all mutations for a single labor state transition.
Build the batch inside the transaction handler, then pass it to
[crate::executor::ExecutionState::commit_labor_tx]. A crash before
commit_labor_tx returns leaves zero partial state on disk — eliminating
the create_contract fund-loss window and milestone_release double-pay window.
#[derive(Default)]
pub struct LaborWriteBatch {
}Source line: 1085.
labor_durable::LaborWriteBatch::new
Create an empty write batch.
pub fn new() -> Self;Source line: 1091.
labor_durable::LaborWriteBatch::put_job
Queue a job posting write.
pub fn put_job(&mut self, job: LaborJob);Source line: 1096.
labor_durable::LaborWriteBatch::put_bid
Queue a bid write.
pub fn put_bid(&mut self, bid: LaborBid);Source line: 1101.
labor_durable::LaborWriteBatch::index_job_bid
Queue a job→bid index write.
pub fn index_job_bid(&mut self, job_id: impl Into<String>, bid_id: impl Into<String>);Source line: 1106.
labor_durable::LaborWriteBatch::put_contract
Queue a contract record write.
pub fn put_contract(&mut self, contract: LaborContract);Source line: 1114.
labor_durable::LaborWriteBatch::put_milestone
Queue a milestone write for contract_id.
pub fn put_milestone(&mut self, contract_id: impl Into<String>, milestone: Milestone);Source line: 1119.
labor_durable::LaborWriteBatch::index_worker
Queue a worker→contract index write.
pub fn index_worker(&mut self, worker_did: impl Into<String>, contract_id: impl Into<String>);Source line: 1127.
labor_durable::LaborWriteBatch::index_dispute
Queue a dispute_id → contract_id index write.
pub fn index_dispute(&mut self, dispute_id: impl Into<String>, contract_id: impl Into<String>);Source line: 1135.
labor_durable::LaborWriteBatch::put_dispute
Queue a full dispute record write.
pub fn put_dispute(&mut self, dispute: Dispute);Source line: 1143.
labor_durable::LaborWriteBatch::put_escrow
Queue an escrow accounting write.
pub fn put_escrow(&mut self, escrow: LaborEscrow);Source line: 1148.
labor_durable::LaborWriteBatch::append_event
Queue an audit event append.
pub fn append_event(&mut self, event: LaborEvent);Source line: 1153.
labor_durable::LaborWriteBatch::put_offer
Queue an open bounty offer write.
pub fn put_offer(&mut self, offer: BountyOffer);Source line: 1158.
labor_durable::LaborWriteBatch::put_claim
Queue an open bounty claim write.
pub fn put_claim(&mut self, claim: BountyClaim);Source line: 1163.
labor_durable::LaborWriteBatch::index_claim
Queue the claimant+deliverable replay guard.
pub fn index_claim(
&mut self,
offer_id: impl Into<String>,
claimant_did: impl Into<String>,
deliverable_hash: impl Into<String>,
claim_id: impl Into<String>,
);Source line: 1168.
labor_durable::LaborWriteBatch::index_offer_claim
Queue deterministic per-offer claim ordering.
pub fn index_offer_claim(
&mut self,
offer_id: impl Into<String>,
claim_sequence: u32,
claim_id: impl Into<String>,
);Source line: 1184.
labor_durable::LaborWriteBatch::put_claim_attestation
Queue a claim attestation write.
pub fn put_claim_attestation(&mut self, attestation: ClaimAttestation);Source line: 1198.
labor_durable::LaborWriteBatch::len
Number of operations queued.
pub fn len(&self) -> usize;Source line: 1204.
labor_durable::LaborWriteBatch::is_empty
Returns true if no operations have been queued.
pub fn is_empty(&self) -> bool;Source line: 1209.
labor_durable::LaborWriteBatch::into_ops
Consume the batch and return the inner op list.
pub fn into_ops(self) -> Vec<LaborBatchOp>;Source line: 1214.