Skip to main content

behavior_actors/
lib.rs

1//! Reusable, pure actors and behavior compositions built on [`mod@behavior`].
2//!
3//! The public taxonomy follows actor-system semantics: [`atomic`], [`composition`],
4//! [`lifecycle`], [`routing`], [`discovery`], [`time`],
5//! [`persistence`], [`workflow`], and [`operations`]. Every template is a
6//! deterministic fold from one concrete event sum to explicit typed
7//! [`behavior::Actions`]. It performs no scheduling, delivery, allocation, observation,
8//! persistence, or I/O itself. Those effects remain inputs and named output
9//! lanes for Bombay's one universal Driver and statically selected Environment
10//! interpreters.
11//!
12//! Public [`behavior::Protocol`] identity remains orthogonal to those internal event and
13//! effect algebras. Concrete actor templates declare their protocol; transparent
14//! wrappers preserve `B::Protocol` and do not become new recipient identities.
15//! [`behavior::BirthProtocols`] projects each template's own protocol and
16//! complete transitive staged-birth protocols into one closed structural
17//! product. Delivery-only external protocols do not enter that product.
18//! [`behavior::LogicalHostRequirements`] separately derives every intentional logical
19//! destination from the concrete sends algebra and every transitive birth.
20//! The projection preserves repeated occurrences and excludes exact,
21//! creator-local, and interpreter-owned lanes; it is static proof metadata,
22//! not a host registry or runtime lookup.
23//!
24//! Catalogue values and wrappers are constructed directly through their public
25//! owning-type constructors. [`Activate`] consumes any concrete definition
26//! into its one initialized [`Active`] state. Rust can infer wrapper stacks at
27//! construction and spawn call sites; applications do not need to name types
28//! such as `Deadline<Stash<Machine<...>>>`.
29//! Correctness-sensitive cross-family orders use ordinary typed nesting and
30//! actor communication. The repository's composition guide records their
31//! construction, error, initialization, and effect-preservation laws.
32//!
33//! The top-level Bombay package is the ordinary application façade. Direct use
34//! of this component crate is intended for interpreter implementation,
35//! component tests, and advanced framework extension.
36//!
37//! Timer wrappers expose their shared event and reaction equations directly;
38//! template-specific aliases do not create nominal distinctions.
39//!
40//! ```
41//! fn accepts_timer_reactions<B: behavior::Behavior>(
42//!     _: behavior_actors::TimedReaction<B>,
43//!     _: behavior_actors::DeadlineReaction<B>,
44//! ) {
45//! }
46//! ```
47//!
48//! Foundational algebra stays owned by the `bombay-behavior` package.
49//!
50//! ```compile_fail,E0425
51//! fn unavailable(_: behavior_actors::Actions<
52//!     behavior::MailAddr,
53//!     behavior::Never,
54//!     behavior::NoSends,
55//!     behavior::NoBirths,
56//! >) {}
57//! ```
58
59mod activation;
60pub mod atomic;
61pub mod composition;
62pub mod discovery;
63pub mod lifecycle;
64mod machine;
65pub mod operations;
66pub mod persistence;
67mod protocol;
68mod requirements;
69pub mod routing;
70mod shutdown;
71mod stash;
72mod termination;
73pub mod time;
74mod watch;
75pub mod workflow;
76
77pub use activation::{Activate, Active, Initialized};
78pub(crate) use atomic::{
79    ActivationPlan, ActorDrainPolicy, DiagnosticAction, DiagnosticDisposition, DiagnosticRoute,
80    InitialWorkerOutcome, InterruptedWorker, ProxyDrain, ProxyInputReceipt, ProxyInputResult,
81    ProxyOperation, ProxyOperationId, ProxyOutcome, ProxyPhase, ReplacementOutcome,
82    RestartReleaseFailure, StableProxy, WorkerAttempt, WorkerChange, WorkerCreationRejection,
83    WorkerStartResult, WorkerSubmission,
84};
85pub use composition::{
86    DeliveryRoute, MessageAdapter, MessageAdapterWithRoute, ReplyDeliveries, ReplyDelivery,
87    ReplyRoute,
88};
89pub use discovery::{
90    Presence, PresenceEntry, PresenceError, PresenceMessage, PresenceOutcome, PresencePhase,
91    PresenceReply, PresenceReport, PresenceSends, PresenceVersion, PubSub, PubSubError,
92    PubSubMessage, Registry, RegistryError, RegistryMessage, RegistryResult, Resolution, Resolver,
93    ResolverConfigError, ResolverMessage, Topic, TopicError, TopicMembership, TopicMessage,
94};
95pub use lifecycle::{
96    BeginShutdownPhases, ChildCreationExpectation, ChildShutdownPhases, ChildShutdownPlanError,
97    ChildTermination, DeclareShutdownPhase, EstablishedTerminationMonitor,
98    EstablishedTerminationReaction, EstablishedTerminationTarget, FinishShutdownPhases,
99    HeterogeneousShutdownCoordinator, HeterogeneousShutdownPlan, HeterogeneousShutdownSends,
100    InstallShutdownPlan, LogicalTerminationTarget, NoShutdownTargets, PeerTermination,
101    PropagateTermination, ReportShutdownPlan, ShutdownChoice, ShutdownCoordinator,
102    ShutdownCoordinatorError, ShutdownCoordinatorEvent, ShutdownPlan, ShutdownPlanError,
103    ShutdownState, ShutdownTargetAt, ShutdownTree, ShutdownTreeError, Task, TaskError, TaskMessage,
104    TaskResult, TaskState, TerminalDisposition, TerminalPropagationPolicy,
105    TerminalPropagationSends, TerminalPropagationState, TerminationMonitor,
106    TerminationMonitorError, TerminationMonitorWith, TerminationObservation,
107    TerminationObservationTarget, TerminationPropagationError, TerminationReaction,
108    TerminationTarget, propagate_abnormal, propagate_all, shutdown_after_children, shutdown_target,
109};
110pub use machine::{Machine, MachineError, Move};
111pub use operations::{
112    ComponentHealth, ComponentHealthState, Configuration, ConfigurationError, ConfigurationMessage,
113    ConfigurationState, ConfigurationVersion, DependencyReadiness, Feature, FeatureSet,
114    FeatureStatus, Health, HealthError, HealthEvidence, HealthMessage, HealthReport, HealthStatus,
115    ObservationVersion, Readiness, ReadinessError, ReadinessEvidence, ReadinessMessage,
116    ReadinessReport, ReadinessStatus,
117};
118pub use persistence::{
119    Cache, CacheConfigError, CacheConfiguration, CacheEntry, CacheMessage, CacheResult, CacheState,
120};
121pub use protocol::{
122    CancelObservation, ChildShutdownRejected, ChildShutdownRejection, ChildStopped,
123    CreationResolved, EstablishedChild, EstablishedObservation, EstablishedShutdownResolved,
124    InterpretEstablishedObservation, InterpretEstablishedShutdown, ObservationAuthority,
125    ObservationId, ObservationOperation, ObservationRejection, ObservationRelationship,
126    ObserveChild, ObserveCreation, ObserveEstablished, ObserveEstablishedCreation, ObservePeer,
127    PeerObservationRejection, PeerStopped, ScheduleAfter, ScheduleAfterRejection, ScheduleAt,
128    ScheduleAtRejection, ShutdownChild, ShutdownEstablished, ShutdownId, ShutdownRejection,
129    ShutdownRequested, TimerElapsed, TimerGeneration, TimerId, TimerScheduled, UnwatchPeer,
130    established_child,
131};
132pub use routing::{
133    AcknowledgementError, AcknowledgementInput, AcknowledgementMessage, AcknowledgementOutcome,
134    AcknowledgementRecord, AcknowledgementState, Acknowledgements, BreakerAttempt,
135    BreakerCompletion, BreakerConfigError, BreakerError, BreakerMessage, BreakerOutcome,
136    BreakerPhase, BreakerRejection, BreakerSends, Buffer, BufferConfigError, BufferConfiguration,
137    BufferMessage, BufferOutcome, BufferRejection, BufferState, Buffered, CircuitBreaker,
138    ClosedPhase, ConsistentHash, CorrelationResult, CorrelationState, Correlator, CorrelatorError,
139    CorrelatorMessage, Deduplicator, DeduplicatorConfigError, DeduplicatorMessage,
140    DeduplicatorOutcome, DeduplicatorState, DeliveryOutcomes, LeastLoaded, Load, LoadEvidence,
141    LoadObservation, LoadVersion, MemberEvidenceError, MemberToken, MemberTokenEvidence,
142    MemberTokenObservation, MemberTokenVersion, OrderGate, OrderGateMessage, OrderGateOutcome,
143    OrderGateState, OverflowPolicy, PriorityQueue, PriorityQueueConfigError, PriorityQueueMessage,
144    PriorityQueueOutcome, PriorityQueueRejection, PriorityQueueState, ProbePhase,
145    RateLimitRejection, RateLimiter, RateLimiterConfigError, RateLimiterMessage,
146    RateLimiterOutcome, RateLimiterState, RendezvousHash, RoundRobin, RouteKey, Router,
147    RouterError, RouterMessage, RoutingObservationRejection, RoutingStrategy, Sequence, Sequencer,
148    SequencerMessage, SequencerOutcome, SequencerState, TokenCount, WorkQueue, WorkQueueMessage,
149    WorkQueueOutcome, WorkQueueRejection, WorkQueueSends, WorkQueueState,
150};
151pub use shutdown::{FinalizeOnShutdown, ShutdownEvent, ShutdownReaction, StopOnShutdown};
152pub use stash::{Stash, StashRoute, StashStatus, StaticallyInfallible};
153pub use termination::{
154    Crash, Exit, ReportTerminalOutcome, RestartDenial, SupervisionFailureReason, TerminalOutcome,
155};
156pub use time::{
157    Deadline, DeadlineReaction, Lease, LeaseMessage, LeaseOutcome, LeaseRejection, LeaseRequest,
158    LeaseSends, LeaseState, OneShot, Periodic, ReceiveTimeout, TimedEvent, TimedReaction,
159};
160pub use watch::{LinkReaction, Watch, WatchEvent, stop_on_abnormal_death};
161pub use workflow::{
162    Barrier, BarrierArrival, BarrierConfigError, BarrierError, BarrierGeneration,
163    BarrierMembership, BarrierMessage, BarrierReleased, BarrierState, Latch, LatchMessage,
164    LatchReleased, LatchState, Workflow, WorkflowConfigError, WorkflowDefinition, WorkflowError,
165    WorkflowInput, WorkflowMessage, WorkflowOutcome, WorkflowRejection, WorkflowState,
166    WorkflowStepState,
167};