This is the canonical shared-state manual. The API is experimental. Read the execution contracts for current persistence, visibility, and compatibility guarantees.
The mental model
A shared-state system has four distinct layers:family-1 might contain a poll and a message board.
A SharedStateMap maps scope keys such as family-1 and family-2 to
independent SharedState spaces.
A store persists spaces while interviews execute. It may be managed locally
or remotely. Storage is separate from the data definitions.
We will build these layers in that order.
Example: choosing an activity
Four people will choose among:Manual chapters
- Machines, commands, and views — Define fields, atomic transitions, requirements, and participant-visible views.
- Testing and serialization — Test a machine without a survey and preserve its definition as versioned JSON.
- Scopes, surveys, and execution — Bind machines to groups, order interviews, and inspect persistent state provenance.
- Collections and lifecycle — Build logs, derive collection views, and distinguish completion from closing.
- Shared-state pattern cookbook — Adapt complete patterns for ballots, markets, private signals, task pools, and payoffs.
- Randomization and exact money — Reproduce keyed draws and tie-breaking, and settle integer units with explicit rounding.
- Survey quotas and screening — Ask respondent type, reserve ten A and ten B places, and end screened-out interviews.
- Adaptive reason discovery — Grow a reason list through Other responses and stop after ten quiet agents.
- Adaptive question coverage — Assign up to three under-covered questions per agent and stop at ten valid answers per question.
- Adaptive pairwise comparisons — Compare products, update scores, and select later pairs using those scores and exploration.
- Appointment booking — Hold, confirm, and release slots with durable reservation identities.
- Adaptive price elicitation — Narrow a personal integer price interval within one survey pass.
- Balanced experimental assignment — Balance several characteristics while assigning conditions atomically.
- Team formation — Let respondents choose teams while enforcing role-specific capacity.
- Second-price auction — Collect sealed bids and settle one unit.
- Uniform-price auction — Allocate multiple units and settle at the highest rejected bid.
- Posted-price market — Sell inventory using versioned quotes and atomic payment.
- Primitive examples and validation — Build and replay nineteen mechanisms from general Machine primitives, with a record of design limitations.
