Skip to content

fold: F-Call step 5 refuses project-owned invocation outside executing (#199) - #2477

Merged
lex00 merged 2 commits into
mainfrom
spec/199-step6-executing
Sep 15, 2026
Merged

lex00 merged 2 commits into
mainfrom
spec/199-step6-executing

Conversation

@lex00

@lex00 lex00 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Closes #199. Implements spec 2.0 and declares 2.1.

The rule

5. Otherwise, under ι = isolated, F-IsolatedRefusal unless the binding is trusted; and under any mode but executing, run where the specifier is a project file. Project-owned invocation is executing's, as step 2's is.

Step 2's project-owned invocation moved behind executing at v0.72.3 (#2455). Step 6 is the same path and had not moved — the comment above the step-2 gate says so in as many words:

F-Call step 6's invocation is for a binding that is neither a declared function nor an interpretable composite, and it still happens — below, in the arm this one is not.

Where the gate sits

invokeResolvedCallee, the one choke point both step-6 callers reach (resolveImportedCall for the declarator form and resolveCompositeCall for <Identifier>(...).step). Constructor revival is a different path and is untouched.

It asks isTrustedExecutableBinding, not isProjectFileSpecifier alone. My first cut used the shape test, which is true of any absolute path — and chant's own modules are imported by absolute path throughout the tests, so it refused propagate and every other host function chant publishes. Four test failures were that mistake rather than the rule. "Project file" is the specifier's origin: an active lexicon package or chant-core's own tree is a package's code, everything else reached relatively or absolutely is the project's.

Fold coverage is unchanged

96 of 109 example projects before and after, with byte-identical generated docs. No corpus example reaches step 6 with a project-file callee — the ones that fold do it by interpretation at step 4.

That was the open question in #199 ("the step-6 subset of that, which is smaller"), and the answer is that it costs the corpus nothing.

executing is now reachable

It existed only on foldProject. discover and build now take it too, with the same sandbox-contradiction refusal, so a caller can ask for the mode the rule names as the way back.

The CLI flag and build.executing config key are #2476, left out deliberately to keep this change to the rule and its plumbing. Nothing in the corpus needs them today, which is why that is a follow-up and not a blocker.

Tests

Six encoded the old behaviour and now encode the new one, each with an executing counterpart so the mode stays covered. Two corrections in my own updates worth naming:

  • "the module did not run" was the wrong assertion. A run verdict means the file is run, and without --sandbox that is this process, so the module runs from the fallback. What the fold no longer does is invoke it — projectFactoryInvocations: 0 states that exactly, and the marker assertions were replaced with counter assertions.
  • fold-provenance.test.ts's fixture put an interpretable composite beside an inadmissible one in one file. A verdict is per file, so the refusal took the whole file to run and every field's origin with it. LegacyService moved to its own file; WebService still proves all four origin kinds.

Verification

  • packages/core/src/discovery — 433 passing
  • full suite — 17781 passing, 7 failing, and the same 7 fail on main (lexicons/aws/src/codegen/any-budget.test.ts and a terraform fmt check needing a binary this machine lacks)
  • tsc --noEmit -p packages/core/tsconfig.json clean
  • scripts/generate-fold-coverage.ts — 96 of 109, no doc diff

SPEC_VERSION 1.8 → 2.1

2.0 is this rule. 2.1 bounds what an entity constructor may do, which packages/core/src/runtime.ts already satisfies — it defines the markers, stores props, and builds one AttrRef per attrMap entry, with no validation, I/O or graph construction.

This closes the one-major window version.test.ts opened in the specification repo, which currently allows chant to declare at most one major behind and names #199 as what closes it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AzfJnYw9p6rAxhJqXK3CPv

…ting` (#199)

spec 2.0 narrows `F-Call` step 5: a declarator whose callee resolves to a
project file is `run` rather than imported and invoked at step 6, under any
mode but `ι = executing`. Invoking it runs the factory body, and its whole
module's top level, in the CLI's own process, and that is the project's own
code rather than a package's.

This is the same migration step 2 already made. Step 2's project-owned
invocation moved behind `executing` at v0.72.3 (#2455); step 6 is the same
path and had not moved. The specification decided first: its rationale says of
`executing` that "it is never the default", and `verdict.md` calls `open` the
strict default.

The gate is in `invokeResolvedCallee`, the one choke point both step-6 callers
reach, and it asks `isTrustedExecutableBinding` rather than
`isProjectFileSpecifier` alone. The shape test is true of any absolute path and
chant's own modules are imported by absolute path throughout the tests, so on
its own it refused `propagate` and every other host function chant publishes.
An active lexicon package or chant-core's own tree is a package's code; a
relative or absolute specifier reaching anything else is the project's.

`executing` was reachable only from `foldProject`. It is now on
`DiscoveryOptions` and `BuildOptions` too, so a caller can ask for the mode the
rule names, with the same sandbox-contradiction refusal `foldProject` has. The
CLI flag and the `build.executing` config key are #2476.

FOLD COVERAGE IS UNCHANGED: 96 of 109 example projects, byte-identical
generated docs. No corpus example reaches step 6 with a project-file callee.

Six tests encoded the old behaviour and now encode the new one, each keeping an
`executing` counterpart so the mode stays covered. Two corrections in them
worth naming:

  - "the module did not run" was the wrong assertion. A `run` verdict means
    the file IS run, and without --sandbox that is this process, so the module
    runs from the fallback. What the fold no longer does is invoke it, which
    `projectFactoryInvocations: 0` states exactly.
  - fold-provenance's fixture had an interpretable composite beside an
    inadmissible one in a single file. A verdict is per file, so the refusal
    took the whole file to run and every field's origin with it. The
    inadmissible one moved to its own file.

SPEC_VERSION 1.8 -> 2.1. 2.0 is this rule. 2.1 bounds what an entity
constructor may do, which `packages/core/src/runtime.ts` already satisfies: it
defines the markers, stores props, and builds one AttrRef per attrMap entry.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AzfJnYw9p6rAxhJqXK3CPv
…ts rules

`scripts/check-docs-citations.ts` loads rules from the pinned
`@intentius/tsad-conformance` and refuses a mismatch with chant's own
SPEC_VERSION:

  Docs citations: chant declares specification 2.1, the loaded rules are 1.8.

That gate is right, and it caught this commit's predecessor: chant cannot
claim a version whose rules it does not install. `@intentius/tsad-conformance`
2.1.0 carries spec 2.1 (typescript-as-data#209, tag `tsad-v2.1.0`), so the
declaration now has the rule set behind it.

  Docs citations: 166 file(s) clean against specification 2.1 (139 rules).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AzfJnYw9p6rAxhJqXK3CPv
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.

design: selective change-set scoping (affected-stack primitive)

1 participant