pub struct Store { /* private fields */ }Expand description
Transactional metadata paired with an immutable content-addressed blob repository.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(
root: impl AsRef<Path>,
blobs: Arc<dyn BlobStore>,
) -> Result<Self, StoreError>
pub fn open( root: impl AsRef<Path>, blobs: Arc<dyn BlobStore>, ) -> Result<Self, StoreError>
Opens or creates a local store directory and acquires its writer lock.
Sourcepub fn open_with_cache_size(
root: impl AsRef<Path>,
blobs: Arc<dyn BlobStore>,
cache_size: usize,
) -> Result<Self, StoreError>
pub fn open_with_cache_size( root: impl AsRef<Path>, blobs: Arc<dyn BlobStore>, cache_size: usize, ) -> Result<Self, StoreError>
Opens a local store with an explicit redb userspace page-cache bound.
Sourcepub async fn persist_commit(
&self,
envelope: &CommitEnvelope,
) -> Result<ApplyOutcome, StoreError>
pub async fn persist_commit( &self, envelope: &CommitEnvelope, ) -> Result<ApplyOutcome, StoreError>
Makes immutable bytes durable before atomically publishing their metadata.
Sourcepub async fn persist_commit_with_records(
&self,
envelope: &CommitEnvelope,
records: &[MaterializedRecord],
) -> Result<ApplyOutcome, StoreError>
pub async fn persist_commit_with_records( &self, envelope: &CommitEnvelope, records: &[MaterializedRecord], ) -> Result<ApplyOutcome, StoreError>
Makes a commit blob durable, then atomically publishes metadata and derived records.
Sourcepub async fn persist_commit_with_reconciliation(
&self,
envelope: &CommitEnvelope,
records: &[MaterializedRecord],
context: &VersionVector,
record_heads: &[RecordHeadSet],
) -> Result<ApplyOutcome, StoreError>
pub async fn persist_commit_with_reconciliation( &self, envelope: &CommitEnvelope, records: &[MaterializedRecord], context: &VersionVector, record_heads: &[RecordHeadSet], ) -> Result<ApplyOutcome, StoreError>
Persists a record commit and atomically advances its incremental causal index.
Sourcepub async fn persist_schema_stages(
&self,
envelope: &CommitEnvelope,
stages: &[SchemaStage],
) -> Result<ApplyOutcome, StoreError>
pub async fn persist_schema_stages( &self, envelope: &CommitEnvelope, stages: &[SchemaStage], ) -> Result<ApplyOutcome, StoreError>
Persists an invisible bounded set of migration stages with its immutable commit.
Sourcepub async fn persist_schema_activation(
&self,
envelope: &CommitEnvelope,
activation: &SchemaActivation,
) -> Result<ApplyOutcome, StoreError>
pub async fn persist_schema_activation( &self, envelope: &CommitEnvelope, activation: &SchemaActivation, ) -> Result<ApplyOutcome, StoreError>
Atomically publishes a completely staged schema transition with its commit.
Sourcepub async fn persist_schema_stages_with_context(
&self,
envelope: &CommitEnvelope,
stages: &[SchemaStage],
context: &VersionVector,
) -> Result<ApplyOutcome, StoreError>
pub async fn persist_schema_stages_with_context( &self, envelope: &CommitEnvelope, stages: &[SchemaStage], context: &VersionVector, ) -> Result<ApplyOutcome, StoreError>
Persists schema stages while atomically advancing the causal commit index.
Sourcepub async fn persist_schema_activation_with_context(
&self,
envelope: &CommitEnvelope,
activation: &SchemaActivation,
context: &VersionVector,
) -> Result<ApplyOutcome, StoreError>
pub async fn persist_schema_activation_with_context( &self, envelope: &CommitEnvelope, activation: &SchemaActivation, context: &VersionVector, ) -> Result<ApplyOutcome, StoreError>
Persists schema activation while atomically advancing the causal commit index.
Sourcepub fn active_schema_activation(
&self,
domain_id: DomainId,
collection_id: CollectionId,
) -> Result<Option<SchemaActivation>, StoreError>
pub fn active_schema_activation( &self, domain_id: DomainId, collection_id: CollectionId, ) -> Result<Option<SchemaActivation>, StoreError>
Returns the active schema activation for a collection, if it has migrated.
Sourcepub fn active_schema_activations(
&self,
domain_id: DomainId,
) -> Result<Vec<SchemaActivation>, StoreError>
pub fn active_schema_activations( &self, domain_id: DomainId, ) -> Result<Vec<SchemaActivation>, StoreError>
Lists active schema cuts for a domain in collection order.
Sourcepub fn migration_frozen(
&self,
domain_id: DomainId,
collection_id: CollectionId,
) -> Result<bool, StoreError>
pub fn migration_frozen( &self, domain_id: DomainId, collection_id: CollectionId, ) -> Result<bool, StoreError>
Returns whether incompatible activation siblings froze a collection.
Sourcepub fn migration_counts(
&self,
domain_id: DomainId,
) -> Result<(usize, usize, usize), StoreError>
pub fn migration_counts( &self, domain_id: DomainId, ) -> Result<(usize, usize, usize), StoreError>
Returns low-cardinality active, staged-record, and frozen migration counts.
Sourcepub fn record_snapshot_observed_at(
&self,
domain_id: DomainId,
unix_seconds: u64,
) -> Result<(), StoreError>
pub fn record_snapshot_observed_at( &self, domain_id: DomainId, unix_seconds: u64, ) -> Result<(), StoreError>
Records when this device last created or installed a verified snapshot.
Sourcepub fn snapshot_observed_at(
&self,
domain_id: DomainId,
) -> Result<Option<u64>, StoreError>
pub fn snapshot_observed_at( &self, domain_id: DomainId, ) -> Result<Option<u64>, StoreError>
Returns the durable local observation time of the newest verified snapshot.
Sourcepub fn schema_stages(
&self,
domain_id: DomainId,
migration_id: MigrationId,
) -> Result<Vec<SchemaStage>, StoreError>
pub fn schema_stages( &self, domain_id: DomainId, migration_id: MigrationId, ) -> Result<Vec<SchemaStage>, StoreError>
Loads every durable stage for one migration in source-key order.
Sourcepub fn contains_commit(
&self,
domain_id: DomainId,
commit_id: CommitId,
) -> Result<bool, StoreError>
pub fn contains_commit( &self, domain_id: DomainId, commit_id: CommitId, ) -> Result<bool, StoreError>
Returns whether commit metadata is accepted locally.
Sourcepub fn is_commit_quarantined(
&self,
commit_id: CommitId,
) -> Result<bool, StoreError>
pub fn is_commit_quarantined( &self, commit_id: CommitId, ) -> Result<bool, StoreError>
Returns whether a commit ID is retained only as equivocation evidence.
Returns the first rejected sequence for an equivocated author, if any.
Sourcepub fn last_sequence(
&self,
domain_id: DomainId,
author: AuthorId,
) -> Result<Option<u64>, StoreError>
pub fn last_sequence( &self, domain_id: DomainId, author: AuthorId, ) -> Result<Option<u64>, StoreError>
Returns the latest accepted author sequence in a domain.
Returns the latest accepted immutable commit for an author in a domain.
Returns an accepted conflicting commit for the envelope’s author sequence.
Sourcepub async fn quarantine_equivocation(
&self,
evidence: &CommitEnvelope,
invalid_commits: &[CommitId],
accepted_frontier: &[CommitId],
author_sequences: &[(AuthorId, u64)],
author_heads: &[(AuthorId, u64, CommitId)],
records: &[MaterializedRecord],
) -> Result<(), StoreError>
pub async fn quarantine_equivocation( &self, evidence: &CommitEnvelope, invalid_commits: &[CommitId], accepted_frontier: &[CommitId], author_sequences: &[(AuthorId, u64)], author_heads: &[(AuthorId, u64, CommitId)], records: &[MaterializedRecord], ) -> Result<(), StoreError>
Atomically quarantines an equivocated branch and publishes rebuilt accepted state.
Sourcepub fn frontier(&self, domain_id: DomainId) -> Result<Vec<CommitId>, StoreError>
pub fn frontier(&self, domain_id: DomainId) -> Result<Vec<CommitId>, StoreError>
Returns the canonical sorted commit frontier for a domain.
Sourcepub fn reconciliation_index_ready(
&self,
domain_id: DomainId,
) -> Result<bool, StoreError>
pub fn reconciliation_index_ready( &self, domain_id: DomainId, ) -> Result<bool, StoreError>
Returns whether the rebuildable causal and record-head indexes are complete.
Sourcepub fn commit_context(
&self,
domain_id: DomainId,
commit_id: CommitId,
) -> Result<Option<VersionVector>, StoreError>
pub fn commit_context( &self, domain_id: DomainId, commit_id: CommitId, ) -> Result<Option<VersionVector>, StoreError>
Loads the inclusive causal context cached for one accepted commit.
Sourcepub fn record_heads(
&self,
domain_id: DomainId,
collection_id: CollectionId,
record_id: &[u8],
) -> Result<Vec<RecordHead>, StoreError>
pub fn record_heads( &self, domain_id: DomainId, collection_id: CollectionId, record_id: &[u8], ) -> Result<Vec<RecordHead>, StoreError>
Loads only the current causal heads for one materialized record.
Sourcepub fn replace_reconciliation_index(
&self,
domain_id: DomainId,
contexts: &[(CommitId, VersionVector)],
heads: &[RecordHead],
) -> Result<(), StoreError>
pub fn replace_reconciliation_index( &self, domain_id: DomainId, contexts: &[(CommitId, VersionVector)], heads: &[RecordHead], ) -> Result<(), StoreError>
Atomically replaces the complete rebuildable reconciliation index for a domain.
Sourcepub fn get_record(
&self,
domain_id: DomainId,
collection_id: CollectionId,
record_id: &[u8],
) -> Result<Option<Vec<u8>>, StoreError>
pub fn get_record( &self, domain_id: DomainId, collection_id: CollectionId, record_id: &[u8], ) -> Result<Option<Vec<u8>>, StoreError>
Loads one canonical materialized record state by primary key.
Sourcepub fn list_records(
&self,
domain_id: DomainId,
collection_id: CollectionId,
) -> Result<Vec<StoredRecord>, StoreError>
pub fn list_records( &self, domain_id: DomainId, collection_id: CollectionId, ) -> Result<Vec<StoredRecord>, StoreError>
Lists canonical record IDs and states in stable primary-key order.
Sourcepub fn lookup_equal(
&self,
domain_id: DomainId,
collection_id: CollectionId,
field_id: u32,
value: &[u8],
) -> Result<Vec<Vec<u8>>, StoreError>
pub fn lookup_equal( &self, domain_id: DomainId, collection_id: CollectionId, field_id: u32, value: &[u8], ) -> Result<Vec<Vec<u8>>, StoreError>
Resolves an equality index to stable record IDs.
Sourcepub fn registered_schema(
&self,
domain_id: DomainId,
collection_id: CollectionId,
version: u32,
) -> Result<Option<SchemaDescriptor>, StoreError>
pub fn registered_schema( &self, domain_id: DomainId, collection_id: CollectionId, version: u32, ) -> Result<Option<SchemaDescriptor>, StoreError>
Loads a registered schema version, if present.
Sourcepub fn latest_registered_schema(
&self,
domain_id: DomainId,
collection_id: CollectionId,
) -> Result<Option<SchemaDescriptor>, StoreError>
pub fn latest_registered_schema( &self, domain_id: DomainId, collection_id: CollectionId, ) -> Result<Option<SchemaDescriptor>, StoreError>
Loads the highest registered schema version for one collection.
Sourcepub fn list_commit_ids(
&self,
domain_id: DomainId,
) -> Result<Vec<CommitId>, StoreError>
pub fn list_commit_ids( &self, domain_id: DomainId, ) -> Result<Vec<CommitId>, StoreError>
Lists accepted commit IDs, including snapshot-covered history, in deterministic order.
Sourcepub fn has_snapshot_coverage(
&self,
domain_id: DomainId,
) -> Result<bool, StoreError>
pub fn has_snapshot_coverage( &self, domain_id: DomainId, ) -> Result<bool, StoreError>
Returns whether this domain relies on snapshot-covered commit history.
Sourcepub fn snapshot_coverage(
&self,
domain_id: DomainId,
) -> Result<Vec<CommitId>, StoreError>
pub fn snapshot_coverage( &self, domain_id: DomainId, ) -> Result<Vec<CommitId>, StoreError>
Lists the exact opaque commit IDs represented by the installed snapshot.
Sourcepub fn snapshot_baseline(
&self,
domain_id: DomainId,
) -> Result<Option<SnapshotBaseline>, StoreError>
pub fn snapshot_baseline( &self, domain_id: DomainId, ) -> Result<Option<SnapshotBaseline>, StoreError>
Loads the immutable snapshot recovery baseline for a compacted domain.
Sourcepub fn claim_blob(
&self,
domain_id: DomainId,
hash: BlobHash,
) -> Result<(), StoreError>
pub fn claim_blob( &self, domain_id: DomainId, hash: BlobHash, ) -> Result<(), StoreError>
Idempotently records local ownership of an immutable blob by one security domain.
Sourcepub fn owns_blob(
&self,
domain_id: DomainId,
hash: BlobHash,
) -> Result<bool, StoreError>
pub fn owns_blob( &self, domain_id: DomainId, hash: BlobHash, ) -> Result<bool, StoreError>
Returns whether an accepted commit or claimed immutable blob belongs to a domain.
Sourcepub fn list_stored_commit_ids(
&self,
domain_id: DomainId,
) -> Result<Vec<CommitId>, StoreError>
pub fn list_stored_commit_ids( &self, domain_id: DomainId, ) -> Result<Vec<CommitId>, StoreError>
Lists commit IDs whose immutable envelope blobs are stored locally.
Sourcepub fn list_stored_commit_ids_through(
&self,
domain_id: DomainId,
max_epoch: u64,
) -> Result<Vec<CommitId>, StoreError>
pub fn list_stored_commit_ids_through( &self, domain_id: DomainId, max_epoch: u64, ) -> Result<Vec<CommitId>, StoreError>
Lists locally stored accepted commits visible through an epoch.
Exports durable per-author sequence baselines for a snapshot.
Sourcepub fn export_materialized(
&self,
domain_id: DomainId,
) -> Result<Vec<MaterializedRecord>, StoreError>
pub fn export_materialized( &self, domain_id: DomainId, ) -> Result<Vec<MaterializedRecord>, StoreError>
Exports complete canonical derived state for snapshots and equivalence checks.
Sourcepub fn replace_materialized(
&self,
domain_id: DomainId,
records: &[MaterializedRecord],
) -> Result<(), StoreError>
pub fn replace_materialized( &self, domain_id: DomainId, records: &[MaterializedRecord], ) -> Result<(), StoreError>
Atomically replaces all derived state for one domain.
Sourcepub fn install_snapshot(
&self,
domain_id: DomainId,
records: &[MaterializedRecord],
covered_commits: &[CommitId],
frontier_commits: &[CommitId],
author_sequences: &[(AuthorId, u64)],
activations: &[SchemaActivation],
observed_at_unix_seconds: u64,
baseline: &SnapshotBaseline,
) -> Result<(), StoreError>
pub fn install_snapshot( &self, domain_id: DomainId, records: &[MaterializedRecord], covered_commits: &[CommitId], frontier_commits: &[CommitId], author_sequences: &[(AuthorId, u64)], activations: &[SchemaActivation], observed_at_unix_seconds: u64, baseline: &SnapshotBaseline, ) -> Result<(), StoreError>
Atomically installs snapshot-derived state and its causal acceptance baseline.
Sourcepub async fn load_commit(
&self,
commit_id: CommitId,
) -> Result<CommitEnvelope, StoreError>
pub async fn load_commit( &self, commit_id: CommitId, ) -> Result<CommitEnvelope, StoreError>
Loads and strictly decodes an accepted immutable commit blob.
Sourcepub async fn scan_commit_orphans(&self) -> Result<Vec<CommitId>, StoreError>
pub async fn scan_commit_orphans(&self) -> Result<Vec<CommitId>, StoreError>
Finds canonical commit blobs left behind before their metadata transaction committed.
Arbitrary application blobs are ignored. The returned IDs are deterministic and can be offered to a repair workflow; scanning never mutates durable state.
Sourcepub fn bootstrap_domain(
&self,
descriptor: &DomainDescriptor,
root: &CapabilityCertificate,
) -> Result<(), StoreError>
pub fn bootstrap_domain( &self, descriptor: &DomainDescriptor, root: &CapabilityCertificate, ) -> Result<(), StoreError>
Atomically records a domain genesis descriptor and its owner capability.
Atomically imports a descriptor, chain, active root/leaf, and trust set.
Atomically imports a signed current authority baseline from a targeted invitation.
Sourcepub fn install_capability(
&self,
capability: &CapabilityCertificate,
) -> Result<CapabilityId, StoreError>
pub fn install_capability( &self, capability: &CapabilityCertificate, ) -> Result<CapabilityId, StoreError>
Installs a delegated capability after validating its durable issuer link.
Sourcepub fn install_capability_chain_atomic(
&self,
chain: &[CapabilityCertificate],
) -> Result<CapabilityId, StoreError>
pub fn install_capability_chain_atomic( &self, chain: &[CapabilityCertificate], ) -> Result<CapabilityId, StoreError>
Atomically installs a validated root-to-leaf capability chain.
Only the leaf becomes active. Intermediate certificates are retained as immutable delegation evidence and cannot replace another subject’s active capability as a side effect of authenticating the leaf.
Sourcepub fn capability(
&self,
capability_id: CapabilityId,
) -> Result<Option<CapabilityCertificate>, StoreError>
pub fn capability( &self, capability_id: CapabilityId, ) -> Result<Option<CapabilityCertificate>, StoreError>
Loads one verified capability certificate by content ID.
Sourcepub fn capability_chain(
&self,
leaf: CapabilityId,
) -> Result<Vec<CapabilityCertificate>, StoreError>
pub fn capability_chain( &self, leaf: CapabilityId, ) -> Result<Vec<CapabilityCertificate>, StoreError>
Resolves a bounded root-to-leaf capability chain.
Sourcepub fn domain_descriptor(
&self,
domain_id: DomainId,
) -> Result<Option<DomainDescriptor>, StoreError>
pub fn domain_descriptor( &self, domain_id: DomainId, ) -> Result<Option<DomainDescriptor>, StoreError>
Loads the immutable descriptor when this is a capability-controlled domain.
Sourcepub fn active_capability(
&self,
domain_id: DomainId,
subject: AuthorId,
) -> Result<Option<CapabilityId>, StoreError>
pub fn active_capability( &self, domain_id: DomainId, subject: AuthorId, ) -> Result<Option<CapabilityId>, StoreError>
Returns the active capability selected for an endpoint in a domain.
Sourcepub fn active_capabilities(
&self,
domain_id: DomainId,
) -> Result<Vec<CapabilityId>, StoreError>
pub fn active_capabilities( &self, domain_id: DomainId, ) -> Result<Vec<CapabilityId>, StoreError>
Lists exact active capability IDs for a domain in canonical order.
Checks active, non-revoked, endpoint-bound permission at an epoch.
Sourcepub fn control_head(
&self,
domain_id: DomainId,
) -> Result<Option<ControlTransition>, StoreError>
pub fn control_head( &self, domain_id: DomainId, ) -> Result<Option<ControlTransition>, StoreError>
Loads and verifies the current single-successor control head.
Sourcepub fn accepted_control_chain(
&self,
domain_id: DomainId,
) -> Result<Vec<ControlTransition>, StoreError>
pub fn accepted_control_chain( &self, domain_id: DomainId, ) -> Result<Vec<ControlTransition>, StoreError>
Returns the accepted control chain in ascending sequence order.
Loads and verifies the optional history-compacting authority baseline.
Checks persisted checkpoint evidence against immutable authority objects.
Sourcepub fn control_transition(
&self,
domain_id: DomainId,
control_id: [u8; 32],
) -> Result<Option<ControlTransition>, StoreError>
pub fn control_transition( &self, domain_id: DomainId, control_id: [u8; 32], ) -> Result<Option<ControlTransition>, StoreError>
Loads one retained canonical control object by content ID.
Sourcepub fn accepted_control_at_sequence(
&self,
domain_id: DomainId,
sequence: u64,
) -> Result<Option<ControlTransition>, StoreError>
pub fn accepted_control_at_sequence( &self, domain_id: DomainId, sequence: u64, ) -> Result<Option<ControlTransition>, StoreError>
Loads one retained accepted transition by its signed sequence.
Sourcepub fn current_epoch(&self, domain_id: DomainId) -> Result<u64, StoreError>
pub fn current_epoch(&self, domain_id: DomainId) -> Result<u64, StoreError>
Returns the epoch authorized by the durable control chain.
Sourcepub fn current_control_sequence(
&self,
domain_id: DomainId,
) -> Result<u64, StoreError>
pub fn current_control_sequence( &self, domain_id: DomainId, ) -> Result<u64, StoreError>
Returns the accepted domain-control sequence, or zero at genesis.
Sourcepub fn subject_revocations_consistent(
&self,
domain_id: DomainId,
) -> Result<bool, StoreError>
pub fn subject_revocations_consistent( &self, domain_id: DomainId, ) -> Result<bool, StoreError>
Checks the rebuildable subject-revocation index against signed control.
Sourcepub fn subject_revocations(
&self,
domain_id: DomainId,
) -> Result<Vec<(AuthorId, u64)>, StoreError>
pub fn subject_revocations( &self, domain_id: DomainId, ) -> Result<Vec<(AuthorId, u64)>, StoreError>
Returns the canonical revocation accumulator derived from signed authority.
Sourcepub fn repair_subject_revocations(
&self,
domain_id: DomainId,
) -> Result<(), StoreError>
pub fn repair_subject_revocations( &self, domain_id: DomainId, ) -> Result<(), StoreError>
Atomically rebuilds subject revocations from the accepted signed chain.
Sourcepub fn current_controller(
&self,
domain_id: DomainId,
) -> Result<AuthorId, StoreError>
pub fn current_controller( &self, domain_id: DomainId, ) -> Result<AuthorId, StoreError>
Returns the endpoint exclusively authorized to sign the next control transition.
Sourcepub fn current_writer(
&self,
domain_id: DomainId,
) -> Result<Option<AuthorId>, StoreError>
pub fn current_writer( &self, domain_id: DomainId, ) -> Result<Option<AuthorId>, StoreError>
Returns the currently designated single writer.
Sourcepub fn observe_control(
&self,
control: &ControlTransition,
) -> Result<(), StoreError>
pub fn observe_control( &self, control: &ControlTransition, ) -> Result<(), StoreError>
Verifies and retains a control object before separately delivered key material is activated.
Sourcepub fn apply_control(
&self,
control: &ControlTransition,
) -> Result<(), StoreError>
pub fn apply_control( &self, control: &ControlTransition, ) -> Result<(), StoreError>
Atomically advances authority, records the causal cut, and revokes endpoint access.
Sourcepub fn apply_control_bundle(
&self,
control: &ControlTransition,
successor_chain: &[CapabilityCertificate],
) -> Result<(), StoreError>
pub fn apply_control_bundle( &self, control: &ControlTransition, successor_chain: &[CapabilityCertificate], ) -> Result<(), StoreError>
Atomically installs successor capability evidence and advances authority.
Adds a device to the local domain authorization set.
Returns whether a device is locally authorized for this domain.
Lists locally authorized devices in canonical identity order.
Sourcepub fn set_device_group(
&self,
domain_id: DomainId,
label: &str,
members: &[AuthorId],
) -> Result<(), StoreError>
pub fn set_device_group( &self, domain_id: DomainId, label: &str, members: &[AuthorId], ) -> Result<(), StoreError>
Replaces bounded application-facing group metadata without changing protocol identity.
Sourcepub fn device_groups(
&self,
domain_id: DomainId,
) -> Result<Vec<(String, Vec<AuthorId>)>, StoreError>
pub fn device_groups( &self, domain_id: DomainId, ) -> Result<Vec<(String, Vec<AuthorId>)>, StoreError>
Lists device groups for one domain in label order.
Sourcepub fn consume_invitation(
&self,
invitation_id: [u8; 32],
) -> Result<bool, StoreError>
pub fn consume_invitation( &self, invitation_id: [u8; 32], ) -> Result<bool, StoreError>
Atomically marks an offline invitation ticket consumed, returning false on replay.