Skip to main content

LocalSqlite

Struct LocalSqlite 

Source
pub struct LocalSqlite { /* private fields */ }

Implementations§

Source§

impl LocalSqlite

Source

pub fn from_db(db: Db) -> Self

Source

pub fn from_db_with_clock(db: Db, clock: Arc<dyn Clock>) -> Self

Source

pub fn last_sync_ms(&self) -> Option<i64>

Source

pub fn insert_local_project( &self, id: &str, file_path: &str, title: &str, now_ms: i64, ) -> Result<(), StoreError>

Source

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.

Source

pub fn project_exists(&self, id: &str) -> Result<bool, StoreError>

Source

pub fn project(&self, id: &str) -> Result<Option<ProjectRecord>, StoreError>

Source

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>

Source

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>

Source

pub fn update_ticket_execution( &self, id: &str, target: Option<&str>, model: Option<&str>, effort: Option<&str>, now_ms: i64, ) -> Result<(), StoreError>

Source

pub fn update_ticket_body( &self, id: &str, body: &str, now_ms: i64, ) -> Result<(), StoreError>

Source

pub fn backfill_ticket_targets( &self, default_target: &str, now_ms: i64, ) -> Result<usize, StoreError>

Source

pub fn ticket(&self, id: &str) -> Result<Option<TicketRecord>, StoreError>

Source

pub fn ticket_by_name( &self, name: &str, ) -> Result<Option<TicketRecord>, StoreError>

Source

pub fn ticket_by_file( &self, file_path: &str, ) -> Result<Option<TicketRecord>, StoreError>

Source

pub fn ticket_by_source_ref( &self, source: &str, source_ref: &str, ) -> Result<Option<TicketRecord>, StoreError>

Source

pub fn tickets(&self) -> Result<Vec<TicketRecord>, StoreError>

Source

pub fn tickets_for_project( &self, project_id: &str, ) -> Result<Vec<TicketRecord>, StoreError>

Source

pub fn ticket_dependencies( &self, ) -> Result<BTreeMap<String, Vec<String>>, StoreError>

Source

pub fn select_ready_ticket( &self, project_id: Option<&str>, trigger_id: &str, now_ms: i64, ) -> Result<Option<String>, StoreError>

Source

pub fn ticket_is_dispatchable( &self, ticket_id: &str, ) -> Result<bool, StoreError>

Source

pub fn unmerged_blockers( &self, ticket_id: &str, ) -> Result<Vec<String>, StoreError>

Source

pub fn readopt_lease( &self, ticket_id: &str, run_id: &str, lease_ms: i64, now_ms: i64, ) -> Result<i64, StoreError>

Source

pub fn renew_lease( &self, ticket_id: &str, run_id: &str, lease_ms: i64, now_ms: i64, ) -> Result<i64, StoreError>

Source

pub fn ticket_ids(&self) -> Result<Vec<String>, StoreError>

Source

pub fn local_ticket_files(&self) -> Result<Vec<LocalTicketFile>, StoreError>

Source

pub fn delete_ticket(&self, id: &str) -> Result<(), StoreError>

Source

pub fn mark_ticket_missing( &self, id: &str, now_ms: i64, ) -> Result<(), StoreError>

Source

pub fn clear_ticket_missing( &self, id: &str, now_ms: i64, ) -> Result<(), StoreError>

Source

pub fn ticket_state(&self, id: &str) -> Result<Option<String>, StoreError>

Source

pub fn set_ticket_hold( &self, id: &str, state: TicketState, now_ms: i64, ) -> Result<String, StoreError>

Source

pub fn ticket_counts(&self) -> Result<TicketCounts, StoreError>

Source§

impl LocalSqlite

Source

pub fn insert_trigger( &self, trigger: &NewTrigger<'_>, now_ms: i64, ) -> Result<(), StoreError>

Seeding primitive: writes one trigger row with a caller-chosen id. Tests use it to build a fixture queue; production creation is LocalSqlite::enqueue_trigger, which mints the id and cannot leave a trigger without its filters.

Source

pub fn insert_trigger_filter( &self, trigger_id: &str, ticket_id: &str, ) -> Result<(), StoreError>

Seeding primitive; see LocalSqlite::insert_trigger.

Source

pub fn queued_triggers(&self) -> Result<Vec<QueuedTrigger>, StoreError>

Source

pub fn dispatchable_triggers( &self, now_ms: i64, ) -> Result<Vec<QueuedTrigger>, StoreError>

Source

pub fn has_claimable_trigger( &self, ticket_id: &str, now_ms: i64, ) -> Result<bool, StoreError>

Whether any queued trigger could select this ticket: the reporting mirror of the claim path’s selection, asked per ticket rather than as “does the queue hold anything at all”.

Source

pub fn next_trigger_eligible_at_ms( &self, now_ms: i64, ) -> Result<Option<i64>, StoreError>

Source

pub fn complete_merged_ticket_triggers( &self, now_ms: i64, ) -> Result<Vec<(String, String)>, StoreError>

Retires triggers left queued against a ticket that merged before the settle path knew to retire them. [complete_for_ticket] only applies from the next settlement onwards, and a merged ticket never settles again, so anything already stranded needs this one-off sweep.

Returns the (trigger_id, ticket_id) pairs it completed, so the caller can report a startup mutation rather than perform it silently. A database with nothing stranded selects no rows and writes nothing, which makes repeated runs free.

Trait Implementations§

Source§

impl WorkState for LocalSqlite

SQLite satisfies atomic claims with an IMMEDIATE transaction and a conditional ticket update. The ticket row is authoritative for attempts: claim consumes one attempt, while release preserves that count as evidence of the completed try. This backend never records runs, and its local-source outcome push is idempotent because release already applied the durable ticket state.

Source§

fn claim_strength(&self) -> ClaimStrength

What this source can promise about claims. The dispatcher never branches on this; it exists for status display and for refusing multi-writer setups on LocalOnly sources.
Source§

fn pull_ready<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<WorkTicket>, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Refresh the daemon’s read cache. Selection runs on the cache; pull is periodic, never per-tick.
Source§

fn active_claims<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ActiveClaim>, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Claims visible at the source. Recovery compares these with recorded runs and releases a claim whose second admission commit never landed.
Source§

fn claim<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ticket: &'life1 TicketRef, owner: &'life2 OwnerId, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<ClaimResult, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

The only authoritative check. Succeeds iff the ticket is still ready at the source. Lost is a normal, silent outcome.
Source§

fn renew<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ticket: &'life1 TicketRef, owner: &'life2 OwnerId, ) -> Pin<Box<dyn Future<Output = Result<ClaimResult, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Heartbeat for long runs. An expired claim is reclaimable by peers.
Source§

fn release<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ticket: &'life1 TicketRef, owner: &'life2 OwnerId, disposition: Disposition, ) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Give the ticket back, per policy. Repeating a completed release is an idempotent success; it never consumes another attempt.
Source§

fn push_outcome<'life0, 'life1, 'async_trait>( &'life0 self, outcome: &'life1 WorkOutcome, ) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Terminal push. Fire-and-forget from the dispatcher’s view.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.