Skip to main content

Store

Struct Store 

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

Implementations§

Source§

impl Store

Source

pub fn create_instance( &self, name: &str, substrate: &str, definition: &str, source_overrides: &BTreeMap<String, String>, definition_dir: &str, dirty: bool, ) -> Result<InstanceRecord, StateError>

Create an instance record. Names are unique across substrates: a clash is an error naming the existing substrate, not a sibling. The UNIQUE PRIMARY KEY enforces this on both backends — fleet-wide when the remote plane is configured.

Source

pub fn instance(&self, name: &str) -> Result<Option<InstanceRecord>, StateError>

Source

pub fn instances(&self) -> Result<Vec<InstanceRecord>, StateError>

Source

pub fn tombstone_instance(&self, name: &str) -> Result<(), StateError>

Teardown leaves a tombstone, not amnesia (§2).

Source

pub fn revive_instance( &self, name: &str, definition: &str, source_overrides: &BTreeMap<String, String>, dirty: bool, ) -> Result<(), StateError>

up on a tombstone is a fresh birth under the old name: new definition snapshot, active status, empty journal.

Source

pub fn update_source_overrides( &self, name: &str, source_overrides: &BTreeMap<String, String>, ) -> Result<(), StateError>

Record per-invocation overrides on resume (an explicit, recorded choice — never ambient discovery).

Source

pub fn update_dirty(&self, name: &str, dirty: bool) -> Result<(), StateError>

Record per-invocation dirty mode on resume.

Source§

impl Store

Source

pub fn record_checkpoint( &self, instance: &str, step_id: &str, resource_kind: &str, resource_id: &str, payload: &str, ) -> Result<(), StateError>

Source

pub fn checkpoint( &self, instance: &str, step_id: &str, ) -> Result<Option<Checkpoint>, StateError>

Source

pub fn checkpoints(&self, instance: &str) -> Result<Vec<Checkpoint>, StateError>

All checkpoints for an instance in recording order — what an interrupted down must hunt down.

Source

pub fn remove_checkpoint( &self, instance: &str, step_id: &str, ) -> Result<(), StateError>

Remove one checkpoint after its resource is verifiably gone.

Source§

impl Store

Source

pub fn renew_lease( &self, instance: &str, duration: Duration, ) -> Result<Lease, StateError>

Set (or reset) the lease to its full duration from now.

Source

pub fn renew_lease_at_recorded_duration( &self, instance: &str, ) -> Result<(), StateError>

Renew at the recorded duration (the start-of-verb renewal: the duration was consented to at creation).

Source

pub fn lease(&self, instance: &str) -> Result<Option<Lease>, StateError>

Source

pub fn delete_lease(&self, instance: &str) -> Result<(), StateError>

A tombstoned instance has no lease left to enforce.

Source

pub fn expired_instances(&self) -> Result<Vec<String>, StateError>

Active instances whose lease has expired — the reaper’s worklist.

Source§

impl Store

Source

pub fn claim_lock( &self, instance: &str, operation: &str, ) -> Result<LockClaim<'_>, StateError>

Source

