Skip to main content

pmcp_workbook_runtime/
lib.rs

1//! `workbook-runtime` — the RUNTIME-only leaf of the v0.5.0 compiler pipeline
2//! (Phase 11, Plan 05 — Codex HIGH #2: the runtime/compiler LINK boundary).
3//!
4//! This crate holds the owned IR types (`Expr`/`BinOp`/`UnOp`/`RangeRef`/`Cell`/
5//! `CellExpr`/`CellValue`), the dependency `Dag` container + `toposort`, the
6//! SERVE-time topo-ordered [`run`] executor, the manifest projection model, and a
7//! PURE-RUST scalar leaf evaluator ([`scalar_eval`]) that REPLACES the
8//! `pmcp-code-mode` (SWC/JS) kernel on the served-binary path.
9//!
10//! It depends on NEITHER `umya` NOR SWC NOR `pmcp-code-mode` NOR `quick-xml` NOR
11//! `zip` — making the Ph10 D-01 boundary a cargo-tree-PROVABLE LINK boundary. The
12//! served binary (Plan 04) depends ONLY on this crate; `workbook-compiler`
13//! re-exports these types FROM here so its public surface (and Plan 03) keeps
14//! compiling unchanged.
15
16// Compiler/clippy-enforced panic-freedom on the library value path (mirrors
17// workbook-compiler). Test code constructs fixtures freely.
18#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
19#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used, clippy::panic))]
20
21/// The shared Excel error-value set.
22pub mod excel_error;
23
24/// The owned A1 range reference + the canonical `cell_key` helper.
25pub mod range_ref;
26
27/// The owned formula AST (Expr/BinOp/UnOp).
28pub mod formula;
29
30/// The located, collect-all lint-finding types (LintFinding/Severity/LintReport).
31pub mod finding;
32
33/// The pure owned dependency `Dag` container + Kahn's `toposort`.
34pub mod dag;
35
36/// Range/reference resolution PRIMITIVES (expand_range/parse_a1/split_ref).
37pub mod resolve;
38
39/// The logical manifest projection model (Manifest/CellRole/Role/InputTier/…).
40pub mod manifest_model;
41
42/// The RUNTIME-safe bundle artifact model + hashing (CellMap/BundleLock + the
43/// integrity hash helpers shared by the emitter and the served integrity check).
44pub mod artifact_model;
45
46/// The dumb-byte `BundleSource` trait (local-dir + feature-gated embedded impls)
47/// — raw-byte access only, so no source can bypass the shared loader's integrity
48/// gate (WBSV-08/WBSV-09).
49pub mod bundle_source;
50
51/// The single shared, fail-closed bundle loader (`load` + `WorkbookBundle` +
52/// `BundleLoadError`) — the ONLY parse+integrity-verify path for any
53/// `BundleSource` (WBSV-08).
54pub mod bundle_loader;
55
56/// The PURE-RUST scalar leaf evaluator that replaces the pmcp-code-mode kernel.
57pub mod scalar_eval;
58
59/// The `sheet_ir` value/eval layer + the SERVE-time executor.
60pub mod sheet_ir;
61
62/// The serve-side render layer (Phase 12): the shared, versioned
63/// `LayoutDescriptor` serde shape (Plan 01) the offline emitter and the
64/// writer-only serve path (Plan 02) both use.
65pub mod render;
66
67/// The shared version-changelog model (Phase 13, Plan 01): the owned serde +
68/// `JsonSchema` records (`ChangeClass`/`Severity`/`OutputMeta`/`OutputDelta`/
69/// `VersionChangelog`) the offline promote gate RECORDS and the served
70/// `diff_version` tool SERVES. Defined HERE (not in `workbook-compiler`) because
71/// the served binary deserializes it — the crate-purity invariant.
72pub mod changelog;
73
74// ---- Curated re-export surface (matches the names workbook-compiler exported) ----
75
76pub use excel_error::ExcelError;
77pub use finding::{LintFinding, LintReport, Severity};
78pub use formula::{BinOp, Expr, UnOp};
79pub use range_ref::{cell_key, RangeRef};
80
81pub use dag::{toposort, upstream_input_leaves, Dag};
82pub use resolve::{
83    a1_to_zero_indexed_row_col, expand_range, parse_a1, split_ref, RangeShape, ResolveError,
84    MAX_RANGE_CELLS,
85};
86
87pub use manifest_model::{
88    is_computed, is_strict_constant, json_key_for_role, role_for_cell, sanitize_tool_name,
89    AnnotationDecl, CapabilityDecl, CellRole, ChangelogEntry, Dtype, GovernedDatum, InputTier,
90    LoopDecl, Manifest, Role, RESERVED_TOOL_NAMES,
91};
92
93pub use artifact_model::{
94    build_bundle_lock, fold_evidence_hash, sha256_hex, update_field, ArtifactHashes, BundleLock,
95    CellEntry, CellMap, Tool,
96};
97
98#[cfg(feature = "embedded")]
99pub use bundle_source::EmbeddedSource;
100pub use bundle_source::{BundleSource, BundleSourceError, LocalDirSource};
101
102pub use bundle_loader::{load as load_bundle, BundleLoadError, WorkbookBundle};
103
104pub use render::{CellLayout, LayoutDescriptor, SheetLayout, LAYOUT_DESCRIPTOR_VERSION};
105
106// NOTE: `changelog::Severity` is INTENTIONALLY not re-exported at the crate root —
107// `finding::Severity` (the lint-finding tier) already occupies the bare `Severity`
108// name (line ~60). The changelog severity is a DISTINCT type; reach it via its
109// module path `pmcp_workbook_runtime::changelog::Severity` (Rule 3 — blocking name
110// collision resolved without aliasing the historical lint `Severity`).
111pub use changelog::{ChangeClass, OutputDelta, OutputMeta, VersionChangelog};
112
113pub use scalar_eval::eval_scalar;
114
115pub use sheet_ir::eval_bridge::{env_key, from_json, percent, powf, preflight_error, to_json};
116pub use sheet_ir::{
117    build_dag, run as run_executor, Cell, CellEnv, CellExpr, CellValue, EvalTrace, EvalValue,
118    RunResult,
119};