Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Map

Summary: how the repository and the Rust crates are laid out, which crate may depend on which, and where to make a change.
Key terms: crate, ports and adapters, use case, port, adapter, composition root, auth-chad, xtask.
Related: Interfaces · Data · AGENTS.md

The repository is one Rust workspace. secrets-core holds all cryptography, encodings and log validation, and the CLI, the web app and the server all use it. The server follows a ports-and-adapters layout: secrets-server-app holds the use cases and the traits they need, the store and HTTP crates implement those traits, and secrets-server wires them together. Accounts come from auth-chad, a separate repository pinned by commit in Cargo.toml.

The picture as text
flowchart TB
    subgraph clients [Clients]
        cli[secrets-cli: secrets-chad]
        web[secrets-web: Leptos, wasm]
        client[secrets-client]
    end
    subgraph server [Server]
        bin[secrets-server: wiring]
        http[secrets-server-http: routes]
        sqlite[secrets-store-sqlite]
        pg[secrets-store-postgres]
        app[secrets-server-app: use cases, ports]
    end
    api[secrets-api: wire types]
    core[secrets-core: crypto, formats, log]
    cli --> client
    web --> client
    client --> api
    client --> core
    bin --> http
    bin --> sqlite
    bin --> pg
    http --> app
    http --> api
    sqlite --> app
    pg --> app
    app --> core

The repository

FolderContents
docs/spec.mdThe exact rules. Change it in the same pull request as the behavior
docs/wiki/This wiki
docs/recipes/One page per task
docs/decisions/Decisions and their reasons
docs/test-vectors/JSON vectors for every format; a compatible implementation passes them
skills/secrets-chad/The guide for coding agents that use the CLI
crates/The Rust crates
action/, action.ymlThe GitHub Action that installs secrets-chad
xtask/cargo xtask ci, the web bundle build, release helpers
scripts/wiki.pyBuilds and checks this wiki

The crates

CratePartJob
secrets-coresharedAll cryptography, encodings, IDs, records, the project log and its validation. no_std with alloc, no I/O
secrets-apisharedThe JSON request and response types of the HTTP API
secrets-clientclientEverything a client checks and plans: discovery, login, pins, log verification, keys, records, changes. Generic over Http, Clock and Draws; runs on auth-chad’s client
secrets-cliclientThe secrets-chad binary: commands, export and run, files, GitHub, agent mode
secrets-webclientThe web app (Leptos, client-side rendered, wasm)
secrets-server-appserverUse cases (App), policy functions, and the ports they need (Store, Random, AuditBuffer). No I/O
secrets-server-httpserverThe axum routes, auth-chad’s account API at /v1/auth with this application’s hooks (Rules), errors, limits, the request log
secrets-store-sqliteserverStore on SQLite (rusqlite, bundled)
secrets-store-postgresserverStore on PostgreSQL (tokio-postgres)
secrets-store-teststestThe Store conformance suite (conformance!), the in-memory MemStore, shared fixtures
secrets-serverserverThe composition root: configuration, backend choice, real clock and randomness, listeners, shutdown
secrets-test-vectorstestGenerates and checks docs/test-vectors/
xtasktoolCI checks for changed crates, the web bundle, release packaging

Dependency rules

  1. Dependencies point inward: secrets-server → secrets-server-http and secrets-store-* → secrets-server-app → secrets-core.
  2. Only secrets-core calls a cryptographic primitive.
  3. secrets-core is no_std with alloc and does no I/O. Use cases in secrets-server-app do no I/O; every effect is a port.
  4. Adapters hold no rules. Use cases know no HTTP and no SQL.
  5. Account rules live in auth-chad. This repository adds projects, records and the hooks that join the two. A change to accounts goes to auth-chad.

Where to make a change

ChangePlace
A format, a signature or a log rulecrates/core/src, the vectors in crates/test-vectors, and spec §5–6
A rule the server enforcescrates/server-app/src/policy.rs or app.rs
A table or columnBoth stores (crates/store-sqlite/src/schema.sql, crates/store-postgres/src) and the conformance suite
A routecrates/server-http/src/routes.rs, the types in crates/api, and spec §10
Signup, device approval or revocation rulesThe hooks in crates/server-http/src/auth.rs
A CLI commandcrates/cli/src/args.rs and commands.rs, and spec §11
What a client verifiescrates/client/src
A web pagecrates/web/src/pages

Code rules

  • Pure functions by default. Every side effect is a trait, injected by the caller, used through generics.
  • Borrow before owning: &str, &[u8], fixed-size arrays.
  • No logging. No secret, key, token or ciphertext in an error message, Debug output or panic.
  • Key material lives in zeroize-on-drop types.
  • No unsafe, unwrap, expect or panic! outside tests.
  • Every cryptographic format has test vectors.

Tests

TestCovers
Test vectorsEvery format in secrets-core
Property tests (proptest)Parsers, encoders, the dotenv round trip, log validation
Conformance suite (secrets_store_tests::conformance!)Every store
HTTP tests with real DPoP proofs, in memoryEvery route
Client tests against the real router, in memorysecrets-client
CLI tests against a local serversecrets-chad
Browser tests (node crates/web/e2e/run.mjs)The web app with a virtual passkey; not in CI yet
Compiled wiki snippetsDoctests of secrets-server-app

cargo xtask ci runs formatting, clippy, tests and doctests for changed crates and their dependents, as CI does.