Crate Layout
Fabric is organized as a Cargo workspace with 14 crates (13 libraries + 1 binary).
Crate Overview
Section titled “Crate Overview”| Crate | Type | Purpose |
|---|---|---|
fabric-domain | lib | Typed IDs (JobId, RunId, WorkflowId, etc.), shared models, errors, time utilities |
fabric-proto | lib | Protobuf definitions and codegen (prost/tonic) — canonical Rust types, gRPC service stubs |
fabric-auth | lib | JWT validation (Supabase HS256), API key hashing/verification (fab_* prefix), principal resolution, auth middleware |
fabric-tenancy | lib | Organizations, teams, memberships, invitations repository layer |
fabric-policy | lib | RBAC evaluation, effective permission computation, resource/action evaluation, authz_guard |
fabric-workflows | lib | DAG definitions, validation (Kahn’s algorithm), runs, node models, context propagation |
fabric-executor | lib/bin | Step claiming (SELECT ... FOR UPDATE SKIP LOCKED), node dispatch (Native/Tool/Provider/Wasm), retries, leases, worker loop |
fabric-events | lib | Domain events, in-process broadcast, persistence, SSE/WebSocket/webhook delivery, audit logs |
fabric-assets | lib | Asset metadata, S3/GCS/local object store abstraction, signed URLs |
fabric-providers | lib | Provider abstraction, registry, routing — OpenAI, Anthropic, Ollama, Whisper, ComfyUI, ONNX, Candle, Echo |
fabric-storage | lib | Persistence abstraction — Postgres (sqlx) + in-memory repos, unified Store enum, usage persistence |
fabric-api | lib | axum routes, gRPC services, request/response envelopes, auth extraction, validation, jobs API, rate limiter, quotas |
fabric | bin | Server binary with serve (control plane) and executor (execution plane) subcommands |
Build Order
Section titled “Build Order”The crates build in dependency order:
1. fabric-proto (protobuf codegen)2. fabric-domain (pure domain types)3. fabric-auth ─┐ fabric-tenancy │ (depend on domain + proto) fabric-workflows ─┘4. fabric-policy (depends on tenancy + domain)5. fabric-events (depends on domain)6. fabric-assets (depends on domain)7. fabric-providers (depends on domain)8. fabric-storage (depends on all domain crates)9. fabric-executor (depends on workflows + providers + storage)10. fabric-api (depends on all lib crates)11. fabric (binary, depends on api + executor)Key Dependencies
Section titled “Key Dependencies”Shared Across Workspace
Section titled “Shared Across Workspace”- tokio — Async runtime
- axum — HTTP framework (control plane)
- tonic / prost — gRPC framework and protobuf codegen
- sqlx — Async Postgres driver
- serde — Serialization/deserialization
- uuid — Canonical ID generation
- time — Timestamp handling
- tracing — Structured logging
Optional Features
Section titled “Optional Features”onnx-runtime— Actual ONNX inference viaortcandle— HuggingFace model loading via Candlewasm-runtime— Wasmtime plugin execution
Design Principles
Section titled “Design Principles”- Protobuf is canonical for message contracts —
fabric-protogenerates the types consumed by all other crates - Pure domain layer —
fabric-domainhas no I/O dependencies - Storage abstraction — All persistence goes through
fabric-storage, which supports both Postgres and in-memory backends - Layered architecture — Each crate has a clear boundary and minimal dependencies