콘텐츠로 이동
GitHub

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.

Terminal window
mise install # pinned tools (hk, convco, cargo-nextest, shellcheck, actionlint, ...)
mise run setup # bun install in capsule-web + capsule-docs
mise 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, then capsule-sdk --features ffi.
  • test-rust-release: the #[cfg(not(debug_assertions))] tests in RELEASE_TEST_CRATES.
  • test-rust-containers: see The container tiers.
  • test-web: builds the WASM glue and KAT fixtures first.
  • i18n and openapi-kynos.
  • audit-docs -- <page.md>...: stamps docs pages as audited at HEAD (Core Principles — Audit Status).
  • For FFI, targets-add, then build-ffi and gen-bindings. On macOS, setup-swift builds the xcframework and the Xcode workspace.
  • check-targets: cargo check of 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 through zig cc (scripts/cross/zig-cc), so no Xcode, NDK or MSVC is needed. Narrow it with --target TRIPLE, --tier 1|2 or --apple. The build-apple, build-android, build-windows and build-linux-cross tasks produce real linked artifacts, so they need each platform’s native toolchain. Off macOS, build-apple falls back to check-targets --apple.
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.

Terminal window
mise run serve-memory

It 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.

Terminal window
JWT_ED25519_DER="$(openssl genpkey -algorithm ed25519 -outform DER | base64 | tr -d '\n')" \
mise run serve-memory
Terminal window
cp capsule-server/.env.example capsule-server/.env # then edit it
mise run serve-deps # Postgres, on loopback
mise run serve

Both 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.

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.

Terminal window
cargo nextest run -p capsule-server # in-process, via kynos::test::TestClient
mise run openapi-kynos # regenerate capsule-server/openapi.json

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:

Terminal window
export CAPSULE_TEST_CONTAINER_CLI=podman
export CAPSULE_TEST_CONTAINER_USERNS=keep-id
mise run test-rust-containers

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.

Terminal window
cargo build --profile profiling -p capsule-server

The 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:

Terminal window
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:3000

perf record --call-graph dwarf works on the same binary.

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).

These are CI-only; a local failure is not a regression you introduced.

  • format-swift and format-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-guard covers Compose from Rust, so that check stays local.