Expand description
coven — host integration for end-to-end encrypted, multi-writer,
bring-your-own-storage SQLite sync. The engine lives in coven-core; this
crate wires it to the filesystem, the platform keyring, and cloud
providers, and re-exports the curated host API.
The public API is exactly the crate-root re-exports below. The engine’s
implementation modules are pub(crate), so a host reaches coven only through
these names — never through coven::sync::… or coven::blob::…. In
particular the sync driver is private: it starts only through
CovenHandle::connect_sync, which holds the lifecycle lock, so a host
cannot drive the loop out from under the handle.
ⓘ
// `sync` is a private module; the sync driver is unreachable from outside.
let _ = coven::sync::sync_manager::SyncManager::start_sync;Re-exports§
pub use coven_core::rusqlite;
Structs§
- Activated
Continuation - Exact durable state required to continue an activated Store device.
- Affected
Row - One table/primary-key identity affected by the shared part of a write.
- Blob
Body - A blob as a sized stream of already-final bytes: sealed chunks for an
encrypted home, plaintext for a browsable one. Encryption-agnostic and
concrete (no
dyn Stream).next_parthands the bytes to a streaming upload in bounded windows so a large blob is never held whole in memory; the onlycollectis the single-request path for blobs at or below a provider’s multipart threshold. - Blob
Decl - Where a blob-bearing table’s blob columns live, declared by the host so coven
can derive every blob a row references without a runtime callback. Resolved
against the live schema into a [
crate::blob::decl::BlobDecls] each cycle. - BlobRef
- A blob a row references: its cloud identity, encryption scope, and the two
declared properties (
provenance+fill). coven derives it from the row’s declared columns (crate::sync::session::BlobDecl) via [decl::BlobDecls]. Where its bytes live depends on its locality and provenance: a user-provided Local blob is the user’s file at its path; a host-provided Local blob is in coven’s local store (storage/local/<namespace>/<id>); a Remote blob’s device-local copy is a cache copy (storage/pinned/<namespace>/<id>/storage/cache/<namespace>/<id>, built from the validated namespace + id — see [cache]). - Blob
Store - Storage implementation for managed local storage.
- Circle
Id - A self-certifying 128-bit circle identity encoded as canonical lowercase base32.
- Circle
Info - Circle
Operation Info - Cloud
Head Version - Opaque provider revision returned by an authoritative coordination read.
- Cloud
Home Config - The cloud home: which provider backs sync and its per-provider settings. One cohesive unit — connecting picks a provider and fills its fields; disconnecting resets the whole thing to default.
- Cloud
KitAccepted Share - Cloud
KitAccepted Share Record - Cloud
KitAtomic Create Batch - Cloud
KitProvider Identity - Cloud
KitRecord Create - Cloud
KitRecord Version - Cloud
KitShare - Cloud
Versioned Head - Config
- Sync + storage configuration for one store.
- Coven
- Coven
Builder - Coven
Config - Coven
Handle - The handle over one coven store.
- Coven
Read Handle - A read-only handle over one coven store, for a same-store secondary reader.
- Cross
Principal Probe Receipt - Device
Activity - Activity summary for a single remote device.
- Device
Join Abandonment - Device
Join Activation - Device
Join Attempt Id - Device
Join Attempt Ref - Device
Join Cancellation - Device
Join Cleanup Activation - Device
Join Cleanup Receipt - Device
Join Client - A joining device’s local half of the four-transfer admission exchange. The journal lives outside the incomplete store directory, so every method can be retried after process termination without losing its exact predecessor.
- Device
Join Journal Database - Durable role journal. Each row stores a closed progress value; SQLite’s compare-and-swap update rejects stale or skipped transitions.
- Device
Join Journal Record - Device
Join Offer - Device
Join Producer Write Revocation - Device
Join Readiness - Device
Provider Access Request - Device
Provider Admission Approval - Device
Provider Admission Completion - Device
Registration Request - Encryption
Service - Manages encryption keys and provides XChaCha20-Poly1305 encryption/decryption
- Exact
Slot Probe Receipt - Fixed
Clock - Every
now()returns the same instant. - Held
Store Position - Hlc
- Hybrid Logical Clock.
- InMemory
Cloud Home - In-memory CloudHome backed by a HashMap.
Cloneshares one backing store, so clones act as separate devices reading and writing the same cloud bucket, and a test can keep its own handle for direct at-rest assertions while each device owns aBox<dyn CloudHome>clone. - Joined
Store - Joiner
Join Closure - Master
Keyring - A store’s master key material: every key it holds. This is the value custody
implementations store, unlock, and re-protect — never a cipher. coven builds
the
EncryptionServicecipher from it internally; custody never touches cipher machinery. - Member
Info - Membership
Coord - Migration
- One ordered step in the host’s synced-schema ladder.
- OAuth
Client Creds - OAuth client credentials for one provider — the consuming app’s registered
OAuth application. coven ships no app credentials of its own; the host
registers them at startup via
set_oauth_client_creds. - OAuth
Client Creds Conflict - Registering OAuth client credentials a second time with values that differ from the first registration — a startup contradiction the host must resolve, not a value coven may silently pick between.
- OAuth
Tokens - Tokens returned from an OAuth authorization or refresh.
- Object
Hash - Object
Slot - Exact logical and physical location persisted before an immutable write.
- Owner
Recovery Authority - Exact Owner grant and recovery-stream authority used to create a replacement device when no activated device continuation survives.
- Passphrase
- A memorized secret that wraps a payload under Argon2id. Held zeroizing — the whole struct is cleared on drop, so no copy of the passphrase outlives it.
- Pending
Branch - Pending
Branch Id - Stable identity of the one ordered provisional Serial branch.
- Pending
Write - Durable write information returned by
CovenHandle::pending_writes. - Provider
Admin Grant Id - Provider
Admin Grant Record - Provider
Admin Join Closure - Provider
Admin State - Provider
Capability Proof - Provider
Device Binding - Provider
Probe Id - Provider
Ready Device Bootstrap - Provisional
Device Bootstrap - Resolved
Provider Binding - Restore
Code - Everything needed to restore a store from cloud storage.
- Restore
Source - Cloud provider source for restore: the join info a restore code carries
plus the extras it can’t (
RestoreCodeomits OAuth tokens because they expire — the user re-authenticates on restore — and holds no live CloudKit driver). - RowBlob
Ref - One exact blob-bearing row version. A reference becomes stale when the live row stamp or any declared blob value changes.
- RowChange
- One row change extracted from a changeset.
- S3Cloud
Home - S3-backed cloud home.
- Sequential
IdProvider - Deterministic but unique:
"{prefix}-0","{prefix}-1", … Preserves the per-entity uniqueness invariant while being reproducible across runs. - Serial
Coordination Probe Receipt - Serialization
Conflict - A Serial branch ran against
base, but storage now commitscurrent. - SqlContext
- Host SQL inside one journaled write transaction.
- Stepping
Clock - Advances a fixed delta per
now()call: the first call returnsstart, the nextstart + step, and so on. For tests that assert ordering. - Store
Batch Commit Ref - Exact identity of one signed Store commit candidate.
- Store
Dir - Typed wrapper for a store directory path.
- Store
Keys - One store’s key material: the encryption master key, cloud-home credentials,
and OAuth tokens, each stored under a store-scoped keyring account
(
{base}:{store_id}). The store’s signing identity is not here — it goes throughcrate::identity_custody::IdentityCustody, the same way the master key goes throughcrate::custody::KeyCustody. - Store
Layout - The host’s on-disk layout for stores: where they live and what the
database file is called. One rule shared by create, open, join, and
restore, so a host that wants
libraries/<id>/library.dbinstead of coven’s defaultstores/<id>/store.dbnames it once here rather than each flow hardwiring (or working around) coven’s own choice. - Sync
Loop Alerts - Sync
Loop Success - Synced
Table - A table that participates in changeset sync, declared at startup by the host
and passed to [
crate::CovenBuilder::synced_tables]. - System
Clock - Production clock: real wall time.
- Timestamp
- A parsed HLC timestamp.
- Updated
AtStamper - A cloneable handle that mints
_updated_atregister values from a sharedHlc— the register-stamping capability, sliced off the whole [crate::sync::sync_manager::SyncManager]. - User
Keypair - Ed25519 keypair for signing changesets and membership changes. The same seed can derive an X25519 keypair for key wrapping.
- Uuid
Provider - Production provider: random v4 UUIDs.
- Write
Batch - WriteId
- Stable identity of one successfully committed host transaction.
- Write
Receipt - Result of one successful host transaction and its durable publication identity.
Enums§
- Audience
- The one audience a synced row belongs to.
- AwsPrincipal
- Blob
Cache Error - Why a blob-cache operation failed.
- Blob
Replacement - A blob’s replacement story: whether the row carrying it may ever be repointed at
a different blob. Orthogonal to
ProvenanceandCacheFill; a blob declares all three. - Blob
Scope - Which key encrypts a blob, as a host names it on a
BlobRef. - Bootstrap
Error - Why joining or restoring a store failed. Both are the same operation — bootstrap a store from the cloud — differing only in their entry data (an invite that wraps the store key vs a restore code that carries the bucket credentials), so they share one error shape rather than two that duplicate most of their variants and then have to map between each other.
- Cache
Fill - A blob’s Remote story: how a device gets the bytes once the blob is Remote.
A cache-mechanism setting — it describes a blob only while Remote — that applies
to ANY blob regardless of
Provenance. Orthogonal to provenance; a blob declares both. - Change
Op - The operation type for a changeset entry.
- Circle
Operation State - Circle
Role - Cloud
Access Outcome - Cloud
Access State - Cloud
Cipher - How a cloud home protects its objects at rest. An
Encryptedhome seals every object under the store key (the default); aPlaintexthome stores objects in the clear so the bucket is browsable, and drops the.encsuffix. - Cloud
File Read Error - Cloud
Head Create Error - Cloud
Head Replace Error - Cloud
Home Credentials - Credentials for the cloud home, stored as a single JSON keyring entry.
- Cloud
Home Error - Errors from raw cloud storage operations.
- Cloud
Home Join Info - Information needed to join a cloud home from another device.
- Cloud
KitEnvironment - Cloud
KitScope - Cloud
KitShare Acceptance - Cloud
KitShare Permission - Cloud
Provider - Cloud home provider selection.
- Config
Error - Configuration errors.
- Coven
Error - Custom
S3Exact Slots - Local operator assertion required before a custom S3 endpoint may provide exact protocol and blob slots. This is local configuration and is never accepted from invite or restore data.
- Custom
S3Serial - Operator assertion required before a custom S3 endpoint may coordinate a
serial Store. AWS S3 itself is selected by leaving
s3_endpointabsent. - DbError
- An error from the owned database.
- Device
Join Action - Device
Join Authorization - Device
Join Cleanup Progress - Device
Join Error - Device
Join Producer - Device
Join Role - Device
Join Status - Device
Provider Admission - Device
Provider Readiness - Encryption
Error - Google
Drive Corpus - Held
Store Coordinate - Held
Store Position Reason - Home
Storage - How a cloud home stores its objects: opaque (encrypted, unreadable to anyone who can read the bucket) or browsable (stored in the clear at readable paths). This is not about who can reach the bucket — the storage provider’s own access control applies either way; it is about whether what they store is legible. The host picks it once, when it creates the home; it cannot change later (it determines how every object is written). One choice drives two mechanisms together:
- Identity
Custody - How a store’s device-signing identity is protected. Selected on the
builder, resolved once per store — the identity sibling of
crate::custody::KeyCustody, same shape. - Identity
Error - Why a
CovenHandleinitialize_identitycall failed. - Join
Code Error - Joiner
Join Terminal - KeyCustody
- How a store’s master key is protected. The builder accepts this and never
sees a cipher again — coven resolves the selection into a
MasterKeyCustodyand builds every cipher from what it supplies. - KeyError
- Make
Local Error - Why a make_local could not complete.
- Make
Remote Error - Why a make_remote (or its cancel) could not be started.
- Master
KeyError - Why a
CovenHandlemaster-key lifecycle call (initialize_master_key,import_master_key) failed. - Member
Role - Migration
Step - How a migration applies its change to the synced schema.
- OAuth
Client Creds Error - A provider’s OAuth client credentials were requested before the host
registered them via
set_oauth_client_creds: either no registration ran at all, or the registered map has no entry for this provider. Surfaced at the OAuth-flow boundary so a mis-configured host gets a typed error naming the startup step, not an emptyclient_idthat fails deep inside a provider flow. - OAuth
Error - Physical
Object Locator - Provider-specific physical address for a caller-reserved immutable slot.
- Provenance
- A blob’s Local story: where its bytes live while the blob is Local, and
whether bringing it back from Remote needs a destination path. Orthogonal to
CacheFill(the Remote story) — a blob declares both. - Provider
Admin Change - Provider
Admin Join Terminal - Provider
Admin Membership Change - Provider
Principal Id - Published
Position - Exact policy-specific position that made a write visible to peers.
- Restore
Authority - The closed authority a restore operation may exercise.
- RowBlob
Authority - The authority state that determines where one row version’s blob lives.
A remote-audience blob remains
PendingRemotewhile its verified plaintext is local and no cloud object has been created;Remotecarries the exact package authority needed to open its committed object. - RowIdentity
- How
(table, id)names one logical row across every device. - S3Endpoint
Binding - Seal
Error - Why sealing or opening a host’s app-data failed.
- Store
Commit Coord - Closed coordinate of one Store commit under the Store’s signed policy.
- Store
Provider Binding - Provider namespace/corpus facts signed once by the Store root.
- Sync
Error - Sync
Loop Status - A sync-loop status the host renders. The loop reports provider reachability,
publication, and one terminal status.
ConflictandBlockedare successful storage cycles with unresolved durable writes;Synchronizedhas none, whileFailedmeans the cycle itself failed. The in-progress marker is the variant itself, so there is no separate “syncing” flag. - Write
Block - A semantic write fault. Retrying transport cannot change this result.
- Write
Policy - Store-wide ordering policy selected by the application and signed into the Store protocol root.
- Write
Resolution - Write
Status - Current durable state of one host transaction.
Constants§
- CHUNK_
SIZE - 64KB plaintext chunks
Traits§
- Blob
Transition Observer - Notified about coven’s blob transitions, for host-specific bookkeeping and UI: per-blob upload progress while a make_remote uploads, per-blob materialize progress while a make_local copies files back, and a completion hook per direction the host turns into its own UI event.
- Clock
- Wall-clock source. Returns a full
DateTime<Utc>; callers derive.timestamp()/.to_rfc3339()as they need. - Cloud
Home - Cloud
KitOps - Synchronous interface for raw CloudKit record operations. Implemented by a host bridge to its platform CloudKit driver. Methods block the calling thread while CloudKit async operations complete.
- Device
Identity Custody - A device’s signing identity’s custody FOR ONE STORE: who unlocks it,
where a newly established one is written, and how it is removed. The
signing-key sibling of
MasterKeyCustody, same three-method shape and the same per-store selection, overUserKeypairinstead of a store’s master keyring. - Device
Provider Access Administrator - Exact
Slot Storage - Low-level cloud storage. Implementations handle a single store.
- IdProvider
- Identifier source. Yields a fresh unique id per call.
- Master
KeyCustody - A store’s master keyring’s custody: who unlocks it, where a newly established or rotated one is written, and how it is removed. Implemented once per protection policy (the OS keyring, a passphrase-wrapped file, an in-memory session value, or a host’s own).
- Part
Sink - The one per-provider streaming-upload surface: a session that accepts ordered
parts and commits. The central [
write_blob] driver opens one of these for a large blob and pumpsBlobBodyparts into it — no backend writes its own upload loop, collect, or progress call.
Functions§
- abandon_
join_ request - Abandon a join request this device generated but never completed —
removes the pending identity
generate_join_requestminted for it.Okwhether or not one was still pending. - authorize_
provider - Run an OAuth authorization flow for the given cloud provider (desktop: opens a browser and captures the redirect on coven’s localhost callback server).
- build_
authorize_ request_ for_ provider - Build an OAuth authorization request for
providerredirecting toredirect_uri, for hosts that capture the redirect themselves (a mobile OS auth session). Pair the returned request, callbackcode, callbackstate, and sameredirect_uriwithexchange_code_for_provider. - create_
cloud_ home - Build a
CloudHomefromconfig, surfacing a missing or malformed provider configuration as a non-retryableCloudHomeError::Configurationso a host can tell “fix your settings” apart from a transient failure it should keep retrying. - decode_
invite_ code_ info - Decode an invite code and return UI-ready info.
- decode_
join_ request - decode_
restore_ code_ info - Decode a restore code and return UI-ready info.
- entry_
for_ test - Test-only: reaches [
entry_for] across the crate boundary. Exists so an integration test can install a specific keyring store and assert which entry-construction path the chokepoint took, without re-implementing its dispatch. - exchange_
code_ for_ provider - Exchange an authorization
codecaptured by the host forprovider’s tokens.redirect_uri,request, andcallback_statemust match the originatingbuild_authorize_request_for_providercall. - fetch_
account_ email - Fetch the email of the account
tokensauthenticated, for the given OAuth provider. The joining device calls this right after authenticating so the approver can share the OAuth folder to its provider-account email. - generate_
join_ request - Build a join request carrying a freshly minted pending identity (see
[
crate::keys::mint_pending_identity]) — the joiner sends its public key before it learns which store the invite names, so the keypair is generated now and held under a pending slot keyed by that public key. Completing the join withcrate::DeviceJoinClient(constructed with this same code) promotes it into the joined store’s own identity;crate::abandon_join_requestdiscards it if the request is abandoned instead. - generate_
restore_ code - Build a RestoreCode from config and custody, then encode it.
- keyring_
service - The registered keyring service name.
Errwhen the host never ran the startupset_keyring_servicecall — surfaced so a mis-ordered host gets a typed error, not a panic deep inside a key operation. - restore_
from_ cloud - Restore a store from cloud storage.
- restore_
from_ code - Restore a store from a restore code string.
- rewrap_
passphrase_ custody - Re-wrap a store’s passphrase-protected master keyring under a new
passphrase — the store-side half of covenpass’s “change passphrase”. The
<store_dir>/master.keyringenvelope is decrypted witholdand re-sealed undernew(fresh salt and nonce). Errors if nothing is established there (KeyError::Persistence) or ifoldis wrong (KeyError::Crypto), leaving the existing file untouched on either failure. After it returns, the store’s custody is re-opened undernew. - rewrap_
passphrase_ identity_ custody - Re-wrap a store’s passphrase-protected signing identity under a new
passphrase — the identity half of a host’s “change passphrase”, the
sibling of
crate::custody::rewrap_passphrase_custody. The store’sidentity.envelopeis decrypted witholdand re-sealed undernew(fresh salt and nonce). Errors if nothing is established there (KeyError::Persistence) or ifoldis wrong (KeyError::Crypto), leaving the existing file untouched on either failure. After it returns, the identity is re-opened undernew. - set_
keyring_ service - Register the process-wide keyring: the service name every entry is stored
under, and the platform keyring store that backs it. Both are one-time
startup registration and must run before any key operation. The store is
installed before the name is recorded, so a failed installation leaves no
registration behind. Re-registering the same name is a no-op; a different
name is a startup contradiction and fails. Fails with
KeyError::UnsupportedKeyringPlatformon a target with no bundled store. - set_
oauth_ client_ creds - Register the host’s OAuth client credentials, keyed by provider name
(
"google_drive","dropbox","onedrive"). Call once at startup, before any OAuth flow. Providers absent from the map get empty credentials. Re-registering the same map is a no-op; a differing map is a startup contradiction and returnsOAuthClientCredsConflict. - sign_
in_ dropbox - Dropbox OAuth sign-in: authorize, create the store folder, save tokens to the keyring. Returns the folder path for the host to persist in its config.
- sign_
in_ google_ drive - Google Drive OAuth sign-in: authorize, find/create the store folder, save tokens to the keyring. Returns the folder id for the host to persist in its own config (coven never writes the host’s config).
- sign_
in_ onedrive - OneDrive OAuth sign-in: authorize, resolve the default drive, create the app
folder, save tokens to the keyring. Returns
(drive_id, folder_id)for the host to persist in its config. - write_
cloud_ object_ stream
Type Aliases§
- BoxPart
Sink - A boxed
PartSinkborrowing its home for'a. - Clock
Ref - Shared handle to a clock. Held by
Clonetypes (CovenHandle,CovenReadHandle) so they clone the handle, not the implementation. - Cloud
Object Stream - Coven
Result - IdRef
- Shared handle to an id provider. Held by
Clonetypes that need to share one id source, so they clone the handle, not the implementation. - Store
Serial Predecessor - Upload
Progress - Reports how many bytes of a
writehave reached the backend so far. Called with the cumulative byte count as the body uploads; backends that can’t observe sub-call progress call it once at the end with the full size. The count is of the bytes handed towrite(the encrypted payload).