CBCL / DocumentationDocs v0.3.1

How a thread becomes state

The host checks the poll definition. The receiver checks each vote. The state rules calculate the tally from the accepted votes.

For an introduction to the terms used here, start with What is CBCL?.

On this page

The stratified admission pipeline

Install the dialect once. The host checks the poll definition and installs it. This gives the receiver the rules for each vote in the poll.

  1. Recognise. Bob sends a vote for Sushi. The receiver reads the message with the installed dialect. It recognises the vote verb and its arguments.
  2. Record. The host verifies Bob’s signature and keeps the authenticated act. Bob’s vote cites Alice’s proposal. The host can keep the vote even if the proposal has yet to arrive.
  3. Admit. The receiver checks the shape of the vote, the authority of the signer, and the cited proposal. While the proposal is missing, the vote is pending. When the proposal arrives and the checks pass, the receiver accepts the vote.
  4. Interpret. The proposal offers Sushi and Pizza. Sushi is an eligible choice, so Bob’s vote can contribute to his current ballot. An accepted act that names a choice outside the poll options contributes nothing to the tally.
  5. Observe. The application reads the tally. If Bob has the only ballot, Sushi has one vote. If Bob later changes his ballot to Pizza, the next read shows one vote for Pizza.

Adapted from Figure 3 in Hugo O’Connor’s A Language for Composing Multi-Agent Protocols (p. 15).

Read the result

The tally is a snapshot. Later votes can change it. A dialect can also define a threshold that records when a condition is reached, or a causal freeze that reads a field at a specified point in the thread. See State language for dialect authors for examples of each read.

Keep the accepted acts with their authenticated signer identities. The host uses these records to calculate the projection again. If a verb uses a clock, the host keeps the clock value for each signer across restarts.

Run Count a vote to see the accepted history produce a tally.

Protocol reference

Use the state language reference to select state rules and check their arguments. The canonical encoding reference explains how hosts derive addresses for acts and dialects.