Skip to content

refactor: evaluator.ts を分ける(式の文字列・配列の評価) - #188

Merged
isamu merged 1 commit into
mainfrom
refactor/split-evaluator
Oct 21, 2026
Merged

isamu merged 1 commit into
mainfrom
refactor/split-evaluator

Conversation

@isamu

@isamu isamu commented Oct 21, 2026

Copy link
Copy Markdown
Member

Summary

Splits evaluator.ts, which scoria flags as god-file (over 500 lines). The code is moved as it was; behaviour does not change.

  • src/engine/expressionText.ts: functions that read a formula's text without evaluating it.
    • renderOperand: writes a value as an operand.
    • maskStringLiterals and isSafeConcatExpression: check a concatenation's structure.
    • endOfStringLiteral: finds where a string literal ends.
    • findCellRefs and substituteCellRefs: find and replace cell references.
    • parseFunctionArgs: splits a call's arguments.
  • src/engine/arrayEvaluation.ts: evaluating an expression over arrays (A1:A3*2) element by element, evaluateOverArrays and its internal pieces.
  • evaluator.ts keeps the evaluation itself (evaluateFormula and what it calls).
  • Imports are pointed at the new modules: dateDisplay.ts, functions/logical.ts and four tests.

Items to Confirm

  • The package's exports. src/engine/index.ts now has export * from "./expressionText" beside export * from "./evaluator", so the names the package exports are unchanged. This is a re-export, kept because it is the public entry point.
  • Behaviour is unchanged. Old (origin/main) and new were run side by side and compared: every formula in the tests (corpusdiff.mts) and a run over generated sheets, all identical.
  • Beyond moving code: pieceAt captured nothing, so it moves to module scope; an inner _ became _cell.
  • yarn lint, yarn typecheck, yarn build, yarn test, yarn test:engine, run-all-fixtures.ts and test:evaluator pass. oxlint reports nothing.

User Prompt

🤖 Generated with Claude Code

work in GUIChatPluginSpreadsheet

…n their own files

expressionText.ts holds what reads a formula's text without evaluating it (rendering an operand,
string literals, cell references, a call's arguments); arrayEvaluation.ts the element-by-element
evaluation of an expression over arrays. Code moved as it was; index.ts exports expressionText so the
package's names stay the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/engine/index.ts
export * from "./formulaError";
export * from "./spreadsheet-errors";
export * from "./evaluator";
export * from "./expressionText";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CODEX VERDICT: CHANGES REQUESTED

  • P2 public-surface compatibility: at src/engine/index.ts:21, export * from "./expressionText" re-exports the moved helpers as intended, but it also newly exports evaluateOverArrays from src/engine/arrayEvaluation.ts:79. That is an unintentional public API addition in a refactor whose stated contract is unchanged exports. Every occurrence of this issue is the single new export function evaluateOverArrays combined with the single export * from "./expressionText" barrel at those sites. Smallest fix: remove export from evaluateOverArrays (or explicitly keep it out of the barrel); retain the expression-text re-export so the pre-existing names remain available. What would change my mind: confirmation that evaluateOverArrays is deliberately part of the public API and this additive surface is documented/desired.
Axis Result
correctness and edge cases none
security (injection / path traversal / code evaluation) none
tests: does a test go red if the new behaviour breaks none; focused engine tests passed (303/303), and the supplied differential source reaches both the evaluator path and array formulas, though its .old checkout was absent here so I did not rerun it
API / schema / wire / on-disk compatibility the public API addition above; no schema, wire, or on-disk changes
consistency with the rest of the codebase none
i18n lockstep (src/lang has 8 locales) none; no src/lang files changed
TIER C (behaviour preservation: a move of code that every formula passes through; a public export surface) public export surface finding above; formula-path behavior otherwise preserved
move fidelity none; moved functions match the origin implementation apart from the allowed export changes, hoisted pieceAt, and _cell rename
module graph none; the EvaluatorContext import is type-only, so no runtime cycle is introduced, and function-registry initialization order is unchanged
public surface: src/engine/index.ts and package entry points src/index.ts and src/core/index.ts export lists are unchanged; src/engine/index.ts preserves the moved names but adds evaluateOverArrays
the differential I ran (corpusdiff.mts, gendiff-cs.mts) none found by inspection; both import SpreadsheetEngine through src/engine/index.ts, and the generated corpus includes array expressions, so they reach the moved code

sha read: 402b7a36abc1f147c14d313feaabf815d2b74546

FINDINGS COMPLETE: I read every hunk of the diff and this is every finding I have.

@isamu

isamu commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

Codex round 1 triage: the one P2 (that evaluateOverArrays becomes public) was settled in the same round. The runtime export lists of src/engine/index.ts, src/index.ts and src/core/index.ts are the same on origin/main and HEAD; Codex checked it in a follow-up call and withdrew the finding (WITHDRAWN). Nothing has been pushed since 402b7a3, and no findings remain.

@isamu
isamu merged commit 4306d06 into main Oct 21, 2026
17 checks passed
@isamu
isamu deleted the refactor/split-evaluator branch October 21, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant