formualizer_eval/engine/effects.rs
1//! Formal effects pipeline for evaluation (ticket 603).
2//!
3//! An `Effect` is an explicit, inspectable side-effect produced by formula
4//! evaluation. Effects are *planned* deterministically from
5//! `(computed_value, workbook_state)` and *applied* sequentially.
6//!
7//! This separation enables:
8//! - Parallel computation with sequential apply
9//! - ChangeLog integration at the effect layer
10//! - Deterministic replay without re-evaluation
11
12use crate::engine::vertex::VertexId;
13use crate::reference::CellRef;
14use formualizer_common::LiteralValue;
15
16/// An explicit, inspectable side-effect produced by formula evaluation.
17#[derive(Debug, Clone)]
18pub enum Effect {
19 /// Write a scalar value (or error) to a formula/named vertex.
20 WriteCell {
21 vertex_id: VertexId,
22 value: LiteralValue,
23 },
24 /// Commit a dynamic array spill to the grid.
25 SpillCommit {
26 anchor_vertex: VertexId,
27 anchor_cell: CellRef,
28 target_cells: Vec<CellRef>,
29 values: Vec<Vec<LiteralValue>>,
30 },
31 /// Clear a previous spill region (before resize or scalar downgrade).
32 SpillClear { anchor_vertex: VertexId },
33}
34
35/// A batch of effects from evaluating a single layer.
36/// Each entry pairs a vertex with its planned effects.
37pub type EffectBatch = Vec<(VertexId, Vec<Effect>)>;