Repository navigation
feat(core): fold call-form composite/intrinsic calls (Checkout(...) factories, helm include/printf) - #1965
Merged
Conversation
… intrinsics Closes the top remaining fold-corpus gate (#1174): a function call used as a value was the sole blocker in most of the 12 github/forgejo/helm entries still falling back to run. Two independent mechanisms, both landed: - fold() gains a narrow case for the `<Identifier>(...).step` composite- consumer idiom (`Checkout({...}).step`, `SetupNode({...}).step`) — the exact shape chant #1544 already carved out of EVL001 as a documented, correct fallback. fold-import.ts's bridge resolves the callee through the folding file's own imports (interpreting a project-file Composite per #1023, invoking a lexicon-package one for real otherwise, exactly as a top-level `export const x = Checkout({...})` already does) and reads `.step` off the real result. The now-redundant `allowCompositeStepAccess` EVL-only opt-in in subset.ts is removed — the shape is unconditionally admissible in both fold() and the shared predicate, closing the divergence #1544 documented. - helm's plugin.ts opts `include`/`required`/`helmDefault`/`toYaml`/ `quote`/`printf`/`tpl`/`lookup`/`filesGet`/`filesGlob`/`filesAsConfig`/ `filesAsSecrets` into `foldsAsCall` (chant #1044's existing mechanism, previously unused by helm since it has no tagged templates at all). `withOrder`/`argoWave` are deliberately left out: they return a plain record meant to be spread, and fold()'s object-spread runs synchronously before the async revival that turns a folded call into its real result, so opting them in would spread the envelope's own keys instead. `If`/`ElseIf`/`Range`/`With` are left out too — their bodies are often arrow functions or nested Declarables fold() already rejects on its own terms, and none of the corpus needs them. Corpus: 82 -> 89 of 108 folding, zero drift on both differentials. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
8 tasks done
lex00
added a commit
that referenced
this pull request
Aug 29, 2026
fold() had no case for a CallExpression whose callee is a property
access, so github.actor.toString()/matrix("os").toString()/[...].join(...)
all fell through to "function call as a value is not foldable" one
blocker behind the composite-call fix in #1965.
Two additions to fold():
- a lexicon-package plain function registered with the new
IntrinsicDef.foldsEagerly evaluates immediately (not enveloped for
later revival), since its result is commonly embedded straight into
a template literal and needs to be the real value to stringify
correctly at fold time
- a method call whose receiver already resolves to a real, non-symbolic
value invokes the named method directly, with no restriction on the
method name beyond the receiver not being one of fold's own envelope
shapes
findSubsetViolation (EVL001's shared predicate) is widened in lockstep
so it never rejects a shape fold() now accepts. github's expression.ts
helpers (matrix, inputs, needs, secrets, ...) are registered
foldsEagerly in the github lexicon plugin.
Fixes #1966
lex00
added a commit
that referenced
this pull request
Aug 29, 2026
…1994) fold() had no case for a CallExpression whose callee is a property access, so github.actor.toString()/matrix("os").toString()/[...].join(...) all fell through to "function call as a value is not foldable" one blocker behind the composite-call fix in #1965. Two additions to fold(): - a lexicon-package plain function registered with the new IntrinsicDef.foldsEagerly evaluates immediately (not enveloped for later revival), since its result is commonly embedded straight into a template literal and needs to be the real value to stringify correctly at fold time - a method call whose receiver already resolves to a real, non-symbolic value invokes the named method directly, with no restriction on the method name beyond the receiver not being one of fold's own envelope shapes findSubsetViolation (EVL001's shared predicate) is widened in lockstep so it never rejects a shape fold() now accepts. github's expression.ts helpers (matrix, inputs, needs, secrets, ...) are registered foldsEagerly in the github lexicon plugin. Fixes #1966
This was referenced Sep 7, 2026
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.
Baseline vs after
Command (same both times):
npx vitest run examples/fold-differential.test.ts --reporter=verbose(afterjust regento build fresh lexicon artifacts).The corpus grew from the 101 the issue measured against (#1172's close-out) to 108 by the time this PR started — unrelated additions between #1169 and now.
EXPECTED_FOLDinexamples/fold-differential.test.tsonly lists the 7 entries this PR moves; a handful of other entries fold today without ever having been added to that list (a pre-existing gap, out of scope here).Per-entry, the 7 that flip:
Docs regenerated with
npm run generate:fold-coverage(82 -> 89 of 108 in bothtypescript-as-data.mdxandsandbox.mdx).Mechanism (a) — composite factory calls narrowed to
.stepCheckout({...}).step,SetupNode({...}).step— every lexicon's single-actionComposite()wrapper, embedded inline in aJob'sstepsarray exactly ascomposites.mdxdocuments.fold()had no case for aCallExpressionused as a value beyond three closed allowlists (a registered chant helper, an opted-in intrinsic, a project-local foldable function, #1373) — a composite factory call fell straight through to "function call as a value is not foldable."This is deliberately narrower than "any call, any member access."
fold()now recognizes exactly the<Identifier>(...).stepshape — the same one chant #1544 already carved out of EVL001 as a documented, correct fallback (allowCompositeStepAccess) rather than a lint error. The callee must be a bare identifier not already claimed by one of the three existing call shapes; the member must be literally"step". It reduces to a new envelope,FoldedCompositeStepCall(packages/core/src/fold/fold.ts), carrying the callee name and folded arguments — nothing is imported or invoked insidefold()itself, matching every other envelope-producing branch there.Revival (
packages/core/src/discovery/fold-import.ts) resolves the callee through the folding file's own imports via a newresolveCompositeCall, which is the nested-value counterpart to the existingresolveCallExpressionthe top-level declarator path (export const x = Checkout({...})) already used: try interpreting the factory body when it's a project-file registeredComposite(chant #1023's existing, unmodified machinery), otherwise import and invoke it for real — the arm every lexicon-package composite (Checkout,SetupNode, …) always takes, exactly as it already does for a top-level declarator.invokeImportedCalleewas split into a node-freeinvokeResolvedCalleecore so this reuses the identical refusal/resolve/import/callable-check/call sequence rather than a second copy — including the--sandboxgate (sandboxedExecutionRefusal), unchanged.Soundness: this is not a new execution class. A lexicon-package composite invoked from a nested value position goes through the exact same in-process invocation a top-level
export const x = Checkout({...})already performs today — same trust boundary, same--sandboxrefusal for a project-owned factory. The--sandboxdifferential (examples/sandbox-execution-boundary.test.ts) still reports 0 project source executed in-process after this change.subset.ts'sallowCompositeStepAccessEVL-only opt-in is removed (not just left in place): oncefold()accepts the shape unconditionally, keeping a separate opt-in flag around would make the shared predicate answer differently fromfold()for a caller that forgets to pass it — exactly the divergence directionsubset.ts's own module doc says it may never have.findSubsetViolation/checkObjectMember/checkArrayElementnow accept<call>(...).stepunconditionally, matching how a nestednew Type(...)has been unconditional since #1169.Residual, found while measuring: 4 more github entries (
docker-build,matrix-test,node-ci,reusable-workflow) also callCheckout(...)but do not flip — each stops one blocker behind it, on an unrelated.toString()method call (github.actor.toString(),matrix("os").toString(),inputs("node-version").toString()) or an array.join(...)inside a step'srun:string. These are plain functions from the github lexicon'sexpression.ts(not registered intrinsics), followed by a method call — a different, unscoped gap (method-call folding in general has no case infold(), by design) that this PR does not attempt. The composite-call cause itself is fully closed wherever it was the actual blocker.Mechanism (b) — helm's call-form intrinsics opted into
foldsAsCallHelm has no tagged templates at all — every intrinsic is a plain call — so before this PR helm had registered every intrinsic with
isTag: falseand never opted any of them intofoldsAsCall(chant #1044's existing mechanism, already used by AWS and Azure). A singleinclude(...)/printf(...)/toYaml(...)anywhere in a chart's resources forced the whole file back to run.Opted in, one at a time, in
lexicons/helm/src/plugin.ts:include,required,helmDefault,toYaml,quote,printf,tpl,lookup,filesGet,filesGlob,filesAsConfig,filesAsSecrets. Onlyinclude/printf/toYamlare actually exercised by the corpus (all three helm entries use all three together, so all three needed opting in before any one entry could flip) — the rest are audited to the identical standard and opted in for consistency with how AWS/Azure's audits cover their full applicable set, not just what their examples happen to exercise.Soundness, per
IntrinsicDef.foldsAsCall's criterion ("calling the intrinsic is a pure function of its arguments that builds a deterministic data envelope"): every one of the 12 is a pure string-interpolation function (lexicons/helm/src/intrinsics.ts) that builds aHelmTpl(or, forlookup, the same shape) from its arguments — no I/O, no mutation, no dependency on anything but the arguments.lookup's own side effect (a live cluster read) happens when Helm renders the resulting template at deploy time, not when this JS function runs atchant buildtime, so invoking it while folding is indistinguishable from invoking it during a real run of the file — the exact bar the field's doc sets.Deliberately left out, each for a specific reason:
values/Release/ChartRef/Capabilities/Templateare proxy objects, never called — nothing to opt in.withOrder/argoWavereturn a plain record meant to be spread ({...withOrder(1)}).fold()'s object-spread handling (Object.assign(obj, src)) runs synchronously on the immediately-folded value, before the async revival that turns a folded call into its real result — opting these in would spread the folded{__intrinsic, args}envelope's own keys into the object instead of the real record. A genuine soundness hazard, not an oversight.If/ElseIf/Range/Withtake an arbitrarybody/elseBodythat is often an arrow function (Range(list, (item) => ({...}))) or a nested Declarable.fold()already rejects a function used as a value on its own terms, so opting these in buys nothing measured on this corpus; left for a future PR to size against real usage rather than widened on speculation.What remains
.toString()/.join()method-call blocker (mechanism (a)'s residual above) — a different, unscoped cause.lexicons/github/examples/docs-snippetsuses a namedconst checkout = Checkout({...})referenced later ascheckout.step— a shape this PR doesn't cover (only the inlineCheckout({...}).stepform, matching the one EVL already carved out and the one the target corpus entries actually use).If/ElseIf/Range/With/withOrder/argoWavehelm intrinsics, and any lexicon-package composite pattern beyond.step, as noted above.Both mechanisms named in #1174 are fully implemented and sound; the residuals above are new causes this PR's own measurement surfaced, not gaps in what #1174 asked for.
Tests
npx tsc --noEmit -p packages/core/tsconfig.json— cleannpx eslint packages/— 0 errors (2 pre-existing warnings, unrelated)npx vitest run examples/fold-differential.test.ts --reporter=verbose— 112/112, zero driftnpx vitest run examples/sandbox-differential.test.ts examples/sandbox-execution-boundary.test.ts --reporter=verbose— 220/220,of which project-owned: 0npx vitest run packages/core— 5017/5017npx vitest run lexicons/helm lexicons/github lexicons/forgejo— 837+474+95 passednpx tsx scripts/check-lexicons.ts— all 15 lexicons 23/23 tier-1 (helm included)npx vitest run(whole repo) — 14281 passed, 0 failedFixes #1174
🤖 Generated with Claude Code