activity_poll definition in Machines, commands, and views. Alternative fragments are labeled separately.
Creating one SharedState space
Place the machine in a state definition:poll. The rest of this walkthrough
uses this definition. The following alternative illustrates multiple machines;
it requires a message_log defined as in Collections and lifecycle:
Creating many scopes with SharedStateMap
Most simulations need one independent space per group:SharedStateMap contains many scopes. One SharedState contains the named
machines within a scope.
Connecting the poll to a survey
Define the question:- read this family’s poll;
- ask the question using that snapshot;
- submit the answer as a vote.
activity.answer means the validated answer to this question. It is not a
placeholder string.
Why reads are explicit
A state value rendered when a survey launches can be stale before a participant reaches the question.family.poll.read() states exactly when freshness
matters.
Every read is logged at the Results level with a read ID, selected scope,
machine name, snapshot ID, interview ID, and survey position. This supports
auditing without promising that a snapshot remains newest after it is read.
Agent grouping and scheduling
Scope and schedule fields are ordinary agent traits:Storage and execution
Attach storage when executing, not when defining data:hike answer without an API key or model
call. Replace it with a configured model for real responses.
The survey’s explicit state steps carry the serializable definition and state
ID; no database handle belongs in the job definition. Local execution manages a
SQLite state service. Remote execution creates or attaches to a remote store and
sends a durable reference with the job:
Results contains state provenance for each binding:
Which options did this respondent see?
For completed ordinary model questions and agent-direct answers, the Runner captures the question’s options before execution. Results uses this snapshot instead of resolving the template against later answers or shared state. The snapshot retains option order, matrix row order, question text and type, and option labels when present. It survives JSON and.ep save/reload.
For example, with the pairwise survey:
source="prompt" identifies the resolved question used to construct a model
prompt; source="agent_direct" identifies the question object passed to a
direct-answering method. Direct methods can receive unrendered question text;
the snapshot records that object faithfully. It does not certify what an
external human-survey UI displayed when replaying previously collected answers.
The references identify all shared-state reads available in that question’s
context, including reads inherited from an earlier question. They are not an
analysis of which fields the template used. No private state is copied into
the question metadata. A model-cache hit retains the current question’s read
references, even when another run produced the cached answer.
The presentation marker is absent for older stored answers, skipped questions,
computed/functional questions, failed tasks, and the special interview-question
execution path. Those entries retain the existing reconstructed metadata, which
must not be treated as evidence that a question was presented. Check for the
marker when auditing historical choices.
Durable state and retries
When binding a state map directly toSQLiteStateBackend, the backend records
the serialized definition fingerprint. Reopening the path with a behaviorally
different definition is an error. Databases created before fingerprints existed
require an explicit, audited adopt_legacy_definition=True; normal execution
never silently adopts them.
Write retries are content-bound. Reusing the same operation identity with the
same inputs and runtime context returns the earlier outcome. Reusing it with
different content is an error, preventing an idempotency retry from becoming a
different scientific action.
Fresh state versus resuming state
A newSharedStateMap(group_state) generates a new state ID. Reusing a saved map
preserves its ID and reconnects to its stored state. Use a new map for an
independent experiment; preserve the serialized map and its definition when
resuming one. Reusing a poll’s ID can retain earlier first-write-wins ballots.
Scope keys such as family-1 isolate groups within that map; they do not reset
its data between runs.