Skip to main content

RuntimeRepository

Trait RuntimeRepository 

Source
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_attempts must preserve the repository’s dispatch order.
  • upsert_lease must atomically claim only dispatchable attempts and move the attempt into leased ownership when the claim succeeds.
  • expire_leases_and_requeue must 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§

Source

fn list_dispatchable_attempts( &self, now: DateTime<Utc>, limit: usize, ) -> Result<Vec<AttemptDispatchRecord>, KernelError>

Return attempts eligible for dispatch at the current time.

Source

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.

Source

fn heartbeat_lease( &self, lease_id: &str, heartbeat_at: DateTime<Utc>, lease_expires_at: DateTime<Utc>, ) -> Result<(), KernelError>

Refresh heartbeat for an existing lease.

Source

fn expire_leases_and_requeue( &self, stale_before: DateTime<Utc>, ) -> Result<u64, KernelError>

Expire stale leases and requeue affected attempts.

Source

fn latest_seq_for_run(&self, run_id: &RunId) -> Result<Seq, KernelError>

Returns latest persisted sequence for a run (used by replay wiring).

Source

fn upsert_bounty(&self, bounty: &BountyRecord) -> Result<(), KernelError>

Create or update a bounty

Source

fn get_bounty( &self, bounty_id: &str, ) -> Result<Option<BountyRecord>, KernelError>

Get a bounty by ID

Source

fn list_bounties( &self, status: Option<&str>, limit: usize, ) -> Result<Vec<BountyRecord>, KernelError>

List bounties by status

Source

fn accept_bounty( &self, bounty_id: &str, accepted_by: &str, ) -> Result<(), KernelError>

Accept a bounty (transition to accepted)

Source

fn close_bounty(&self, bounty_id: &str) -> Result<(), KernelError>

Close a bounty (transition to closed)

Source

fn upsert_swarm_decomposition( &self, task: &SwarmTaskRecord, ) -> Result<(), KernelError>

Create or update swarm task decomposition

Source

fn get_swarm_decomposition( &self, parent_task_id: &str, ) -> Result<Option<SwarmTaskRecord>, KernelError>

Get swarm task decomposition

Source

fn register_worker(&self, worker: &WorkerRecord) -> Result<(), KernelError>

Register a worker

Source

fn get_worker( &self, worker_id: &str, ) -> Result<Option<WorkerRecord>, KernelError>

Get a worker by ID

Source

fn list_workers( &self, domain: Option<&str>, status: Option<&str>, limit: usize, ) -> Result<Vec<WorkerRecord>, KernelError>

List workers by domain and status

Source

fn heartbeat_worker( &self, worker_id: &str, heartbeat_at_ms: i64, ) -> Result<(), KernelError>

Update worker heartbeat

Source

fn create_recipe(&self, recipe: &RecipeRecord) -> Result<(), KernelError>

Create a recipe

Source

fn get_recipe( &self, recipe_id: &str, ) -> Result<Option<RecipeRecord>, KernelError>

Get a recipe by ID

Source

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)

Source

fn list_recipes( &self, author_id: Option<&str>, limit: usize, ) -> Result<Vec<RecipeRecord>, KernelError>

List recipes by author

Source

fn express_organism(&self, organism: &OrganismRecord) -> Result<(), KernelError>

Express a recipe as an organism

Source

fn get_organism( &self, organism_id: &str, ) -> Result<Option<OrganismRecord>, KernelError>

Get an organism by ID

Source

fn update_organism( &self, organism_id: &str, current_step: i32, status: &str, ) -> Result<(), KernelError>

Update organism status (step progression)

Source

fn create_session(&self, session: &SessionRecord) -> Result<(), KernelError>

Create a collaborative session

Source

fn get_session( &self, session_id: &str, ) -> Result<Option<SessionRecord>, KernelError>

Get a session by ID

Source

fn add_session_message( &self, message: &SessionMessageRecord, ) -> Result<(), KernelError>

Add a message to session history

Source

fn get_session_history( &self, session_id: &str, limit: usize, ) -> Result<Vec<SessionMessageRecord>, KernelError>

Get session message history

Source

fn open_dispute(&self, dispute: &DisputeRecord) -> Result<(), KernelError>

Open a dispute

Source

fn get_dispute( &self, dispute_id: &str, ) -> Result<Option<DisputeRecord>, KernelError>

Get a dispute by ID

Source

fn get_disputes_for_bounty( &self, bounty_id: &str, ) -> Result<Vec<DisputeRecord>, KernelError>

Get disputes for a bounty

Source

fn resolve_dispute( &self, dispute_id: &str, resolution: &str, resolved_by: &str, ) -> Result<(), KernelError>

Resolve a dispute

Provided Methods§

Source

fn transition_timed_out_attempts( &self, _now: DateTime<Utc>, ) -> Result<u64, KernelError>

Transition attempts that exceeded their configured execution timeout.

Implementors§