Enrichment Pipeline
The Enrichment Pipeline is a deterministic, pure-function pipeline that converts a minimal Plan Draft (produced by the Planner) into a fully typed Full Plan IR (ready for validation and execution).
import { enrichPlanDraft, CapabilityRegistry } from '@zakardo/core';import type { PlanDraft, EnrichmentResult } from '@zakardo/core';
const registry = new CapabilityRegistry();// ... register capabilities ...
const draft: PlanDraft = { goal: 'List all VIP contacts', steps: [ { capability: 'contacts_list', version: '1.0.0', description: 'Get VIP contacts', inputs: { tag: 'VIP' } }, ],};
const result: EnrichmentResult = enrichPlanDraft(draft, registry);
if (result.ok) { console.log(result.plan); // Full PlanIR — ready for validation} else { console.error(result.errors); // Structured enrichment errors}The 8 Steps
Section titled “The 8 Steps”Each step is a pure function. The pipeline composes them sequentially, failing fast on unresolvable errors.
Step 1: Capability Resolution
Section titled “Step 1: Capability Resolution”Resolves capability names and versions from the registry. Fails if a capability is not registered or the requested version does not exist.
Error codes: CAPABILITY_NOT_FOUND, VERSION_NOT_FOUND
Step 2: Schema Inference
Section titled “Step 2: Schema Inference”Infers the plan’s input and output schemas from the resolved capability definitions. The plan’s overall input schema is the union of all step inputs that are not satisfied by other step outputs.
Step 3: Binding Conversion
Section titled “Step 3: Binding Conversion”Converts the simplified draft bindings (e.g., { tag: "VIP" }) into full path expression bindings (e.g., $context.plan.inputs.tag). Literal values become LiteralBinding objects.
Helper exports:
import { convertDraftBinding, convertStepBindings, buildOutputNameMap } from '@zakardo/core';Step 4: Condition Conversion
Section titled “Step 4: Condition Conversion”Converts conditions from the draft format to structured Condition objects. In v1, natural language conditions are passed through with a raw flag for future LLM-based structuring.
Step 5: Dependency Analysis
Section titled “Step 5: Dependency Analysis”Analyzes path expressions in bindings to compute depends_on relationships between steps. If Step 2’s input references $context.steps.step_0.output.contacts, then Step 2 depends on Step 0.
This produces a directed acyclic graph (DAG) that determines execution order. Cycles are detected and reported as errors.
Error codes: CIRCULAR_DEPENDENCY
Step 6: Index Assignment
Section titled “Step 6: Index Assignment”Assigns deterministic step_index values and output_key identifiers to each step. Output keys follow the pattern step_0, step_1, etc.
Step 7: Metadata Generation
Section titled “Step 7: Metadata Generation”Generates plan-level metadata:
plan_id— unique UUID v4version—1.0.0for new plansname— derived from the goallifecycle_state—CANDIDATEfor new plans
Step 8: Default Policies
Section titled “Step 8: Default Policies”Applies default error handling, retry, and execution constraints:
- Error policy — default behavior on step failure
- Retry policy — exponential backoff for transient errors
- Execution constraints — timeout limits, mode requirements
EnrichmentResult Type
Section titled “EnrichmentResult Type”type EnrichmentResult = | { ok: true; plan: PlanIR } | { ok: false; errors: readonly EnrichmentError[] };
interface EnrichmentError { code: string; step_index?: number; capability?: string; message: string; suggestion?: string;}EnrichmentOptions
Section titled “EnrichmentOptions”const result = enrichPlanDraft(draft, registry, { plan_name: 'Custom Plan Name', // Override auto-generated name version: '2.0.0', // Override default version});Further Reading
Section titled “Further Reading”- Plans Concept — how drafts and Plan IR relate
- Validator API — what happens after enrichment
- Plan IR Specification — full specification (section 10)