Repository navigation
Conversation
Add Calc::recalc_missing for read-only consumers that need to fill absent results while treating existing formula caches as fixed inputs. Preserve formula metadata and cached spill state, restrict dynamic follow-up rounds to the missing set, and clear obsolete spills when an unparseable missing anchor becomes an error. Restore the full dependency graph before returning so later incremental edits retain normal calculation behavior. Cover cached values, metadata, spill dependencies, repeated invocation and the editing lifecycle, and document the cache-freshness and missing-spill limitations. Model: openai-codex/gpt-6.1-sol
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Calculation API and behavior crates/calc/src/recalc.rs, docs/architecture.md |
Adds Calc::recalc_missing. It evaluates parseable formulas with empty cached values, assigns #NAME? to unparseable formulas, restores the full dependency graph, and retains detected dynamic cycles. The architecture document describes the API and its limits. |
Behavior validation crates/calc/src/tests.rs |
Adds tests for cached-value preservation, dependency chains, errors, spill state, repeated calls, incremental recalculation, and dynamic cycles. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Possibly related issues
- Issue 2048: This PR preserves cached results during missing-result recalculation, but does not change the XLSX importer that drops saved non-anchor values.
- Issue 2137: This PR can retain cached spill values during missing-result recalculation, but does not change the XLSX importer that drops absent spill caches.
Suggested reviewers: nihilist-narwhal, prxnvt
Merge Risk: 
Minimal · up to 7f2cd
-
The new opt-in calculation behavior has no established issue requiring a fix before merge. The reported checks should be confirmed as part of normal merge validation.
Security architecture risk: 
Low · up to 7f2cd
-
The opt-in mode reuses existing calculation capabilities and preserves saved results by design. No introduced security vulnerability was identified. Callers must not treat the operation as validation of saved values, and recovery after abnormal interruption is not established.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — Within the inspected path, workbook formulas and cached values can influence derived results, spill state, and calculation diagnostics in the supplied Workbook. The new entrypoint changes evaluation selection rather than adding evaluator authority or a cross-service execution path.
Trust Boundaries and Controls
- observed — The caller explicitly chooses to trust saved nonempty results. A workbook producer can therefore influence newly calculated outputs through those saved inputs; recalc_missing does not authenticate or validate them. This is an explicit contract limitation, not an evidenced bypass of an existing validation control.
Resilience and Maintainability Implications
- inferred — Graph restoration is evidenced for normal completion, including ordinary formula-error results, but is not an atomic rollback guarantee after panic unwinding. The new method replaces graph state and may write workbook state before restoration, without a rollback guard. Existing recalc_all also mutates in place; no PR-specific attacker-triggered unwind was established, and external callers' recovery behavior is unavailable.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title names the main change: a new Calc::recalc_missing API that calculates formulas with missing (Value::Empty) results while keeping saved formula caches unchanged. The raw summary and PR objectives both describe this as the central purpose, so the title matches the changeset and is specific enough for a teammate scanning history.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Merge current upstream main into the published recalc-missing branch without rewriting its review history. Keep both architecture histories and upstream multi-command engine documentation alongside the cache-preserving API notes. Retain cycles detected while evaluating missing formulas across the final full-graph rebuild. Dynamic references can close loops that the static graph cannot rediscover, so combine fresh detections with rebuilt cycle information rather than discarding them while restoring normal incremental editing. Model: openai-codex/gpt-6.1-sol
|
Review notes (not a formal review) on head 7f2cdeb. Checked
Not checked
|
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: the calculation engine can compute missing results without replacing saved formula caches. The new function calculates only formulas whose cached result is empty, using every other formula's cached result as a fixed input (even errors, empty text, volatile functions and unknown user-defined functions), keeping formula metadata for ISFORMULA and FORMULATEXT, and retaining the spills of cached anchors; it is meant for read-only consumers that prefer saved results over recalculation. The documentation is candid about the limits (it does not validate cache freshness or rebuild an anchor's absent spill range). That makes the function safe for viewers, and its name and doc should keep that scope so nobody uses it for editing. The same bounded recalculation rounds apply to untrusted workbooks. A test with a workbook that has some cached and some missing values is the proof. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
|
@FredApps Agreed on the scope: this is an explicit cache-preserving calculation policy for read-only consumers, not a freshness check or a replacement for normal editor recalculation. The public The mixed-cache regression is already present in These regressions passed locally on the published head |
FredApps
left a comment
There was a problem hiding this comment.
Re-review at 7f2cdebc.
My 11-01 points are covered.
Scope. The Calc::recalc_missing rustdoc keeps it to read-only consumers. It says plainly that the function trusts every non-empty saved result and does not check freshness. Normal recalculation remains recalc_all.
Implementation. I read the code in crates/calc/src/recalc.rs:
- Only formulas with an empty cached value go into the graph, so cached formulas stay fixed inputs through the follow-up rounds.
- An unparseable missing formula gets
#NAME?, and its stale spill is removed. - The full graph is rebuilt afterwards, so
cells_changedworks as usual. - Cycles found through dynamic reads are kept.
Tests. The mixed-cache test I asked for is recalc_missing_is_repeatable_and_restores_incremental_editing: a stale cached 99 stays, the missing dependent is computed, and normal editing then replaces both. The other four recalc_missing_* tests cover errors, metadata, chains, spills and cycles.
CI is green on this head. The only conflict with main is docs/architecture.md. Once that is merged and CI is green again, I have nothing further. Nothing calls the API yet, which is expected since #2824 builds on it. I did not run the tests.
Problem
Read-only embedders can use saved formula results, or call
recalc_alland replace them. They cannot fill only missing results while preserving cached unsupported functions, volatile results, errors and formula metadata.Change
Add
Calc::recalc_missing(&mut Workbook):Value::Empty; all other saved results remain fixed inputs.ISFORMULAandFORMULATEXT, and retain cached anchors' existing spill values/ranges.cells_changedcalls retain normal editing behavior.The API is additive; importers, UI open policy and
recalc_allare unchanged. This is distinct from an all-or-none open recalculation option.Coverage
Regressions cover cached UDFs, stale/volatile results, error and empty-text caches, missing chains, formula metadata, cached spill references, new spills, repeated calls and subsequent incremental editing. An external public-API consumer exercises the read-only and editing lifecycle.
Verification
-D warnings), tests, assets and layering gates passed.recalc_missingregressions and an external public-API smoke passed after the final stale-spill fix.The default Homebrew compiler did not have the Wasm standard library installed; the Wasm check passed with the installed rustup stable compiler via a command-local
RUSTCoverride. No global toolchain settings were changed.Summary by CodeRabbit
#NAME?error.