Local Development
Unauditedयह कंटेंट अभी तक आपकी भाषा में उपलब्ध नहीं है।
Every command runs through mise. mise.toml pins the toolchain and defines the task graph, with
long tasks in mise-tasks/, and mise tasks lists everything. A bare task fixes; its -check
variant verifies only. CI jobs map 1:1 onto the check-* tasks, so a green local check-* is
what CI runs. The Rust toolchain is pinned in rust-toolchain.toml and Swift tooling in
capsule-swift/mise.toml.
First-time setup
Section titled “First-time setup”mise install # pinned tools (hk, convco, cargo-nextest, shellcheck, actionlint, ...)mise run setup # bun install in capsule-web + capsule-docsmise run hooks-install # git hooks (hk)| Task | Scope |
|---|---|
mise run check |
The full gate: format-check, then lint-check, then test |
mise run check-rust |
Rust format, clippy, docs, codegen drift (i18n, OpenAPI, READMEs), architecture and licence checks, builds and bindings; sequential under one target/ lock |
mise run check-web |
Web format, lint, type check, test, build |
mise run check-docs |
Docs format, lint, Astro build (a broken internal link fails it) |
mise run check-md |
markdownlint over every .md |
mise run check-kotlin |
Kotlin format and lint |
mise run lint-check-shell |
shellcheck over the shell scripts in mise-tasks/, scripts/ and every *.sh, then actionlint over .github/workflows/; part of lint-check and pre-push |
Frequently used tasks:
test-rust: nextest over the workspace, thencapsule-sdk --features ffi.test-rust-release: the#[cfg(not(debug_assertions))]tests inRELEASE_TEST_CRATES.test-rust-containers: see The container tiers.test-web: builds the WASM glue and KAT fixtures first.i18nandopenapi-kynos.audit-docs -- <page.md>...: stamps docs pages as audited at HEAD (Core Principles — Audit Status).- For FFI,
targets-add, thenbuild-ffiandgen-bindings. On macOS,setup-swiftbuilds the xcframework and the Xcode workspace. check-targets:cargo checkof the FFI for every Tier-1 and Tier-2 cross target (Apple, Android, Windows, aarch64 Linux) from a macOS or Linux host. The C that build scripts compile goes throughzig cc(scripts/cross/zig-cc), so no Xcode, NDK or MSVC is needed. Narrow it with--target TRIPLE,--tier 1|2or--apple. Thebuild-apple,build-android,build-windowsandbuild-linux-crosstasks produce real linked artifacts, so they need each platform’s native toolchain. Off macOS,build-applefalls back tocheck-targets --apple.
Running a server locally
Section titled “Running a server locally”capsule-server [--config PATH] <SUBCOMMAND> serve [--listen HOST:PORT] [--memory] [--blob-root PATH] gc [--apply] [--grace-window-hours N] [--memory] --blob-root PATH purge [--apply] [--limit N] [--memory] --blob-root PATH scrub [--deep] [--budget BYTES] [--memory] --blob-root PATH gen-openapi [FILE] [--check]Settings come from flag, then environment, then default. capsule-server/.env.example is a
starting template, and Config::load in capsule-server/src/config.rs reads the full set. There is
no configuration file (--config is refused). Every configuration fault is reported in one
message with exit code 2.
The development profile
Section titled “The development profile”mise run serve-memoryIt binds 127.0.0.1, prints its address and answers every operation with real Argon2id sign-in.
Blobs go to a real filesystem store under target/capsule-server-blobs; everything else is
in-process and lost on exit. After a restart scrub therefore reports every blob as an orphan, and
gc can only mark, never sweep.
It signs tokens with the published example key unless JWT_ED25519_DER is set. Those tokens are
forgeable, which is why it is loopback-only.
JWT_ED25519_DER="$(openssl genpkey -algorithm ed25519 -outform DER | base64 | tr -d '\n')" \ mise run serve-memoryA configured server
Section titled “A configured server”cp capsule-server/.env.example capsule-server/.env # then edit itmise run serve-deps # Postgres, on loopbackmise run serveBoth secrets, JWT_ED25519_DER and ATTESTATION_KEY_SEED, ship commented out, so an unedited copy
refuses to start; uncomment each and supply your own. ATTESTATION_KEY_SEED MUST be independent of
the token key (Durability — Custody Receipts). Values are literal, with no shell
expressions, because podman, compose and systemd read the file too.
serve checks DATABASE_URL’s schema against its migrations and refuses if it is behind, naming
capsule-server-migration up. A missing or unreachable database is a refusal, never a silent
fall-back to in-memory adapters. serve-deps is separate on purpose; stop it with
podman compose -f capsule-server/compose.yaml down. TLS is terminated by the ingress, not the
server.
Logs go to stderr and stdout is data: serve prints listening on <url> and operator commands
print their report. LOG_FORMAT is pretty in debug builds and json in release. RUST_LOG
filters.
The operator commands
Section titled “The operator commands”gc, purge and scrub are the jobs in Library Maintenance and Atomic Writes. They take a blob root
and no token-signing key. Only purge --apply also needs ATTESTATION_KEY_SEED: it signs each
purge into the owner ledger (Server Filesystem — The Owner Ledger) first and refuses to
apply without it. Without --memory they read Postgres (index, marks and, for scrub, live
upload sessions). gc and purge dry-run unless --apply. scrub mutates nothing and exits
non-zero on a non-empty report, including a --deep pass that ran out of budget.
Without running anything
Section titled “Without running anything”cargo nextest run -p capsule-server # in-process, via kynos::test::TestClientmise run openapi-kynos # regenerate capsule-server/openapi.jsonThe container tiers
Section titled “The container tiers”test-rust needs no podman. Cases needing Postgres are gated on CAPSULE_TEST_POSTGRES=1, and
otherwise print a skip line and pass. test-rust-containers enables it and runs every gated case one container at a time, failing on
any skip line. CI runs it as the blocking rust-containers job. Each case starts its container
with the docker CLI, or the one CAPSULE_TEST_CONTAINER_CLI names. Locally, with rootless
podman:
export CAPSULE_TEST_CONTAINER_CLI=podmanexport CAPSULE_TEST_CONTAINER_USERNS=keep-idmise run test-rust-containersProfiling a build
Section titled “Profiling a build”The profiling Cargo profile is release plus line tables. The same LTO and codegen units mean the
samples describe the code that ships, and the line tables let a profiler map them to file:line,
including inlined frames.
cargo build --profile profiling -p capsule-serverThe binary lands in target/profiling/, and any sampler that reads DWARF works on it. Neither samply
nor perf is a mise tool, so install one yourself. Run samply the way serve-memory runs, with a
fresh key and bound to loopback:
JWT_ED25519_DER="$(openssl genpkey -algorithm ed25519 -outform DER | base64 | tr -d '\n')" \BLOB_ROOT=./target/capsule-server-blobs \ samply record target/profiling/capsule-server serve --memory --listen 127.0.0.1:3000perf record --call-graph dwarf works on the same binary.
Git hooks
Section titled “Git hooks”mise run hooks-install installs hk from hk.pkl, and each step delegates to a mise task.
mise run hooks-uninstall removes them.
- pre-commit runs auto-fixing formatters and linters on staged files and re-stages the fixes.
- pre-push runs read-only checks, tests and
check-commits(convco).
Known-broken local gates
Section titled “Known-broken local gates”These are CI-only; a local failure is not a regression you introduced.
format-swiftandformat-check-swift: swiftformat is SIGKILLed on macOS dev hosts. Swift tasks self-skip off macOS.- Kotlin lanes (
*-kotlin): the root Gradle build fails on recent JDKs.i18n-guardcovers Compose from Rust, so that check stays local.