Skip to content

feat(core): fold — composite factory interpretation (removes the last run) #1023

Closed

Description

@lex00

Part of the fold epic. Cold-handoff. Hardest issue — the one that removes the last run. Depends on #4.

Context

A composite is a factory function (VpcStack({...})) the current model evaluates by running. To fold it, the folder must (a) recognize the callee is a registered Composite (not an arbitrary helper — a bare call stays rejected) and (b) interpret the factory body. The body is not arbitrary TS: EVL009/EVL010 already forbid data transforms and extractable constants inside composite factories, so it is limited to props, siblings, imported identifiers, ?? defaults, and resource()/nested-composite calls returning an object map.

Scope

Implement a constrained interpreter for composite factory bodies:

  • Resolve a call whose callee is a registered Composite; reject any other call (unchanged).
  • Bind the factory's props param to the folded argument object.
  • Evaluate the returned resource map: each resource(type, (siblings) => ({...})) callback folds with props and siblings in scope (EVL005 guarantees expression bodies; EVL007 guarantees siblings keys exist).
  • Support nested composites (recursion), ?? defaults on props.
  • Respect EVL009/010 constraints; anything outside them → FoldError.

Acceptance criteria

Out of scope

Any composite pattern EVL009/010 do not already permit — those stay a lint error, not a fold target.

Epic: #1019

Activity

  1. added
    enhancement
    on Jul 24, 2026
  2. changed the title [-]feat(core): fold — opt-in build path with run-fallback for composites[/-] [+]feat(core): fold — composite factory interpretation (removes the last run)[/+] on Jul 24, 2026
  3. lex00 commented on Jul 28, 2026

    @lex00
    ContributorAuthor

    Shipped in PR #1167 with one acceptance box honestly not met: 'corpus folds with zero run-path fallback' was unreachable when written — the 46 run-fallback entries are held by export default / exported functions / nested-new / process.env, not composite calls. What shipped: a closed interpretable subset (contract-documented), interpretation replacing invocation for project-owned registered Composites, verbatim fallback otherwise, execution accounting in both reports, and the boundary suite now asserting projectFactoryInvocations === 0 per entry. On the corpus, #1023's own class is empty; the machinery's real audience is an application's own composites/*.ts. The measured next gate is filed as the nested-new issue above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions