Files
2026-10-21 21:01:23 -03:00

5.2 KiB

Tasks: table-formulas (roadmap 40)

Spec: spec.md. Ordered tasks depend on preceding tasks only; each finishes with independently runnable behavior tests.

First tool call rule: after at most three focused reads, write FIRST OWNS file in SECOND tool call: compiling stub plus one failing behavior test, then make it pass. New paths below are explicitly marked new; other paths verified in source on 2026-10-21. Standing VERIFY: export PATH="$HOME/.cargo/bin:$PATH"; cargo test -p <pkg>; cargo clippy -p <pkg> --all-targets -- -D warnings; rustfmt --edition 2024 <owned Rust files>; UI tasks also cargo xtask i18n and inspect snapshot PNG at 1440x900 Mocha/Latte. Final task: cargo xtask ci. These are FUTURE implementation checks; documentation author runs no cargo. Standing DO NOT: edit outside OWNS, mutate Git, add dependencies, blanket lint allows, panic/unchecked input indexing, IO during paint, overwrite malformed user data, bypass atomic vault writes, cargo fmt --all. No new crate planned: no root Cargo.toml or xtask/src/layers.rs edits required. If implementation introduces a crate, stop for scope approval then explicitly own root Cargo.toml and xtask/src/layers.rs registration before compiling.

Phase 1

  • 1. Bounded formula grammar and cell dependency evaluation (brief briefs/27-table-formula-model.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: 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.

    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: standing, -p notescraft-blocks.

    DO NOT: Add dependency or reuse Bases expression grammar as if A1 were note property syntax.

Phase 2

  • 2. Shared table extraction and read-only command.

    OWNS: crates/blocks/src/table_formulas/table.rs (new), crates/blocks/src/table_formulas/mod.rs (declaration/export), crates/engine/src/block_edit/formulas.rs (new), crates/engine/src/block_edit/mod.rs (module/registration), crates/engine/src/ai/assistant_gate.rs, crates/engine/tests/core_commands.rs (CORE_IDS), crates/engine/tests/table_formulas.rs (new)

    FILES TO OPEN: spec.md D3, crates/ui-egui/src/views/note_view/blocks/table.rs, crates/ui-egui/src/views/note_view/blocks/table/edit.rs, crates/blocks/src/parse.rs

    GOAL: Extract shared cell tokenizer/ranges and opt-in marker detection; implement table.formulas.evaluate JSON contract; reject unmarked table as not_enabled, malformed/table_index bad params with zero writes.

    TESTS: Escaped/code-span pipes; Unicode/CRLF/short row normalization; marked/unmarked; malformed marker; multiple tables/index bounds; readonly works; engine coordinates equal pure fixtures; disk untouched.

    VERIFY: standing, -p notescraft-engine.

    DO NOT: Materialize computed values or alter source.

Phase 3

  • 3. Visual formula rendering and editing.

    OWNS: crates/ui-egui/src/views/note_view/blocks/table/formulas.rs (new), crates/ui-egui/src/views/note_view/blocks/table.rs (module and shared extraction), crates/ui-egui/src/views/note_view/blocks/table/edit.rs, crates/ui-egui/src/text/views/blocks.rs, crates/i18n/locales/en.toml (append formula keys), tests in owned table modules

    FILES TO OPEN: spec.md D3, crates/ui-egui/src/views/note_view/blocks/table.rs, crates/ui-egui/src/views/note_view/blocks/table/edit.rs

    GOAL: Render computed display/error tooltip only when opted in; exact-source cache; raw formula editing with existing NoteEdit/undo; confirm structural edits and preserve references; render literal code uncomputed.

    TESTS: UI values versus formula editor; edit/undo raw bytes; unmarked snapshot unchanged; structural confirm/cancel; source/engine coordinate parity; unchanged frame evaluation counter zero; both-theme screenshot.

    VERIFY: standing, -p notescraft-ui-egui.

    DO NOT: Rewrite refs, write result values automatically or export executable CSV silently.

Phase 4

  • 4. Compatibility corpus and status.

    OWNS: crates/engine/tests/table_formulas.rs, ROADMAP.md, docs/ARCHITECTURE.md, docs/CODE-MAP.md, specs/plugins-parity/roadmap.md (rank40)

    FILES TO OPEN: spec.md acceptance criteria

    GOAL: Close acceptance with hostile-input and source preservation fixtures; document NotesCraft-only opt-in syntax, f64 limits and raw export.

    TESTS: All caps and error codes; marker remains after edit; unmarked tables unaffected; source byte checks.

    VERIFY: standing, -p notescraft-engine.

    DO NOT: Claim Excel/Advanced Tables formula compatibility.