Keel by ChimpLabs
Jump to page or section Esc
Documentation

Primitives Overview

Directory of all 16 core Keel primitives in @chimp-labs/keel plus DurableStream in @chimp-labs/keel-streams, workflows in @chimp-labs/keel-workflow, and the 9-package monorepo structure.

Keel provides 16 core platform primitives in @chimp-labs/keel (with zero optional peer dependencies), durable append-only streams (DurableStream) in @chimp-labs/keel-streams, and durable workflows (Workflow and Signal) in @chimp-labs/keel-workflow. Each primitive has a reference guide covering the plain TypeScript SDK (@chimp-labs/keel/sdk), native Effect v4 APIs, configuration options, service scoping, typed errors, backend behavior, and in-memory testing.

Monorepo packages (9 packages)

Package Purpose
@chimp-labs/keel 16 core primitives, plain TypeScript SDK (./sdk), Memory/SQLite/S3 backends, Open Plugin Protocol, and the keel CLI (db, codegen, skill) — zero optional peer dependencies
@chimp-labs/keel-postgres PostgreSQL 17 backend adapter (KeelPostgresLive, PostgresClientLive, JSONB GIN & expression indexes, LISTEN/NOTIFY, FOR UPDATE SKIP LOCKED, multi-replica coordination, and schema migrations)
@chimp-labs/keel-surreal SurrealDB 4 backend adapter (KeelSurrealLive, KeelSurrealCoreLive, KeelSurrealHttpLive, KeelSurrealTransportLive, KeelSurrealConfigLive, and SurrealDB schema migrations)
@chimp-labs/keel-streams DurableStream primitive, TopicDurableStreamLive, in-memory backend, zero-dependency S2 (./s2, s2-lite / s2.dev) backend, and NATS JetStream (./nats) backend — plugs into createKeel({ resources }) via the Open Plugin Protocol
@chimp-labs/keel-workflow Durable Workflow & Signal orchestration (WorkflowStoreMemory, WorkflowStoreFromTable, ./postgres, ./surreal) — plugs into createKeel({ resources }) via the Open Plugin Protocol
@chimp-labs/keel-go Polyglot zero-dependency Go service contract codegen (generateGoServiceContract, keel codegen --lang go)
@chimp-labs/keel-rust Polyglot zero-SDK Rust service contract codegen (generateRustServiceContract, keel codegen --lang rust)
@chimp-labs/keel-alchemy Alchemy v2 single-call stacks (keelDockerStack, keelCloudflareStack), pure topology planners, Cloudflare Workers/edge runtime (./cloudflare, ./cloudflare/edge, ./cloudflare/stack), and Docker (./docker)
@chimp-labs/keel-nestjs NestJS 10/11 adapter with TC39 Stage 3 decorators, native Effect v4 & Stream returns, @Inject, @Transactional, KeelContextMiddleware, and static AppModule topology inference

Data & storage (4 primitives)

Primitive Builder or import Description
Bucket k.bucket MIME- and size-guarded object storage with streaming reads, tenantScoped prefixes, and S3 or R2 presigned URLs
Cache k.cache Read-through cache with singleflight stampede protection (getOrCompute) and tag invalidation
KV k.kv Typed key-value namespaces with TTL expiration, setIfNotExists, atomic incr, and CAS
Table k.table Relational + JSONB tables with GIN/expression indexes, dot-path queries, @> containment, ACID transactions, foreign keys, typed joins, tenantScoped isolation, watches, and atomic CDC

Events & streams (4 primitives)

Primitive Builder or import Description
Cron k.cron Distributed scheduled jobs with 5-field cron expressions, timezones, and leader locks
DurableStream DurableStream (@chimp-labs/keel-streams) S2.dev v1-compatible durable append-only streams with monotonic seqNum, CAS (412), leader fencing, trimming, ?wait long-poll, and live SSE tailing
JobQueue k.queue Background job queues with delays, visibility timeouts, retries, push or poll workers, and DLQ
Topic k.topic Typed pub/sub topics, durable replay streams, schema upcasting, compile-time wildcards, and transactional outbox

Services & topology (4 primitives)

Primitive Builder or import Description
ExternalSystem k.external Third-party API wrappers with secrets, schema validation, timeouts, and retries
Modulith k.modulith / Modulith Opinionated single-unit composition of bounded-context services with shared DB defaults, inferred & explicit pub/sub contracts, boundary enforcement, and extract() to Topology
Service k.service Bounded-context contracts declaring owned resources, publishes/subscribes, dependencies, and closed error boundaries
Topology Topology Multi-unit microservice boundaries, per-unit DB schema isolation, Rust and Go codegen, and Docker or Cloudflare deployment

Coordination & secrets (5 primitives)

Primitive Builder or import Description
Flag k.flag Schema-typed feature flags evaluated against request context with default fallbacks
Idempotency k.idempotency Exactly-once execution deduplication caching typed success outcomes while never caching failures
Lock k.lock Distributed leases with automatic TTL renewal and guaranteed release on exit or interruption
RateLimit k.rateLimit Sliding-window quotas with weighted costs, check, guard, reset, and HTTP 429 retryAfterMs errors
Secret k.secret Boot-verified redacted credentials backed by env vars, mounted files, Effect Config, or chained stores

Durable workflows (@chimp-labs/keel-workflow)

Primitive Builder or import Description
Workflow workflow / Workflow Crash-resilient step journaling, durable sleep, event waits, and reverse LIFO saga compensation
Signal signal / Signal Typed external signals that wake suspended workflows live via PostgreSQL LISTEN/NOTIFY or SurrealDB LIVE SELECT