Expand description
The store’s SQLite database, protected internal tables and app migrations.
DatabaseBuilder opens a store with one locked writer and read-only
connections, or with read-only connections alone. App SQL runs inside the
borrowed MigrationContext or SqlContext; no raw connection leaves its
owner. A local write commits its app rows, unsigned record and merge metadata
together on the writer connection.
Modules§
- operation_
kind - The journal kind of each operation coven runs, and the
started_byof those coven starts on its own. Sync gives each kind its steps; the database finds invites’ rows itself, forcoven_invitesand to end them when the installation stops for good. - slot_
json - A slot as the JSON coven keeps it in: its number. For
#[serde(with = "coven_database::slot_json")]. - test_
utils - Schema fixtures and crash checkpoints for tests of the production database.
- types
- Traits dealing with SQLite data types.
Macros§
- named_
params - A macro making it more convenient to pass lists of named parameters
as a
&[(&str, &dyn ToSql)]. - params
- A macro making it more convenient to pass longer lists of
parameters as a
&[&dyn ToSql].
Structs§
- Admin
Effect - Membership and required reload work installed with an authorized admin slot.
- Attempt
Commits - Every commit made outside one attempt since it began, kept until the attempt names the rows its wait depends on.
- Boundary
Coverage - A checked raise or reset and its authenticated snapshot coverage.
- Bulk
SqlContext - App SQL inside one bulk write (§4): it changes device-local tables alone, and may read any table app SQL reads. Returning an error rolls back every statement. This borrowed context cannot change the transaction, access coven’s tables or write a synced one.
- Cache
Bytes - The cache’s bytes: every declared namespace’s, and the partial downloads pins left, which the cache neither counts nor evicts.
- Cache
Reservation - Bytes reserved for one file’s whole encrypted cache file while it is written, until a prepared pin takes it (§17.8).
- Change
Source - An original row change or direct execution target used as data (§9.5, §9.6).
- Circle
- A circle the local member belongs to (E12).
- Circle
Member Info - An active store member in a circle (E12).
- Claim
- A claim retains every attempt, including attempts that lost contention.
- Claim
Attempt - A create-once request, persisted before the provider is called.
- Claim
Bytes - Bounded reads of the current attempt’s durable ciphertext.
- Claim
Upload - Durable transfer state for the current attempt’s exact sealed bytes.
- Column
Change - One column of a change, retaining its original parent generations privately.
- Commit
Scope - Commits made by database calls that a
CommitScope::runfuture starts belong to that scope. Calls started from other tasks, including tasks the future spawns, are outside it. - Copy
Reservation - The copies one call to make files device-only is writing, which no other write’s removal takes while it is held or a step it runs is under way. Once both end, whatever became of the call, the next write removes those its switch didn’t keep.
- Database
- Shared ownership of the database, as its writer or a read-only handle
(
Database<ReadOnly>), which reads the store through the same calls and cannot write synced rows or migrate. A read-only handle’s connections can change only local cache metadata, and its shared store lock prevents deletion until all of them close. Closing any clone closes them all. - Database
Builder - Choices needed to open the database part of a store.
- Database
Changes - A live commit observation; coalesces changes and ends when the writer closes.
- Device
Info - One of a member’s device ids in the committed prefix (E9).
- Device
Only Copy - A cloud file to make device-only here: its id, the stored bytes its copy was downloaded from, the copy’s path, which becomes the original this device records, and the hashes of the bytes written to it, which a later move to the cloud checks the copy against (§17.3).
- Downloaded
Write Stream - A checked write header and its audience streams. The database commits only after sync confirms authentication. Parts follow the header’s order and count.
- File
Candidate - A fixed file path awaiting a storage-deletion decision (§17.10).
- File
Column - A column holding a file’s id, or NULL (§17.2, E2). It references the file as a foreign key references its parent.
- File
Database - File queue and cache access, on the store’s writer or a read-only
handle (
FileDatabase<ReadOnly>), which reads and caches files and can change only its local cache metadata. The upload and pin queue and the file records are the writer’s. Construct beside the database at the application composition root. - File
Hasher - Hashes a file’s bytes as they pass, in order, into its
FileHashes. - File
Hashes - A file’s content hash and the hash of each 64-KiB plaintext chunk, the last possibly shorter, from one read of its bytes: what an upload checks each chunk it sends against (§17.1, §17.9).
- File
Location - A stored file’s fixed location: the uploader, the stored object’s id and the file’s key. Equality compares the whole text, so another object or key is another location. Diagnostics never show the key.
- FileRef
- One file as its record stood when it was read.
- File
Upload - One durable upload of one stored object; its plaintext chunk hashes are
owned child rows. The location carries the path and key its staging
fixed. Failures live in
_coven_pendingunder the object’s subject, not here. - Folder
Copy - One copy a call to make files device-only writes (§17.3): its path, the temporary name in the same folder its bytes are written under, and the folders the call makes on its path.
- Function
Arguments - The arguments SQLite passes one call of an app function. Only the arguments: the connection running the statement stays coven’s.
- Header
Evidence - A write’s signed header and every part root, retained from receipt or a loaded snapshot (D9).
- InFlight
- The stored objects this process is transferring one way. The worker transferring them adds each attempt as it starts and removes it as it ends, saying how, cancelled included. Clones share it.
- Incoming
Slot - An authenticated slot whose floor check completed before installation.
- Input
Budget - Retained encrypted bytes have a maintained total and explicit eviction count.
- Journal
- The journal inside one write, for sync’s steps.
- Live
Query - A subscription’s results and lifetime; dropping it ends future runs. Its
results fail with
E, the query closure’s own error type. - Live
Query Closed - The query was dropped before its request could be replaced.
- Live
Query Requests - Shared access to replacing a live query’s request.
- Live
Query Revision - A request revision assigned by one live query.
- Live
Query Runs - How often a live query had run when asked, for tests and benchmarks that measure how many of its runs writes caused, and how many found nothing new.
- Loaded
Snapshot - Files retained by a loaded snapshot.
- Local
Bytes - What a store keeps on this device, in bytes on disk (§17.8, §19.3).
- Local
Bytes Watch - The measurements of what the store keeps on this device, as they change.
- Local
Evidence - What this device knows locally about a file it uploads (§17.6): the upload, where its bytes go, its move, and the records about each.
- Local
File Stream - An open local file checked against its recorded facts. Retaining it keeps the opened bytes readable across its upload completing and file unlinking, and prevents store deletion until its reads and handles have finished.
- Lost
Cell - One retained value and the write that set it.
- Lost
Value - One durable lost cell or removed row.
- Member
Info - A live member and every device they registered (E9).
- Migration
- One numbered change to the app’s database, with its declared kind. Clones retain the same callbacks across bootstrap and database opening.
- Migration
Context - App SQL inside the transaction owned by the migration run. The context borrows its owner and cannot change the transaction or connection.
- Migration
Outcome - The classification of a migration committed by this open.
- MoveId
- One move’s identity on this device, never reused (§17.3, E3).
- Namespace
- A kind of file with its cache budget, declared when the store opens (§17.1, §17.8, E1).
- Namespace
Bytes - One namespace’s cache, in bytes on disk.
- NewOperation
- The initial state committed before any external effect.
- Object
Removal - An object to delete from storage once
afterhas passed. - Operation
Id - The local, never reused identity of an operation.
- Operation
Record - A journal row read as one committed value.
- Operation
Update - A step transition, guarded against stale callers.
- PinProgress
- Verified cache coverage of requested files (§17.8, E8).
- PinRequest
- One file this device keeps whole as a switch asked.
- Prepared
Device Only - Cloud files downloaded to copies in the person’s folder, ready for one
write to make them device-only here (§17.3, E8). It holds nothing close
waits for. Committed by no write, its copies stay reserved while it is
held, and the next write or open removes them once it drops;
abandonremoves them at once. - Prepared
Pin - Files ready to pin in one write (§17.8). It holds nothing close waits for. Dropped uncommitted, or after the store closes, its copies’ names go free, and the next write or open removes their bytes.
- Prepared
Uploads - A captured queue prefix whose writes all have their first-attempt keys
fixed, in queue order. Only
crate::Database::prepare_uploadsmakes one, andcrate::Database::read_uploadsreads its writes’ plaintext. - Prepared
User File - An original read whole once before entering a write: its path, size and modification time, and the content hash and chunk hashes of the bytes that read found, which coven records and checks the original against.
- Provider
Access - A request makes confirmation unknown until the provider supplies evidence.
- Provider
Access Change - One account’s intention derived from membership and this device’s invitations.
- Provider
Access Request - A request remains associated with its account until confirmation matches intention.
- Raise
Capture - A breaking raise’s fixed original prefix and current counted coverage.
- Read
- A read that starts when polled and retains its store borrow until it ends, on the store’s writer or a read-only handle.
- Reconfigurable
Live Query - A subscription whose request may be replaced while it runs. Its results
fail with
E, the query closure’s own error type. - Reconfigurable
Live Query Event - One result with the exact request and revision that produced it.
- Retained
Bytes - Independent cursor over one pinned input. Closing the database invalidates every cursor; an absent cached range returns an I/O error, never a network read.
- Retained
Input - One observed object version. A replacement invalidates the preceding handle.
- Retained
Range - Encrypted bytes received for one provider observation; completion is separate.
- Retry
State - What decides the person’s retry, as
coven_retry_effectholds it. - Retry
Wait - A persisted wait:
TandW, and the consecutive unsuccessful attempts that choseW, so reopening does not reset the backoff exponent. - Row
- A single result row of a query.
- RowChange
- One row change of a waiting write (E13).
- RowKey
- The primary-key values of a row, in the table’s declared key order (api.md).
- Slot
- A positive position in the store’s shared sequence (§5). Slot 0 names
nothing: a prefix applied through 0 has applied no slot, and that count
stays a plain
u64. - Snapshot
Reload - Complete checked input for an atomic reload. Sync derives the administrative
projection from the original signed history carried by the store snapshot
and retained slots. Each readable audience reaches
targetbefore commit. - Snapshot
Staging - One snapshot’s staging, from its first batch to the load or file check that reads its records, or the discard that removes them (§16.2). It is the one holder of what it stages for that whole operation: its steps are its phases, and the load takes it whole. Dropped while still holding records, as by a cancelled or panicking caller, it removes them.
- SqlContext
- App SQL inside one local write, and coven’s steps beside it (§4). Returning an error rolls back every statement and step. This borrowed context cannot change the transaction or access coven’s tables.
- SqlFunctions
- The app’s collations and scalar functions. Coven registers every one on each connection it opens to the store’s database, before any app SQL runs there: the writer, which also migrates, applies other devices’ writes and merges, the readers, and every connection of a read-only handle.
- SqlRead
Context - SQL access to one read-only snapshot. The connection and internal tables remain private; even SQL with RETURNING cannot write through this context.
- Sqlite
Settings - SQLite settings for every connection coven opens to the store’s database:
the writer and the readers of a writable handle, and every connection of a
read-only one. A setting left
Nonekeeps SQLite’s own default, exceptcheckpoint_fullfsyncon macOS and iOS, which coven turns on, andauto_vacuum, which isIncremental. Coven applies them as each connection opens, before any of its own statements. - Sqlite
Settings InEffect - The SQLite settings one connection to the store’s database has in effect, as SQLite reports them. Every connection has the same, except that a writable handle’s writer never checkpoints as it commits.
- Staged
Digest - A digest of one staging’s records as its tables hold them. Staging is a function of the snapshot’s bytes, so two stagings of the same snapshot hold the same records, and differ only where this device’s disk changed one (§19.1).
- Staged
Files - App bytes
stage_fileswrote to coven’s copies of them, under names reserved in this store, with what its batch returned, until a write puts them in rows (§17.2). It holds nothing close waits for. Dropped uncommitted, or after the store closes, its names go free, and the next write or open removes the bytes. - Store
Circle - A circle and its current membership; deleted circles retain their name. Its keys come from received introductions, not this membership projection (§12.1).
- Store
Device - One install, retained after removal or replacement so its older objects remain attributable (§10.4).
- Store
Identity - A store’s identity and current name (§10).
- Store
Member - A member in the applied prefix, keyed by stable id in
StoreState::members. - Store
State - Store state, including removed identities needed to check older writes (§10.4).
- Store
Version - A selected version raise and the snapshot it chose (§18.3).
- Sync
Facts - What the sync state is computed from, in one committed snapshot.
- Sync
Status Row coven_sync_status’s row as it is read.- Synced
Table - A synced table’s key, audience, file references, shared triggers and whether only each row’s original creator writes it directly (E2).
- Transfer
Meter - Tells one attempt how far it has got. Once the attempt ends, it tells nothing: a request still finishing can’t move a later attempt.
- Transfer
Progress - How far one transfer has got: the bytes of its encrypted object handed to the connection or received, in whatever order, out of the object’s whole size. Known from the transfer’s start; never stored.
- Transfer
Watch - Hears how far each file in flight one way has got. Changes that arrive faster than the reader reads are heard together: the next read names each file that differs from what the reader last heard, and how each one it heard in flight ended.
- Transferring
- One attempt to transfer a stored object. Its worker ends it as its transfer ended; dropping it otherwise, as a cancelled attempt does, ends it as dropped.
- Unsent
Work - What this device committed and has not uploaded: writes and files (E1).
- Upload
Bytes - An incremental SQLite BLOB reader. It never collects the waiting write.
- Upload
Facts - One upload in the queue, as the sync state reads it.
- Upload
Parts - Audience stream descriptors paired with their bounded plaintext readers.
- Upload
Plaintext - A waiting write’s plaintext, fixed at commit, read under one committed reader transaction.
- Upload
Progress - Bytes the provider confirmed in a recorded upload session. Sending bytes alone does not advance it.
- Upload
Queue State - The queue as the app observes it: the pause setting and every queued file with its recorded session, from one committed state, and the files this process is sending as it was read (E7).
- User
File - The facts recorded for the user’s original, which coven never changes.
- Waiting
Upload - A captured write ready to seal. Sealing and transport belong to sync; these are its input streams and the keys it seals with.
- Write
Authorship - A write’s signed header and part roots, and the hashers that check each opened part against its root (D9, D11). The database checks the roots; sync checks the header signature with the rest of the object.
- Write
Batch - App bytes to stage, before the write that puts them in rows; a failure discards all of them. Each staged file gets a new id from the store’s id source, which the batch borrows while the app stages; the write’s SQL puts the id in the rows that reference the file.
- WriteId
- One device’s numbered write (§4).
- Writers
- The other devices that can still write: every device besides this one not gone for good (§14.1), each with the slot whose entry added it, when known. Stored files (§17.10) and kept records (§16.7) wait for the same devices.
Enums§
- Analysis
Limit - How many rows of each index
ANALYZEreads. - Apply
Outcome - Applying a previously applied write never runs it again.
- Auto
Vacuum - What happens to the pages deleted content frees.
- Binding
- When a write setting a file reference goes out (§17.4, E2).
- Boundary
- A checked raise/reset and the snapshot named by that entry. Its selection is derived from kept entries, independently of whether coverage has been read.
- Cache
Size - A page cache’s size, which SQLite counts in pages or in kibibytes.
- Cache
Spill - Whether a transaction may spill changed pages before it commits.
- Change
Op - The operation a waiting write performs on a row.
- Checkpoint
Mode - SQLite’s checkpoint modes (
PRAGMA wal_checkpoint). - Claim
Read - Authenticated observations supplied by the sync reader.
- Claim
Settlement - Settlement of the most recent attempt.
- Claim
Work - The original work carried by a claim. Every slot kind shares one counter.
- Coven
Migration Error - Coven’s local tables cannot be used at this version (Appendix C.1, E1).
- DbError
- A failed database call or a write the database refuses (§4, §9, §15, §17).
- Determinism
- Whether a scalar function’s result depends on its arguments alone.
- Device
State - What counted administrative slots did to a device id (E9). Later slots from a removed or replaced device are refused (§14.1, D6).
- Device
Stop - Why a device stopped for good (§14.1, §19.3).
- Downloaded
Part Stream - Whether sync could decrypt the corresponding part in the header.
- Entry
Target - The target a proposed change can no longer affect.
- File
Evidence - What checked retained bytes establish about the uploaded files they name (§17.10).
- File
Place - Where a file is (§17.2): in storage, or only on one device.
- File
Source - An owned buffer or a reader whose stream coven consumes exactly once.
- File
Work - Which of this device’s work on a file’s stored bytes a record is about.
- Incremental
Vacuum - How many free pages an incremental vacuum gives back.
- Journal
Size Limit - How large the WAL file may stay after a checkpoint resets it.
- Live
Query Cause - Why this run was requested; the first run answers the initial request.
- Load
Step - A step of loading a store from storage (§13.4), in the order they run. A step runs only when it has work to do.
- Local
File Error - A local file operation’s typed failure.
- Lost
- Values retained when a cell loses or a row is removed.
- Migration
Change - How one migration changed the schema and synced rows (§18.1).
- Migration
Error - The application migration run could not complete.
- Move
File - A file of this device, on it only, to move to the cloud (§17.3, E3).
- OldWrites
- What a breaking migration does with received late old-version writes.
- Open
Error - Opening the database failed: its writer or read-only connections, its lock, its settings or its migrations (§4, E1, E13).
- Open
Step - A step of opening a store for writing (§4), in the order they run. A step runs only when it has work to do, so most opens report none.
- Operation
Outcome - How an operation an app’s write journaled ended (§11.4):
coven_operations.outcomeholds it from the transaction that ends the operation’s journal row until a write acknowledges it, so an outcome nobody awaited is still there to read. - Operation
Rejection - Why the current applied state refuses an administrative operation.
- Page
Size - A database page size: a power of two from 512 bytes to 64 KiB.
- Place
- Where a staged file is to be: on this device only, or uploaded to the cloud (§17.3).
- Prerequisite
Rows - Committed state a waiting operation names.
- Provenance
- A namespace’s kind: whose bytes its files are (§17.1).
- Read
Only - A read-only handle: it reads synced rows and keeps its own file cache, and nothing else (E1).
- Recorded
Location - Whether a storage location is recorded on this device, and whether this device holds credentials for it (§19.1), with the location’s provider. The database keeps the provider as the name sync gives it.
- Removal
Rule - A rule responsible for a removed row.
- Replacement
- The write, rules, breaking schema version, dropped data or refused permission responsible for a loss.
- Retry
Subject - The work a persisted wait delays.
- Retry
Sync - Whether a started connection will plan.
- RowAuthorization
Failure - Why a member’s row change was refused (§9.6).
- RowIdentity
- How independently inserted rows choose their identity (§9.2).
- Schema
Error - A schema rule checked on open and after migrating (§9, §15.1).
- Secure
Delete - Whether deleted content is overwritten.
- Slot
Content - One slot kind; readable write parts are applied together.
- Snapshot
Error - Snapshots or their gap writes could not be loaded into this database.
- Snapshot
Source - One readable audience’s starting prefix.
- Snapshot
Write Error - A snapshot failed to read, encode or reach its plaintext consumer.
- Sqlite
Error - Enum listing possible errors from rusqlite.
- Staged
Damage - Damage a test makes to a staging, as damage on this device’s disk would (§19.1).
- Temp
Store - Where temporary tables and indices are kept.
- Temporary
Directory Error - Why the folder for temporary tables could not be named (E1).
- Transfer
Change - A change to one file’s progress, or every file’s.
- Transfer
End - How a file’s transfer ended, decided in the step that takes it out of the files in flight. When two attempts move one file at once, the last to end says it.
- Undo
Cause - Why an operation was undone (§11.6).
- Unproven
Files - Why retained bytes cannot yet name every file they refer to (§17.10).
- Upload
Completion - What an upload’s completion did (§17.3, §17.9).
- Upload
Read Error - A queue read failed in the database or in its consumer.
- WalAutocheckpoint
- When coven checkpoints the WAL by itself.
- WalCheckpoint
- What a checkpoint did, as SQLite reports it.
- Write
Cutoff - Why a lower slot permanently excludes an original write.
- Write
Wait - A prerequisite for applying a downloaded write.
- Writer
- The store’s one writer: it writes, migrates, transfers files and keeps their records (§4).
Constants§
- BOUND_
FILE_ LIMIT - The size limit of a bound reference that declares none: 1.5 MiB (§17.4).
- REQUEST_
FIXED_ STEP - The step a provider-access operation reaches once its request’s target is fixed, before storage is called.
Traits§
- Authorship
- What a loader needs from sync to authenticate another member’s write.
- File
Location Key - Crate-to-crate access to a stored file’s key, for coven’s owners; not re-exported by the app API.
- Mode
- The mode a store’s handle opened in:
WriterorReadOnly. - Params
- Trait used for sets of parameter passed into SQL statements/queries.
- Pending
Value - Sync supplies its complete typed record; the database owns its atomic lifetime. The associated subject is the stable key, independent of the reason.
- SqlRead
- Ordinary SQL reads through a read context or a write’s, so code that reads the same way inside a write and outside one is written once. Inside a write it sees the write’s own changes.
- ToSql
- A trait for types that can be converted into SQLite values. Returns
crate::Error::ToSqlConversionFailureif the conversion fails. - Write
Failure - A caller’s write error can retain both its original cause and failures that
happen while rolling back or removing bytes, and says which bug it carries,
for a write whose caller stopped waiting (E15). A write fails with its
closure’s own error type, which implements this:
DbErrorfor ordinary database clients, sync’s error for sync’s writes, and an app’s own type for the app’s writes through the facade (E3).
Functions§
- closed_
sync_ facts - What a closed store’s sync state is computed from, and its unsent work,
in one committed snapshot of its database, read through a connection of
its own while
lock, the store’s writer lock, shows that no handle has it open (api.md E1, E5). It reads only coven’s tables, so the app’s declarations aren’t needed; coven’s tables must be at this coven’s version, as a read-only open requires. Nothing is sent or downloaded and no network is watched, as for a read-only handle. A caller that stops waiting leaves the read to finish, and its panic goes to the store’s bug sink (E15). - discarded_
operations - The operation journal of a database a device reset discarded (§19.3), read
in place and read-only on a blocking thread, never opened as a store. A
journal SQLite reports damaged, or whose records don’t decode, is
DamagedDatabase. Likeread_store_name, it reads only coven’s table and needs none of the app’s collations or functions. A caller that stops waiting leaves the read to finish, and its panic goes tobugs(E15). - discarded_
store_ name - The local creation name in a reset’s discarded database. The reset owner
holds its directory lease while reading this setting. Like
read_store_name, it reads only_coven_store_stateand needs none of the app’s collations or functions. A caller that stops waiting leaves the read to finish, and its panic goes tobugs(E15). - prepare_
user_ file - Read a user’s original once, recording its whole-file hash and each upload chunk’s hash from the same bytes, and reporting total bytes read. Changes during the read are refused; later ones fail its upload, whether it is staged for the cloud or moved there later.
- read_
store_ name - Read the name for a local store listing without migrations or a writer.
It reads only coven’s
_coven_store_state, and SQLite looks a collation or function up only for a statement that uses it, so the app’s aren’t needed. A caller that stops waiting leaves the read to finish, and its panic goes to the store’s bug sink (E15). - set_
temporary_ directory - Keep SQLite’s temporary tables in
directory, for every store this process opens from now on. Call it before opening any store. - sqlite_
error_ is_ disk - Whether SQLite failed because of the disk under it: full, failing, gone read-only, or damaged.
- stored_
time - The time a stored count of milliseconds since the Unix epoch names, as
coven_retry_effect.cooling_untilandcoven_sync_status.last_syncedhold it. One the clock can’t name isDamagedDatabase(§19.3). - unix_
seconds_ and_ nanos - A time as
coven_user_fileslists a modification time, inmodified_secondsandmodified_nanos: whole seconds since the Unix epoch, rounded down, and the nanoseconds past that second, from 0 through 999,999,999 (§17.3). Half a second before the epoch is (-1, 500,000,000). An app compares a file’s time on disk with the view’s through it.
Type Aliases§
- Sqlite
Result - A typedef of the result returned by many methods.