Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Bombay Behavior core type inventory

Scope

This document inventories the types exported at the root of the bombay-behavior crate (behavior in Rust source). The authority for the list is crates/behavior/src/lib.rs; semantic descriptions are taken from the defining modules in crates/behavior/src. It describes the current source surface, not a proposed redesign.

The inventory includes public traits, structs, enums, and type aliases. It also identifies the crate's public functions and #[behavior] macro because they construct or consume the types. It excludes private module items, test-only fixtures, and downstream types generated in a user's crate except for a separate description of the macro-generated family.

Some root exports are marked #[doc(hidden)]. They remain listed because they are publicly nameable implementation contracts, but ordinary behavior authors should not treat them as the preferred API.

Semantic center

The central relationship is:

Protocol = address namespace × public message type

Behavior = protocol
         × complete event algebra
         × send product
         × birth algebra
         × phase menu
         × controlled error

BehaviorActed<B>
    = Result<
          Actions<BehaviorAddr<B>, B::Ph, B::Sends, B::Birth>,
          B::Error,
      >

Actions = sends
        × ordered staged fresh creations
        × (Continue | Goto(phase) | Stop(Stopped))

Protocol is stable public communication identity. Behavior is the concrete stateful fold implementing that protocol. They are deliberately separate: recipients and deliveries do not recursively carry a destination behavior's sends, births, phases, or errors.

Actions is Bombay's typed realization of actor-transition effects. It is not described as a literal Agha effect triple: the Rust surface additionally owns typed send products, creator-local child routing, phases, controlled errors, termination, initialization effects, and Bombay interpretation ordering.

Protocol, behavior, and transition types

TypeKindSemantic role
ProtocolTraitAssociates one stable public actor identity with Addr: Address and Msg. It is independent of transition implementation.
MessageProtocol<A, M>Zero-state structReusable nominal-free protocol signature for address type A and message type M.
BehaviorTraitPure initialized fold from one complete typed event to BehaviorActed<Self>. Associated types expose protocol, event, sends, phases, controlled error, and birth capability.
BehaviorActed<B>Type aliasExact controlled result type of behavior B: Acted<BehaviorAddr<B>, B::Ph, B::Sends, B::Birth, B::Error>.
BehaviorAddr<B>Type aliasProjects the address namespace from B::Protocol.
BehaviorMessage<B>Type aliasProjects the public message type from B::Protocol.
InitializationTurnNon-constructible structPrevents direct caller fabrication; trusted public composition ports can issue it repeatedly, while the consuming Activate path enforces one initialization for its owned definition.
ActiveTurnNon-constructible structLifecycle- or composition-issued authority to invoke one active transition.
BehaviorLayer<B>TraitStatically constructs one fully concrete behavior from another; closures implement it without trait objects or effects.
BehaviorBaseTraitProjects a composed wrapper to its authored base behavior without exposing wrapper depth.
LogicalHostRequirementsTraitDerives the ordered, duplicate-preserving logical protocol hosts required by a behavior's sends and transitive births. It is static evidence, not allocation.

The associated type equation of Behavior is:

Behavior {
    Protocol: Protocol
    Event: UserEvent<Addr = BehaviorAddr<Self>,
                     Message = BehaviorMessage<Self>>
    Sends: SendEffects + SendsFor<Event>
    Ph
    Error
    Birth: BirthMode
}

Next-state and action types

TypeKindSemantic role
NeverUninhabited enumProves absence. It is used for no phase transitions, impossible events, and empty closed sums.
StoppedUnit structPayload-free normal behavior-termination marker. Lifecycle provenance belongs in typed protocols, not this seat.
Step<Ph, R>EnumExhaustive next verdict: Continue, Goto(Ph), or Stop(R).
Become<Ph>Type aliasBehavior next verdict, fixed to Step<Ph, Stopped>.
Actions<A, Ph, Sends, Birth>StructExplicit transition product with named sends, ordered creates, and become_ legs. The interpreter commits creations before same-action sends that may depend on them.
Acted<A, Ph, Sends, Birth, E>Type aliasResult<Actions<A, Ph, Sends, Birth>, E>.
AppendSend<Input, Path>TraitAppends one input to a statically selected send lane while preserving creation and next-state legs.

Actions constructors (cont, stop, goto, send, and create) construct values only. They do not interpret sends, allocate actors, change runtime state, or perform lifecycle work.

Addressing and installed-capability types

