Architecture
The one canonical execution path Kaji uses to run a capability, and the boundaries it does and does not own.
Execution Path
kaji.execute(capability, request) is the only way a capability runs. There
is no second path, so no caller can accidentally skip a safety boundary. For
one request, the executor:
- Validates
principalIdandidempotencyKeyare non-empty strings. - Validates
inputagainst the capability’sinput.parse(). - Claims the idempotency key in the execution store. An existing claim
returns the same recorded or in-flight outcome instead of running
executeagain; a conflicting claim (same key, different input, capability, or principal) settlesfailed. - Calls
authorize({ principalId, input }). Afalseresult or a thrown error settlesdenied. - If
approval({ principalId, input })returnstrue, calls the configuredapprovehandler. A missing handler, an invalid decision, a rejected decision, or a handler error settlesrejected. - Calls
execute(input, context)at most once. - Records the outcome in the execution store and returns it.
Cancellation is checked before each step that hasn’t yet started a side
effect; once execute has been called, Kaji can no longer prove the action
didn’t begin, so every failure path from that point settles unknown rather
than an ordinary failure.
request
→ validate input
→ claim idempotency key
→ authorize
→ approve (if required)
→ execute (side effects may begin here)
→ record outcome
Boundaries
Kaji owns the execution boundary; it does not own what’s on either side of it.
- Capability code is ordinary application code.
execute,authorize, andapprovalare functions your application supplies. Kaji never contains business logic, and it never calls a capability’s functions outsidekaji.execute(). - The execution store is a narrow contract. It claims idempotency keys
atomically and records terminal outcomes. It is not a general event log,
and v0 ships only
memoryStore(), a process-local, non-durable implementation. A production deployment supplies its own durableExecutionStore. - Approval is a decision, not a UI. Kaji calls the
approvehandler you configure and enforces its decision; it does not implement a review queue, notification system, or audit UI. - Cancellation and timeout use native
AbortSignal. Kaji combines the caller’s signal with its owntimeoutMsinto one effective signal; it does not invent a Kaji-specific cancellation token.
Footnotes
Kaji has no agent loop, model provider, tool registry, session or event
store, CLI, or hosted control plane. An agent framework, MCP server, or
direct application code decides what action to request; Kaji only governs
how that one action is safely executed. See docs/product.md in the
repository for the complete non-goal list.