Skip to main content

behavior_actors/
lib.rs

1//! Reusable, pure actors and behavior compositions built on [`mod@behavior`].
2//!
3//! The public owners include [`supervisor`], [`pool`], [`proxy`], [`worker`], [`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 deadlines around stashed state machines.
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;
60mod inputs;
61mod retention;
62mod templates;
63pub use templates::{ZeroCapacity, diagnostic, pool, proxy, supervisor, worker};
64pub mod composition;
65pub mod discovery;
66pub mod lifecycle;
67mod machine;
68pub mod operations;
69pub mod persistence;
70mod protocol;
71mod requirements;
72pub mod routing;
73mod shutdown;
74mod stash;
75mod termination;
76pub mod time;
77mod watch;
78pub mod workflow;
79
80pub use activation::{Activate, Active, Initialized};
81pub use composition::{DeliveryRoute, MessageAdapter, ReplyDeliveries, ReplyDelivery, ReplyRoute};
82pub(crate) use diagnostic::{DiagnosticAction, DiagnosticDisposition, DiagnosticRoute};
83pub use discovery::{
84    Presence, PresenceEntry, PresenceError, PresenceMessage, PresenceOutcome, PresencePhase,
85    PresenceReply, PresenceReport, PresenceSends, PresenceVersion, PubSub, PubSubError,
86    PubSubMessage, Registry, RegistryError, RegistryMessage, RegistryResult, Resolution, Resolver,
87    ResolverConfigError, ResolverMessage, Topic, TopicError, TopicMembership, TopicMessage,
88};
89pub(crate) use lifecycle::ActorDrainPolicy;
90pub use lifecycle::{
91    BeginShutdownPhases, ChildCreationExpectation, ChildShutdownPhases, ChildShutdownPlanError,
92    ChildTermination, DeclareShutdownPhase, EstablishedTerminationMonitor,
93    EstablishedTerminationReaction, EstablishedTerminationTarget, FinishShutdownPhases,
94    HeterogeneousShutdownCoordinator, HeterogeneousShutdownPlan, HeterogeneousShutdownSends,
95    InstallShutdownPlan, LogicalTerminationTarget, NoShutdownTargets, PeerTermination,
96    PropagateTermination, ReportShutdownPlan, ShutdownChoice, ShutdownCoordinator,
97    ShutdownCoordinatorError, ShutdownCoordinatorEvent, ShutdownPlan, ShutdownPlanError,
98    ShutdownState, ShutdownTargetAt, ShutdownTree, ShutdownTreeError, Task, TaskError, TaskMessage,
99    TaskResult, TaskState, TerminalDisposition, TerminalPropagationPolicy,
100    TerminalPropagationSends, TerminalPropagationState, TerminationMonitor,
101    TerminationMonitorError, TerminationMonitorWith, TerminationObservation,
102    TerminationObservationTarget, TerminationPropagationError, TerminationReaction,
103    TerminationTarget, propagate_abnormal, propagate_all, shutdown_after_children, shutdown_target,
104};
105pub use machine::{Machine, MachineError, Move};
106pub use operations::{
107    ComponentHealth, ComponentHealthState, Configuration, ConfigurationError, ConfigurationMessage,
108    ConfigurationState, ConfigurationVersion, DependencyReadiness, Feature, FeatureSet,
109    FeatureStatus, Health, HealthError, HealthEvidence, HealthMessage, HealthReport, HealthStatus,
110    ObservationVersion, Readiness, ReadinessError, ReadinessEvidence, ReadinessMessage,
111    ReadinessReport, ReadinessStatus,
112};
113pub use persistence::{
114    Cache, CacheConfigError, CacheConfiguration, CacheEntry, CacheMessage, CacheResult, CacheState,
115};
116pub use protocol::timer;
117pub use protocol::{
118    CancelObservation, ChildShutdownRejected, ChildShutdownRejection, ChildStopped,
119    CreationResolved, EstablishedChild, EstablishedObservation, EstablishedShutdownResolved,
120    InterpretEstablishedObservation, InterpretEstablishedShutdown, ObservationAuthority,
121    ObservationId, ObservationOperation, ObservationRejection, ObservationRelationship,
122    ObserveChild, ObserveCreation, ObserveEstablished, ObserveEstablishedCreation, ObservePeer,
123    OwnedScheduleAfter, OwnedScheduleAt, OwnedTimerElapsed, OwnedTimerScheduled,
124    PeerObservationRejection, PeerStopped, ScheduleAfter, ScheduleAfterRejection, ScheduleAt,
125    ScheduleAtRejection, ShutdownChild, ShutdownEstablished, ShutdownId, ShutdownRejection,
126    ShutdownRequested, TimerElapsed, TimerGeneration, TimerId, TimerScheduled, UnwatchPeer,
127    established_child,
128};
129pub(crate) use proxy::{
130    InitialWorkerOutcome, ProxyDrain, ProxyInputReceipt, ProxyInputResult, ProxyOperation,
131    ProxyOperationId, ProxyOutcome, ProxyPhase, ReplacementOutcome, StableProxy, WorkerStartResult,
132};
133pub use retention::{InputLimit, InputRetention};
134pub use routing::{
135    AcknowledgementError, AcknowledgementInput, AcknowledgementMessage, AcknowledgementOutcome,
136    AcknowledgementRecord, AcknowledgementState, Acknowledgements, BreakerAttempt,
137    BreakerCompletion, BreakerConfigError, BreakerError, BreakerMessage, BreakerOutcome,
138    BreakerPhase, BreakerRejection, BreakerSends, Buffer, BufferConfigError, BufferConfiguration,
139    BufferMessage, BufferOutcome, BufferRejection, BufferState, Buffered, CircuitBreaker,
140    ClosedPhase, ConsistentHash, CorrelationResult, CorrelationState, Correlator, CorrelatorError,
141    CorrelatorMessage, Deduplicator, DeduplicatorConfigError, DeduplicatorMessage,
142    DeduplicatorOutcome, DeduplicatorState, DeliveryOutcomes, LeastLoaded, Load, LoadEvidence,
143    LoadObservation, LoadVersion, MemberEvidenceError, MemberToken, MemberTokenEvidence,
144    MemberTokenObservation, MemberTokenVersion, OrderGate, OrderGateMessage, OrderGateOutcome,
145    OrderGateState, OverflowPolicy, PriorityQueue, PriorityQueueConfigError, PriorityQueueMessage,
146    PriorityQueueOutcome, PriorityQueueRejection, PriorityQueueState, ProbePhase,
147    RateLimitRejection, RateLimiter, RateLimiterConfigError, RateLimiterMessage,
148    RateLimiterOutcome, RateLimiterState, RendezvousHash, RoundRobin, RouteKey, Router,
149    RouterError, RouterMessage, RoutingObservationRejection, RoutingStrategy, Sequence, Sequencer,
150    SequencerMessage, SequencerOutcome, SequencerState, TokenCount, WorkQueue, WorkQueueMessage,
151    WorkQueueOutcome, WorkQueueRejection, WorkQueueSends, WorkQueueState,
152};
153pub use shutdown::{FinalizeOnShutdown, ShutdownEvent, ShutdownReaction, StopOnShutdown};
154pub use stash::{Stash, StashRoute, StashSends, StashStatus, StaticallyInfallible, UnlimitedStash};
155pub(crate) use supervisor::directory::{InterruptedWorker, WorkerChange};
156pub use termination::{
157    Crash, Exit, ReportTerminalOutcome, RestartDenial, SupervisionFailureReason, TerminalOutcome,
158};
159pub use time::{
160    Deadline, DeadlineReaction, Lease, LeaseMessage, LeaseOutcome, LeaseRejection, LeaseRequest,
161    LeaseSends, LeaseState, OneShot, Periodic, ReceiveTimeout, TimedEvent, TimedReaction,
162};
163pub use watch::{LinkReaction, Watch, WatchEvent, stop_on_abnormal_death};
164pub(crate) use worker::{
165    RestartReleaseFailure, StartupPlan, WorkerAttempt, WorkerCreationRejection, WorkerSubmission,
166};
167pub use workflow::{
168    Barrier, BarrierArrival, BarrierConfigError, BarrierError, BarrierGeneration,
169    BarrierMembership, BarrierMessage, BarrierReleased, BarrierState, Latch, LatchMessage,
170    LatchReleased, LatchState, Workflow, WorkflowConfigError, WorkflowDefinition, WorkflowError,
171    WorkflowInput, WorkflowMessage, WorkflowOutcome, WorkflowRejection, WorkflowState,
172    WorkflowStepState,
173};