Repository navigation
fix(core): fold fallback reasons lead with the cause, one line, unified wording (#1054) - #1109
Merged
Merged
Conversation
fold()'s shared message builders (subset.ts's computedPropertyNameMessage, dynamicElementAccessMessage, callExpressionMessage) and two hand-written fold.ts messages (an unregistered tagged-template name, a nested `new Type(...)` used as a value) all embedded a node's raw getText(). For most call sites that's a short identifier, but nothing bounded it: a callee that happens to span multiple lines would leak straight into a fold fallback reason exactly like #1054's destructured-export case. Add briefNodeText() (subset.ts): collapses internal whitespace/newlines to single spaces and caps the result to a bounded length, so every message built from it is guaranteed single-line regardless of the node's own formatting. Applied to all four sites. Behavior is identical for the short, single-line nodes every existing test exercises (whitespace-collapse and truncation are no-ops when the text already fits) — this is diagnostics text only, no fold decision changes.
…nify call-as-value wording (#1054) Two problems in fold-import.ts's fallback reasons, found while measuring fold blockers across the corpus (#1020/#1044): - A destructured composite export's failure reason embedded decl.node.getText() — the ENTIRE call expression. For a real multi-prop composite call that's 20+ lines, so the actual error (e.g. "unresolved identifier: config") landed after all of it, and any line-oriented consumer of `[fold:run]` output only ever saw the opening line. Now reports `"<bound names>" (destructured from <Callee>(...)) is not foldable: <error>` — brief, always one line, nested positions preserved. - resolveCallExpression had its own hand-written "call expression as a value is not foldable: ..." string, distinct from fold()'s "function call as a value is not foldable: ..." for the identical rejection (a bare call used where a value is needed). Both wordings are real in the corpus today (e.g. shared/iam-crdb.ts's `REGIONS.map(...)` vs east/k8s/namespace.ts's `ALL_CIDRS.map(...)`), so a tool grouping fallback reasons by text has to match both or silently under-count one. resolveCallExpression now calls subset.ts's callExpressionMessage directly instead of building its own copy — one wording, one builder. Verified against the real corpus: fold-differential stays 53/98 fold with zero drift, and the per-file fold/run mode assignment is unchanged for all 409 fold decisions across the corpus — only reason text changed.
Contributor
Author
|
Orchestrator verification: fold-differential re-run independently — 53/98, drift 0, decisions unchanged (the diagnostics-only contract holds); 3 clean full-suite runs at baseline (26s, 8712 passed). Wording unification onto subset.ts's shared builder and the data-vs-diagnostic getText() split both check out on diff read. Merging. |
This was referenced Jul 27, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1054.
Restatement of acceptance criteria
node.getText()of a multi-line node — every reason stays on one line, so a line-oriented consumer (grep, a log aggregator) sees the whole thing.function call as a value is not foldable: ...(fold.ts) vscall expression as a value is not foldable: ...(fold-import.ts) — collapse to one wording, so a tool grouping fallback reasons by text stops silently under-counting one of them.just fold-differentialstays 53/98 fold with zero drift, and the per-entry report is unchanged.just build,just lint,just testgreen;just check-lexiconsno regression.The issue named two lines (
fold-import.ts's destructured-export reason). Since main has grown (#1044/#1063 call-form intrinsics + lexicon-package folding, #1091/#1097/#1105 today), I audited every reason-construction site acrosspackages/core/src/discovery/fold-import.tsandpackages/core/src/fold/*.tsrather than just those two lines. Found 7 diagnostic-text sites embedding rawgetText()(the 2 the issue names, plusresolveCallExpression's two call-as-value throws, fold.ts's nested-new-as-value message, and subset.ts's 3 shared message builders used byfold()'sfoldError). All 7 now go through one bounded, single-line-safe helper. I also found 3 moregetText()sites that are data, not diagnostic text (the resource type name captured in the folded spec, the tag name used for intrinsic-registry lookup, and destructuring binding-name extraction) — touching those would risk changing what gets serialized, so they're deliberately untouched.The fix
briefNodeText(node, maxLength = 60)(new,fold/subset.ts): collapses a node'sgetText()— internal whitespace including newlines — down to single spaces, then truncates with a trailing...past the cap. Used everywhere a node fragment gets embedded in a message.fold-import.ts): now identifies the export by its binding names and the source's callee, never the raw call:"<names>" (destructured from <Callee>(...)) is not foldable: <error>.resolveCallExpressionno longer hand-rolls"call expression as a value is not foldable: ...". It now callssubset.ts's exportedcallExpressionMessage(node)directly — the same builderfold()already uses for a call used as a prop value. One wording, one source of truth, reused rather than a third string invented.subset.tsalready documents itself as the shared-message-builder modulefold()and the EVL lint classifier both import from, so this fixes the one place that had drifted from it.err.message (reason)) — they were already single-line once their inner pieces stopped embedding raw multi-line text, which thebriefNodeTextfix above takes care of.Before / after (pasted from real corpus runs —
examples/cockroachdb-multi-region-gke)Before:
(Line 1 is 13 physical lines,
grep 'unresolved identifier'on[fold:run]output never matches it. Lines 2 and 3 are the same rejection shape with two different wordings.)After:
One line each, the actual cause (
unresolved identifier: config,REGIONS.map(...)) is present andgrep-able, and lines 2/3 now read identically for the identical rejection shape.Checked the full corpus, not just this one entry: before the fix there were 11 multi-line destructured-export reasons and 3 occurrences of the old
call expression as a valuewording (vs. ~15 already usingfunction call as a valuefor the equivalent case) across the 98-entry corpus. After the fix: 0 remaining multi-line reasons, 0 occurrences of the old wording, and every[fold:*]line the CLI would print is exactly one line.Wording decision
Kept
function call as a value is not foldable: <callee>(...)(fold.ts/subset.ts's existing text) as the one wording, and hadfold-import.ts'sresolveCallExpressioncallsubset.ts's exportedcallExpressionMessage()directly instead of inventing a third string.subset.tsalready frames itself as the shared-message-builder module bothfold()and the EVL lint classifier import from specifically so the same violation never has two different diagnostic strings —resolveCallExpression's own hand-rolled"call expression as a value"copy was the one place that had drifted from that. Reusing the existing builder was less code than merging two wordings into a new third one, and keeps future changes to this message in one place.Gate evidence
just build(tsc --noEmit -p packages/core/tsconfig.json):just lint:just test(full suite):just fold-differential(the hard constraint — decisions unchanged):53/98, zero drift, identical to
main— confirmed independently with a scratch script that reproduces the CLI's[fold:*]output and diffs the per-file fold/run mode assignment for all 409 file-level decisions in the corpus before vs. after: 0 differences (only reason text changed).just check-lexicons:(14 pre-existing KNOWN failures, all tracked against other issues — unchanged by this PR.)
Docs:
docs/src/content/docs/concepts/typescript-as-data.mdx's generated fold-coverage block and its "published fold coverage count matches this run's live count" guard both stayed green with no edits needed — the count is unaffected (diagnostics only) and no doc text quotes either of the changed wordings.Tests
packages/core/src/fold/subset.test.ts: newbriefNodeTextunit tests (short text passes through, multi-line collapses to one line, over-cap text truncates) and acallExpressionMessagetest proving a multi-line argument list never leaks into the message.packages/core/src/discovery/fold-import.test.ts: strengthened the existing "composite factory defined locally" test to an exact-match assertion locking in the unified wording; added a case for a non-identifier callee (builder.build(...)); added two new tests for the destructured-export reason format (a resolution failure and a "not an object" failure) — this path had zero prior test coverage of its reason text.All of the above are
.toBe(...)exact matches or meaningful.toContain(...)checks, not weakened to substrings loose enough to pass on garbage.Out of scope (per the task): wiring the intrinsic registry into EVL lint rules is #1106;
runLintis untouched.