2.1 KiB
TASK table-formula-model: Bounded formula grammar and cell dependency evaluation
Runs through OpenCode (specs/agents/opencode-runbook.md attached automatically). Task 1 of specs/plugins-parity/table-formulas/tasks.md.
OWNS
crates/blocks/src/table_formulas/mod.rs (new, first write), crates/blocks/src/table_formulas/parse.rs (new), crates/blocks/src/table_formulas/eval.rs (new), crates/blocks/src/lib.rs (module/export and errors), unit tests in new modules
FILES TO OPEN
spec.md D1/D2, crates/blocks/src/lib.rs, crates/bases/src/eval/ops.rs (finite number handling reference only), crates/ui-egui/src/views/note_view/blocks/table.rs
GOAL / API
Write FIRST OWNS file in SECOND tool call (compiling stub plus one failing behavior test first).
evaluate(cells: &[Vec<String>]) -> Result<Evaluation> with stable cell diagnostics; parse formulas into bounded AST, compute dependency DAG iteratively, no scripts or IO. Implement D1 coordinate/numeric/aggregate semantics and every D2 resource cap.
Follow specs/plugins-parity/table-formulas/spec.md limits, error semantics and acceptance criteria exactly. New modules need rustdoc and parent declaration/re-exports; no IO.
TESTS
Arithmetic precedence/unary; A1 body coords; ranges; each aggregate including empty/text; cycles and propagation; nonfinite/divzero/out-of-bounds; depth/formula/cell/edge/operation caps; deterministic results; raw cell strings unchanged.
VERIFY
export PATH="$HOME/.cargo/bin:$PATH"
cargo test -p notescraft-blocks
cargo clippy -p notescraft-blocks --all-targets -- -D warnings
# rustfmt --edition 2024 followed by the owned Rust paths only
Confirm new tests appear in test output. No cargo execution during specification authoring.
DO NOT
Add dependency or reuse Bases expression grammar as if A1 were note property syntax. No dependency additions, Git mutations, Cargo edits, UI work or files outside OWNS. Reject hostile input with errors; never clamp/truncate or panic. Root Cargo.toml / xtask/src/layers.rs registration is unnecessary because this task extends existing crate.