wavekat_flow/lib.rs
1//! `wavekat-flow` — the call-flow ("Receptionist") document model for the
2//! WaveKat voice platform.
3//!
4//! The types in this crate are **generated at build time** from the
5//! normative JSON Schema at `schema/flow.v1.schema.json` — the single
6//! source of truth shared with the `@wavekat/flow-schema` npm package.
7//! See `build.rs`.
8//!
9//! Phase 2 (this milestone) adds the semantic validator ([`validate`]), the
10//! hours/timezone math ([`hours`]), and the interpreter ([`engine`] + its
11//! [`trace`] output) alongside the generated model, adapted to the generated
12//! types and pinned by the shared conformance corpus. The engine owns the
13//! [`engine::FlowEffects`] trait *definition*; the daemon keeps its live impl
14//! in its own codebase. Comment-preserving mutation stays TS-only.
15
16/// The generated document model (`Flow`, `Node`, `Prompt`, …), emitted
17/// from the schema by `typify` into `OUT_DIR/flow_types.rs`.
18///
19/// `Node` is an internally-tagged enum (`#[serde(tag = "kind")]`): the
20/// `build.rs` schema normalization inlines the per-node `oneOf` branches
21/// and rewrites the `kind` `const` to a single-valued `enum` so typify
22/// discriminates on `kind` instead of emitting an `#[serde(untagged)]` enum
23/// that would mis-deserialize (a menu as a greeting).
24pub mod model {
25 #![allow(clippy::all)]
26 include!(concat!(env!("OUT_DIR"), "/flow_types.rs"));
27}
28
29/// Hand-written helpers layered on the generated model (logic, not shape).
30mod model_ext;
31
32pub mod engine;
33pub mod hours;
34pub mod trace;
35pub mod validate;
36
37pub use model::*;
38pub use model_ext::NodeId;
39
40/// The normative JSON Schema (draft 2020-12) as a string, bundled so
41/// consumers can run structural validation without reaching outside the
42/// crate. The crate-local copy is synced from the repo-root schema by
43/// `build.rs` (and is what ships in the published package).
44pub const FLOW_V1_SCHEMA: &str = include_str!("../schema/flow.v1.schema.json");
45
46/// Schema versions this crate's model describes. Twin:
47/// `packages/flow-schema/src/model.ts` `SUPPORTED_SCHEMA_VERSIONS`.
48pub const SUPPORTED_SCHEMA_VERSIONS: &[u32] = &[1];