Skip to main content

licoup_workflow/
lib.rs

1//! Pure LicoUp workflow compiler and transition machine.
2//!
3//! The generic compilation and transition machinery is owned by `acativa`;
4//! this crate owns the LicoUp-bound vocabulary layered over it: the
5//! `licoup.adaptive-flywheel.workflow.v1` schema identity this build compiles
6//! under, the persisted run snapshot and reducer event spellings
7//! (`conversationId`, assistant memberships, assistant failure events, the
8//! three-way callback decision), and the strategy error vocabulary the host
9//! surfaces.
10//!
11//! Workflow definitions are parsed and analyzed once into immutable indexes.
12//! Runtime state changes are pure: callers persist the returned snapshot and
13//! commands, then execute effects through their owning adapters.
14
15pub use acativa::workflow::dispatch;
16
17pub mod analysis;
18pub mod compile;
19pub mod diagnostic;
20pub mod ir;
21pub mod machine;
22pub mod strategy;
23pub mod syntax;
24
25pub use analysis::{
26    AnalyzedWorkflow, WorkflowValidation, WorkflowValidationFailure, analyze,
27    compile_workflow_source, compile_workflow_value, validate_workflow_value,
28};
29pub use compile::CompiledWorkflow;
30pub use diagnostic::{
31    PreflightDiagnostic, WorkflowDiagnosticActualKind, WorkflowDiagnosticCode,
32    WorkflowDiagnosticExpected, WorkflowDiagnosticRecovery, WorkflowDiagnosticStage,
33};
34pub use dispatch::{
35    ClaimLease, ClaimVerdict, CompletionVerdict, DispatchDecision, DispatchGate, DispatchIntent,
36    DispatchRecipient, DispatchRefusal, EffectCompletion, EffectProgress, RecoveryVerdict,
37    SuccessorAdmission, SuccessorEdge, SuccessorGate, SuccessorRefusal, claim_effect,
38    recover_claim, settle_effect,
39};
40pub use ir::*;
41pub use machine::{
42    CommandKind, CommandStatus, ReducerEvent, ReducerOutput, RunCommand, RunSnapshot, reduce,
43};
44pub use strategy::{
45    ASSISTANT_TEMPORARY_DEFINITION_PREFIX, BindingCandidate, BindingValue, StrategyAuthorization,
46    StrategyDefinition, StrategyDefinitionSummary, StrategyDiagnostic, StrategyError,
47    StrategyErrorCode, StrategyProjection,
48};
49pub use syntax::{ParsedWorkflow, parse};
50
51/// The workflow schema identity this build compiles and validates under. It is
52/// bound once here so the store, the runtime and every caller share the same
53/// vocabulary; the engine underneath stays schema-free.
54pub const WORKFLOW_SCHEMA_VERSION: &str = "licoup.adaptive-flywheel.workflow.v1";
55
56/// The schema identity the compiler is given, as the engine's own type.
57pub(crate) fn workflow_schema() -> SchemaId {
58    SchemaId::new(WORKFLOW_SCHEMA_VERSION)
59}
60
61pub use acativa::SchemaId;
62
63pub const MAX_ACTIVE_EFFECTS: usize = acativa::MAX_ACTIVE_EFFECTS;
64pub const MAX_GRAPH_STATES: usize = acativa::MAX_GRAPH_STATES;
65pub const MAX_GRAPH_TRANSITIONS: usize = acativa::MAX_GRAPH_TRANSITIONS;
66pub const MAX_BINDING_SLOTS: usize = acativa::MAX_BINDING_SLOTS;
67pub const MAX_RUNTIME_REQUIREMENTS: usize = acativa::MAX_RUNTIME_REQUIREMENTS;
68pub const MAX_WORKSET_ITEMS: usize = acativa::MAX_WORKSET_ITEMS;
69pub const MAX_RETRY_ATTEMPTS: u8 = acativa::MAX_RETRY_ATTEMPTS;
70
71/// Compile a canonical in-memory definition through the same analysis path as
72/// source and value entry points.
73pub fn compile_workflow(
74    definition: WorkflowDefinition,
75) -> Result<CompiledWorkflow, WorkflowValidationFailure> {
76    acativa::compile_workflow(definition, &workflow_schema())
77        .map_err(WorkflowValidationFailure::from)
78}