sigil-labor-api · store
Source declarations, signatures and documentation for store.
Source: sigil/node/../labor-api/src/store/mod.rs. SHA-256: 98c04b58075150a11ed6dafe2fd066f9695397b2ef2182f2f20a93638a277836.
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.
store::postgres
Storage backend trait and implementations.
[LaborStore] is the contract that all storage backends must satisfy.
The production binary always uses [postgres::PostgresStore]; the
in-memory backend exists solely for tests and is compiled only when
the memory-store feature is active.
#[cfg(feature = "postgres")]
pub mod postgres;Source line: 9.
store::memory
#[cfg(feature = "memory-store")]
pub mod memory;Source line: 12.
store::LaborStore
Storage contract for the labor market service.
All implementations must be Send + Sync to be shared across Tokio tasks
via Arc<dyn LaborStore>.
Pagination contract
Listing endpoints accept a cursor (after: Option<Uuid>) and a limit.
Implementations MUST return results in deterministic order (by id for
jobs/applications, by created_at then id for tie-breaking) so that
(after, limit) produces stable, non-overlapping pages across requests.
Reputation units
All score values are integer micro-units (1.0 ≡ 1_000_000) to keep rolling averages exact. Implementations MUST perform the average update inside a single SQL statement so concurrent reviewers cannot corrupt the running totals.
#[async_trait::async_trait]
pub trait LaborStore: Send + Sync {
// ---- Jobs ---------------------------------------------------------------
async fn insert_job(&self, job: JobPosting) -> Result<JobPosting, LaborError>;
/// List jobs with optional keyword + status filters and cursor pagination.
async fn list_jobs(
&self,
keyword: Option<&str>,
status: Option<&str>,
after: Option<Uuid>,
limit: u32,
) -> Result<Vec<JobPosting>, LaborError>;
async fn get_job(&self, id: Uuid) -> Result<Option<JobPosting>, LaborError>;
async fn update_job_status(
&self,
id: Uuid,
status: &str,
) -> Result<Option<JobPosting>, LaborError>;
// ---- Applications -------------------------------------------------------
async fn insert_application(&self, app: JobApplication) -> Result<JobApplication, LaborError>;
/// List applications for a job with cursor pagination.
async fn list_applications(
&self,
job_id: Uuid,
after: Option<Uuid>,
limit: u32,
) -> Result<Vec<JobApplication>, LaborError>;
// ---- Contracts ----------------------------------------------------------
/// Atomically insert a contract AND mark the job as `filled`.
async fn insert_contract_and_fill_job(
&self,
contract: Contract,
) -> Result<Contract, LaborError>;
async fn get_contract(&self, id: Uuid) -> Result<Option<Contract>, LaborError>;
async fn update_contract_status(
&self,
id: Uuid,
status: &str,
) -> Result<Option<Contract>, LaborError>;
// ---- Reputation ---------------------------------------------------------
/// Atomically update (or insert) a reputation row using running-average
/// arithmetic executed inside the database. Score parameters are in
/// micro-units (1.0 = 1_000_000).
async fn upsert_reputation(
&self,
agent_id: &str,
quality_micro: u64,
reliability_micro: u64,
speed_micro: u64,
) -> Result<ReputationScore, LaborError>;
async fn get_reputation(&self, agent_id: &str) -> Result<Option<ReputationScore>, LaborError>;
}Source line: 38.
pub use async_trait::async_trait;
pub use async_trait::async_trait;Source line: 104.