@intentius/chant 0.71.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/discovery/fold-import.d.ts +28 -1
- package/dist/discovery/fold-import.d.ts.map +1 -1
- package/dist/fold/fold.d.ts +29 -0
- package/dist/fold/fold.d.ts.map +1 -1
- package/dist/fold/subset.d.ts +34 -1
- package/dist/fold/subset.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/cli/commands/lint.test.ts +38 -4
- package/src/discovery/fold-host-packages.test.ts +89 -0
- package/src/discovery/fold-import.ts +35 -53
- package/src/fold/fold.test.ts +99 -6
- package/src/fold/fold.ts +139 -0
- package/src/fold/subset.test.ts +161 -20
- package/src/fold/subset.ts +136 -1
- package/src/index.ts +1 -1
- package/src/meta/declared-imports.test.ts +141 -0
|
@@ -252,7 +252,20 @@ export declare function lexiconPackageName(lexiconName: string): string;
|
|
|
252
252
|
* fold may not import or invoke anything outside the trusted allowlist —
|
|
253
253
|
* see {@link FoldSession.sandbox}.
|
|
254
254
|
*/
|
|
255
|
-
export declare function createFoldSession(intrinsics?: readonly IntrinsicDef[], buildParams?: Readonly<Record<string, BuildParamValue>>, lexicons?: readonly string[], sandbox?: boolean
|
|
255
|
+
export declare function createFoldSession(intrinsics?: readonly IntrinsicDef[], buildParams?: Readonly<Record<string, BuildParamValue>>, lexicons?: readonly string[], sandbox?: boolean,
|
|
256
|
+
/**
|
|
257
|
+
* chant#2438 — package specifiers to allow verbatim, alongside the ones
|
|
258
|
+
* derived from `lexicons`.
|
|
259
|
+
*
|
|
260
|
+
* A chant build's active packages are always `@intentius/chant-lexicon-*`,
|
|
261
|
+
* so naming lexicons is the whole story there. A caller embedding the fold
|
|
262
|
+
* path against a host that is not a chant lexicon has packages the naming
|
|
263
|
+
* convention cannot express: the specification's conformance harness supplies
|
|
264
|
+
* `@tsad/shapes`, which is its host's own specifier. The boundary is
|
|
265
|
+
* unchanged, an explicitly named package of this build, only now it can be
|
|
266
|
+
* named as a specifier rather than only as a lexicon.
|
|
267
|
+
*/
|
|
268
|
+
lexiconPackages?: readonly string[]): FoldSession;
|
|
256
269
|
/**
|
|
257
270
|
* What the fold pass actually EXECUTED, and what it interpreted instead — the
|
|
258
271
|
* number chant #1023 is measured by, and the one the #1093/#1111
|
|
@@ -515,6 +528,20 @@ export interface FoldProjectOptions {
|
|
|
515
528
|
readonly buildParams?: Readonly<Record<string, BuildParamValue>>;
|
|
516
529
|
/** chant #1093: this build asked for the sandbox, so fold may not reach outside the trusted allowlist. */
|
|
517
530
|
readonly sandbox?: boolean;
|
|
531
|
+
/**
|
|
532
|
+
* chant#2438 — package specifiers to follow a bare import into, verbatim,
|
|
533
|
+
* alongside whatever `lexicons` names.
|
|
534
|
+
*
|
|
535
|
+
* For a chant project this is never needed: an active package is always
|
|
536
|
+
* `@intentius/chant-lexicon-<name>`, which `lexicons` already expresses. It
|
|
537
|
+
* is here for a caller driving the fold path against a host of its own, where
|
|
538
|
+
* the package has a name chant's convention cannot spell. The specification's
|
|
539
|
+
* conformance harness is the first such caller, with `@tsad/shapes`.
|
|
540
|
+
*
|
|
541
|
+
* The boundary does not move. This is still an allowlist the caller states
|
|
542
|
+
* outright, matched by text, and absent it nothing bare resolves at all.
|
|
543
|
+
*/
|
|
544
|
+
readonly lexiconPackages?: readonly string[];
|
|
518
545
|
}
|
|
519
546
|
/** One file's place in a whole-build fold, as {@link foldProject} reports it. */
|
|
520
547
|
export interface FoldProjectVerdict {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fold-import.d.ts","sourceRoot":"","sources":["../../src/discovery/fold-import.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAMjC,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAkC,KAAK,iBAAiB,EAAyB,MAAM,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AAM,EAAE,CAAC;IACtC,qFAAqF;IACrF,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IACjE,0GAA0G;IAC1G,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C;AAED,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;IACjC,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,aAAa,CAAA;KAAE,CAAC;IAC3D,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,UAAU,GAAE,SAAS,YAAY,EAAO,EACxC,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAoC1C"}
|
package/dist/fold/fold.d.ts
CHANGED
|
@@ -411,6 +411,35 @@ export declare class FoldableFunction {
|
|
|
411
411
|
*/
|
|
412
412
|
leakedIdentity: boolean;
|
|
413
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* True when a module-level `const` is (transitively) bound to a `new Type(...)`.
|
|
416
|
+
* Follows an identifier chain (`const a = new T(); const b = a;`) so aliasing
|
|
417
|
+
* cannot smuggle a module-level resource into a function body.
|
|
418
|
+
*
|
|
419
|
+
* chant#2436 moved this here from ../discovery/fold-import.ts so the two places
|
|
420
|
+
* that build {@link FoldableFunction}s share one implementation rather than two
|
|
421
|
+
* that can drift.
|
|
422
|
+
*/
|
|
423
|
+
export declare function constResolvesToResource(consts: ReadonlyMap<string, ts.Expression>, name: string, seen?: Set<string>): boolean;
|
|
424
|
+
/**
|
|
425
|
+
* Every top-level function a file declares, exported or not, as a
|
|
426
|
+
* {@link FoldableFunction}: `function f(...) {...}` and `const f = (...) => …`.
|
|
427
|
+
*
|
|
428
|
+
* The markers carry `externals` BY REFERENCE, so the caller may keep filling it
|
|
429
|
+
* after this returns (which is how a sibling function, or a resource built
|
|
430
|
+
* later, becomes reachable from a body).
|
|
431
|
+
*
|
|
432
|
+
* `consts` drops every `new`-bound const, transitively through aliases: a body
|
|
433
|
+
* that mentions one must read the live instance out of `externals`, the same
|
|
434
|
+
* object the module's own fold registered, never re-fold the initializer and
|
|
435
|
+
* construct a duplicate of a resource discovery already has.
|
|
436
|
+
*
|
|
437
|
+
* chant#2436 — one implementation, called both by ../discovery/fold-import.ts
|
|
438
|
+
* during a build and by {@link fold} when a unit-level fold has no externals of
|
|
439
|
+
* its own. Getting the `new`-bound stripping wrong yields a wrong value rather
|
|
440
|
+
* than a fallback to run, which is why there is only one copy of it.
|
|
441
|
+
*/
|
|
442
|
+
export declare function collectSameFileFunctions(sourceFile: ts.SourceFile, consts: ReadonlyMap<string, ts.Expression>, file: string, externals: ReadonlyMap<string, unknown>, failures?: ReadonlyMap<string, string>): Map<string, FoldableFunction>;
|
|
414
443
|
export declare function isFoldableFunction(value: unknown): value is FoldableFunction;
|
|
415
444
|
/**
|
|
416
445
|
* The SHAPE half of what makes a project-local function foldable (chant
|
package/dist/fold/fold.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../src/fold/fold.ts"],"names":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CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAItE;AAOD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,CAYnF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,GAAG,MAAM,CAGtD;AAgRD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,EAClC,UAAU,GAAE,SAAS,YAAY,EAAO,EACxC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,WAAW,CAmeb;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,EAAE,CAAC,aAAa,EACtB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,EAClC,UAAU,GAAE,SAAS,YAAY,EAAO,EACxC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,cAAc,CA6BhB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,QAAQ,SAAc,EACtB,UAAU,GAAE,SAAS,YAAY,EAAO,GACvC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CA6BjC"}
|
package/dist/fold/subset.d.ts
CHANGED
|
@@ -46,7 +46,16 @@ import { type IntrinsicDef } from "../lexicon.js";
|
|
|
46
46
|
* expression, its operator, and (for keys) its literal-ness. It
|
|
47
47
|
* deliberately does NOT resolve bindings or perform any evaluation, because
|
|
48
48
|
* three things a full fold needs are inherently environment-dependent and
|
|
49
|
-
* cannot be recovered from shape alone
|
|
49
|
+
* cannot be recovered from shape alone.
|
|
50
|
+
*
|
|
51
|
+
* One thing it does read beyond the expression itself, since chant#2435: the
|
|
52
|
+
* enclosing file's top-level bindings, for `S-CallLocal`. A call to a
|
|
53
|
+
* project-local function is admitted by NAME (see
|
|
54
|
+
* {@link collectLocalCallables}), which is decidable from that file's syntax
|
|
55
|
+
* and needs no resolution. Before that, this module rejected all four shapes
|
|
56
|
+
* the build folds, which is the one direction `F-Direction` forbids, and it
|
|
57
|
+
* made `chant lint` report EVL001 on a file `chant build --fold` folds
|
|
58
|
+
* cleanly. The three genuinely environment-dependent cases are:
|
|
50
59
|
*
|
|
51
60
|
* 1. Identifier *resolution* — is a bare name actually a local `const`,
|
|
52
61
|
* vs. an unbound name? That needs the file's `consts` map. Both
|
|
@@ -196,6 +205,30 @@ export declare function isLiteralElementKey(node: ts.Expression): node is ts.Str
|
|
|
196
205
|
* one-line reason either.
|
|
197
206
|
*/
|
|
198
207
|
export declare function briefNodeText(node: ts.Node, maxLength?: number): string;
|
|
208
|
+
/**
|
|
209
|
+
* Every name a file binds to something a project-local call can reach.
|
|
210
|
+
*
|
|
211
|
+
* Two bindings, both of which the specification's `S-LocalFunction` names and
|
|
212
|
+
* both decidable from this file's own syntax, which is all a shape classifier
|
|
213
|
+
* has:
|
|
214
|
+
*
|
|
215
|
+
* - a top-level `function f(...) {...}`, or a `const f = (...) => ...`
|
|
216
|
+
* (a function expression counts, and parentheses / `as` / `satisfies`
|
|
217
|
+
* wrappers are unwrapped), exported or not;
|
|
218
|
+
* - a name imported from a *project* specifier, one starting `./` or `../`.
|
|
219
|
+
* A bare specifier is a package, and a package's function is not
|
|
220
|
+
* project-local.
|
|
221
|
+
*
|
|
222
|
+
* Deliberately syntax-only, and deliberately not a judgment about the callee's
|
|
223
|
+
* body. Whether the body is admissible is `S-FnBody`'s question and the fold's
|
|
224
|
+
* to answer, exactly as it already is for a call this classifier admits by
|
|
225
|
+
* name (a registered authoring helper, an opted-in intrinsic).
|
|
226
|
+
*
|
|
227
|
+
* Mirrors `collectLocalFunctions` in ../discovery/fold-import.ts, which builds
|
|
228
|
+
* the real `FoldableFunction` for each of these during a build. This one only
|
|
229
|
+
* needs the names.
|
|
230
|
+
*/
|
|
231
|
+
export declare function collectLocalCallables(sourceFile: ts.SourceFile): ReadonlySet<string>;
|
|
199
232
|
export declare function computedPropertyNameMessage(node: ts.PropertyName): string;
|
|
200
233
|
export declare function dynamicElementAccessMessage(keyNode: ts.Expression): string;
|
|
201
234
|
export declare const UNSUPPORTED_OBJECT_MEMBER_MESSAGE = "unsupported object member";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subset.d.ts","sourceRoot":"","sources":["../../src/fold/subset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAiD,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9F
|
|
1
|
+
{"version":3,"file":"subset.d.ts","sourceRoot":"","sources":["../../src/fold/subset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAiD,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwKG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,mEAAmE;AACnE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE/C,uGAAuG;AACvG,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;I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B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAElE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,EAAE,CAAC,wBAAwB,EACjC,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,GACnC,eAAe,GAAG,SAAS,CAc7B;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,GACnC,eAAe,GAAG,SAAS,CAkO7B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export * from "./graph-layout.js";
|
|
|
38
38
|
export * from "./graph-lens.js";
|
|
39
39
|
export * from "./detectLexicon.js";
|
|
40
40
|
export * from "./fold/fold.js";
|
|
41
|
-
export { findSubsetViolation, checkObjectMember, type SubsetViolation, type SubsetRuleId } from "./fold/subset.js";
|
|
41
|
+
export { findSubsetViolation, checkObjectMember, collectLocalCallables, type SubsetViolation, type SubsetRuleId } from "./fold/subset.js";
|
|
42
42
|
export { SPEC_VERSION } from "./fold/subset.js";
|
|
43
43
|
export { foldProject, planFoldTaintWithEdges, type FoldProjectOptions, type FoldProjectVerdict, type TaintPlan, type TaintEdgeKind, } from "./discovery/fold-import.js";
|
|
44
44
|
export * from "./lint/parser.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa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AAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAClE,cAAc,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC5F,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0",
|
|
4
4
|
"description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -93,6 +93,7 @@
|
|
|
93
93
|
"@dagrejs/dagre": "^3.0.0",
|
|
94
94
|
"esbuild": "^0.28.1",
|
|
95
95
|
"fflate": "^0.8.2",
|
|
96
|
+
"js-yaml": "^4.3.1",
|
|
96
97
|
"picomatch": "^4.0.3",
|
|
97
98
|
"tsx": "^4.0.0",
|
|
98
99
|
"typescript": "^5.5.0",
|
|
@@ -494,10 +494,42 @@ export const queue = new Queue({ name: Ref(environment) });
|
|
|
494
494
|
|
|
495
495
|
test("an unregistered call is still flagged as EVL001 in the same project", async () => {
|
|
496
496
|
await writeFile(join(testDir, "chant.config.json"), JSON.stringify({ lexicons: ["aws"] }));
|
|
497
|
+
// The call is to a name imported from a PACKAGE, which is what "unregistered"
|
|
498
|
+
// has to mean for this test to be about the registry. It used to be a
|
|
499
|
+
// same-file `function makeName()`, which chant#2435 established is
|
|
500
|
+
// `S-CallLocal` and admissible — the build folds that shape, so flagging it
|
|
501
|
+
// was the divergence, not the point being asserted here.
|
|
497
502
|
await writeFile(
|
|
498
503
|
join(testDir, "index.ts"),
|
|
499
504
|
`
|
|
500
505
|
import { Ref } from "@intentius/chant-lexicon-aws";
|
|
506
|
+
import { randomUUID } from "node:crypto";
|
|
507
|
+
|
|
508
|
+
class Queue {
|
|
509
|
+
constructor(_props: Record<string, unknown>) {}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export const queue = new Queue({ name: randomUUID() });
|
|
513
|
+
`,
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
const result = await lintCommand({ path: testDir, format: "stylish" });
|
|
517
|
+
|
|
518
|
+
const evl001 = result.diagnostics.filter((d) => d.ruleId === "EVL001");
|
|
519
|
+
expect(evl001).toHaveLength(1);
|
|
520
|
+
expect(evl001[0].message).toContain("statically evaluable");
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
test("a call to a project-local function is not flagged (chant#2435)", async () => {
|
|
524
|
+
await writeFile(join(testDir, "chant.config.json"), JSON.stringify({ lexicons: ["aws"] }));
|
|
525
|
+
// All three `S-LocalFunction` bindings in one file: a top-level function
|
|
526
|
+
// declaration, an arrow const, and a name imported from a project
|
|
527
|
+
// specifier. A build folds a call to each, so EVL001 must not flag one.
|
|
528
|
+
await writeFile(join(testDir, "helpers.ts"), `export function suffix(s: string): string { return s + "-x"; }\n`);
|
|
529
|
+
await writeFile(
|
|
530
|
+
join(testDir, "index.ts"),
|
|
531
|
+
`
|
|
532
|
+
import { suffix } from "./helpers";
|
|
501
533
|
|
|
502
534
|
class Queue {
|
|
503
535
|
constructor(_props: Record<string, unknown>) {}
|
|
@@ -507,15 +539,17 @@ function makeName(): string {
|
|
|
507
539
|
return "generated";
|
|
508
540
|
}
|
|
509
541
|
|
|
510
|
-
|
|
542
|
+
const label = (s: string): string => s.toUpperCase();
|
|
543
|
+
|
|
544
|
+
export const a = new Queue({ name: makeName() });
|
|
545
|
+
export const b = new Queue({ name: label("k") });
|
|
546
|
+
export const c = new Queue({ name: suffix("q") });
|
|
511
547
|
`,
|
|
512
548
|
);
|
|
513
549
|
|
|
514
550
|
const result = await lintCommand({ path: testDir, format: "stylish" });
|
|
515
551
|
|
|
516
|
-
|
|
517
|
-
expect(evl001).toHaveLength(1);
|
|
518
|
-
expect(evl001[0].message).toContain("statically evaluable");
|
|
552
|
+
expect(result.diagnostics.filter((d) => d.ruleId === "EVL001")).toHaveLength(0);
|
|
519
553
|
});
|
|
520
554
|
});
|
|
521
555
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { describe, test, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { foldProject } from "../index";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* chant#2438 — a host package that is not a chant lexicon.
|
|
9
|
+
*
|
|
10
|
+
* `FoldSession.lexiconPackages` is the entire allowlist a bare import is
|
|
11
|
+
* followed into, matched by text, and it has only ever been built from
|
|
12
|
+
* `@intentius/chant-lexicon-<name>`. That covers every chant project, because
|
|
13
|
+
* a chant project's active packages are exactly that.
|
|
14
|
+
*
|
|
15
|
+
* It does not cover a caller driving the fold path against a host of its own.
|
|
16
|
+
* The specification's conformance harness is the first: its `shapes` host owns
|
|
17
|
+
* `@tsad/shapes`, a name the convention cannot spell, so all twenty-five of its
|
|
18
|
+
* hosted whole-build fixtures were unanswerable at chant and reported skipped.
|
|
19
|
+
*
|
|
20
|
+
* `FoldProjectOptions.lexiconPackages` names such a package outright. The
|
|
21
|
+
* boundary is unchanged: still an allowlist the caller states, still matched by
|
|
22
|
+
* text, still empty by default.
|
|
23
|
+
*/
|
|
24
|
+
describe("foldProject — a host package outside the lexicon convention (chant#2438)", () => {
|
|
25
|
+
let root: string;
|
|
26
|
+
|
|
27
|
+
/** A project with a real `@tsad/shapes` in its own `node_modules`. */
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
root = mkdtempSync(join(tmpdir(), "chant-host-pkg-"));
|
|
30
|
+
const pkg = join(root, "node_modules", "@tsad", "shapes");
|
|
31
|
+
mkdirSync(pkg, { recursive: true });
|
|
32
|
+
writeFileSync(
|
|
33
|
+
join(pkg, "package.json"),
|
|
34
|
+
JSON.stringify({ name: "@tsad/shapes", version: "1.0.0", type: "module", main: "index.js" }),
|
|
35
|
+
);
|
|
36
|
+
writeFileSync(join(pkg, "index.js"), "export const SIZES = { small: 1, large: 3 };\n");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(() => rmSync(root, { recursive: true, force: true }));
|
|
40
|
+
|
|
41
|
+
const app = (source: string): string => {
|
|
42
|
+
const file = join(root, "app.ts");
|
|
43
|
+
writeFileSync(file, source);
|
|
44
|
+
return file;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
test("is not followed without being named, which is the pre-#2438 answer", async () => {
|
|
48
|
+
const file = app('import { SIZES } from "@tsad/shapes";\nexport const s = SIZES.large;\n');
|
|
49
|
+
const verdict = (await foldProject([file])).get(file)!;
|
|
50
|
+
|
|
51
|
+
expect(verdict.verdict).toBe("run");
|
|
52
|
+
expect(verdict.reason).toContain("unresolved identifier: SIZES");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("is followed when named, and the data export folds as a value", async () => {
|
|
56
|
+
const file = app('import { SIZES } from "@tsad/shapes";\nexport const s = SIZES.large;\n');
|
|
57
|
+
const verdict = (await foldProject([file], [], { lexiconPackages: ["@tsad/shapes"] })).get(file)!;
|
|
58
|
+
|
|
59
|
+
// The specification's `F-Host-DataExports/plain-data-export` fixture, and
|
|
60
|
+
// its `expect.json`, are exactly this.
|
|
61
|
+
expect(verdict.verdict).toBe("fold");
|
|
62
|
+
expect(Object.fromEntries(verdict.exports!)).toEqual({ s: 3 });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("naming one package does not open any other", async () => {
|
|
66
|
+
const other = join(root, "node_modules", "@tsad", "elsewhere");
|
|
67
|
+
mkdirSync(other, { recursive: true });
|
|
68
|
+
writeFileSync(
|
|
69
|
+
join(other, "package.json"),
|
|
70
|
+
JSON.stringify({ name: "@tsad/elsewhere", version: "1.0.0", type: "module", main: "index.js" }),
|
|
71
|
+
);
|
|
72
|
+
writeFileSync(join(other, "index.js"), "export const OTHER = 9;\n");
|
|
73
|
+
|
|
74
|
+
const file = app('import { OTHER } from "@tsad/elsewhere";\nexport const s = OTHER;\n');
|
|
75
|
+
const verdict = (await foldProject([file], [], { lexiconPackages: ["@tsad/shapes"] })).get(file)!;
|
|
76
|
+
|
|
77
|
+
expect(verdict.verdict).toBe("run");
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("sits alongside `lexicons`, rather than replacing it", async () => {
|
|
81
|
+
const file = app('import { SIZES } from "@tsad/shapes";\nexport const s = SIZES.small;\n');
|
|
82
|
+
const verdict = (
|
|
83
|
+
await foldProject([file], [], { lexicons: ["aws"], lexiconPackages: ["@tsad/shapes"] })
|
|
84
|
+
).get(file)!;
|
|
85
|
+
|
|
86
|
+
expect(verdict.verdict).toBe("fold");
|
|
87
|
+
expect(Object.fromEntries(verdict.exports!)).toEqual({ s: 1 });
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
FoldableFunction,
|
|
18
18
|
isFoldableFunction,
|
|
19
19
|
locate,
|
|
20
|
+
collectSameFileFunctions,
|
|
21
|
+
constResolvesToResource,
|
|
20
22
|
type FoldedResource,
|
|
21
23
|
type FoldedValue,
|
|
22
24
|
type FoldedIntrinsic,
|
|
@@ -307,6 +309,19 @@ export function createFoldSession(
|
|
|
307
309
|
buildParams?: Readonly<Record<string, BuildParamValue>>,
|
|
308
310
|
lexicons: readonly string[] = [],
|
|
309
311
|
sandbox = false,
|
|
312
|
+
/**
|
|
313
|
+
* chant#2438 — package specifiers to allow verbatim, alongside the ones
|
|
314
|
+
* derived from `lexicons`.
|
|
315
|
+
*
|
|
316
|
+
* A chant build's active packages are always `@intentius/chant-lexicon-*`,
|
|
317
|
+
* so naming lexicons is the whole story there. A caller embedding the fold
|
|
318
|
+
* path against a host that is not a chant lexicon has packages the naming
|
|
319
|
+
* convention cannot express: the specification's conformance harness supplies
|
|
320
|
+
* `@tsad/shapes`, which is its host's own specifier. The boundary is
|
|
321
|
+
* unchanged, an explicitly named package of this build, only now it can be
|
|
322
|
+
* named as a specifier rather than only as a lexicon.
|
|
323
|
+
*/
|
|
324
|
+
lexiconPackages: readonly string[] = [],
|
|
310
325
|
): FoldSession {
|
|
311
326
|
return {
|
|
312
327
|
intrinsics,
|
|
@@ -315,7 +330,7 @@ export function createFoldSession(
|
|
|
315
330
|
importCache: new Map(),
|
|
316
331
|
resolvePathCache: new Map(),
|
|
317
332
|
buildParams,
|
|
318
|
-
lexiconPackages: new Set(lexicons.map(lexiconPackageName)),
|
|
333
|
+
lexiconPackages: new Set([...lexicons.map(lexiconPackageName), ...lexiconPackages]),
|
|
319
334
|
sandbox,
|
|
320
335
|
factoryModules: new Map(),
|
|
321
336
|
};
|
|
@@ -764,14 +779,6 @@ function collectLocalBindings(sourceFile: ts.SourceFile): Map<string, LocalBindi
|
|
|
764
779
|
}
|
|
765
780
|
|
|
766
781
|
/** `(x) => …` / `function (x) {…}`, possibly wrapped in parens/`as`/`satisfies` — the initializer shapes that make a `const` a function binding. */
|
|
767
|
-
function unwrapFunctionInitializer(node: ts.Expression): ts.ArrowFunction | ts.FunctionExpression | undefined {
|
|
768
|
-
let current = node;
|
|
769
|
-
while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current)) {
|
|
770
|
-
current = current.expression;
|
|
771
|
-
}
|
|
772
|
-
return ts.isArrowFunction(current) || ts.isFunctionExpression(current) ? current : undefined;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
782
|
/**
|
|
776
783
|
* chant #1373 — every top-level function a file declares, exported or not, as
|
|
777
784
|
* a {@link FoldableFunction}: `function f(...) {...}` and `const f = (...) =>
|
|
@@ -786,29 +793,10 @@ function unwrapFunctionInitializer(node: ts.Expression): ts.ArrowFunction | ts.F
|
|
|
786
793
|
* module-level resource through `externals` only.
|
|
787
794
|
*/
|
|
788
795
|
function collectLocalFunctions(sourceFile: ts.SourceFile, ctx: ResolveCtx): Map<string, FoldableFunction> {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
const functions = new Map<string, FoldableFunction>();
|
|
794
|
-
const add = (name: string, fn: ts.FunctionDeclaration | ts.ArrowFunction | ts.FunctionExpression): void => {
|
|
795
|
-
functions.set(name, new FoldableFunction(name, fn, ctx.file, consts, ctx.externals, ctx.crossFileFailures));
|
|
796
|
-
};
|
|
797
|
-
|
|
798
|
-
for (const statement of sourceFile.statements) {
|
|
799
|
-
if (ts.isFunctionDeclaration(statement)) {
|
|
800
|
-
if (statement.name && statement.body) add(statement.name.text, statement);
|
|
801
|
-
continue;
|
|
802
|
-
}
|
|
803
|
-
if (!ts.isVariableStatement(statement)) continue;
|
|
804
|
-
if ((statement.declarationList.flags & ts.NodeFlags.Const) === 0) continue;
|
|
805
|
-
for (const decl of statement.declarationList.declarations) {
|
|
806
|
-
if (!ts.isIdentifier(decl.name) || !decl.initializer) continue;
|
|
807
|
-
const fn = unwrapFunctionInitializer(decl.initializer);
|
|
808
|
-
if (fn) add(decl.name.text, fn);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
return functions;
|
|
796
|
+
// chant#2436 — the walk itself, and the `new`-bound stripping that makes it
|
|
797
|
+
// correct, live in ../fold/fold.ts so a unit-level fold with no externals of
|
|
798
|
+
// its own binds exactly what a build binds.
|
|
799
|
+
return collectSameFileFunctions(sourceFile, ctx.consts, ctx.file, ctx.externals, ctx.crossFileFailures);
|
|
812
800
|
}
|
|
813
801
|
|
|
814
802
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -1939,27 +1927,6 @@ function factoryModuleScopeResolved(
|
|
|
1939
1927
|
return scope.resolved;
|
|
1940
1928
|
}
|
|
1941
1929
|
|
|
1942
|
-
/**
|
|
1943
|
-
* True when a module-level `const` is (transitively) bound to a
|
|
1944
|
-
* `new Type(...)`. Mirrors `fold()`'s own `resolvesToResource`, but follows an
|
|
1945
|
-
* identifier chain (`const a = new T(); const b = a;`) so aliasing can't smuggle
|
|
1946
|
-
* a module-level resource into a factory body — see
|
|
1947
|
-
* {@link FactoryModuleScope.consts}.
|
|
1948
|
-
*/
|
|
1949
|
-
function constResolvesToResource(
|
|
1950
|
-
consts: Map<string, ts.Expression>,
|
|
1951
|
-
name: string,
|
|
1952
|
-
seen: Set<string>,
|
|
1953
|
-
): boolean {
|
|
1954
|
-
if (seen.has(name)) return false;
|
|
1955
|
-
seen.add(name);
|
|
1956
|
-
const init = consts.get(name);
|
|
1957
|
-
if (init === undefined) return false;
|
|
1958
|
-
if (ts.isNewExpression(init)) return true;
|
|
1959
|
-
if (ts.isIdentifier(init)) return constResolvesToResource(consts, init.text, seen);
|
|
1960
|
-
return false;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
1930
|
/**
|
|
1964
1931
|
* Find `export const <exportName> = Composite(<fn>, "<name>")` at the top level
|
|
1965
1932
|
* of `scope`'s module, verifying that `Composite` really is chant's own in that
|
|
@@ -4099,6 +4066,20 @@ export interface FoldProjectOptions {
|
|
|
4099
4066
|
readonly buildParams?: Readonly<Record<string, BuildParamValue>>;
|
|
4100
4067
|
/** chant #1093: this build asked for the sandbox, so fold may not reach outside the trusted allowlist. */
|
|
4101
4068
|
readonly sandbox?: boolean;
|
|
4069
|
+
/**
|
|
4070
|
+
* chant#2438 — package specifiers to follow a bare import into, verbatim,
|
|
4071
|
+
* alongside whatever `lexicons` names.
|
|
4072
|
+
*
|
|
4073
|
+
* For a chant project this is never needed: an active package is always
|
|
4074
|
+
* `@intentius/chant-lexicon-<name>`, which `lexicons` already expresses. It
|
|
4075
|
+
* is here for a caller driving the fold path against a host of its own, where
|
|
4076
|
+
* the package has a name chant's convention cannot spell. The specification's
|
|
4077
|
+
* conformance harness is the first such caller, with `@tsad/shapes`.
|
|
4078
|
+
*
|
|
4079
|
+
* The boundary does not move. This is still an allowlist the caller states
|
|
4080
|
+
* outright, matched by text, and absent it nothing bare resolves at all.
|
|
4081
|
+
*/
|
|
4082
|
+
readonly lexiconPackages?: readonly string[];
|
|
4102
4083
|
}
|
|
4103
4084
|
|
|
4104
4085
|
/** One file's place in a whole-build fold, as {@link foldProject} reports it. */
|
|
@@ -4146,6 +4127,7 @@ export async function foldProject(
|
|
|
4146
4127
|
options.buildParams,
|
|
4147
4128
|
options.lexicons ?? [],
|
|
4148
4129
|
options.sandbox ?? false,
|
|
4130
|
+
options.lexiconPackages ?? [],
|
|
4149
4131
|
);
|
|
4150
4132
|
const attempts = new Map<string, FoldFileResult>();
|
|
4151
4133
|
for (const file of files) attempts.set(file, await tryFoldFile(file, intrinsics, session));
|