Workflow sequence
- 01Hash and store source
- 02Extract typed fields
- 03Attach page and source references
- 04Run deterministic validation
- 05Route uncertain fields to review
- 06Publish approved record
Sequence definition
Use this sequence definition as a starting point. Set tenant_id to your tenant and use a fresh UUID for id before publishing. Implement the named business handlers in your workers; the JSON does not include provider integrations. Keep credentials in the credential store.
{
"id": "d5217d64-8969-5043-a33b-dea85ae7666f",
"tenant_id": "demo",
"namespace": "default",
"name": "document_extraction_provenance_v1",
"version": 1,
"deprecated": false,
"blocks": [
{
"type": "step",
"id": "archive",
"handler": "archive_source",
"params": {}
},
{
"type": "step",
"id": "extract",
"handler": "extract_with_citations",
"params": {}
},
{
"type": "step",
"id": "validate",
"handler": "validate_document_fields",
"params": {}
},
{
"type": "router",
"id": "review_gate",
"routes": [
{
"condition": "outputs.validate.needs_review == true",
"blocks": [
{
"type": "step",
"id": "review",
"handler": "human_review",
"params": {},
"wait_for_input": {
"prompt": "Approve extracted document fields?",
"timeout": 172800000,
"store_as": "review_decision",
"choices": [
{
"label": "Approve",
"value": "approved"
},
{
"label": "Reject",
"value": "rejected"
}
]
}
}
]
}
],
"default": []
},
{
"type": "step",
"id": "publish",
"handler": "publish_approved_record",
"params": {
"idempotency_key": "{{outputs.archive.sha256}}"
},
"when": "outputs.validate.needs_review == false || context.data.review_decision == "approved""
}
],
"created_at": "2026-09-05T00:00:00Z"
}Handlers must validate required inputs and outputs. Quote extraction returns confidence; document validation returns needs_review; source archiving returns sha256. Guards read these values through outputs, and approval decisions through context.data.
Idempotency keys in params are a contract for your worker to enforce at the provider. They do not make an external write exactly-once automatically.
Steps with wait_for_input resume through an authorized human_input:{block_id} signal carrying a declared choice. A CRM or scheduling integration may supply a verified choice. Timeouts fail the wait; they do not select a follow-up or escalation branch automatically. Configure alerts and recovery for timed-out runs before production.
Review rejection skips the guarded publish or spreadsheet write. No write is authorized merely because the review step finished.
Production controls to keep
✓ Stable idempotency keys around external writes
✓ Explicit validation before the success state
✓ Bounded retries with provider-aware backoff
✓ Searchable source and destination identifiers
✓ A named owner for exhausted retries
✓ A replay test using duplicate input