Persistence with SQLite
Create a local durable store:
The database is initialized additively. Opening an older workflow database
creates newly introduced tables without deleting existing execution data.
Resumption still requires compatible pinned definitions; see the version-2
migration guidance in execution contracts.
Opening and submitting work
coordinator.open(item_id):
- verifies that the item is ready or in progress;
- loads participant traits;
- reads authorized shared state;
- assembles prior visible answers and submissions;
- evaluates available derived values;
- renders every survey question;
- saves the exact render and state versions; and
- marks the item in progress.
OpenedWorkItem contains the rendered survey and execution
context. Reopening reuses the first saved render and observations, preserving
survey rules, memory, instructions, and groups. It does not refresh shared state.
Submit an answer with a stable idempotency key:
attempt_id; stale
workers cannot accept new responses.
The durable outbox
When an item becomes ready, the coordinator creates an outbox record in the same workflow store. Delivery reads only pending records:DeliveryRequest contains:
workflow_outbox_claims across failures and restarts, and do not expire
automatically: a slow request or a crash after external delivery must not cause
another invitation.
After stopping the original dispatcher, reconcile an abandoned claim with the
external provider. If delivery succeeded, call
store.mark_delivered(outbox_id, claim_token=token). If retry is safe, call
store.release_outbox_claim(outbox_id, claim_token=token) before dispatching
again. The table records the outbox ID, ownership token, and claim time.
Humanize does not provide end-to-end exactly-once delivery here; a failure
between its remote calls and the local task record requires this reconciliation.
Humanize and real respondents
HumanizeDeliveryAdapter is intentionally thin. For each ready item it:
- opens and renders the participant-specific survey;
- creates a private Humanize survey;
- creates a delivery;
- records the external survey and delivery identifiers; and
- returns a delivery receipt.
coordinator.submit(). That submission may
make new items ready, after which the outbox dispatcher delivers the next wave.
Humanize owns survey presentation, invitations, and response collection. It
does not need to understand the dependency graph.
Simulated respondents
The simulation uses the same coordinator and store with an in-memory inbox:EDSLAgentAnswerer runs each rendered survey through the ordinary EDSL
agent/model pipeline. A scripted object implementing answer(agent, opened) is
often better for deterministic tests.
response_delay and the virtual clock can model elapsed time without sleeping:
