Core Principles
UnauditedQuesti contenuti non sono ancora disponibili nella tua lingua.
These principles bind every Capsule component, client and server. The rules after them bind every
doc in design/.
Principles
Section titled “Principles”- Determinism and idempotency. Raw original data is the source of truth. Every process is repeatable from its inputs.
- 4 KiB alignment. Data crossing disk or memory boundaries is processed and written 4 KiB-aligned unless a concrete case demands otherwise.
- Forward and backward compatibility. Old clients ignore new fields and new clients tolerate missing ones, subject to the asymmetry below (Postel’s Law (asymmetric)).
- Data integrity. Capsule never deletes data unexpectedly. It acts only in strict scenarios and otherwise crashes early. Server data is assumed durable; client data is assumed losable.
- Ephemeral derived data. Anything that is not an original asset is rebuildable and treated as such.
- Encryption and compartmentalization. Metadata is encrypted alongside data. Every boundary (album, peer, event, user, version) is a failure-containment boundary.
- Offline/online divide. A feature works either solely online or solely offline, never differently by connectivity.
- Recovery-first. The filesystem is reconstructible from partial corruption. Sidecars are the canonical metadata store; the database is a rebuildable query cache.
- Self-describing. Each media file is paired with a CBOR sidecar holding all user-editable and stable metadata, interpretable without a database.
- Atomic writes. Temp file and rename everywhere. Never overwrite in place.
Postel’s Law (asymmetric)
Section titled “Postel’s Law (asymmetric)”Within a known schema version Capsule is liberal: unknown sidecar fields are preserved verbatim and missing optional fields are tolerated. Across versions it is closed. A structure announcing a schema version (sidecar_schema, crypto_suite_id, protocol_version) above the receiver’s maximum is rejected, never best-effort parsed. See Schema Rules and Open Questions.
Single Source of Truth
Section titled “Single Source of Truth”Every primitive, construction, format or component identity is declared in exactly one owner doc. Other docs link the declaration and never restate the choice. Explaining a behaviour elsewhere (“STREAM tags catch chunk reordering”) is fine; restating the choice (“we use SHA-256”) is not. When in doubt, link.
| Domain | Owner doc |
|---|---|
| Cryptographic primitives, constructions, version identifiers | Cryptographic Primitives |
| Key hierarchy, device coordination | Key Management |
| MLS membership, ciphersuite binding | MLS Group Membership |
| Asset + metadata encryption | Asset and Metadata Encryption |
| Provenance chains, signed manifests | Signed Manifests and Provenance |
| MLS resilience | MLS Resilience |
| Device enrollment | Device Enrollment |
| ML pipelines, weight registry, model identities, embedding provenance | AI/ML Integrations |
| Face clustering, people corrections | People |
| Memory generators, memory state | Memories |
| LQIP, thumbnail/preview formats | Thumbnails and Previews |
| Server filesystem, required services | Server Filesystem |
| Client filesystem, local index | Client Filesystem |
| Library self-maintenance, atomic-write granularity | Library Maintenance and Atomic Writes |
| Tokens, identity binding, auth flow | Authentication |
| Backup container, escrow, recovery paths | Backup and Recovery |
| CRDTs, identifiers, geolocation, sidecar schema | Metadata |
| Import pipeline | Import Pipeline |
| Upload protocol | Upload |
| Download, transfer scheduler | Download |
| Sync feed, auto-sync | Sync |
| Storage durability, verify-before-destroy | Durability |
| Tethered camera import | Import — Camera Import |
| Plaintext export, archive format | Export |
| Connection and retry classes, transport security | Network Resilience |
| Offline-first requirements | Local Gallery |
| Federation trust, capability tokens | Federation |
| LAN discovery, peer channel | Peering |
| Album protocol version pinning | Versioning |
| Stacking, trash retention | Asset Organization |
| Search grammar, search index | Search |
| Places, map clustering, geocoding | Places |
| Lifecycle action set | Authorization |
| Rate limits, freshness gates, server-side membership | Authorization |
| Damage scenarios, client classes | Threat Model |
| Risk register | Implementation Risk Register |
| Refuse-by-default validation invariants | Validation Invariants |
| Schema evolution, deprecation | Schema Rules and Open Questions |
| Outbound licence, dependency-licence policy | Licensing |
| Share links | Share Links |
| Upload links, guest drops | Web Upload |
| Moderation, reporting, blocklists | Moderation |
| Quota accounting + enforcement | Quota |
| Client validation duties, sandboxed decoder | Clients |
| OS integrations (intents, shortcuts, system pickers) | Platform Integrations |
| Alerts, delivery, wake tier | Notifications |
| Catalogs, locale resolution, error codes | Internationalization |
| API surface ↔ transport map | API Surfaces |
| Developer-reference generation | Developer Documentation |
| Performance metrics, benchmarks | Performance |
| Supply-chain policy | Supply Chain |
Doc Structure
Section titled “Doc Structure”Design docs are not templated, but each must answer four questions: where it lives (crate or module), what its public surface is (schema, wire format, trait, error domain), what it defers to (owner-doc links) and how it is validated (a tier from Validation Tiers, where non-obvious). The code is the source of truth for module layout. Docs state contracts, not restated code.
Implementation Status
Section titled “Implementation Status”A doc naming an implementing module states per surface whether it is Implemented (module exists, its tier runs in CI), Planned (contract designed, no code) or Blocked (planned, with a named external blocker). A planned contract is written in normative present tense but must not claim the code exists. Every module a doc names that does not exist yet must be listed in capsule-docs/planned-modules.txt.
Audit Status
Section titled “Audit Status”Every authored page carries a required audit frontmatter field pinning its last human audit. It holds either audit: none, an explicit statement that the page has never been audited, or a stamp:
audit: commit: <40-hex sha> # the commit whose copy of the page was audited date: YYYY-MM-DD # when, in UTC digest: sha256:<64-hex> # of the page with this field removedThe status a reader sees is never written down. The site computes it by comparing the stamped digest with the page as it is now:
| Status | When | Shown |
|---|---|---|
| Audited | The digest matches: the page is exactly what was audited. | “Audited as of <commit> on <date>” |
| Changed since audit | The page has changed since its stamp. | “Last audited as of <commit> on <date>” |
| Unaudited | audit: none |
“Unaudited” |
Any edit after an audit therefore shows at once, with no one having to remember to flip a flag, and the computation needs no git history. An auditor commits their edits, reviews the page as committed, then stamps it with mise run audit-docs -- <page> (bun run audit-page <page> inside capsule-docs) and commits the stamp. The tool refuses a page that differs from HEAD, so the pinned commit always holds the audited text. test-docs fails on a missing or malformed field, and wherever the stamped commit is in local history it checks that the digest matches that commit’s copy of the page.
Unaudited and changed pages still publish, and the docs site badges each of them in its navigation (Visual Language — Docs Site). A translation is audited on its own. A locale route with no translation shows the English page and that page’s status. Generated reference pages carry no audit: they track their artifact, not a review. A splash page such as the support page has no sidebar to badge, so it may leave the field out.
Validation Tiers
Section titled “Validation Tiers”The tier is decided by what is mocked, not by where the test lives.
- Unit: in-module tests against the contract, with peers and externals mocked. Deterministic and fast.
- Smoke: one module’s real implementation with real I/O and backing services (e.g. a Postgres container), peers mocked.
- E2E: several modules wired against real infrastructure. The list is bounded in the E2E case index; growth past it signals unwanted coupling.
Damage Containment
Section titled “Damage Containment”A faulty, malicious or version-mismatched client must not inflict irreparable damage on user data. These principles name the posture and the Threat Model owns the defenses: the client-class taxonomy, the damage-scenario-to-invariant map, validation invariants, fail-closed protocol negotiation, and the cross-cutting idempotency, atomicity and quarantine rules.