Persistence Patterns
Verify-then-Persist
Verify-then-Persist
A step that emits structured JSON, gated by a jsonMatches schema, with a write action on the gate. Turns a stateless ladder into a learning system.
Shape and when to use
Shape: a step emits structured JSON, an if: { jsonMatches: ... } gate verifies the JSON matches a schema, and a then: { write: ... } action persists the verified output to a slate.
When to use: durable learning across calls. Record what worked, what didn't, structured outcomes that future invocations can read via slateRead or retrieve:.
Cost: 1 LLM call (no extra cost; the gate and write run after the step). The gate evaluation and slate write are sub-millisecond operations against the hot tier.
Config sketch
- id: extract
type: normal
fields:
- { name: Context, type: text, from: input.context }
systemPrompt: |
Output JSON summarizing the key finding:
{"fact": "...", "confidence": 0.0-1.0}
if:
jsonMatches:
type: object
required: [fact, confidence]
properties:
fact: { type: string, minLength: 1 }
confidence: { type: number, minimum: 0.6 }
additionalProperties: false
then:
write:
to: { slate: "Memory", folder: facts, file: core.md }
from: output
on: append
else: continueThe gate-and-write pattern is what turns a stateless ladder into a learning system. Every call contributes durable memory, but only for outputs that pass verification. Bad outputs (low confidence, missing fields, malformed JSON) are silently dropped via the else: continue path.