pub fn release_lock(&self, claim: &LockClaim<'_>) -> Result<(), StateError>

Source

pub fn lock_holder_alive(&self, instance: &str) -> Result<bool, StateError>

Source§

impl Store

Source

pub fn submit_operation( &self, id: &str, instance: &str, verb: &str, request: &Value, ) -> Result<Operation, StateError>

A client-chosen ID makes retry after a lost submit response idempotent.

Source

pub fn operation(&self, id: &str) -> Result<Option<Operation>, StateError>

Source

pub fn operation_request(&self, id: &str) -> Result<Value, StateError>

Internal execution input. Never included in public operation responses.

Source

pub fn operation_request_matches( &self, id: &str, request: &Value, ) -> Result<bool, StateError>

Compare a retry without requiring the retained source archive.

Source

pub fn expired_operation_inputs(&self) -> Result<Vec<String>, StateError>

Terminal inputs expire only after their birth has been collected. Unbound failures also wait until the alias has no instance or pending work.

Source

pub fn retire_operation_input(&self, id: &str) -> Result<bool, StateError>

Call after deleting operation-owned files. A crash before this update leaves the original request available to retry that deletion.

Source

pub fn pending_operations(&self) -> Result<Vec<Operation>, StateError>

Source

pub fn operations( &self, instance: Option<&str>, ) -> Result<Vec<Operation>, StateError>

Source

pub fn running_operation_id( &self, instance: &str, ) -> Result<Option<String>, StateError>

Source

pub fn start_operation(&self, id: &str) -> Result<bool, StateError>

Only one worker can win this transition, even after duplicate submission.

Source

pub fn mark_verification_journal(&self, id: &str) -> Result<(), StateError>

Publish before verification can run a command. Older unjournaled proofs stay interrupted.

Source

pub fn recover_operations(&self) -> Result<(), StateError>

Called only while holding the controller’s OS ownership lock after restart.

Source

pub fn cancel_operation(&self, id: &str) -> Result<bool, StateError>

Source

pub fn finish_operation( &self, id: &str, status: OperationStatus, result: Option<&Value>, error: Option<&Value>, ) -> Result<(), StateError>

Source

pub fn operation_event(&self, id: &str, event: &Value) -> Result<(), StateError>

Source

pub fn operation_events( &self, id: &str, after: i64, ) -> Result<Vec<OperationEvent>, StateError>

Source§

impl Store

Source

pub fn placements( &self, owner: &str, ) -> Result<BTreeMap<String, String>, StateError>

Source

pub fn bind_placements( &self, instance: &str, desired: &BTreeMap<String, String>, ) -> Result<(), StateError>

Call while holding the instance operation claim, before external effects. Retired bindings remain readable for old receipts and can change only after all checkpoints and unfinished resources for that node are gone.

Source§

impl Store

Source

pub fn record_reap_failure( &self, instance: &str, error: &str, ) -> Result<(), StateError>

Record a failed reap, advancing the backoff. attempts increments; next_retry_at is now + the doubled delay.

Source

pub fn clear_reap_failure(&self, instance: &str) -> Result<(), StateError>

Clear an instance’s reap-failure record — a successful reap or a successful manual down calls this through the engine.

Source

pub fn reap_attempt( &self, instance: &str, ) -> Result<Option<ReapAttempt>, StateError>

Source

pub fn gc_due_tombstones(&self) -> Result<Vec<String>, StateError>

Tombstoned instances whose GC window has elapsed — the reaper deletes the row (FK cascade cleans leases/locks/checkpoints) and removes the logs dir (D14).

Source

pub fn delete_instance(&self, instance: &str) -> Result<(), StateError>

Delete an instance row outright (the GC step). FK cascade removes its leases, locks, checkpoints, and reap-attempt row.

Source§

impl Store

Source

pub fn resource_intent( &self, intent: ResourceIntent<'_>, ) -> Result<ResourceRecord, StateError>

Persist before creating anything. A retry returns the original recovery context, so a changed request cannot hide an unfinished creation.

Source

pub fn resource_intent_payload( &self, owner: &str, key: &str, payload: &str, ) -> Result<(), StateError>

Persist submission state while the create result is still unknown.

Source

pub fn resource_created( &self, owner: &str, key: &str, id: &str, payload: &str, ) -> Result<(), StateError>

Save the returned handle before configuring, deploying, or waiting.

Source

pub fn resource_refresh_payload( &self, owner: &str, key: &str, id: &str, payload: &str, ) -> Result<(), StateError>

Refresh credentials or recovery handles without changing the resource’s phase.

Source

pub fn resource_rearm( &self, owner: &str, key: &str, id: &str, payload: &str, ) -> Result<(), StateError>

Recreate only after the previous resource was independently observed absent.

Source

pub fn resource_ready(&self, owner: &str, key: &str) -> Result<(), StateError>

Source

pub fn resource_absent(&self, owner: &str, key: &str) -> Result<(), StateError>

Only call after verified absence or release of a borrowed/shared reference.

Source

pub fn resources(&self, owner: &str) -> Result<Vec<ResourceRecord>, StateError>

Source

pub fn resource( &self, owner: &str, key: &str, ) -> Result<Option<ResourceRecord>, StateError>

Source§

impl Store

Source

pub fn stage_definition( &self, instance: &str, definition: &str, revision: &str, ) -> Result<(), StateError>

Source

pub fn applied_definition( &self, owner: &str, ) -> Result<Option<String>, StateError>

Source

pub fn instance_revision( &self, owner: &str, ) -> Result<Option<RevisionState>, StateError>

Source

pub fn stage_step( &self, owner: &str, step: &str, revision: &str, ) -> Result<RevisionState, StateError>

Source

pub fn step_revision( &self, owner: &str, step: &str, ) -> Result<Option<RevisionState>, StateError>

Source

pub fn step_applied( &self, owner: &str, step: &str, revision: &str, ) -> Result<(), StateError>

Source

pub fn revision_applied( &self, owner: &str, revision: &str, ) -> Result<(), StateError>

Source

pub fn record_observation( &self, owner: &str, node: &str, evidence: &Value, ) -> Result<(), StateError>

Source§

impl Store

Source

pub fn remember_environment( &self, owner_id: &str, environment: &BTreeMap<String, String>, raw: &BTreeMap<String, String>, ) -> Result<(), StateError>

Public URL references stay usable in operation results. Literal env values, secret references, and sensitive keys still enter redaction history. This never removes a value already recorded as a secret.

Source

pub fn remember_secrets<'a>( &self, owner_id: &str, values: impl IntoIterator<Item = &'a str>, ) -> Result<(), StateError>

Must finish before a secret is injected into user code.

Source

pub fn redactor(&self) -> Result<Redactor, StateError>

Include retired births: provider logs can contain values from old revisions.

Source

pub fn bind_operation_instance( &self, id: &str, owner_id: &str, ) -> Result<(), StateError>

Source§

impl Store

Source

pub fn open(path: &Path) -> Result<Self, StateError>

Open (creating and migrating as needed) a local file store.

Source

pub fn open_remote(_url: &str, _token: &str) -> Result<Self, StateError>

Direct remote databases cannot own lifecycle execution. Kept as an explicit error for callers migrating to the controller transport.

Source

pub fn open_configured() -> Result<Self, StateError>

Open this controller’s local state and reject obsolete fleet config.

Source

pub fn open_with_paths(paths: &Paths) -> Result<Self, StateError>

Source

pub fn state_dir() -> PathBuf

$XDG_STATE_HOME/stackless, falling back to ~/.local/state/stackless.

Source

pub fn default_path() -> PathBuf

The default per-user location: $XDG_STATE_HOME/stackless/state.db, falling back to ~/.local/state/stackless/state.db.

Source

pub fn now_secs() -> i64

The shared clock, for callers outside the store (the reaper’s tick). Same value Store::now writes into rows.

Source§

impl Store

Source

pub fn stripe_project( &self, scope: &str, ) -> Result<Option<StripeProjectRecord>, StateError>

Source

pub fn instance_stripe_project( &self, owner_id: &str, ) -> Result<Option<StripeProjectRecord>, StateError>

Source

pub fn bind_stripe_project( &self, owner_id: &str, scope: &str, project_id: Option<&str>, ) -> Result<StripeProjectRecord, StateError>

The shared project intent and the instance binding precede CLI effects.

Source

pub fn start_stripe_project_creation( &self, scope: &str, ) -> Result<bool, StateError>

A lost create response must be resolved by exact-name inventory lookup. It never authorizes a second create request.

Source

pub fn stripe_project_created( &self, scope: &str, project_id: &str, ) -> Result<(), StateError>

Source§

impl Store

Source

pub fn host_execution_allowed(&self, owner_id: &str) -> Result<bool, StateError>

Source

pub fn grant_host_execution(&self, owner_id: &str) -> Result<(), StateError>

Trait Implementations§

Source§

impl Clone for Store

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Store

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.