Skip to content

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

Closed

Description

@lex00

Found wiring the specification's isolation mode through chant's adapter (chant#2438, tsad#113).

What

spec/judgments.md, F-IsolatedRefusal:

Under ι = isolated, any step above that would resolve and invoke or import a binding not on the trust allowlist (R2.1) - a project-owned factory, constructor, or intrinsic, is run("isolation"), even where B, open ⊢ f ⇓ fold(…). Interpretation (step 4) is not an invocation and is unaffected. Observable: R9.2's projectFactoryInvocations is zero across every folded file under isolated.

The observable is about invocation, not about reading source. F-Call step 4 interprets a factory body from the defining module's source and never imports it.

chant's --sandbox (#1093) is stronger: it refuses to import project code at all, which takes interpretation down with invocation.

Measured

Mapping the specification's isolated onto sandbox: true and running the composite-factory fixtures, the negatives start agreeing and the positives break:

S-FactoryBody/consts-then-a-final-return
  good.ts:  reference fold, chant run
S-FactoryParams/one-plainly-bound-parameter
  named.ts: reference fold, chant run

good.ts imports a composite whose factory body is consts then a final return, which is inside S-FactoryBody. Interpreting it needs the defining module's source and nothing else. Under isolated the reference folds it; chant's sandbox refuses.

Direction

This one is a coverage loss in the safe direction, unlike chant#2441: chant refuses where the specification permits, so it falls back to run rather than producing a value. It is the same class as the F-Div rows, and no output is wrong.

What it costs is that chant cannot answer any isolated fixture. The conformance adapter reports "unavailable" for them rather than folding in open mode, so F-IsolatedRefusal's own fixture is skipped at chant.

What the knob needs

Only that under --sandbox, F-Call step 4 still runs for a project composite whose registration the scan already found, and step 5 refuses the rest. chant's resolveInterpretableFactory already reads the defining module's source rather than importing it (inventory rows L7.1 to L7.5), so the interpretation path is already import-free; what refuses it is the blanket sandbox check in front.

Related

tsad#24 tracks the fixture this blocks. chant#2438 is the adapter work that surfaced it.

Activity

  1. added
    area:core
    P3
    on Sep 12, 2026
  2. lex00 commented on Sep 12, 2026

    @lex00
    ContributorAuthor

    Correcting my own framing: the gap is wider than this issue first described, and the fix is not a knob.

    What I originally wrote

    That --sandbox refuses to interpret where F-IsolatedRefusal refuses only to invoke, and that the fix was for step 4 to keep running under sandbox.

    What is actually happening

    Interpretation is already tried first and is not itself gated. resolveImportedCall calls resolveInterpretableFactory before anything is imported, and only falls through to invokeResolvedCallee, which holds the sandbox refusal, when interpretation declines.

    Interpretation declines here for a different reason. The factory body is ({ name }) => ({ bucket: new Bucket({ name }) }), so interpreting it reaches new Bucket(...), and constructing a host entity hits the same sandbox gate at the constructor site (fold-import.ts, the sandboxedExecutionRefusal(binding, ctx, typeName, "constructor") call). The refusal is on constructing, not on interpreting.

    Why that makes it a feature rather than a fix

    Under ι = isolated the specification does not construct at all. judgments.md, the isolated profile table:

    F-Val-Fate | altered: revival is serialization. An envelope is the output; {__resource}, {__intrinsic} and {__attrRef} reach the artifact as data for the host's serializer to map. No constructor and no function is invoked

    So the correct isolated behaviour is to fold new Bucket({ name }) to a {__resource} envelope and carry it into the artifact, not to construct it and not to fall back to run. chant under --sandbox falls back to run.

    Letting step 4 proceed would therefore not be enough, and would be worse than the current state: chant would construct live instances where the reference produces envelopes, and the exports would disagree instead of the verdicts. What isolated needs is envelope-mode folding, which is a change to what fold produces rather than to which paths are allowed to run.

    That is a real feature with a wide blast radius, not something to squeeze in. Re-scoping this issue accordingly, and it is not a blocker for anything today: chant simply reports "unavailable" for isolated fixtures in the conformance adapter, which is the contract behaviour and visible in the report.

    Direction is unchanged

    Still the safe one. chant refuses where the specification permits, so it loses coverage and never produces wrong output.

  3. lex00 commented on Sep 12, 2026

    @lex00
    ContributorAuthor

    Third and final correction, and this one is measured rather than reasoned. The cause is not the sandbox, and not envelope folding.

    What actually happens

    Folding the S-FactoryBody fixture directly, with and without sandbox:

    sandbox=false
      good.ts       fold
      no-return.ts  fold     <- the NEGATIVE case, folds
      empty.ts      fold     <- likewise
    
    sandbox=true
      good.ts       run   "g" is not foldable: composite factory "Good" is imported
                          from "./good-shapes", which is neither ...
      no-return.ts  run   (same shape)
      empty.ts      run   (same shape)
    

    The refusal names the project-file specifier at the invoke site, not the host constructor. So interpretation never engaged, under either setting, and everything went to arm 2.

    Why interpretation never engages

    findCompositeDefinition requires the registration form to be chant's own Composite:

    const compositeBinding = scope.imports.get(init.expression.text);
    if (!compositeBinding || compositeBinding.imported !== "Composite") return undefined;
    if (!isChantOwnedHelperBinding(compositeBinding, { ...ctx, file: scope.file })) return undefined;

    The fixture's Composite comes from @tsad/shapes, the host. It is not chant's, so resolveInterpretableFactory declines and arm 2 takes over: it invokes under open, and refuses under sandbox because the defining module is a project file.

    That accounts for every row above, including why the negatives fold under open (invocation succeeds, F-Call step 6) and why good.ts fails under sandbox for a reason that has nothing to do with new Bucket(...).

    So the real gap

    F-Host-Composite says the host supplies the registration form. chant recognises only its own, which is correct and deliberate for a chant project, where Composite is chant's and a shadowing local one must not count. It has simply never had to consider a host that supplies its own.

    What would close it is a rule for when a Composite-shaped call from an active host package counts as a registration form. That is a design decision about chant's composite model, not a knob, and it wants its own discussion: today the predicate's whole job is to refuse anything that is not chant's, and widening it touches the provenance question #1082 settled.

    Withdrawn from earlier comments

    • It is not that --sandbox blocks step 4. Step 4 is never reached.
    • It is not that isolated needs envelope folding in chant. The fixture's expected export is a constructed Bucket's own shape, {entityType, lexicon, props, attributes}, which is what chant already produces when it folds; encodeValue compares structurally, so no envelope mode is required for the exports to match.

    I got this wrong twice by reasoning from the spec text toward chant rather than reading what chant did. The measurement above is the thing to trust.

  4. lex00 commented on Sep 12, 2026

    @lex00
    ContributorAuthor

    Traced it to the exact line, and the fix is two steps rather than one. Neither is landed; I tried the first and backed it out.

    Instrumented, not inferred

    [2442] Composite from @tsad/shapes | allowlist=@tsad/shapes | chantOwned=false
    [2442] Good:     factory=true   interpreted=false
    [2442] Named:    factory=true   interpreted=false
    [2442] NoReturn: factory=false
    [2442] Empty:    factory=false
    

    NoReturn and Empty are correctly not interpretable, for their own stated reasons. Good and Named are recognised and then interpretation declines.

    Step 1, recognition

    findCompositeDefinition requires the registration form to be chant's own:

    if (!isChantOwnedHelperBinding(compositeBinding, { ...ctx, file: scope.file })) return undefined;

    Widening that to also accept a package the caller explicitly named in lexiconPackages makes factory=true where it was false, which is the first line of the trace above. It is inert for every real chant project: a chant build's allowlist holds only @intentius/chant-lexicon-*, and no lexicon exports a Composite (checked across all seventeen).

    Step 2, interpretation, not done

    With recognition fixed the body still declines, so the call falls through to the invocation arm exactly as before and the observable behaviour is unchanged. Good's body constructs a host entity, new Bucket({ name }), and that is where interpretation gives up.

    So step 1 alone changes nothing an adapter or a build can see. I backed it out rather than land half a provenance widening: the predicate's whole job today is to refuse what is not chant's, and loosening it without the half that makes it pay off is the kind of change that bites later.

    What the fix needs

    Both steps together: recognise a named host's registration form, and let interpretation construct a host entity from inside a factory body. The second is the one worth designing, and it is what decides whether this is small or not.

    Superseded

    Two earlier comments on this issue. It is not --sandbox blocking step 4, and it is not envelope folding. Both were reasoned from the specification toward chant instead of measured; the trace above is the thing to trust.

  5. lex00 commented on Sep 12, 2026

    @lex00
    ContributorAuthor

    Traced to the bottom. Three layers, not one, and the third is what makes this a feature rather than a fix.

    The whole chain, instrumented

    [2442] Composite from @tsad/shapes | allowlist=@tsad/shapes | chantOwned=false
    [2442] Good: factory=true  interpreted=false
    [2442] interpret "Good" declined: Composite "Good" member "bucket" is not a Declarable or CompositeInstance
    
    1. Recognition. findCompositeDefinition requires Composite to be chant's own. A host's form is refused, so interpretation never starts.
    2. Interpretation. With recognition widened, the body runs and reaches new Bucket({ name }).
    3. Member validation. chant's Composite requires every member to be a Declarable or a CompositeInstance. The host's Bucket is neither.

    Layer 3 is the one that decides the shape of this. isDeclarable keys off chant's own marker:

    DECLARABLE_MARKER in value && value[DECLARABLE_MARKER] === true

    The host's entities carry Symbol.for("tsad.conformance.declarable") instead. So chant does not reject the host's entity for being malformed; it rejects it for not being chant's.

    What that means

    This is not a knob and not a provenance widening. It is host entity interoperability: chant accepting an entity whose liveness marker is not its own, across at least three predicates that each independently ask "is this chant's?".

    It is also a decision the specification has a position on and chant does not yet implement. tsad#109 moved the reference's isLiveObject to treat an own symbol or a non-enumerable own property as the entity marker (L6.1); chant's isDeclarable requires one specific symbol set to true.

    So the question for chant is whether isDeclarable should recognise a foreign entity marker, and if so on whose say-so — a caller-named host package seems the only safe answer, matching how lexiconPackages already scopes the rest of this.

    Status

    Nothing landed. I implemented layer 1, confirmed it works (factory=true where it was false), and backed it out: on its own it changes nothing observable, since the call still falls through to the invocation arm, and loosening a predicate whose job is to refuse what is not chant's without the layers that make it pay off is worse than leaving it.

    Superseded

    The first two comments on this issue. It is not --sandbox blocking step 4, and it is not envelope folding. Both were reasoned from the specification toward chant rather than measured. The trace above is the thing to trust.

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

    P3area:core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions