How torbenanderson/icebox-cli works
1. What this repo is
- Icebox is a single Rust CLI binary (src/main.rs, src/lib.rs) for brokered secret handling.
- Its architectural goal is to keep API keys/passwords out of agent state, store them encrypted on disk, and only unwrap them at execution time.
2. Top-level runtime flow
- User command enters the CLI.
- Parsing and command dispatch happen in the Rust application layer.
- Commands then route into the appropriate subsystem: config/agent management, vault storage, enclave-backed key handling, or future secure run flows.
3. Identity is the central domain model
- The agent and config modules model named agents and the active agent registry.
- register-agent is the bootstrap path: it creates an agent identity, writes registry state, and initializes the per-agent storage directory.
- Agent names are constrained and each agent gets an isolated namespace under ICEBOX_HOME / ~/.icebox.
4. Filesystem layout is an explicit boundary
- Persistent state is rooted under ~/.icebox or ICEBOX_HOME.
- The main artifacts are:
- config.json for agent registry and active selection
- identities/<name>/identity.pub for the public identity key
- identities/<name>/enclave.keyref as a stable label for the wrapping key
- identities/<name>/key.enc for wrapped private-key material
- planned/related vault files such as vault.enc
- This filesystem layout is part of the architecture, not just implementation detail.
5. Secret storage and retrieval
- The vault module represents encrypted secret storage per agent.
- The current MVP slice supports adding secrets; the broader design includes listing, removing, and running commands with injected credentials.
- The vault is intended to store only encrypted values, with plaintext appearing only transiently during trusted execution.
6. Secure Enclave is the hard security boundary
- The enclave and platform-specific DID backend files (src/did/backend_darwin.rs, backend_stub.rs) show that key wrapping is backend-driven.
- On macOS, the Secure Enclave is the intended trust anchor for local key protection.
- The README makes clear that this is the MVP lane; Linux is currently only for non-enclave development/test paths.
7. Identity backend abstraction is deliberate
- The codebase is already structured around a split between local-enclave and future paired-remote-signer identity lanes.
- src/did.rs and backend modules indicate the design is meant to support multiple identity/wrapping implementations behind one contract.
- That means the diagram should show a stable identity interface with pluggable backend implementations underneath.
8. Command execution is a planned trust boundary
- runner is the module for the future run path: decrypt secret, inject into a subprocess, capture results.
- The README emphasizes that Icebox itself avoids persisting secrets in agent state, but the invoked subprocess is still a trust boundary and can exfiltrate via stdout, files, or network.
- This is the main “broker” flow the project is aiming toward, even though it is not fully implemented yet.
9. Contracts and schemas are part of the architecture
- docs/architecture/contracts/*.schema.json define the intended shapes for config, manifest, bundle manifest, and vault-related data.
- These schemas act as a boundary between code, docs, and persisted artifacts.
- The architecture diagram should treat them as validation contracts for on-disk and interchange formats.
10. Documentation is unusually central
- docs/architecture/ is effectively the system design source of truth: security model, identity/enclave model, vault integrity, platform strategy, and ADRs.
- docs/plan/ tracks roadmap/state, while docs/reference/ holds error codes and versioning.
- For architecture understanding, the repo is “docs-driven”: code implements a narrowly scoped MVP, but many critical boundaries are documented first.
11. Quality and verification pipeline
- Tests are split into integration, e2e, security, and system, mirroring different architectural concerns.
- The e2e tests map closely to product milestones such as keypair generation, enclave wrapping, no-plaintext-on-disk, duplicate guards, active-agent tracking, and vault creation.
- CI workflows also enforce formatting, linting, docs, schema checks, security audit, and mutation testing.
12. Current implementation status
- The repository is still pre-MVP / alpha.
- Implemented: CLI scaffolding, identity bootstrap (register-agent), encrypted secret add flow, config/state handling, and supporting test coverage.
- Planned: list/remove/run, multi-agent workflows, DID publishing, seed backup, and server/browser-extension phases.
13. How to draw the diagram
- Put the CLI binary at the center.
- Draw one boundary around local filesystem state (ICEBOX_HOME), one around Secure Enclave / platform key wrapping, and one around the subprocess execution target.
- Show data moving from CLI → config/agent selection → enclave-backed key material → encrypted vault storage, with the future run path decrypting only at the point of execution.
Main entry points: lib.rs Core lib · did.rs Identity API · vault.rs Vault · e2e.rs E2E tests
Components 21
Runtime
CLI entrypoint and core Rust modules
- CLI · Command-line entrypoint and dispatch surface
src/main.rs - Core lib · Shared application layer for command routing and orchestration
src/lib.rs - Agent · Named agent identity and active-registry domain
src/agent.rs - Config · Persistent agent registry and active selection handling
src/config.rs - Vault · Encrypted per-agent secret storage and vault operations
src/vault.rs - Runner · Planned secret-unwrapping and subprocess execution path
src/runner.rs
Local State
Persistent files under ICEBOX_HOME or ~/.icebox
- ICEBOX_HOME · Persistent on-disk state rooted at ~/.icebox or ICEBOX_HOME
- Identity files · Per-agent identity namespace with public key and wrapped key material
- Vault file · Encrypted vault payload stored per agent
Security Boundary
Identity wrapping and enclave-backed key handling
- Identity API · Stable interface for identity and key-wrapping implementations
src/did.rs - macOS backend · Secure Enclave-backed implementation for Darwin
src/did/backend_darwin.rs - Stub backend · Non-enclave development and fallback implementation
src/did/backend_stub.rs - Enclave · Local trust anchor for wrapping private key material
src/enclave.rs
Contracts
Schema-defined persisted and interchange formats
- Config schema · Contract for registry and active-agent state
docs/architecture/contracts/config.schema.json - Vault schema · Contract for encrypted vault data shape
docs/architecture/contracts/vault.schema.json
Architecture Docs
Design source of truth and ADRs
- Overview · High-level repository and system architecture narrative
docs/architecture/overview.md - Security model · Threat model, trust boundaries, and security assumptions
docs/architecture/security-model.md - Identity design · Identity, enclave, and backend split documentation
docs/architecture/identity-and-enclave.md - Data layout · Filesystem layout and persistent artifact structure
docs/architecture/data-models-and-layout.md
Verification
Tests and CI checks that enforce the design
- E2E tests · End-to-end coverage for bootstrap, enclave wrapping, and vault behavior
tests/e2e.rs - CI workflow · Automated formatting, linting, docs, schema, security, and mutation checks
.github/workflows/ci.yml
Connections 26
- CLI → Core lib: dispatches · CLI parses commands and hands off into the application layer
- Core lib → Config: routes · Command handling reaches registry and active-agent state
- Core lib → Agent: models · Core logic works with named agent identities
- Core lib → Vault: routes · Secret add and future vault operations flow through the vault module
- Core lib → Identity API: abstracts · Core relies on a stable identity/wrapping contract
- Core lib → Runner: plans · Future run path will broker secret injection at execution time
- Config → ICEBOX_HOME: persists · Registry state is stored under the local Icebox home directory
- Agent → Identity files: namespaces · Each agent gets an isolated filesystem namespace
- Vault → Vault file: stores · Vault data is kept as encrypted on-disk artifacts
- Vault → ICEBOX_HOME: anchors · Vault storage is rooted in the local state directory
- Identity API → macOS backend: implements · Darwin backend provides the enclave-backed implementation
- Identity API → Stub backend: implements · Stub backend supports non-enclave development and tests
- Identity API → Enclave: wraps via · Identity contract delegates key wrapping to the enclave boundary
- Enclave → Identity files: writes · Wrapped key material and identity artifacts live in per-agent storage
- Runner → Vault: reads · Execution flow will decrypt or load secrets from the vault transiently
- Runner → Identity API: unseals via · Runner depends on the identity contract to recover secrets at execution time
- Config schema → Config: validates · Schema defines the registry state shape
- Vault schema → Vault: validates · Schema defines the vault data contract
- Overview → Security model: references · Architecture overview is supported by the security model
- Overview → Identity design: references · Overview points to identity and enclave design
- Overview → Data layout: references · Overview points to the explicit filesystem layout
- E2E tests → Core lib: verifies · E2E tests cover CLI flows and state transitions
- E2E tests → Identity API: verifies · E2E tests cover backend wrapping behavior
- E2E tests → Vault: verifies · E2E tests cover vault creation and sealed storage
- CI workflow → E2E tests: runs · CI enforces the test suite and surrounding quality gates
- CI workflow → Config schema: checks · CI validates docs and schema contracts