Skip to content

fix(fold): interpret a composite the host registered (#2442) - #2443

Merged
lex00 merged 1 commit into
mainfrom
fix/2442-host-composite
Sep 12, 2026
Merged

lex00 merged 1 commit into
mainfrom
fix/2442-host-composite

Conversation

@lex00

@lex00 lex00 commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2442.

What was wrong

findCompositeDefinition required Composite to be chant's own. That is right for a chant project and is the provenance question #1082 settled: a project-local function Composite(...) shadowing the name is not chant's, and a call to it is not a registered composite.

It had never had to consider a host supplying the registration form (F-Host-Composite), because a chant project's active packages are all lexicons and no lexicon exports a Composite. Reaching the new branch at all needs a caller that named its own host packages (FoldProjectOptions.lexiconPackages, #2438), so nothing about a chant build moves. A test asserts that: unnamed, the host package is not resolvable and the sandbox refuses the invocation arm exactly as before.

The half with teeth

Recognising the form only gets interpretation started. The members it produces are then the host's, and wrapping them in chant's Composite runs chant's member validation, which asks for chant's own Declarable and refuses an entity carrying a different marker.

That was the actual failure, found by instrumenting rather than by reading:

Composite "Good" member "bucket" is not a Declarable or CompositeInstance

The specification's shapes host marks its entities with Symbol.for("tsad.conformance.declarable"). Chant was refusing them for not being chant's, not for being malformed. A host's form now returns its members as the factory built them; chant's own form still goes through Composite, unchanged.

I diagnosed this wrong twice on the issue before instrumenting (first --sandbox blocking step 4, then envelope folding); both are corrected there.

Effect

Clears the last three fixtures the specification's conformance harness held out under isolated mode, with every verdict and every export matching the reference adapter:

S-FactoryBody/consts-then-a-final-return
  bad-shapes.ts run OK / empty.ts run OK / good-shapes.ts run OK
  good.ts fold OK {"g":{"bucket":{"entityType":"Bucket","lexicon":"shapes",...
  no-return.ts run OK
S-FactoryParams/one-plainly-bound-parameter — named.ts fold OK, rest/two run OK
F-IsolatedRefusal/a-project-factory-is-refused-not-invoked — app.ts run OK, shapes.ts run OK

Gates

  • scripts/typecheck.ts: 31 known failures, no regressions
  • eslint clean
  • npx vitest run: 7 failed / 17,704 passed, the known local-only baseline (6 any-budget, 1 carve-bridge)
  • New: packages/core/src/discovery/fold-host-composite.test.ts, three cases — the host's form folds to the host's own members, a factory outside the subset is still refused rather than invoked, and the form is only recognised when the caller named the package.

`findCompositeDefinition` required `Composite` to be chant's own. That is
right for a chant project and is the provenance question #1082 settled: a
project-local `function Composite(...)` shadowing the name is not chant's,
and a call to it is not a registered composite.

It had never had to consider a host supplying the form
(`F-Host-Composite`), because a chant project's active packages are all
lexicons and no lexicon exports a `Composite`. Reaching the new branch at
all needs a caller that named its own host packages
(`FoldProjectOptions.lexiconPackages`, #2438), so no chant build moves.

The second half is the one with teeth. Recognising the form only gets
interpretation started; the members it produces are then the host's, and
wrapping them in chant's `Composite` runs chant's member validation, which
asks for chant's own `Declarable` and refuses an entity carrying a
different marker. That was the actual failure the conformance harness hit:
`Composite "Good" member "bucket" is not a Declarable or CompositeInstance`.
A host's form now returns its members as the factory built them; chant's
own form still goes through `Composite`, unchanged.

Clears the last three fixtures the specification's harness held out —
`S-FactoryBody`, `S-FactoryParams` and `F-IsolatedRefusal` under isolated
mode — with every verdict and export matching the reference adapter.
@lex00
lex00 force-pushed the fix/2442-host-composite branch from b1fa9df to 726b7ab Compare September 12, 2026 22:15
@lex00
lex00 merged commit 1727232 into main Sep 12, 2026
5 checks passed
@lex00
lex00 deleted the fix/2442-host-composite branch September 12, 2026 22:29
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.

--sandbox refuses to interpret a project composite, where F-IsolatedRefusal refuses only to invoke

1 participant