Skip to main content

Crate capsule_core

Crate capsule_core 

Source
Expand description

Capsule’s stateless core: pure functions over values — cryptography and the MLS authority, canonical CBOR, sidecar and CRDT logic, validation, media, LQIP, sharing and drop crypto, and ML orchestration.

It holds no connection, file handle or database, and reads no environment, clock or filesystem: storage reaches it through ports such as ml::VectorIndex, and time and identifier randomness through ambient::Clock and ambient::Rng, all of which callers implement. Local state — the SQLite index, the on-disk library, the Workspace, import execution, backup I/O and the hardware signers — lives in capsule-library; network state lives in capsule-sdk. Two exceptions, each confined to one module:

  • the OS CSPRNG behind crypto::rng: key material must never come from an injectable, and therefore replaceable, source;
  • catch_unwind in media::decode: a decoder panic on hostile input must become a typed error, not abort the caller.

cargo xtask architecture-check enforces the rest.

Modules§

ambient
The Clock and Rng a caller injects, and the IdSource that mints UUIDv7s from them. Always compiled: pure over its two traits, no native deps. The ambient inputs a caller injects: wall-clock time and identifier randomness.
backup
The portable backup artifact and recovery mechanisms (SSoT: Backup and Recovery).
cbor
Canonical CBOR (RFC 8949 §4.2 deterministic encoding).
client_build
Client build identification — the client_version / generated_by_client grammar and the build-embedded git commit. Always compiled: pure string formatting, no native deps. Client build identification — the client_version / generated_by_client grammar.
cohort
Device-cohort hash — the advisory session-grouping aid (SSoT: Authentication — Device Cohorts).
constants
content_type
The file extension an original is named by for its sidecar content_type — the one table the library’s adoption and a restore share. Always compiled: a pure string table. The file extension an original is named by for its sidecar content_type.
crypto
Capsule’s cryptographic data plane.
culling
The client-side culling workflow engine (SSoT: Organization — Culling).
derivative_format
The closed set of still-derivative formats and the structural check over it — the tier table’s format column as a type. Always compiled, and for the same reason lqip is: the crates that receive a DerivativeManifest (capsule-server, capsule-wasm) build with default-features = false, so a check they cannot link is a check that never runs. Depends only on crypto::provenance. The one public path to its items: media does not re-export them. The closed set of committed still-derivative formats, and the structural check over it.
domain
drop
Web-upload guest drops — contract skeleton (SSoT: Web Upload).
enrollment
The wire form of the cross-device add ceremony (SSoT: Device Enrollment § Cross-Device Add): what each device advertises, the payloads they relay, and the safety code over them.
exif
federation
Aggregated federated albums — the album-group view (SSoT: Federation — Federated Shared Albums and Organization — views).
import
The pure half of import: candidate grouping, special-file classification, the import scope, default-album resolution and the upload policy. Scanning a directory, planning against the index and executing an import are local state and live in capsule-library’s import module, which re-exports everything here.
lqip
LQIP — the chromahash placeholder carried in the signed sidecar’s lqip field. Always compiled, and deliberately so: the placeholder is produced by the import pipeline, read by the apps through the FFI crates, and read by the browser through capsule-wasm, so there is exactly one implementation and every surface links it. chromahash has zero runtime dependencies and targets wasm32-unknown-unknown. The one native-gated part is lqip::sidecar, because sidecar itself is. LQIP — the low-quality image placeholder carried in every asset’s signed sidecar.
media
Still decode, orientation, metadata normalisation and derivative generation over rawshift-image (media feature, implied by native). Feature-gated rather than native-gated so the codec stack is one manifest edit away from being dropped from a size-constrained build, and so the wasm32-unknown-unknown sealing surface provably does not link it. See media. Still-image decode, orientation, metadata normalisation and derivative generation — the Capsule-side owner of the media pipeline.
metadata
ml
On-device ML orchestration and the model inventory seam (SSoT: AI/ML Integrations).
notify
Alert classes and their trigger predicates — the one shared decision function every platform evaluates instead of reimplementing the taxonomy (core half; SSoT: Notifications).
sharing
Share-link generation, encapsulation crypto, and the recipient-side sharing::open_scope path. Always compiled: it depends only on cbor + crypto, both of which target wasm32-unknown-unknown, so the browser share viewer (via capsule-wasm) can unwrap a link client-side. The native issuer (ShareLinkIssuer on capsule-library’s Workspace) is not needed in the browser; only the pure crypto + recipient-open path is. Share links — link generation and capability validation (SSoT: Share Links).
sidecar
validation
Refuse-by-default validation invariants — the operational core of the threat model (SSoT: Threat Model — Validation Invariants).