pub trait RuntimeRepository: Send + Sync {
Show 32 methods
// Required methods
fn list_dispatchable_attempts(
&self,
now: DateTime<Utc>,
limit: usize,
) -> Result<Vec<AttemptDispatchRecord>, KernelError>;
fn upsert_lease(
&self,
attempt_id: &str,
worker_id: &str,
lease_expires_at: DateTime<Utc>,
) -> Result<LeaseRecord, KernelError>;
fn heartbeat_lease(
&self,
lease_id: &str,
heartbeat_at: DateTime<Utc>,
lease_expires_at: DateTime<Utc>,
) -> Result<(), KernelError>;
fn expire_leases_and_requeue(
&self,
stale_before: DateTime<Utc>,
) -> Result<u64, KernelError>;
fn latest_seq_for_run(&self, run_id: &RunId) -> Result<Seq, KernelError>;
fn upsert_bounty(&self, bounty: &BountyRecord) -> Result<(), KernelError>;
fn get_bounty(
&self,
bounty_id: &str,
) -> Result<Option<BountyRecord>, KernelError>;
fn list_bounties(
&self,
status: Option<&str>,
limit: usize,
) -> Result<Vec<BountyRecord>, KernelError>;
fn accept_bounty(
&self,
bounty_id: &str,
accepted_by: &str,
) -> Result<(), KernelError>;
fn close_bounty(&self, bounty_id: &str) -> Result<(), KernelError>;
fn upsert_swarm_decomposition(
&self,
task: &SwarmTaskRecord,
) -> Result<(), KernelError>;
fn get_swarm_decomposition(
&self,
parent_task_id: &str,
) -> Result<Option<SwarmTaskRecord>, KernelError>;
fn register_worker(&self, worker: &WorkerRecord) -> Result<(), KernelError>;
fn get_worker(
&self,
worker_id: &str,
) -> Result<Option<WorkerRecord>, KernelError>;
fn list_workers(
&self,
domain: Option<&str>,
status: Option<&str>,
limit: usize,
) -> Result<Vec<WorkerRecord>, KernelError>;
fn heartbeat_worker(
&self,
worker_id: &str,
heartbeat_at_ms: i64,
) -> Result<(), KernelError>;
fn create_recipe(&self, recipe: &RecipeRecord) -> Result<(), KernelError>;
fn get_recipe(
&self,
recipe_id: &str,
) -> Result<Option<RecipeRecord>, KernelError>;
fn fork_recipe(
&self,
original_id: &str,
new_id: &str,
new_author: &str,
) -> Result<Option<RecipeRecord>, KernelError>;
fn list_recipes(
&self,
author_id: Option<&str>,
limit: usize,
) -> Result<Vec<RecipeRecord>, KernelError>;
fn express_organism(
&self,
organism: &OrganismRecord,
) -> Result<(), KernelError>;
fn get_organism(
&self,
organism_id: &str,
) -> Result<Option<OrganismRecord>, KernelError>;
fn update_organism(
&self,
organism_id: &str,
current_step: i32,
status: &str,
) -> Result<(), KernelError>;
fn create_session(&self, session: &SessionRecord) -> Result<(), KernelError>;
fn get_session(
&self,
session_id: &str,
) -> Result<Option<SessionRecord>, KernelError>;
fn add_session_message(
&self,
message: &SessionMessageRecord,
) -> Result<(), KernelError>;
fn get_session_history(
&self,
session_id: &str,
limit: usize,
) -> Result<Vec<SessionMessageRecord>, KernelError>;
fn open_dispute(&self, dispute: &DisputeRecord) -> Result<(), KernelError>;
fn get_dispute(
&self,
dispute_id: &str,
) -> Result<Option<DisputeRecord>, KernelError>;
fn get_disputes_for_bounty(
&self,
bounty_id: &str,
) -> Result<Vec<DisputeRecord>, KernelError>;
fn resolve_dispute(
&self,
dispute_id: &str,
resolution: &str,
resolved_by: &str,
) -> Result<(), KernelError>;
// Provided method
fn transition_timed_out_attempts(
&self,
_now: DateTime<Utc>,
) -> Result<u64, KernelError> { ... }
}Expand description
Runtime repository contract used by scheduler and lease manager.
Implementations are responsible for making dispatch ownership transitions explicit:
list_dispatchable_attemptsmust preserve the repository’s dispatch order.upsert_leasemust atomically claim only dispatchable attempts and move the attempt into leased ownership when the claim succeeds.expire_leases_and_requeuemust reclaim only leases whose expiry is older than the supplied stale cutoff, so callers can apply a heartbeat grace window before requeueing work.
Required Methods§
Sourcefn list_dispatchable_attempts(
&self,
now: DateTime<Utc>,
limit: usize,
) -> Result<Vec<AttemptDispatchRecord>, KernelError>
fn list_dispatchable_attempts( &self, now: DateTime<Utc>, limit: usize, ) -> Result<Vec<AttemptDispatchRecord>, KernelError>
Return attempts eligible for dispatch at the current time.
Sourcefn upsert_lease(
&self,
attempt_id: &str,
worker_id: &str,
lease_expires_at: DateTime<Utc>,
) -> Result<LeaseRecord, KernelError>
fn upsert_lease( &self, attempt_id: &str, worker_id: &str, lease_expires_at: DateTime<Utc>, ) -> Result<LeaseRecord, KernelError>
Create or replace a lease for an attempt.
Sourcefn heartbeat_lease(
&self,
lease_id: &str,
heartbeat_at: DateTime<Utc>,
lease_expires_at: DateTime<Utc>,
) -> Result<(), KernelError>
fn heartbeat_lease( &self, lease_id: &str, heartbeat_at: DateTime<Utc>, lease_expires_at: DateTime<Utc>, ) -> Result<(), KernelError>
Refresh heartbeat for an existing lease.
Sourcefn expire_leases_and_requeue(
&self,
stale_before: DateTime<Utc>,
) -> Result<u64, KernelError>
fn expire_leases_and_requeue( &self, stale_before: DateTime<Utc>, ) -> Result<u64, KernelError>
Expire stale leases and requeue affected attempts.
Sourcefn latest_seq_for_run(&self, run_id: &RunId) -> Result<Seq, KernelError>
fn latest_seq_for_run(&self, run_id: &RunId) -> Result<Seq, KernelError>
Returns latest persisted sequence for a run (used by replay wiring).
Sourcefn upsert_bounty(&self, bounty: &BountyRecord) -> Result<(), KernelError>
fn upsert_bounty(&self, bounty: &BountyRecord) -> Result<(), KernelError>
Create or update a bounty
Sourcefn get_bounty(
&self,
bounty_id: &str,
) -> Result<Option<BountyRecord>, KernelError>
fn get_bounty( &self, bounty_id: &str, ) -> Result<Option<BountyRecord>, KernelError>
Get a bounty by ID
Sourcefn list_bounties(
&self,
status: Option<&str>,
limit: usize,
) -> Result<Vec<BountyRecord>, KernelError>
fn list_bounties( &self, status: Option<&str>, limit: usize, ) -> Result<Vec<BountyRecord>, KernelError>
List bounties by status
Sourcefn accept_bounty(
&self,
bounty_id: &str,
accepted_by: &str,
) -> Result<(), KernelError>
fn accept_bounty( &self, bounty_id: &str, accepted_by: &str, ) -> Result<(), KernelError>
Accept a bounty (transition to accepted)
Sourcefn close_bounty(&self, bounty_id: &str) -> Result<(), KernelError>
fn close_bounty(&self, bounty_id: &str) -> Result<(), KernelError>
Close a bounty (transition to closed)
Sourcefn upsert_swarm_decomposition(
&self,
task: &SwarmTaskRecord,
) -> Result<(), KernelError>
fn upsert_swarm_decomposition( &self, task: &SwarmTaskRecord, ) -> Result<(), KernelError>
Create or update swarm task decomposition
Sourcefn get_swarm_decomposition(
&self,
parent_task_id: &str,
) -> Result<Option<SwarmTaskRecord>, KernelError>
fn get_swarm_decomposition( &self, parent_task_id: &str, ) -> Result<Option<SwarmTaskRecord>, KernelError>
Get swarm task decomposition
Sourcefn register_worker(&self, worker: &WorkerRecord) -> Result<(), KernelError>
fn register_worker(&self, worker: &WorkerRecord) -> Result<(), KernelError>
Register a worker
Sourcefn get_worker(
&self,
worker_id: &str,
) -> Result<Option<WorkerRecord>, KernelError>
fn get_worker( &self, worker_id: &str, ) -> Result<Option<WorkerRecord>, KernelError>
Get a worker by ID
Sourcefn list_workers(
&self,
domain: Option<&str>,
status: Option<&str>,
limit: usize,
) -> Result<Vec<WorkerRecord>, KernelError>
fn list_workers( &self, domain: Option<&str>, status: Option<&str>, limit: usize, ) -> Result<Vec<WorkerRecord>, KernelError>
List workers by domain and status
Sourcefn heartbeat_worker(
&self,
worker_id: &str,
heartbeat_at_ms: i64,
) -> Result<(), KernelError>
fn heartbeat_worker( &self, worker_id: &str, heartbeat_at_ms: i64, ) -> Result<(), KernelError>
Update worker heartbeat
Sourcefn create_recipe(&self, recipe: &RecipeRecord) -> Result<(), KernelError>
fn create_recipe(&self, recipe: &RecipeRecord) -> Result<(), KernelError>
Create a recipe
Sourcefn get_recipe(
&self,
recipe_id: &str,
) -> Result<Option<RecipeRecord>, KernelError>
fn get_recipe( &self, recipe_id: &str, ) -> Result<Option<RecipeRecord>, KernelError>
Get a recipe by ID
Sourcefn fork_recipe(
&self,
original_id: &str,
new_id: &str,
new_author: &str,
) -> Result<Option<RecipeRecord>, KernelError>
fn fork_recipe( &self, original_id: &str, new_id: &str, new_author: &str, ) -> Result<Option<RecipeRecord>, KernelError>
Fork a recipe (create a copy with new ID)
Sourcefn list_recipes(
&self,
author_id: Option<&str>,
limit: usize,
) -> Result<Vec<RecipeRecord>, KernelError>
fn list_recipes( &self, author_id: Option<&str>, limit: usize, ) -> Result<Vec<RecipeRecord>, KernelError>
List recipes by author
Sourcefn express_organism(&self, organism: &OrganismRecord) -> Result<(), KernelError>
fn express_organism(&self, organism: &OrganismRecord) -> Result<(), KernelError>
Express a recipe as an organism
Sourcefn get_organism(
&self,
organism_id: &str,
) -> Result<Option<OrganismRecord>, KernelError>
fn get_organism( &self, organism_id: &str, ) -> Result<Option<OrganismRecord>, KernelError>
Get an organism by ID
Sourcefn update_organism(
&self,
organism_id: &str,
current_step: i32,
status: &str,
) -> Result<(), KernelError>
fn update_organism( &self, organism_id: &str, current_step: i32, status: &str, ) -> Result<(), KernelError>
Update organism status (step progression)
Sourcefn create_session(&self, session: &SessionRecord) -> Result<(), KernelError>
fn create_session(&self, session: &SessionRecord) -> Result<(), KernelError>
Create a collaborative session
Sourcefn get_session(
&self,
session_id: &str,
) -> Result<Option<SessionRecord>, KernelError>
fn get_session( &self, session_id: &str, ) -> Result<Option<SessionRecord>, KernelError>
Get a session by ID
Sourcefn add_session_message(
&self,
message: &SessionMessageRecord,
) -> Result<(), KernelError>
fn add_session_message( &self, message: &SessionMessageRecord, ) -> Result<(), KernelError>
Add a message to session history
Sourcefn get_session_history(
&self,
session_id: &str,
limit: usize,
) -> Result<Vec<SessionMessageRecord>, KernelError>
fn get_session_history( &self, session_id: &str, limit: usize, ) -> Result<Vec<SessionMessageRecord>, KernelError>
Get session message history
Sourcefn open_dispute(&self, dispute: &DisputeRecord) -> Result<(), KernelError>
fn open_dispute(&self, dispute: &DisputeRecord) -> Result<(), KernelError>
Open a dispute
Sourcefn get_dispute(
&self,
dispute_id: &str,
) -> Result<Option<DisputeRecord>, KernelError>
fn get_dispute( &self, dispute_id: &str, ) -> Result<Option<DisputeRecord>, KernelError>
Get a dispute by ID
Sourcefn get_disputes_for_bounty(
&self,
bounty_id: &str,
) -> Result<Vec<DisputeRecord>, KernelError>
fn get_disputes_for_bounty( &self, bounty_id: &str, ) -> Result<Vec<DisputeRecord>, KernelError>
Get disputes for a bounty
Sourcefn resolve_dispute(
&self,
dispute_id: &str,
resolution: &str,
resolved_by: &str,
) -> Result<(), KernelError>
fn resolve_dispute( &self, dispute_id: &str, resolution: &str, resolved_by: &str, ) -> Result<(), KernelError>
Resolve a dispute
Provided Methods§
Sourcefn transition_timed_out_attempts(
&self,
_now: DateTime<Utc>,
) -> Result<u64, KernelError>
fn transition_timed_out_attempts( &self, _now: DateTime<Utc>, ) -> Result<u64, KernelError>
Transition attempts that exceeded their configured execution timeout.