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/// Reference-input reconciliation (WBVER-03): re-run the executor at the
75/// workbook's reference inputs and diff each output against `Tool.oracle` within
76/// `TOL` — the reader-free, pure-diff core of the `verify_accuracy` meta-tool.
77pub mod reconcile;
78
79// ---- Curated re-export surface (matches the names workbook-compiler exported) ----
80
81pub use excel_error::ExcelError;
82pub use finding::{LintFinding, LintReport, Severity};
83pub use formula::{BinOp, Expr, UnOp};
84pub use range_ref::{cell_key, RangeRef};
85
86pub use dag::{toposort, upstream_input_leaves, Dag};
87pub use resolve::{
88 a1_to_zero_indexed_row_col, expand_range, parse_a1, split_ref, RangeShape, ResolveError,
89 MAX_RANGE_CELLS,
90};
91
92pub use manifest_model::{
93 is_computed, is_strict_constant, json_key_for_role, role_for_cell, sanitize_tool_name,
94 AnnotationDecl, CapabilityDecl, CellRole, ChangelogEntry, Dtype, GovernedDatum, InputTier,
95 LoopDecl, Manifest, Role, RESERVED_TOOL_NAMES,
96};
97
98pub use artifact_model::{
99 build_bundle_lock, fold_evidence_hash, sha256_hex, update_field, ArtifactHashes, BundleLock,
100 CellEntry, CellMap, Tool,
101};
102
103#[cfg(feature = "embedded")]
104pub use bundle_source::EmbeddedSource;
105pub use bundle_source::{BundleSource, BundleSourceError, LocalDirSource};
106
107pub use bundle_loader::{load as load_bundle, BundleLoadError, WorkbookBundle};
108
109pub use render::{
110 CellLayout, LayoutDescriptor, RenderMode, SheetLayout, LAYOUT_DESCRIPTOR_VERSION,
111};
112
113// NOTE: `changelog::Severity` is INTENTIONALLY not re-exported at the crate root —
114// `finding::Severity` (the lint-finding tier) already occupies the bare `Severity`
115// name (line ~60). The changelog severity is a DISTINCT type; reach it via its
116// module path `pmcp_workbook_runtime::changelog::Severity` (Rule 3 — blocking name
117// collision resolved without aliasing the historical lint `Severity`).
118pub use changelog::{ChangeClass, OutputDelta, OutputMeta, VersionChangelog};
119
120pub use reconcile::{
121 reconcile_reference, seed_reference_inputs, OutputRow, ReconcileReport, ToolReport,
122};
123
124pub use scalar_eval::eval_scalar;
125
126pub use sheet_ir::eval_bridge::{env_key, from_json, percent, powf, preflight_error, to_json};
127pub use sheet_ir::{
128 build_dag, run as run_executor, Cell, CellEnv, CellExpr, CellValue, EvalTrace, EvalValue,
129 RunResult,
130};