Expand description
Capsule client SDK: the sanctioned network path for every Capsule client (upload protocol, sync/download, auth flows).
§REST client generation (spargen)
The typed REST client (rest) is generated from the server’s OpenAPI 3.2 schema by
spargen, our in-house generator, at build time (see build.rs). The previous progenitor
pipeline is gone deliberately: progenitor consumes OpenAPI 3.0 only, which forced a lossy
down-conversion of the document the server actually emits — a standing source of drift and
failures. We do not downgrade schemas. client::AuthenticatedClient wraps the generated
Client, composing it with auth’s session/token store so callers issue typed calls and
never juggle raw tokens.
The generated client covers the plain request/response surfaces (auth, quota, storage-verify, receipts, devices, escrow, the sync feed, …). What stays hand-written is orchestration, never a second parser:
upload— the resumable upload state machine, whose protocol is too stateful for request/response codegen;sync— the cursor and anti-rewind state machine over the generatedGET /v1/syncoperation (there is no gRPC feed; the wire here is generated like every other);directory,upgrade, andverify’s receipt fetch — the fourapplication/cboroperationsspargen0.5 cannot lower, narrowed out inbuild.rs.
Modules§
- albums
- Album provisioning — telling the server an album exists.
- auth
- SDK-owned authentication: the session/token store and the auto-refresh engine.
- cache_
budget - The client cache budget driven by the connection class (SSoT: design/filesystem/client § Automatic cache management, and design/networking § Connection Classes).
- client
- The session-composed typed REST client.
- cohort
- Client-side device-cohort emission and the devices-grouping view model (SSoT: Authentication — Device Cohorts).
- directory
- Publishing and fetching the signed device directory (over the server’s directory surface).
- events
- The typed transfer event stream: what an upload, a push or a fetch is doing, as it does it, for a caller that renders progress (the TUI’s transfer view, a mobile progress bar).
- federation
FederationPull— a peer server pulling one shared album from its home server.- fetch
- Tiered, on-demand blob fetch (SSoT: Download & Sync).
- ffi
- uniffi surface over the SDK’s user-flow primitives (login → upload → status →
sync) for Swift/Kotlin/Linux consumers (
ffifeature). A thin, async-capable wrapper overauth,upload, andsync; tokens never cross the boundary (the session-handle pattern). Seeffi. uniffi bindings: an async-capable wrapper over the SDK’s user-flow primitives, so iOS/macOS (Swift), Android (Kotlin), and Linux consumers call one SDK instead of reimplementing login/upload/sync flows. - net
- Connection-class and retry-policy contract types (SSoT: the Network
Resilience design doc). Detection (OS signals + behavioral promotion to
ConnectionClass::Adverse) and the per-class retry engines live here: class detection feeds the sync and cache budgets, and the adverse class hardens the network behaviour. - peering
- LAN peering: direct device-to-device sync within a single user’s own devices (SSoT: Peering).
- push
- Pushing a locally-imported asset to a server — the glue between
capsule_core’sUploadBundleand the hand-written upload client. - recovery
- Recovery-secret verification cadence and the guided re-wrap flow ( SSoT: Backup — Recovery Verification Cadence and § On Repeated Failure: Guided Re-Wrap).
- rest
- The typed REST client generated by
spargenfrom the server’s committed OpenAPI 3.2 schema (openapi.json), emitted intoOUT_DIRbybuild.rsand included verbatim here. Oneasyncmethod per operation, typed models, typed errors, and an embedded freestandingreqwestruntime —spargennever enters the runtime dependency tree. Do not edit: regenerate the schema withmise run openapi-kynos(andmise run openapi-check-kynosgates it); the client re-generates on every build. The ergonomic, session-composed entry point isclient::AuthenticatedClient; reach forrest::Clientdirectly only for unauthenticated calls. - share
- The owner’s two share-link operations over the generated client (#622): register a link
the issuing client published (
POST /v1/shares), and revoke one (DELETE /v1/shares/{opaque_id}). - staged
- The client-side staged upload scheduler (SSoT: Download & Sync — Upload Tiering (Staged Uploads)).
- sync
- The key-free sync consumer (SSoT: Download & Sync).
- upgrade
- The album-upgrade proposal client. Hand-written for one reason only: its request
body is
application/cbor, whichspargen0.5 cannot lower, sobuild.rsnarrows the operation out of the generated client. TheGETandDELETEon the same path are JSON and are generated — reach them throughclient::AuthenticatedClient. Proposing an album upgrade — the client half of the ceremony’s one server-side step (over the server’s album-upgrade wire). - upload
- Upload client module for Capsule SDK.
- verify
- Verify-before-destroy: the client half of storage verification (SSoT: Storage Verification — Verify Before Destroy).