This guide orients contributors working on the clawforge-controlplane crate.
backend/controlplane/src/
├── lib.rs # crate docs + module wiring
├── config.rs # ControlPlaneConfig (CLAWFORGE_CP_*)
├── constants.rs # RiskLevel, DataAccessLevel, LifecycleStatus
├── error.rs # ControlPlaneError + Result
├── logging.rs # cp_info! / cp_warn! / cp_blocked!
├── registry/ # Agent Registry (Phase 2)
├── governance/ # Governance Engine (Phase 3)
├── observability/ # Execution events & metrics (Phase 4)
├── gateway/ # Security Gateway (Phase 5)
├── mcp/ # MCP Governance (Phase 6)
├── marketplace/ # Agent Marketplace (Phase 7)
├── integrations/ # Enterprise Integrations (Phase 8)
└── compliance/ # Government Compliance Pack (Phase 9)
Each domain follows the same shape: a model.rs of serde types, a store.rs
SQLite store with open(path) + in_memory(), and #[cfg(test)] unit tests
beside the code.
- One vocabulary. Reuse
constants::{RiskLevel, DataAccessLevel, LifecycleStatus}rather than redefining per module. - Errors. Return the crate-wide
Result<T>(error::Result).Fromimpls convertrusqliteandserde_jsonerrors automatically. - Storage. JSON-encode list/enum columns so schemas stay stable across
vocabulary changes; provide both
openandin_memoryconstructors. - Logging. Emit via
cp_info!/cp_warn!/cp_blocked!so audit and observability tooling sees a consistentclawforge::controlplanetarget. - No
unsafe, edition 2021, idiomatic Rust.
- Create
src/<domain>/{mod.rs, model.rs, store.rs}. - Wire
pub mod <domain>;intolib.rsand re-export the key types. - Add
#[cfg(test)]tests and adocs/<domain>.md. - Keep each commit atomic and green (
cargo test -p clawforge-controlplane).
cargo build -p clawforge-controlplane
cargo test -p clawforge-controlplane
cargo fmt
cargo clippy -p clawforge-controlplane # optional lint passThe Marketplace installs into the Registry; Governance approves Registry agents; the Security Gateway reads the Registry (and is consulted on MCP/integration use); Observability records what happened; Compliance reports over all of it. See diagrams.md and use-cases.md.