TypeKindSemantic role
AddressTraitDefines a pure logical address namespace and its creator-local Nonce. A nonce is correlation, not address or freshness proof.
MailAddrNewtype structBuilt-in u64 logical address whose nonce is also u64.
EndpointAddressTraitRuntime-owned projection from a logical address namespace and protocol to an exact endpoint representation.
Recipient<P>StructPure logical destination for protocol P; proves protocol/address/message agreement but not installation.
EstablishedRecipient<P>StructInert runtime-issued capability for one exact installed incarnation of protocol P. Its endpoint is not directly exposed.
InterpretEstablished<P>TraitExplicit power-user boundary that consumes an established recipient's exact endpoint.
EstablishedActor<B>StructExact installed capability that preserves both the public recipient and the concrete installed behavior type B.
Delivery<P>StructPure logical communication containing Recipient<P> and P::Msg.
EstablishedDelivery<P>StructPure communication to one exact EstablishedRecipient<P> without logical-address resolution.

The capability strength increases from logical naming to installed evidence:

Recipient<P>
    logical protocol destination

EstablishedRecipient<P>
    exact installed endpoint for P

EstablishedActor<B>
    exact installed endpoint for B::Protocol
    + static proof of concrete behavior B

None of these values has an ambient send, shutdown, allocation, or lookup method. Effects cross explicit interpreter traits.

Event and ingress types

