pub struct Store { /* private fields */ }Implementations§
Source§impl Store
impl Store
Sourcepub fn open(path: &Path, now_ms: i64) -> Result<Self, StoreError>
pub fn open(path: &Path, now_ms: i64) -> Result<Self, StoreError>
Opens (creating if needed) the database and migrates it to the current
schema version. The daemon is the only writer; now_ms is injected so
decision-adjacent timestamps never read the wall clock here.
pub fn insert_local_project( &self, id: &str, file_path: &str, title: &str, now_ms: i64, ) -> Result<(), StoreError>
Sourcepub fn upsert_local_project(
&self,
id: &str,
file_path: &str,
title: &str,
now_ms: i64,
) -> Result<(), StoreError>
pub fn upsert_local_project( &self, id: &str, file_path: &str, title: &str, now_ms: i64, ) -> Result<(), StoreError>
Inserts or refreshes a project indexed from a committed file. Startup and reindex call this for every configured project file, so it must tolerate rows that already exist.
pub fn project_exists(&self, id: &str) -> Result<bool, StoreError>
pub fn project(&self, id: &str) -> Result<Option<ProjectRecord>, StoreError>
pub fn insert_local_ticket( &self, id: &str, project_id: &str, file_path: &str, name: &str, blocked_by: &[String], worktree: &str, target: Option<&str>, model: Option<&str>, effort: Option<&str>, flow: &str, state: TicketState, now_ms: i64, ) -> Result<(), StoreError>
pub fn update_local_ticket( &self, id: &str, name: &str, blocked_by: &[String], worktree: &str, target: Option<&str>, model: Option<&str>, effort: Option<&str>, flow: &str, now_ms: i64, ) -> Result<(), StoreError>
Sourcepub fn apply_reindex(
&self,
project_ids: &[String],
tickets: &[ReindexTicket],
now_ms: i64,
) -> Result<ReindexResult, StoreError>
pub fn apply_reindex( &self, project_ids: &[String], tickets: &[ReindexTicket], now_ms: i64, ) -> Result<ReindexResult, StoreError>
Applies a complete authored ticket snapshot without disturbing runtime history for IDs that remain present. Missing local rows and everything that depends on them are removed explicitly so the operation can report how much non-derivable state was discarded.
pub fn update_ticket_execution( &self, id: &str, target: Option<&str>, model: Option<&str>, effort: Option<&str>, now_ms: i64, ) -> Result<(), StoreError>
pub fn update_ticket_body( &self, id: &str, body: &str, now_ms: i64, ) -> Result<(), StoreError>
Sourcepub fn backfill_ticket_targets(
&self,
default_target: &str,
now_ms: i64,
) -> Result<usize, StoreError>
pub fn backfill_ticket_targets( &self, default_target: &str, now_ms: i64, ) -> Result<usize, StoreError>
Version-two rows predate target snapshots. Once a repository has a target configuration, persist its default before dispatch can observe those rows.
pub fn ticket(&self, id: &str) -> Result<Option<TicketRecord>, StoreError>
Sourcepub fn ticket_by_name(
&self,
name: &str,
) -> Result<Option<TicketRecord>, StoreError>
pub fn ticket_by_name( &self, name: &str, ) -> Result<Option<TicketRecord>, StoreError>
Resolves a ticket by its human-facing name. Names are not guaranteed
unique across projects, so the lowest id wins deterministically; show
tries this only after an exact id match fails.
pub fn ticket_by_file( &self, file_path: &str, ) -> Result<Option<TicketRecord>, StoreError>
pub fn ticket_by_source_ref( &self, source: &str, source_ref: &str, ) -> Result<Option<TicketRecord>, StoreError>
pub fn tickets(&self) -> Result<Vec<TicketRecord>, StoreError>
pub fn tickets_for_project( &self, project_id: &str, ) -> Result<Vec<TicketRecord>, StoreError>
pub fn ticket_dependencies( &self, ) -> Result<BTreeMap<String, Vec<String>>, StoreError>
pub fn ticket_ids(&self) -> Result<Vec<String>, StoreError>
pub fn local_ticket_files(&self) -> Result<Vec<LocalTicketFile>, StoreError>
Sourcepub fn ticket_is_referenced(&self, id: &str) -> Result<bool, StoreError>
pub fn ticket_is_referenced(&self, id: &str) -> Result<bool, StoreError>
Whether run history, a lease, an activation, or another ticket’s blocker list still points at this row; deleting it would then violate a foreign key or orphan run evidence.
pub fn delete_ticket(&self, id: &str) -> Result<(), StoreError>
Sourcepub fn mark_ticket_missing(
&self,
id: &str,
now_ms: i64,
) -> Result<(), StoreError>
pub fn mark_ticket_missing( &self, id: &str, now_ms: i64, ) -> Result<(), StoreError>
Stamps a ticket whose committed file has disappeared. The stamp keeps the row out of selection without disturbing its state; an existing stamp is preserved so the deletion clock starts at the first pass.
pub fn clear_ticket_missing( &self, id: &str, now_ms: i64, ) -> Result<(), StoreError>
pub fn ticket_state(&self, id: &str) -> Result<Option<String>, StoreError>
Sourcepub fn set_ticket_hold(
&self,
id: &str,
state: TicketState,
now_ms: i64,
) -> Result<String, StoreError>
pub fn set_ticket_hold( &self, id: &str, state: TicketState, now_ms: i64, ) -> Result<String, StoreError>
Applies the operator-controlled ready/held side-state transition. The conditional update prevents an override from stealing a live claim or rewriting an evidence-derived outcome.
Sourcepub fn retry_ticket(&self, id: &str, now_ms: i64) -> Result<String, StoreError>
pub fn retry_ticket(&self, id: &str, now_ms: i64) -> Result<String, StoreError>
Returns a failed ticket to the ready queue and starts its attempt counter over. Other states remain evidence-derived and immutable here.
pub fn insert_activation( &self, activation: &NewActivation<'_>, now_ms: i64, ) -> Result<(), StoreError>
pub fn insert_activation_filter( &self, activation_id: &str, ticket_id: &str, ) -> Result<(), StoreError>
pub fn queued_activations(&self) -> Result<Vec<QueuedActivation>, StoreError>
Sourcepub fn dispatchable_activations(
&self,
now_ms: i64,
) -> Result<Vec<QueuedActivation>, StoreError>
pub fn dispatchable_activations( &self, now_ms: i64, ) -> Result<Vec<QueuedActivation>, StoreError>
Queued activations whose time gate is open, oldest first.
pub fn next_activation_eligible_at_ms( &self, now_ms: i64, ) -> Result<Option<i64>, StoreError>
Sourcepub fn select_ready_ticket(
&self,
activation: &QueuedActivation,
now_ms: i64,
) -> Result<Option<String>, StoreError>
pub fn select_ready_ticket( &self, activation: &QueuedActivation, now_ms: i64, ) -> Result<Option<String>, StoreError>
Deterministic ready-work selection within an activation’s scope:
oldest registration first, ticket ID as the tiebreak. --only filters
apply when the activation has filter rows.
pub fn ticket_is_dispatchable( &self, ticket_id: &str, ) -> Result<bool, StoreError>
pub fn unmerged_blockers( &self, ticket_id: &str, ) -> Result<Vec<String>, StoreError>
Sourcepub fn mark_run_running(
&self,
run_id: &str,
branch: &str,
worktree_path: &str,
pid: u32,
pid_start_time: Option<i64>,
process_group_id: u32,
worker_token: &str,
worker_socket_path: &str,
now_ms: i64,
) -> Result<(), StoreError>
pub fn mark_run_running( &self, run_id: &str, branch: &str, worktree_path: &str, pid: u32, pid_start_time: Option<i64>, process_group_id: u32, worker_token: &str, worker_socket_path: &str, now_ms: i64, ) -> Result<(), StoreError>
Records a successful launch: the run turns running and carries the
worktree, branch, and durable process identity.
Sourcepub fn record_cancel_requested(
&self,
run_id: &str,
now_ms: i64,
) -> Result<(), StoreError>
pub fn record_cancel_requested( &self, run_id: &str, now_ms: i64, ) -> Result<(), StoreError>
Durably records an operator’s cancellation intent, idempotently: the
dedupe key makes a repeated cancel a no-op rather than new evidence.
Sourcepub fn cancellation_requested(&self, run_id: &str) -> Result<bool, StoreError>
pub fn cancellation_requested(&self, run_id: &str) -> Result<bool, StoreError>
Whether cancellation intent was recorded for the run, so an exit event
racing the cancel still resolves to Cancelled.
Sourcepub fn insert_note(
&self,
id: &str,
run_id: &str,
text: &str,
now_ms: i64,
) -> Result<(), StoreError>
pub fn insert_note( &self, id: &str, run_id: &str, text: &str, now_ms: i64, ) -> Result<(), StoreError>
Appends a worker’s advisory note. The agent’s only write: it records text against the run and moves nothing.
Sourcepub fn notes_for_run(&self, run_id: &str) -> Result<Vec<String>, StoreError>
pub fn notes_for_run(&self, run_id: &str) -> Result<Vec<String>, StoreError>
Notes recorded against one run, in the order they arrived.
pub fn notes_for_project( &self, project_id: &str, ) -> Result<Vec<ProjectNote>, StoreError>
pub fn commit_evidence_for_project( &self, project_id: &str, ) -> Result<Vec<ProjectCommitEvidence>, StoreError>
pub fn next_note_ordinal(&self) -> Result<i64, StoreError>
Sourcepub fn run_evidence(
&self,
run_id: &str,
) -> Result<Vec<(String, String)>, StoreError>
pub fn run_evidence( &self, run_id: &str, ) -> Result<Vec<(String, String)>, StoreError>
Evidence rows for one run in observation order, as (kind, data_json).
pub fn vendor_error_for_run( &self, run_id: &str, ) -> Result<Option<VendorErrorMatch>, StoreError>
pub fn latest_vendor_error_for_ticket( &self, ticket_id: &str, ) -> Result<Option<VendorErrorMatch>, StoreError>
Sourcepub fn events_after(
&self,
after: i64,
limit: usize,
) -> Result<Vec<EventRecord>, StoreError>
pub fn events_after( &self, after: i64, limit: usize, ) -> Result<Vec<EventRecord>, StoreError>
Reads activity-feed rows with sequence > after, oldest first. The
last row’s sequence is the caller’s next cursor.
pub fn latest_event_sequence(&self) -> Result<i64, StoreError>
Sourcepub fn trim_events(&self, keep: i64) -> Result<(), StoreError>
pub fn trim_events(&self, keep: i64) -> Result<(), StoreError>
Drops all but the newest keep activity-feed rows. Sequences are never
reused after a trim, so cursors held by watchers stay valid.
pub fn run(&self, id: &str) -> Result<Option<RunRecord>, StoreError>
Sourcepub fn run_for_ticket_attempt(
&self,
ticket_id: &str,
attempt: i64,
) -> Result<Option<RunRecord>, StoreError>
pub fn run_for_ticket_attempt( &self, ticket_id: &str, attempt: i64, ) -> Result<Option<RunRecord>, StoreError>
The run a <ticket>-r<attempt> alias names. The pair is unique because
attempts are allocated once per ticket at claim time.
Sourcepub fn runs_for_ticket(
&self,
ticket_id: &str,
) -> Result<Vec<RunRecord>, StoreError>
pub fn runs_for_ticket( &self, ticket_id: &str, ) -> Result<Vec<RunRecord>, StoreError>
Every run a ticket has produced, newest attempt first, so a bare ticket reference can name the latest run and still report the earlier ones.
Sourcepub fn runs_with_id_prefix(
&self,
prefix: &str,
) -> Result<Vec<RunRecord>, StoreError>
pub fn runs_with_id_prefix( &self, prefix: &str, ) -> Result<Vec<RunRecord>, StoreError>
Runs whose internal id starts with prefix. More than one row means the
reference is ambiguous, so the caller needs the candidates, not a pick.
Sourcepub fn active_run_for_ticket(
&self,
ticket_id: &str,
) -> Result<Option<(String, i64)>, StoreError>
pub fn active_run_for_ticket( &self, ticket_id: &str, ) -> Result<Option<(String, i64)>, StoreError>
The ticket’s live run as (id, attempt). The attempt travels with the
id so callers can name the run by alias without re-reading the row.
Sourcepub fn active_runs(&self) -> Result<Vec<ActiveRun>, StoreError>
pub fn active_runs(&self) -> Result<Vec<ActiveRun>, StoreError>
Leased nonterminal runs that consume capacity, oldest first.
Sourcepub fn queued_ticket_activation(
&self,
ticket_id: &str,
kind: ActivationKind,
) -> Result<Option<String>, StoreError>
pub fn queued_ticket_activation( &self, ticket_id: &str, kind: ActivationKind, ) -> Result<Option<String>, StoreError>
Finds a still-queued activation of kind scoped to one ticket, used
to keep reposting the same file idempotent.
Sourcepub fn reschedule_activation(
&self,
id: &str,
eligible_at_ms: i64,
now_ms: i64,
) -> Result<(), StoreError>
pub fn reschedule_activation( &self, id: &str, eligible_at_ms: i64, now_ms: i64, ) -> Result<(), StoreError>
Moves a still-queued timed activation to a new eligibility instant,
so reposting a ticket with a different --at time reschedules the
existing activation instead of queueing a duplicate.
Sourcepub fn next_activation_ordinal(&self) -> Result<i64, StoreError>
pub fn next_activation_ordinal(&self) -> Result<i64, StoreError>
Reserves the next activation ordinal without reusing IDs removed by reindex.
pub fn paused(&self) -> Result<bool, StoreError>
pub fn clear_restart_draining(&self, now_ms: i64) -> Result<(), StoreError>
pub fn restart_draining(&self) -> Result<bool, StoreError>
pub fn active_cooldown_for_target( &self, target: &str, now_ms: i64, ) -> Result<Option<CooldownRecord>, StoreError>
pub fn active_cooldowns( &self, now_ms: i64, ) -> Result<Vec<CooldownRecord>, StoreError>
pub fn next_active_cooldown( &self, now_ms: i64, ) -> Result<Option<i64>, StoreError>
pub fn set_paused(&self, paused: bool, now_ms: i64) -> Result<(), StoreError>
pub fn begin_restart_draining( &mut self, active_runs: usize, now_ms: i64, ) -> Result<bool, StoreError>
Sourcepub fn resume_scheduler(&mut self, now_ms: i64) -> Result<bool, StoreError>
pub fn resume_scheduler(&mut self, now_ms: i64) -> Result<bool, StoreError>
Resuming cancels both scheduler holds in one durable transition.