agenticraft_foundation.mpst.global_types¶
Global type specification — bird's-eye view of multi-party protocols.
Global session types for multi-party choreographies.
Global types describe the overall communication structure from a bird's-eye view, specifying message exchanges between all participants.
Syntax: - p → q : M.G (Message: p sends M to q, then continue with G) - p → q : {lᵢ: Gᵢ} (Choice: p sends choice lᵢ to q, continue with Gᵢ) - μX.G (Recursion: recursive type bound to X) - X (Variable: recursion variable reference) - end (End: successful termination)
References: - Honda, Yoshida, Carbone (2008) - Multiparty Session Types
EndType
dataclass
¶
Bases: SessionType
End type: Successful session termination.
Represents the end of a session with no further communication. Written as 'end' in session type notation.
MessageType
dataclass
¶
Bases: SessionType
Message type: p → q : M.G
Represents a single message from sender to receiver, followed by a continuation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
sender |
Sending participant p
TYPE:
|
receiver |
Receiving participant q
TYPE:
|
payload |
Message payload M
TYPE:
|
continuation |
Continuation type G
TYPE:
|
ChoiceType
dataclass
¶
Bases: SessionType
Choice type: p → q : {lᵢ: Gᵢ}
Represents a branching choice where sender selects a label and both parties continue with the corresponding branch.
| ATTRIBUTE | DESCRIPTION |
|---|---|
sender |
Participant making the choice p
TYPE:
|
receiver |
Participant receiving the choice q
TYPE:
|
branches |
Mapping from labels to continuation types
TYPE:
|
RecursionType
dataclass
¶
Bases: SessionType
Recursion type: μX.G
Represents a recursive session type where variable X is bound in the body G.
| ATTRIBUTE | DESCRIPTION |
|---|---|
variable |
Recursion variable name X
TYPE:
|
body |
Body of the recursion G
TYPE:
|
unfold_once()
¶
Unfold one level of recursion.
Returns the body with the variable replaced by self.
VariableType
dataclass
¶
Bases: SessionType
Variable type: X
Represents a recursion variable reference.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Variable name
TYPE:
|
ParallelType
dataclass
¶
Bases: SessionType
Parallel composition: G₁ | G₂
Represents parallel execution of two independent sessions. Participants of G₁ and G₂ should be disjoint.
| ATTRIBUTE | DESCRIPTION |
|---|---|
left |
Left session type G₁
TYPE:
|
right |
Right session type G₂
TYPE:
|
msg(sender, receiver, label, continuation=None, payload_type='any')
¶
Convenience constructor for MessageType.
| PARAMETER | DESCRIPTION |
|---|---|
sender
|
Sending participant
TYPE:
|
receiver
|
Receiving participant
TYPE:
|
label
|
Message label
TYPE:
|
continuation
|
Continuation type (default: EndType)
TYPE:
|
payload_type
|
Type of payload
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MessageType
|
MessageType instance |
Example
Client → Server : Request. Server → Client : Response. end¶
msg("client", "server", "request", msg("server", "client", "response"))
choice(sender, receiver, branches)
¶
Convenience constructor for ChoiceType.
| PARAMETER | DESCRIPTION |
|---|---|
sender
|
Participant making the choice
TYPE:
|
receiver
|
Participant receiving the choice
TYPE:
|
branches
|
Mapping from label strings to continuation types
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ChoiceType
|
ChoiceType instance |
Example
choice("client", "server", { "buy": msg("server", "client", "confirm"), "cancel": msg("server", "client", "cancelled"), })
rec(variable, body)
¶
Convenience constructor for RecursionType.
| PARAMETER | DESCRIPTION |
|---|---|
variable
|
Recursion variable name
TYPE:
|
body
|
Body of the recursion
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RecursionType
|
RecursionType instance |
Example
μX. Client → Server : Request. Server → Client : Response. X¶
rec("X", msg("client", "server", "request", msg("server", "client", "response", var("X"))))
var(name)
¶
Convenience constructor for VariableType.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Variable name
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
VariableType
|
VariableType instance |
parallel(left, right)
¶
Convenience constructor for ParallelType.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
Left session type
TYPE:
|
right
|
Right session type
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ParallelType
|
ParallelType instance |