CBCL / DocumentationDocs v0.3.1

Protocols and roles

A protocol describes the predecessors that permit each verb. The receiver checks the addresses in the message against acts in the same thread.

StepMeaning
(then begin open)Permit an opening step.
(then open review close)Add two edges. A review follows an open. A close follows a review.
(then (any accept refuse) record)A record can follow either named predecessor.
(then (all inspect approve) release)The receiver must have evidence from the two predecessors before release.
(then begin (repeat 3 tick))Permit three positions for the verb along a causal chain.

A protocol can contain one or more then clauses. Each clause has two or more steps. An any or all group has two or more members.

A repeat has a positive integer count and a nonempty body. It can contain nested repeats. The parser expands a repeat within a finite budget. The wire message uses the original verb name at each position.

On this page

Use any to record a decision

A reviewer can accept or refuse a request. Either response permits a record.

(define request-review (cbcl) @team
  (extend open (to) (tell to))
  (extend accept (to) (tell to))
  (extend refuse (to) (tell to))
  (extend record (to) (tell to))
  (protocol
    (then begin open (any accept refuse))
    (then (any accept refuse) record)))

For example, Alice opens a request. Bob refuses it. Alice can record the decision with Bob’s refusal as its predecessor. She does not need an acceptance. The opening act alone does not permit a record.

Use all to release a shipment

A shipment needs two checks. One checks the label. The other checks the seal.

(define shipment-check (cbcl) @team
  (extend open (to) (tell to))
  (extend check-label (to) (tell to))
  (extend check-seal (to) (tell to))
  (extend release (to) (tell to))
  (protocol
    (then begin open)
    (then open check-label)
    (then open check-seal)
    (then (all check-label check-seal) release)))

Both checks can follow the same opening act. They can occur in either order. The release must cite both checks. If the receiver gets the release before it gets the cited seal check, it must wait for that evidence.

Roles and recipients

(define review-request (cbcl) @team
  (:roles (chair (* reviewer)))
  (extend open (to) :from chair :to (chair reviewer) (tell to))
  (extend review (to) :from reviewer :to chair (tell to))
  (protocol (then begin open review)))

The role chair has one key. The indexed role (* reviewer) has one or more keys. The sender annotation names one role. The recipient annotation names a role or a list of roles. The thread root binds those roles to keys with with-roles. For example, the cast could contain ((chair @alice) (reviewer @bob @carol)).

The receiver checks the authenticated signer against the cast. For an indexed-role join, it also checks the required participants. Two messages from one participant cannot establish participation by two distinct keys.

Local evidence

The default locality mode is (:causal-locality reject). The installer checks the evidence routes for each endpoint. With (:causal-locality derive), the installer can derive routes for more header evidence. The header can identify a predecessor without its payload. Some completion checks use only full acts.

A missing predecessor can leave an act pending. A known predecessor of the wrong type can cause rejection. An accepted act can affect the fields in the state clause. See Annotated dialects for repeat positions and role-scoped edits.