Graph Engineering in Dori
How Dori models AI agents, data transformations, and workflows as deterministic DAGs with edge contracts and verifier nodes.
Complex AI applications break when built as simple linear prompt chains. Dori uses Graph Engineering—treating execution steps as graph nodes connected by explicit data contracts and runtime verifiers.
Core Graph Engineering Principles
1. Edge Contracts & Zero-Token Transformations
Data passed between nodes is governed by strict Zod schema contracts.
- Zero-Token Edge Transforms: Data normalization (deduplication, date parsing, structure cleaning) runs in pure TypeScript code on the edge before calling LLM models, eliminating wasted token spend.
- Contract Enforcement: Every tool call and engine action validates input and output payloads against strict Zod definitions (
guardrails.ts).
2. Parallel Fan-Out & Fan-In Barriers
To eliminate sequential latency bottlenecks:
- Parallel Fan-Out: Document parsing, OCR, and audio transcription fan out concurrently across worker pools.
- Fan-In Synchronization Barriers: Parent synthesis nodes wait at explicit barrier nodes to aggregate payloads before running state updates.
3. Output Guardrails & Convergence Loops
Outputs are never assumed to be valid without empirical verification:
- Guardrail Nodes: Workflow outputs pass through typed guardrails (
ApprovalGuard,PermissionGuard,EvidenceGuard) before a state transition commits.EvidenceGuardruns a cross-model groundedness check, sending generated text and its sources to a judge model from a different provider family than the one that generated it. - Convergence Loops: If a guardrail returns a
warnorfailverdict, the workflow surfaces the failure and can cycle back to the execution node, repeating until criteria pass.
4. Content-Addressable Short-Circuiting
To minimize unnecessary re-indexing:
- Files are fingerprinted using SHA-256 content hashes.
- Unchanged files short-circuit downstream parsing and vector embedding nodes entirely.
5. CQRS & Reactive Event Streaming
- Read/Write Decoupling: Vault file edits and database writes update raw state. The engine projects read-optimized query snapshots (
domain-records.ts) for the UI. - Server-Sent Events (SSE): Workflow state updates stream directly to UI components (
live-events.ts), updating indicators and attention badges reactively without polling.
