Skip to main content
This application combines personal choice with composition constraints. Each team needs one Designer and two Builders. Respondents choose their role, see only teams with a seat for it, and join at most one team during a single survey pass.

Build and run the complete example

Everything needed for this example is defined on this page. Use an EDSL build that includes the Machine and Runner APIs documented in this manual. Execute the following four Python blocks in order in one session, or concatenate them into one script. They require EDSL and the Python standard library; no repository example modules or external data files are needed. The scripted run makes no model API calls. The default eight-person demo fills Orion and Lyra with one Designer and two Builders each. A third Designer cannot join even while Builder seats remain. A final excess Builder is screened out before the role question because all teams are full. All six admitted respondents receive their introduction question. No model API calls are made.

1. Define the Machine

The Machine stores each respondent’s role and membership. Eligibility is a serialized expression over the live role counts, and joining rechecks that capacity.

2. Construct the Survey

These ordinary Survey gates distinguish full enrollment, role-specific availability, and successful admission. The final admitted member can still finish.

3. Define the scripted respondents

The population has three Designers followed by five Builders. Each agent chooses the first eligible team and supplies an introduction if admitted.

4. Run and inspect the answers

Model("test") supplies the Jobs model dimension. The agents above answer locally, and QuestionCompute evaluates the routing gates without a model call.

Watch the roles fill, respondent by respondent

The follow-up Python blocks use the definitions and Results created above. In this scripted population, the first three respondents choose Designer and the next five would choose Builder. Everyone selects the first team they are shown. R2 encounters a closed role, not a full study: four Builder seats are still open. R3 can therefore join Orion. R4 still sees both teams because Orion has one Builder seat left; only after R4 joins does Orion disappear for later Builders. R6 takes the final seat and still receives the introduction question. R7 stops before being asked a role. These are two different stop points in the same Survey.

Check the last seat and the two screened-out respondents

The admitted membership and the completed introduction are separate facts. Inspecting only the membership count would miss a routing mistake that stopped R6’s interview immediately after admission.

Machine policy

A study scope stores two maps: profiles records one role per respondent, and members records their chosen team and role. Each configured role has the same positive seat count in every configured team. The view derives available team IDs by counting members with the respondent’s role in each team. An existing member sees their own team even when it is full. A respondent with no profile sees no eligible options. A new join rechecks live capacity; an earlier view is not an admission guarantee. Concurrent attempts for the last role seat cannot overfill it. Membership is immutable. A changed team or role is rejected rather than silently moving someone. Completion means that all configured role seats across all teams are filled. Lacking applicants for one role can therefore leave the study incomplete even when many other applicants have been screened out.

Survey routing

The adapter uses ordinary reads, computed gates, and Survey stop rules:
  1. Stop new respondents at entry if all teams are full; let existing members resume.
  2. Ask and register the role, then read role-specific availability.
  3. Stop if there are no options or the reported role conflicts with a saved profile.
  4. Ask for a team and attempt the atomic join.
  5. Read the outcome; only an admitted member receives the introduction question.
The grouped schedule serializes the demo but does not use a schedule-wide stop_when=teams.is_complete() rule. Such a condition can become true immediately after the last join and suppress that member’s remaining questions. The entry gate prevents new admissions while allowing the last member to finish. This behavior has a dedicated end-to-end regression test and illustrates the difference between closing enrollment and stopping all remaining tasks. A race can invalidate a displayed option. The post-join gate stops the losing interview; this adapter does not implement a reselection loop. Results preserves the options actually shown, so a rejected join can still be audited against its read-version-linked presentation.

Try a population with no Builders

Population exhaustion is different from Machine completion. Reuse the adapter with only the first three scripted respondents, all Designers, and a fresh state map:
The run ends because there are no more respondents. Each team has its Designer and still needs two Builders. The Machine does not lower the role requirements, move a Designer into a Builder seat, or declare completion to accommodate the available pool. Those would be additional policies to specify explicitly.

Tests and design findings

The application tests cover role exhaustion with other seats still available, immutable profiles and teams, missing roles, explicit close, competing joins, SQLite restart/replay, isolated scopes, fresh-process serialization, changed reports across jobs, actual displayed choices, and completion of the final admitted interview. This example enforces role composition, not skill verification or interpersonal compatibility. The host supplies stable identities and authenticates actions; self-reported roles are accepted as given. There is no departure/replacement policy, waitlist, automatic relaxation of missing roles, or global matching objective. Those are distinct mechanisms to specify before extending the example. The definition is 10,516 JSON bytes; its six-member corpus replay peaks at 5,581 host budget steps per transition. The profiler reproduces these development measurements, which do not establish hosted human-survey support or a portable execution-cost bound.