Architecture
Small, separate layers underneath; one coherent experience on top. Dependencies only ever point down, and a layer you do not use is not in your binary.
Layers#
| Layer | Contains | Today |
|---|---|---|
| L3 · Experience | The rustclamp facade, and later a CLI, macros, recipes and templates. | Facade works the rest Planned |
| L2 · Modules | Integrations: HTTP, CLI, worker, databases, messaging. | HTTP, PostgreSQL, messaging Prototype worker, scheduler Prototype the rest Later |
| L1 · Coordination | Kernel and Runtime; later configuration, observability, testing. | Kernel, Runtime Prototype |
| L0 · Foundations | Core contracts and small primitives: Clock, module and capability identities, opt-in lifecycle phases. | Prototype |
Crates#
| Package | Role | Depends on |
|---|---|---|
rustclamp | Facade: Clamp::run and the prelude | nothing |
rustclamp-core | Domain-neutral contracts: modules, capabilities, contributions, lifecycle phases | nothing |
rustclamp-kernel | Resolution, cycle detection, projection, freeze | Core |
rustclamp-runtime | Task supervision: manual driver, optional Tokio adapter | Core; Tokio only with the tokio feature |
rustclamp-http | Optional: route contributions, request context, serving | Core, Axum, Tower HTTP, Tokio |
rustclamp-postgres | Optional: qualified pools, ownership, migrations | Core, SQLx |
rustclamp-messaging | Optional: versioned envelope, MessageBus capability | Core, Serde, serde_json |
rustclamp-worker | Optional: handler contribution target, failure classification | Core, Messaging, serde_json |
rustclamp-scheduler | Optional: clock-driven job target, admission and drain | Core |
Nine public repositories, one package each. A generated local workspace ties them together for development; Git ownership stays separate (ADR 0001). A crate boundary has to earn its existence through dependency isolation, portability or ownership — not aesthetics.
The composition path#
Independent Rust components
│
▼
Modules
│
▼
Capabilities + Contributions
│
▼
Process projection
│
▼
Minimal Kernel
│
▼
Running application
This is the design direction. Projection, resolution and freeze exist as prototypes; a single end-to-end pipeline from blueprint to a running production process does not exist yet.
Non-negotiables#
| Rule | Why | Enforced |
|---|---|---|
No unsafe | Clamp should not ask for more trust than Rust itself. | unsafe_code = "forbid" in every crate |
| Documented public API | Contracts are the product; undocumented ones are accidents. | missing_docs = "deny" |
| Dependencies only where they are the point | Unused architecture must cost nothing, and your supply chain stays yours. Facade, Core and Kernel have none; an integration brings only the crates it wraps. | Resolved-dependency allowlists in tools/boundaries.py |
| No globals, no service locator | Hidden coupling and untyped lookup are what Clamp exists to remove. | By construction: no registry, TypeId or Any map |
| Ambiguity is an error | “Last registration wins” hides real bugs. | Resolver tests |
| Immutable after freeze | Runtime behaviour stays predictable and inspectable. | Compile-fail doc test |
| Measured, not asserted | Cost claims need a control and raw samples. | Evidence with caveats |
What Clamp is not#
Not a framework that owns your application, a web framework, an async runtime, an ORM, a dependency-injection container, a virtual machine or an AI framework. Not a replacement for Tokio, Axum, SQLx or Serde. Clamp coordinates the libraries that already do those jobs well — integrate before reinventing.