TypeKindSemantic role
User<A, M>StructBase public user-message event with from: A and message: M.
UserEventTraitConstructs and extracts the public User lane through a complete composed event algebra.
EventLayer<Owned, Inner>EnumConcrete coproduct `Owned(Owned)
ComposedEventTraitIdentifies an event algebra's inner event and its structure-preserving injection.
EventIngress<Source, Input>TraitOwner-selected construction of one input lane without caller-visible wrapper paths.
ChildInputIngress<Source, Input>TraitConstructs a private parent-to-child input in the concrete child's event algebra.
InjectEvent<Input, Path>TraitLow-level path-indexed injection into a structural event coproduct.
Ingress<Input, Path>Zero-state structAddress-free capability selecting one exact interpreter-return ingress member.
HereUnit structCompile-time path selecting the current event or send layer.
Inside<Path>Zero-state structCompile-time path selecting an inner layer.

Here and Inside<Path> are structural proof types, not runtime routing addresses. Ordinary composed templates should prefer semantic EventIngress<Source, Input> implementations so callers do not count wrapper depth.

Send products and interpretation types

Send-product algebra

TypeKindSemantic role
SendEffectsTraitClosed value algebra with empty, ordered append, and statically selected lane emission.
SendsFor<Event>Marker traitProves that a send product's returning interpreter requests are lawful for the exact complete event algebra.
SendInput<Input, Path>TraitSelects one request lane at compile time and emits into it.
OwnUninhabited marker enumSelects a named send product's own semantic lane.
NoSendsUnit structNamed empty send product.
SendLayer<Owned, Inner>StructNamed product of wrapper-owned and inner send effects. Interpretation preserves inner-to-outer authored order.
LogicalDeliveryProtocolsTraitProjects possible logical recipients from a send product while preserving order and duplicates.
InterpreterRequestTraitDeclares a request's emitter continuation and its possible logical recipient protocols.
InterpreterRequests<M>StructOrdered send lane of runtime-local requests with no actor address.
NoReturnToEmitterUninhabited enumDeclares that an interpreter request produces no later local event.
ReturnsToEmitter<Input, Path>Zero-state structDeclares a later local event of Input at a compile-time event path.
ReportToParent<R>StructTransfers an owned report through the established creator/child relationship; the interpreter attaches the exact occurrence-local creation ID.

The crate supplies SendEffects/interpretation implementations for selected Vec<T> lanes, including logical deliveries, established deliveries, creator-local child deliveries and inputs, and Vec<Never>. A general Vec<T> is a send value container, but only statically supported effect kinds receive interpreter meaning.

Interpreter capabilities

TypeKindSemantic role
ActionItemTraitFixes one action item's accepted receipt, rejection, and prerequisite types for every runtime.
ItemSettlement<Item, Accepted, Rejection, Prerequisite>EnumConserves one attempted item across acceptance, rejection, prerequisite blocking, and interpreter corruption.
SettledItem<Item, Settlement>EnumDistinguishes an attempted item from an untouched item after earlier corruption.
Interpretation<Settlement>EnumOwns the complete product after successful traversal or corruption.
SendSettlementsTraitProjects one concrete sends product to its runtime-independent settlement product.
ActionSettlementsTraitProjects one concrete Actions product to its complete creation-and-send settlement.
BehaviorSettlementsTraitBlanket projection from a concrete behavior to that exact action-settlement type without restating internal birth or send bounds.
InterpretItem<Item, RootEvent, Path>TraitLets one concrete runtime attempt exactly one statically selected action item.
InterpretSends<Interpreter, RootEvent, Path>TraitExhaustively interprets one complete send product in structural order.
SourceSettlementCustody<Host, RootEvent>TraitOffers at most one emitter-return settlement input in declared order while retaining the exact residual product.
SourceCustody<Residual>EnumDistinguishes an exhausted product, exactly one admitted input, and closed admission with complete residual ownership.

These are statically dispatched interpreter obligations. A composite send product cannot silently omit a lane: the concrete interpreter must implement every required capability or fail to compile. Source custody uses the same declared order, but returns after one successful admission so the runtime can process that input and all transitive effects before offering the next one.

Staged creation and lifecycle result types

Creation values and outcomes

TypeKindSemantic role
CreationIdNewtype structOpaque correlation within one statically declared child occurrence; it is not an address, route, identity, or provenance.
CreationSequenceStructChecked source of non-reused IDs. Retaining one per occurrence is sufficient; one owner may share a sequence across several occurrences for a stronger guarantee.
CreationKindEnumBehavior-owned intent: ordinary Birth or fresh Replacement { previous }.
CreateChild<A, New>StructPure staged request containing a creation ID, owned child behavior, and creation intent.
Creations<Item>StructOne ordered creation batch. Runtime route preparation accepts the whole batch or returns it untouched.
RoutedCreation<A, New>Hidden structInterpreter-private pairing of a complete creation with its selected runtime route.
AllocationRejectionEnumTyped fresh-address failures: exhaustion or already-claimed proposed address.
ChildNamespaceExhaustedStructThe interpreter cannot route the complete declared creation batch without partial route consumption.
CreationRejectionEnumComplete rejected-child reasons after routing: allocation, initialization, or environment/commit failure.
CommittedChild<C, Occurrence>StructOne committed child's ID, creation kind, occurrence, and exact installed C actor.
EstablishedCreation<C, Occurrence>EnumNamed Installed(CommittedChild) or Rejected result for one concrete child occurrence.
ObserveCreation<P, Occurrence>StructSame-action request for the exact protocol/occurrence creation result; returns CreationResolved<P::Addr> and depends on CreationCorrelation<P, Occurrence>.
ChildDelivery<P, Occurrence>StructSame-action public-protocol delivery to a declared creator-local child occurrence.
ChildInput<Child, Source, Input, Occurrence>StructPrivate typed input to a concrete declared child event lane.
ChildReport<R>StructParent event payload containing the interpreter-attached creation ID and owned report.

Creation is staged, not performed by CreateChild. Behavior issues a CreationId and emits the child in the same transition. Exact correlation is the static child occurrence together with that ID. Independent layers may use equal numeric IDs for distinct occurrences; reuse within one occurrence remains invalid. The interpreter privately selects routes for the complete Creations batch before it hosts any child. A creation becomes established only after fresh allocation, initialization, installation, commit, and binding. Behavior never constructs or stores a runtime route.

Heterogeneous creation products

TypeKindSemantic role
Children<A, Product>StructBuilder for a pure ordered heterogeneous product of staged direct-child creations.
NoChildrenUnit structEmpty heterogeneous creation product.
ChildCons<A, C, Earlier>StructOne creation appended to an earlier heterogeneous product.
ChildProduct<A>TraitSealed recursive conversion from Children's product into one ordered Creations batch over a closed child choice.

Each Children::child or Children::create call adds one new structural child occurrence, so conversion into Creations is total. Equal IDs in distinct occurrences remain distinct correlations. Runtime route exhaustion returns the entire batch through ChildNamespaceExhausted.

Closed birth and topology type algebra

Birth capability and child sums

TypeKindSemantic role
BirthModeTraitAssociates a behavior with its closed child type algebra.
NoBirthsUnit structBirth mode whose child algebra is Never.
Births<C>Zero-state structBirth mode admitting closed child algebra C.
ChildChoice<Head, Tail>EnumClosed recursive heterogeneous sum of concrete child behaviors.
ChildHeadUnit structStructural position selecting a sum's head.
ChildTail<Position>Zero-state structStructural position selecting inside a sum's tail.
ChildPosition<Children, Child>Sealed proof traitProves that an exact child behavior occupies an exact structural position.
BirthNodeAppend<Tail>Sealed composition traitAppends one closed direct-child algebra after another while preserving existing positions and creation order.
BirthNodeAt<Position>Hidden sealed traitInverse projection from a structural position to its child type.

ChildChoice is a creation-only sum, not a message envelope, behavior trait object, registry, or runtime dispatcher.

Nominal child roles and occurrence resolution

TypeKindSemantic role
ChildRole<Parent>TraitAuthored proof that one nominal role names one exact direct child and structural position of Parent.
ChildOccurrence<Parent>TraitDeclares the sealed descriptor used to resolve one nominal or raw structural occurrence.
DeclaredChildOccurrenceHidden unit structDescriptor for an authored nominal child role.
StructuralChildOccurrence<Position>Hidden zero-state structDescriptor for a raw structural child position.
ChildOccurrenceResolution<Parent, Occurrence>Hidden sealed traitRestricts which descriptor may resolve a given occurrence.
ResolveChildOccurrence<Occurrence>Sealed traitResolves an occurrence against the concrete emitter, following topology-transparent BehaviorBase wrappers lawfully.
ResolvedChild<Emitter, Occurrence>Type aliasProjects the exact resolved child behavior.
ResolvedChildPosition<Emitter, Occurrence>Type aliasProjects the exact resolved structural birth position.
RoleChild<Parent, Role>Type aliasProjects the child behavior selected by one nominal role.
RoleProtocol<Parent, Role>Type aliasProjects the canonical protocol of a role-selected child.

Nominal roles distinguish duplicate occurrences even when they contain the same child behavior. A role and its structural position are topology evidence, not protocol identity, actor identity, or runtime lookup keys.

Interpreter dispatch and child occurrence products

TypeKindSemantic role
ChildCreationOutcome<C, Occurrence>EnumEstablished child, initialization rejection retaining child/error, caught pure-fold panic retaining the extant child, or host rejection retaining child/uninterpreted initialization actions/reason.
EstablishChild<Occurrence, C>TraitConcrete interpreter ownership port returning the fixed ChildCreationOutcome result for C at one exact occurrence.
ChildCreationProduct<A, Occurrence>Hidden traitRuntime-independent result product for a closed creation-only child sum.
DispatchBirth<A, Host>TraitExhaustive static dispatch over one closed creation-only child sum.
ChildOccurrenceShapeTraitDownstream type constructor defining empty and per-child representations for a direct-child occurrence product.
ChildOccurrenceProduct<Shape>Sealed traitSelects a shape-owned static representation for a closed direct-child algebra.
ChildOccurrences<Children, Shape>Type aliasOccurrence-preserving representation selected by one child shape.

These types let an interpreter prove support for every child alternative at compile time. They do not perform runtime protocol lookup or erase the child behavior type.

Protocol and host projections

TypeKindSemantic role
NoBirthProtocolsUnit structEmpty projected protocol product.
BirthProtocol<P, Tail>Zero-state structOne protocol occurrence followed by a remaining projected product.
BirthProtocolHeadUnit structStructural position selecting the current projected protocol.
BirthProtocolTail<Position>Zero-state structStructural position selecting inside the remaining protocol projection.
BirthProtocolAt<P, Position>Marker traitStatic membership evidence for one protocol occurrence.
BirthProtocolProductHidden traitClosed append operation over protocol products.
BirthProtocolsTraitProjects a behavior's own protocol and every protocol reachable through transitive births.
BirthNodeProtocolsHidden traitRecursively projects protocols from one closed birth node.
BirthNodeLogicalHostsHidden traitRecursively projects logical host requirements from one closed birth node.

Protocol products preserve repeated occurrences. They are static evidence and perform no allocation, hosting, normalization, or runtime lookup.

Finite sequence observation

The Behavior crate exposes no mailbox reducer or finite-stream result. Its contract ends at one initialization or event transition and the resulting Actions. Runtime scheduling belongs to Bombay. Repository tests use behavior_testkit::drive, whose Trace preserves the final active behavior, ordered sends and creations, initialization-inclusive transition count, pending mailbox suffix, and an exhaustive DriveDisposition distinguishing a drained mailbox from BehaviorStopped(Stopped).

Public companion operations

ItemKindRole
initializeHidden functionCanonical wrapper boundary invoking one inner initialization fold and returning its complete actions unchanged.
delegate_transitionHidden functionCanonical wrapper boundary invoking one inner event fold and returning its complete actions unchanged.
behaviorAttribute macroGenerates the mechanical Protocol, Behavior, BehaviorBase, closed send product, and closed birth-role wiring for an inherent impl.

For an actor named Actor, the macro may generate these concrete types when the corresponding declarations exist:

ActorSends
ActorSends<Field>                 one uninhabited selector per send lane
ActorActions                     fluent action-extension trait
ActorChildren                    closed ChildChoice alias
ActorChildren<Field>             one nominal role type per child declaration
ActorChild                       namespace containing role values

The exact generated Rust names preserve the actor and authored field names. The macro does not create actors, interpret effects, introduce a dynamic envelope, or grant capabilities absent from the handwritten core types.

Boundary summary

The crate intentionally stops at the pure algebra and minimal typed interpreter contracts:

  • Behavior consumes one event and returns Actions.
  • Actions owns sends, staged fresh creations, and next behavior or stop.
  • event, send, and birth products are concrete closed sums/products;
  • recipients distinguish logical identity from exact installed capability;
  • creation IDs remain creator-local correlation rather than actor identity;
  • interpreter traits realize typed effects without dynamic dispatch; and
  • reducers observe folds without becoming a scheduler or runtime.

Scheduling, mailbox transport, clocks, endpoint allocation, installation, effect settlement, and actor execution remain interpreter responsibilities.