AIConcept

AI — Concept

Causet treats AI as declarative infrastructure, not ad-hoc API calls in application code — and not as the center of the product.

AI is additive. Causet is useful for any multi-step workflow; agents are the sharpest version of the same state problem. Memory becomes state, decisions become events, tool calls become inspectable side effects, and approvals become explicit events on the same timeline as a payment or access-request flow.

You declare providers, prompts, decisions, and memories in the Product DSL. The compiler validates schemas and produces causet.decisions.json; the runtime executes LLM calls when rules invoke op: decision in side_effects.

AI is a rule operation — same execution model as emits and submits, but external I/O that runs after core rules commit and is not replayed from ledger history the way core rules are.


The four DSL pieces

PieceRole
ProvidersLogical LLM backends (reasoning, embeddings) — executor, model, temperature
PromptsReusable templates with {{ variable }} bindings
DecisionsNamed operations: provider + prompt + input/output schema + event to emit
MemoriesEvent-driven embedding ingestion + retrieval at decision time

Decisions reference providers and prompts by key. Memories feed context into prompts via {{ memories.<name> }}.


Where AI runs in the intent lifecycle

PhaseAI allowed?
PreflightNo — validation only
CoreNo — must stay deterministic and replayable
Side effectsYes — op: decision runs here

Keep entity mutations and the primary domain event in core. Run LLM calls in side_effects after core commits.

Not the same as timeline. Decision routes are runtime forensics for all rule steps. An AI call appears as one decision step in that trace. See Debugging.


Two kinds of memory

Application memoryVector memory
StorageEntity state fieldsEmbedded text from ledger events
Updated byCore rules (set, push, add)Async ingestion worker
Retrieved viaEntity snapshot / projectionsSimilarity search at decision time
ReplayDeterministic from ledgerRe-ingested from source events

Use entity state for structured counters and history. Use vector memory when you need semantic search over unstructured text in prompts.


Compiler artifact

When your app defines any of providers, prompts, decisions, or memories, compile produces:

build/out/causet.decisions.json

Deploy it with your release. The runtime loads the AI IR per fork when rules invoke op: decision.


When to use AI in Causet

Good fitPoor fit
Classification, triage, moderationSimple field validation (use preflight)
Structured extraction from textDeterministic transforms (use core rules)
Summarization with typed outputLong-running human-in-the-loop (use workflows)
RAG over customer historyHigh-frequency hot-path logic without LLM need

Next steps