pub struct Store { /* private fields */ }Implementations§
Source§impl Store
impl Store
Sourcepub fn create_instance(
&self,
name: &str,
substrate: &str,
definition: &str,
source_overrides: &BTreeMap<String, String>,
definition_dir: &str,
dirty: bool,
) -> Result<InstanceRecord, StateError>
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.
pub fn instance(&self, name: &str) -> Result<Option<InstanceRecord>, StateError>
pub fn instances(&self) -> Result<Vec<InstanceRecord>, StateError>
Sourcepub fn tombstone_instance(&self, name: &str) -> Result<(), StateError>
pub fn tombstone_instance(&self, name: &str) -> Result<(), StateError>
Teardown leaves a tombstone, not amnesia (§2).
Sourcepub fn revive_instance(
&self,
name: &str,
definition: &str,
source_overrides: &BTreeMap<String, String>,
dirty: bool,
) -> Result<(), StateError>
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.
Sourcepub fn update_source_overrides(
&self,
name: &str,
source_overrides: &BTreeMap<String, String>,
) -> Result<(), StateError>
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).
Sourcepub fn update_dirty(&self, name: &str, dirty: bool) -> Result<(), StateError>
pub fn update_dirty(&self, name: &str, dirty: bool) -> Result<(), StateError>
Record per-invocation dirty mode on resume.
Source§impl Store
impl Store
pub fn record_checkpoint( &self, instance: &str, step_id: &str, resource_kind: &str, resource_id: &str, payload: &str, ) -> Result<(), StateError>
pub fn checkpoint( &self, instance: &str, step_id: &str, ) -> Result<Option<Checkpoint>, StateError>
Sourcepub fn checkpoints(&self, instance: &str) -> Result<Vec<Checkpoint>, StateError>
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.
Sourcepub fn remove_checkpoint(
&self,
instance: &str,
step_id: &str,
) -> Result<(), StateError>
pub fn remove_checkpoint( &self, instance: &str, step_id: &str, ) -> Result<(), StateError>
Remove one checkpoint after its resource is verifiably gone.
Source§impl Store
impl Store
Sourcepub fn renew_lease(
&self,
instance: &str,
duration: Duration,
) -> Result<Lease, StateError>
pub fn renew_lease( &self, instance: &str, duration: Duration, ) -> Result<Lease, StateError>
Set (or reset) the lease to its full duration from now.
Sourcepub fn renew_lease_at_recorded_duration(
&self,
instance: &str,
) -> Result<(), StateError>
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).
pub fn lease(&self, instance: &str) -> Result<Option<Lease>, StateError>
Sourcepub fn delete_lease(&self, instance: &str) -> Result<(), StateError>
pub fn delete_lease(&self, instance: &str) -> Result<(), StateError>
A tombstoned instance has no lease left to enforce.
Sourcepub fn expired_instances(&self) -> Result<Vec<String>, StateError>
pub fn expired_instances(&self) -> Result<Vec<String>, StateError>
Active instances whose lease has expired — the reaper’s worklist.
Source§impl Store
impl Store
pub fn claim_lock( &self, instance: &str, operation: &str, ) -> Result<LockClaim<'_>, StateError>
pub fn release_lock(&self, claim: &LockClaim<'_>) -> Result<(), StateError>
pub fn lock_holder_alive(&self, instance: &str) -> Result<bool, StateError>
Source§impl Store
impl Store
Sourcepub fn submit_operation(
&self,
id: &str,
instance: &str,
verb: &str,
request: &Value,
) -> Result<Operation, StateError>
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.
pub fn operation(&self, id: &str) -> Result<Option<Operation>, StateError>
Sourcepub fn operation_request(&self, id: &str) -> Result<Value, StateError>
pub fn operation_request(&self, id: &str) -> Result<Value, StateError>
Internal execution input. Never included in public operation responses.
Sourcepub fn operation_request_matches(
&self,
id: &str,
request: &Value,
) -> Result<bool, StateError>
pub fn operation_request_matches( &self, id: &str, request: &Value, ) -> Result<bool, StateError>
Compare a retry without requiring the retained source archive.
Sourcepub fn expired_operation_inputs(&self) -> Result<Vec<String>, StateError>
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.
Sourcepub fn retire_operation_input(&self, id: &str) -> Result<bool, StateError>
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.
pub fn pending_operations(&self) -> Result<Vec<Operation>, StateError>
pub fn operations( &self, instance: Option<&str>, ) -> Result<Vec<Operation>, StateError>
pub fn running_operation_id( &self, instance: &str, ) -> Result<Option<String>, StateError>
Sourcepub fn start_operation(&self, id: &str) -> Result<bool, StateError>
pub fn start_operation(&self, id: &str) -> Result<bool, StateError>
Only one worker can win this transition, even after duplicate submission.
Sourcepub fn mark_verification_journal(&self, id: &str) -> Result<(), StateError>
pub fn mark_verification_journal(&self, id: &str) -> Result<(), StateError>
Publish before verification can run a command. Older unjournaled proofs stay interrupted.
Sourcepub fn recover_operations(&self) -> Result<(), StateError>
pub fn recover_operations(&self) -> Result<(), StateError>
Called only while holding the controller’s OS ownership lock after restart.
pub fn cancel_operation(&self, id: &str) -> Result<bool, StateError>
pub fn finish_operation( &self, id: &str, status: OperationStatus, result: Option<&Value>, error: Option<&Value>, ) -> Result<(), StateError>
pub fn operation_event(&self, id: &str, event: &Value) -> Result<(), StateError>
pub fn operation_events( &self, id: &str, after: i64, ) -> Result<Vec<OperationEvent>, StateError>
Source§impl Store
impl Store
pub fn placements( &self, owner: &str, ) -> Result<BTreeMap<String, String>, StateError>
Sourcepub fn bind_placements(
&self,
instance: &str,
desired: &BTreeMap<String, String>,
) -> Result<(), StateError>
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
impl Store
Sourcepub fn record_reap_failure(
&self,
instance: &str,
error: &str,
) -> Result<(), StateError>
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.
Sourcepub fn clear_reap_failure(&self, instance: &str) -> Result<(), StateError>
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.
pub fn reap_attempt( &self, instance: &str, ) -> Result<Option<ReapAttempt>, StateError>
Sourcepub fn gc_due_tombstones(&self) -> Result<Vec<String>, StateError>
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).
Sourcepub fn delete_instance(&self, instance: &str) -> Result<(), StateError>
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
impl Store
Sourcepub fn resource_intent(
&self,
intent: ResourceIntent<'_>,
) -> Result<ResourceRecord, StateError>
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.
Sourcepub fn resource_intent_payload(
&self,
owner: &str,
key: &str,
payload: &str,
) -> Result<(), StateError>
pub fn resource_intent_payload( &self, owner: &str, key: &str, payload: &str, ) -> Result<(), StateError>
Persist submission state while the create result is still unknown.
Sourcepub fn resource_created(
&self,
owner: &str,
key: &str,
id: &str,
payload: &str,
) -> Result<(), StateError>
pub fn resource_created( &self, owner: &str, key: &str, id: &str, payload: &str, ) -> Result<(), StateError>
Save the returned handle before configuring, deploying, or waiting.
Sourcepub fn resource_refresh_payload(
&self,
owner: &str,
key: &str,
id: &str,
payload: &str,
) -> Result<(), StateError>
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.
Sourcepub fn resource_rearm(
&self,
owner: &str,
key: &str,
id: &str,
payload: &str,
) -> Result<(), StateError>
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.
pub fn resource_ready(&self, owner: &str, key: &str) -> Result<(), StateError>
Sourcepub fn resource_absent(&self, owner: &str, key: &str) -> Result<(), StateError>
pub fn resource_absent(&self, owner: &str, key: &str) -> Result<(), StateError>
Only call after verified absence or release of a borrowed/shared reference.
pub fn resources(&self, owner: &str) -> Result<Vec<ResourceRecord>, StateError>
pub fn resource( &self, owner: &str, key: &str, ) -> Result<Option<ResourceRecord>, StateError>
Source§impl Store
impl Store
pub fn stage_definition( &self, instance: &str, definition: &str, revision: &str, ) -> Result<(), StateError>
pub fn applied_definition( &self, owner: &str, ) -> Result<Option<String>, StateError>
pub fn instance_revision( &self, owner: &str, ) -> Result<Option<RevisionState>, StateError>
pub fn stage_step( &self, owner: &str, step: &str, revision: &str, ) -> Result<RevisionState, StateError>
pub fn step_revision( &self, owner: &str, step: &str, ) -> Result<Option<RevisionState>, StateError>
pub fn step_applied( &self, owner: &str, step: &str, revision: &str, ) -> Result<(), StateError>
pub fn revision_applied( &self, owner: &str, revision: &str, ) -> Result<(), StateError>
pub fn record_observation( &self, owner: &str, node: &str, evidence: &Value, ) -> Result<(), StateError>
Source§impl Store
impl Store
Sourcepub fn remember_environment(
&self,
owner_id: &str,
environment: &BTreeMap<String, String>,
raw: &BTreeMap<String, String>,
) -> Result<(), StateError>
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.
Sourcepub fn remember_secrets<'a>(
&self,
owner_id: &str,
values: impl IntoIterator<Item = &'a str>,
) -> Result<(), StateError>
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.
Sourcepub fn redactor(&self) -> Result<Redactor, StateError>
pub fn redactor(&self) -> Result<Redactor, StateError>
Include retired births: provider logs can contain values from old revisions.
pub fn bind_operation_instance( &self, id: &str, owner_id: &str, ) -> Result<(), StateError>
Source§impl Store
impl Store
Sourcepub fn open(path: &Path) -> Result<Self, StateError>
pub fn open(path: &Path) -> Result<Self, StateError>
Open (creating and migrating as needed) a local file store.
Sourcepub fn open_remote(_url: &str, _token: &str) -> Result<Self, StateError>
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.
Sourcepub fn open_configured() -> Result<Self, StateError>
pub fn open_configured() -> Result<Self, StateError>
Open this controller’s local state and reject obsolete fleet config.
pub fn open_with_paths(paths: &Paths) -> Result<Self, StateError>
Sourcepub fn state_dir() -> PathBuf
pub fn state_dir() -> PathBuf
$XDG_STATE_HOME/stackless, falling back to ~/.local/state/stackless.
Sourcepub fn default_path() -> PathBuf
pub fn default_path() -> PathBuf
The default per-user location: $XDG_STATE_HOME/stackless/state.db,
falling back to ~/.local/state/stackless/state.db.
Sourcepub fn now_secs() -> i64
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
impl Store
pub fn stripe_project( &self, scope: &str, ) -> Result<Option<StripeProjectRecord>, StateError>
pub fn instance_stripe_project( &self, owner_id: &str, ) -> Result<Option<StripeProjectRecord>, StateError>
Sourcepub fn bind_stripe_project(
&self,
owner_id: &str,
scope: &str,
project_id: Option<&str>,
) -> Result<StripeProjectRecord, StateError>
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.
Sourcepub fn start_stripe_project_creation(
&self,
scope: &str,
) -> Result<bool, StateError>
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.