@intentius/chant 0.24.0 → 0.26.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/build.d.ts.map +1 -1
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/config-import.d.ts +33 -0
- package/dist/config-import.d.ts.map +1 -0
- package/dist/config-sandbox.d.ts +47 -0
- package/dist/config-sandbox.d.ts.map +1 -0
- package/dist/config.d.ts +11 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/discovery/entity-wire-codec.d.ts +15 -10
- package/dist/discovery/entity-wire-codec.d.ts.map +1 -1
- package/dist/discovery/graph.d.ts.map +1 -1
- package/dist/discovery/sandbox/config-run.d.ts +24 -0
- package/dist/discovery/sandbox/config-run.d.ts.map +1 -0
- package/dist/discovery/sandbox/config-wire.d.ts +84 -0
- package/dist/discovery/sandbox/config-wire.d.ts.map +1 -0
- package/dist/discovery/sandbox/driver.d.ts +49 -0
- package/dist/discovery/sandbox/driver.d.ts.map +1 -1
- package/dist/discovery/sandbox/fork.d.ts +70 -0
- package/dist/discovery/sandbox/fork.d.ts.map +1 -0
- package/dist/discovery/sandbox/policy-run.d.ts +33 -0
- package/dist/discovery/sandbox/policy-run.d.ts.map +1 -0
- package/dist/discovery/sandbox/policy-wire.d.ts +177 -0
- package/dist/discovery/sandbox/policy-wire.d.ts.map +1 -0
- package/dist/discovery/sandbox/run.d.ts +10 -20
- package/dist/discovery/sandbox/run.d.ts.map +1 -1
- package/dist/intrinsic-interpolation.d.ts.map +1 -1
- package/dist/lexicon-output.d.ts +62 -6
- package/dist/lexicon-output.d.ts.map +1 -1
- package/dist/lint/config.d.ts +6 -0
- package/dist/lint/config.d.ts.map +1 -1
- package/dist/lint/policy-import.d.ts +50 -0
- package/dist/lint/policy-import.d.ts.map +1 -0
- package/dist/lint/policy-sandbox.d.ts +89 -0
- package/dist/lint/policy-sandbox.d.ts.map +1 -0
- package/dist/lint/policy.d.ts +12 -1
- package/dist/lint/policy.d.ts.map +1 -1
- package/dist/stack-output.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/build.test.ts +96 -1
- package/src/build.ts +36 -12
- package/src/cli/commands/build.ts +46 -5
- package/src/cli/main.test.ts +93 -17
- package/src/cli/main.ts +111 -11
- package/src/config-import.ts +43 -0
- package/src/config-sandbox.ts +138 -0
- package/src/config.ts +14 -5
- package/src/discovery/entity-wire-codec.ts +35 -21
- package/src/discovery/entity-wire.test.ts +26 -0
- package/src/discovery/graph.test.ts +40 -1
- package/src/discovery/graph.ts +8 -2
- package/src/discovery/sandbox/config-boundary.test.ts +239 -0
- package/src/discovery/sandbox/config-run.ts +130 -0
- package/src/discovery/sandbox/config-wire.test.ts +110 -0
- package/src/discovery/sandbox/config-wire.ts +195 -0
- package/src/discovery/sandbox/driver.ts +200 -0
- package/src/discovery/sandbox/fork.ts +148 -0
- package/src/discovery/sandbox/policy-boundary.test.ts +325 -0
- package/src/discovery/sandbox/policy-run.ts +180 -0
- package/src/discovery/sandbox/policy-wire.test.ts +310 -0
- package/src/discovery/sandbox/policy-wire.ts +277 -0
- package/src/discovery/sandbox/run.ts +28 -85
- package/src/intrinsic-interpolation.test.ts +27 -1
- package/src/intrinsic-interpolation.ts +10 -2
- package/src/lexicon-output.test.ts +173 -1
- package/src/lexicon-output.ts +123 -14
- package/src/lint/config.ts +8 -4
- package/src/lint/policy-import.ts +70 -0
- package/src/lint/policy-sandbox.ts +123 -0
- package/src/lint/policy.ts +20 -2
- package/src/stack-output.test.ts +118 -0
- package/src/stack-output.ts +21 -5
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAA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AC,MAAM,CAAC,EAC9B,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,WAAW,CAAC,CAgBtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAUnD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB;IACpB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,2CAA2C;IAC3C,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB;IAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAoB/C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,uBAAuB;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,2JAA2J;IAC3J,WAAW,CAAC,EAAE,OAAO,kBAAkB,EAAE,oBAAoB,EAAE,CAAC;CACjE;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA+Y9E;AAiDD;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAIlD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAItD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,YAAY,EACrB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,GACxC,MAAM,IAAI,CAmCZ"}
|
package/dist/cli/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAMA,OAAO,EAAmC,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAMA,OAAO,EAAmC,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAoE9E;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAoQpD;AA2aD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB5E"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single place chant evaluates a project's `chant.config.ts` **in the CLI's
|
|
3
|
+
* own process**.
|
|
4
|
+
*
|
|
5
|
+
* This is the config-side analogue of `./discovery/import.ts`'s `importModule`
|
|
6
|
+
* — one narrow module whose only job is "execute project-authored code here",
|
|
7
|
+
* so that the question "did any project code run in this process?" has one
|
|
8
|
+
* place to look and one place to instrument (see
|
|
9
|
+
* `examples/sandbox-execution-boundary.test.ts`, which spies on both).
|
|
10
|
+
*
|
|
11
|
+
* Callers must not `import()` a config file directly. `./config-sandbox.ts`
|
|
12
|
+
* decides whether a given load is allowed to come through here at all: under
|
|
13
|
+
* `chant build --sandbox` it routes the evaluation into the sandboxed child
|
|
14
|
+
* instead (chant #1113), and these functions are never reached.
|
|
15
|
+
*
|
|
16
|
+
* `chant.config.json` is pure data and is parsed, not executed — it never goes
|
|
17
|
+
* through this module.
|
|
18
|
+
*/
|
|
19
|
+
/** The shape a config module evaluates to, before `default`/`config`/namespace selection. */
|
|
20
|
+
export type ConfigModuleNamespace = Record<string, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Import a `chant.config.ts` into THIS process and return its module namespace.
|
|
23
|
+
* Node's ESM registry caches it, so repeated loads within one CLI invocation
|
|
24
|
+
* evaluate the file once — the behavior `loadChantConfig` has always had.
|
|
25
|
+
*/
|
|
26
|
+
export declare function importConfigModule(configPath: string): Promise<ConfigModuleNamespace>;
|
|
27
|
+
/**
|
|
28
|
+
* `require()` a `chant.config.ts` into THIS process from `dir`'s resolution
|
|
29
|
+
* context — the synchronous path `./lint/config.ts`'s `loadConfig` has used
|
|
30
|
+
* since before the async loader existed (`chant lint` is a sync pipeline).
|
|
31
|
+
*/
|
|
32
|
+
export declare function requireConfigModule(configPath: string, dir: string): ConfigModuleNamespace;
|
|
33
|
+
//# sourceMappingURL=config-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-import.d.ts","sourceRoot":"","sources":["../src/config-import.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AAEH,6FAA6F;AAC7F,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5D;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAE3F;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAG1F"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ConfigModuleNamespace } from "./config-import.js";
|
|
2
|
+
/**
|
|
3
|
+
* Arm sandboxed config evaluation for the rest of this process. Called from
|
|
4
|
+
* `../cli/main.ts` immediately after `parseArgs`, when `--sandbox` was passed
|
|
5
|
+
* — before the first config load. Idempotent; there is deliberately no
|
|
6
|
+
* disarm, because a security mode that can be turned off partway through a
|
|
7
|
+
* process is not one.
|
|
8
|
+
*/
|
|
9
|
+
export declare function armSandboxConfigEvaluation(): void;
|
|
10
|
+
/** Whether {@link armSandboxConfigEvaluation} has been called. */
|
|
11
|
+
export declare function isSandboxConfigEvaluationArmed(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Test-only reset. Vitest gives each test file its own module registry, so
|
|
14
|
+
* this exists for suites that arm and disarm within one file.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resetSandboxConfigEvaluationForTests(): void;
|
|
17
|
+
/**
|
|
18
|
+
* The export a config module's configuration lives on: an explicit `default`,
|
|
19
|
+
* a named `config`, else the module namespace itself (a config authored as a
|
|
20
|
+
* set of top-level named exports). Applied identically on both sides of the
|
|
21
|
+
* boundary — in the child by `./discovery/sandbox/driver.ts`'s config driver,
|
|
22
|
+
* here for the in-process path — so `--sandbox` changes only where the file is
|
|
23
|
+
* evaluated, never how its result is read.
|
|
24
|
+
*/
|
|
25
|
+
export declare function selectConfigExport(namespace: ConfigModuleNamespace): unknown;
|
|
26
|
+
/**
|
|
27
|
+
* Evaluate a project's `chant.config.ts` and return its configuration object,
|
|
28
|
+
* pre-`normalizeConfig`. Sandboxed when armed, in-process otherwise.
|
|
29
|
+
*
|
|
30
|
+
* @param configPath - Absolute path to the config file.
|
|
31
|
+
* @param projectRoot - Directory to grant the sandboxed child read access to;
|
|
32
|
+
* defaults to the config file's own directory.
|
|
33
|
+
*/
|
|
34
|
+
export declare function evaluateProjectConfig(configPath: string, projectRoot?: string): Promise<unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Synchronous counterpart for `./lint/config.ts`'s `loadConfig` (`chant lint`
|
|
37
|
+
* is a sync pipeline and predates the async loader).
|
|
38
|
+
*
|
|
39
|
+
* When armed, this cannot spawn a child — so it uses the result of an earlier
|
|
40
|
+
* armed load of the same file, and refuses if there isn't one. In practice
|
|
41
|
+
* there always is: `../cli/main.ts` loads the project config before dispatching
|
|
42
|
+
* to any command. Refusing rather than falling back to an in-process `require`
|
|
43
|
+
* is the point — a sync call site is exactly where a boundary would otherwise
|
|
44
|
+
* be lost by accident.
|
|
45
|
+
*/
|
|
46
|
+
export declare function evaluateProjectConfigSync(configPath: string, dir: string): unknown;
|
|
47
|
+
//# sourceMappingURL=config-sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-sandbox.d.ts","sourceRoot":"","sources":["../src/config-sandbox.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAmDtG;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AAED,kEAAkE;AAClE,wBAAgB,8BAA8B,IAAI,OAAO,CAExD;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,IAAI,IAAI,CAG3D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,qBAAqB,GAAG,OAAO,CAE5E;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,EAClB,WAAW,GAAE,MAA4B,GACxC,OAAO,CAAC,OAAO,CAAC,CAclB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAUlF"}
|
package/dist/config.d.ts
CHANGED
|
@@ -276,8 +276,17 @@ export declare const DEFAULT_CHANT_CONFIG: ChantConfig;
|
|
|
276
276
|
/**
|
|
277
277
|
* Load project configuration from a directory.
|
|
278
278
|
*
|
|
279
|
-
* Tries `chant.config.ts` first
|
|
280
|
-
*
|
|
279
|
+
* Tries `chant.config.ts` first, then `chant.config.json`. Returns default
|
|
280
|
+
* config if neither exists.
|
|
281
|
+
*
|
|
282
|
+
* chant #1113 — `chant.config.ts` is project-authored code, so *where* it is
|
|
283
|
+
* evaluated is a security question, and the answer is
|
|
284
|
+
* `./config-sandbox.ts`'s: in a sandboxed child when this process was armed by
|
|
285
|
+
* `chant build --sandbox`, in-process (exactly as before) otherwise. Either
|
|
286
|
+
* way the result is the same plain configuration object, and validation
|
|
287
|
+
* ({@link normalizeConfig}) happens here, in the trusted process.
|
|
288
|
+
* `chant.config.json` is data, not code — it is parsed in-process under
|
|
289
|
+
* `--sandbox` too, because there is nothing to execute.
|
|
281
290
|
*/
|
|
282
291
|
export declare function loadChantConfig(dir: string): Promise<ResolvedConfig>;
|
|
283
292
|
/**
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],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GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAGlF;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAGrF;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,UAAU,CAE1F;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,uBAAuB;IACtC,gJAAgJ;IAChJ,OAAO,EAAE,OAAO,CAAC;IACjB,qIAAqI;IACrI,GAAG,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACtB,6RAA6R;IAC7R,sBAAsB,EAAE;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,GAAG,uBAAuB,CAanF;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAW1E"}
|
|
@@ -23,20 +23,25 @@
|
|
|
23
23
|
* value) becomes a name-keyed marker instead. {@link decodeEntitySet} is the
|
|
24
24
|
* inverse — it rebuilds a live `Map<string, Declarable>` whose entities are
|
|
25
25
|
* BEHAVIORALLY indistinguishable from what `discover()` would have produced
|
|
26
|
-
* in-process: real `AttrRef` instances
|
|
27
|
-
* `
|
|
26
|
+
* in-process: real `AttrRef` instances, not a duck-typed `{__attrRef}`
|
|
27
|
+
* envelope alone. `new AttrRef(...)` here is plain, direct construction from
|
|
28
|
+
* this module's own class — this codec runs inside the same module graph as
|
|
29
|
+
* every downstream reader (`intrinsic-interpolation.ts`'s
|
|
28
30
|
* `defaultInterpolationSerializer`, `discovery/graph.ts`'s
|
|
29
31
|
* `buildDependencyGraph`, `build.ts`'s `detectCrossLexiconRefs`/
|
|
30
|
-
* `computeStackGraph
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* `computeStackGraph`, all converted to `isAttrRefLike` duck-typing by chant
|
|
33
|
+
* #1137 for the OTHER hazard, a separately-loaded lexicon copy) — so there is
|
|
34
|
+
* no dual-package boundary to duck-type across here, and building the real
|
|
35
|
+
* class is simply less code than hand-assembling a shape-alike stand-in with
|
|
36
|
+
* matching methods, and whole-entity embeds restored to the SAME object
|
|
37
|
+
* reference (not a structurally-equal clone), so `entityNames.get(decl)`
|
|
38
|
+
* keeps working by identity exactly as it does today.
|
|
34
39
|
*
|
|
35
40
|
* `serializer-walker.ts`'s `walkValue` needs NO changes for this: it already
|
|
36
41
|
* falls back to reading a plain `{__attrRef}` envelope (added for intrinsics
|
|
37
42
|
* whose own `toJSON()` embeds one). `decodeEntitySet` goes further and
|
|
38
|
-
* reconstructs the real class
|
|
39
|
-
*
|
|
43
|
+
* reconstructs the real class, both simpler here and a belt-and-suspenders
|
|
44
|
+
* match for any call site that still checks `instanceof AttrRef` directly.
|
|
40
45
|
*
|
|
41
46
|
* Naming happens exactly once, inside the boundary — `resolveAttrRefs`
|
|
42
47
|
* (./resolve.ts) runs as part of `discover()`, before `encodeEntitySet` is
|
|
@@ -78,7 +83,7 @@ import { type Declarable } from "../declarable.js";
|
|
|
78
83
|
* form. `refs` additionally captures any `AttrRef`/whole-entity reference
|
|
79
84
|
* found while walking the intrinsic's OWN fields (not through `toJSON()`)
|
|
80
85
|
* — `buildDependencyGraph` and `detectCrossLexiconRefs`/`computeStackGraph`
|
|
81
|
-
* walk raw entity property trees looking for `
|
|
86
|
+
* walk raw entity property trees looking for an `AttrRef`-like value/a
|
|
82
87
|
* tracked `Declarable`, not through `toJSON()`, so a ref nested inside e.g.
|
|
83
88
|
* a `Sub` template needs to still be discoverable post-decode for
|
|
84
89
|
* cross-lexicon output auto-detection and dependency ordering to keep
|
|
@@ -141,7 +146,7 @@ export interface WireLexiconOutputEntity {
|
|
|
141
146
|
form: "lexiconOutput";
|
|
142
147
|
name: string;
|
|
143
148
|
outputName: string;
|
|
144
|
-
/** The wrapped `AttrRef` or
|
|
149
|
+
/** The wrapped `AttrRef`, `Intrinsic`, or literal — encodes to `{__attrRef}`, `{__intrinsic}`, or a plain JSON primitive respectively (chant #1121; see {@link WireValue}). */
|
|
145
150
|
ref: WireValue;
|
|
146
151
|
}
|
|
147
152
|
export type WireEntity = WireDeclarableEntity | WireLexiconOutputEntity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-wire-codec.d.ts","sourceRoot":"","sources":["../../src/discovery/entity-wire-codec.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"entity-wire-codec.d.ts","sourceRoot":"","sources":["../../src/discovery/entity-wire-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAA2C,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAOzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,EAAE,GACX;IAAE,SAAS,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACpD;IAAE,WAAW,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACnC;IAAE,UAAU,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,C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CA0C5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/discovery/graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/discovery/graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAKhD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAChC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAuB1B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface SandboxConfigResult {
|
|
2
|
+
/** The evaluated configuration, as plain JSON. Interpreted (default/config/namespace selection already applied in the child; Zod validation still to come) by `../../config.ts`'s `normalizeConfig`, in the parent, unchanged. */
|
|
3
|
+
config: unknown;
|
|
4
|
+
/** esbuild bundling wall-clock time. */
|
|
5
|
+
bundleMs: number;
|
|
6
|
+
/** Bundle size in bytes. */
|
|
7
|
+
bundleBytes: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Evaluate `configPath` in a sandboxed child and return its configuration as
|
|
11
|
+
* plain data.
|
|
12
|
+
*
|
|
13
|
+
* Throws — rather than degrading to an in-process import or to defaults — when
|
|
14
|
+
* the config cannot be evaluated inside the boundary or cannot cross it as
|
|
15
|
+
* JSON. Under `--sandbox` a config that "almost" loaded is not a safe thing to
|
|
16
|
+
* proceed with, and quietly falling back would give away the property the flag
|
|
17
|
+
* exists to provide.
|
|
18
|
+
*
|
|
19
|
+
* @param configPath - Absolute path to the project's `chant.config.ts`.
|
|
20
|
+
* @param projectRoot - Directory the child is granted `--allow-fs-read` for
|
|
21
|
+
* (the config's own project root, i.e. `findProjectConfig`'s `dir`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function evaluateConfigSandboxed(configPath: string, projectRoot: string): Promise<SandboxConfigResult>;
|
|
24
|
+
//# sourceMappingURL=config-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-run.d.ts","sourceRoot":"","sources":["../../../src/discovery/sandbox/config-run.ts"],"names":[],"mappings":"AA0DA,MAAM,WAAW,mBAAmB;IAClC,kOAAkO;IAClO,MAAM,EAAE,OAAO,CAAC;IAChB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,mBAAmB,CAAC,CA6C9B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chant #1113 — what a `chant.config.ts` may contain if it is to be evaluated
|
|
3
|
+
* inside the sandbox boundary and handed back to the CLI as data.
|
|
4
|
+
*
|
|
5
|
+
* Under `--sandbox` the config file is evaluated in a child process (see
|
|
6
|
+
* `./config-run.ts`), so the only thing that can come back is what survives a
|
|
7
|
+
* process boundary: JSON. Node's IPC channel serializes with `JSON.stringify`
|
|
8
|
+
* by default, and `JSON.stringify` is *lossy without complaining* — a function
|
|
9
|
+
* property vanishes, a `Date` becomes a string, a `Map` becomes `{}`, `NaN`
|
|
10
|
+
* becomes `null`. Silently handing the CLI a config that differs from the one
|
|
11
|
+
* the project wrote is the worst available outcome for a security feature, so
|
|
12
|
+
* this module walks the value FIRST and reports every offending key path.
|
|
13
|
+
* `./config-run.ts` turns a non-empty report into a build error that names the
|
|
14
|
+
* keys; nothing is ever dropped quietly.
|
|
15
|
+
*
|
|
16
|
+
* This module is bundled INTO the generated config driver (`./driver.ts`'s
|
|
17
|
+
* `generateConfigDriverSource`) and runs inside the sandboxed child, next to
|
|
18
|
+
* the project code it is inspecting — so it must not import anything, and must
|
|
19
|
+
* not touch the filesystem, the environment or the process.
|
|
20
|
+
*
|
|
21
|
+
* chant #1131 reuses the same walk for the OTHER direction: a `lint.policies`
|
|
22
|
+
* check runs inside a sandboxed child and its `PostSynthDiagnostic[]` has to
|
|
23
|
+
* come back as data (`./policy-wire.ts`). That is the same "JSON is lossy
|
|
24
|
+
* without complaining" problem with a different root value, so the walk is
|
|
25
|
+
* exported as {@link scanValueWireSafety} rather than copied.
|
|
26
|
+
*
|
|
27
|
+
* ## What `ChantConfig` legally holds
|
|
28
|
+
*
|
|
29
|
+
* Every field of `ChantConfig` (`../../config.ts`) is JSON data: string arrays
|
|
30
|
+
* (`lexicons`, `capabilities`, `environments`), strings (`sourceDir`), nested
|
|
31
|
+
* plain objects of strings/booleans (`ownership`, `build`, `release`, `sbom`,
|
|
32
|
+
* `signing`, `vulnPolicy`), arrays of plain objects (`stacks`), and records of
|
|
33
|
+
* plain objects (`buildParams`). `lint` is a `LintConfig`, whose rule values
|
|
34
|
+
* are a severity string or a `[severity, options]` tuple, and whose `plugins`
|
|
35
|
+
* / `policies` are file *paths* — chant loads those modules itself, they are
|
|
36
|
+
* not functions embedded in the config. So the declared type admits nothing
|
|
37
|
+
* that fails the check below.
|
|
38
|
+
*
|
|
39
|
+
* The one way to get there is `ChantConfigSchema`'s `.passthrough()`, which
|
|
40
|
+
* accepts unknown extra keys of any type (that is how a lexicon extends the
|
|
41
|
+
* config — `temporal:` in the temporal lexicon's `TemporalChantConfig`, itself
|
|
42
|
+
* pure data). A project that parks a function under such a key gets a clear
|
|
43
|
+
* error naming it, rather than a config that silently lost it.
|
|
44
|
+
*
|
|
45
|
+
* ## The one accepted lossy case: `undefined` object properties
|
|
46
|
+
*
|
|
47
|
+
* `{ sourceDir: undefined }` and `{}` are indistinguishable to every reader of
|
|
48
|
+
* `ChantConfig` — each field is optional and every resolver tests
|
|
49
|
+
* `config.x === undefined` / `?.` — so an `undefined`-valued property is
|
|
50
|
+
* dropped rather than rejected, exactly as omitting the key would be. An
|
|
51
|
+
* `undefined` inside an ARRAY is a different story (`JSON.stringify` rewrites
|
|
52
|
+
* it to `null`, changing the element), and is reported.
|
|
53
|
+
*/
|
|
54
|
+
/** One value in the config that cannot cross the sandbox boundary as data. */
|
|
55
|
+
export interface ConfigWireOffender {
|
|
56
|
+
/** Dotted/bracketed path from the config root, e.g. `lint.rules.foo` or `stacks[0].name`. */
|
|
57
|
+
path: string;
|
|
58
|
+
/** What was found there, phrased for an error message (e.g. `a function`, `a Date`). */
|
|
59
|
+
found: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* chant #1131 — report every value ANYWHERE in `value` that cannot cross the
|
|
63
|
+
* sandbox boundary as JSON, with paths rooted at `rootPath`.
|
|
64
|
+
*
|
|
65
|
+
* {@link scanConfigWireSafety} is the config-shaped entry point (it tolerates a
|
|
66
|
+
* module namespace object at the root); this one takes the value as given, so
|
|
67
|
+
* an array root (`diagnostics`) or a plain object root both work. Same rules,
|
|
68
|
+
* same `undefined`-object-property allowance — see the module doc.
|
|
69
|
+
*/
|
|
70
|
+
export declare function scanValueWireSafety(value: unknown, rootPath?: string): ConfigWireOffender[];
|
|
71
|
+
/**
|
|
72
|
+
* Report every value in `config` that cannot cross the sandbox boundary as
|
|
73
|
+
* JSON. An empty array means a `JSON.parse(JSON.stringify(config))` round-trip
|
|
74
|
+
* preserves the configuration exactly (modulo `undefined` object properties,
|
|
75
|
+
* which are dropped — see the module doc).
|
|
76
|
+
*
|
|
77
|
+
* `config` itself may be a module namespace object (`await import(...)` with
|
|
78
|
+
* no `default` export), which is not a plain object; its own enumerable keys
|
|
79
|
+
* are walked the same way rather than being reported wholesale.
|
|
80
|
+
*/
|
|
81
|
+
export declare function scanConfigWireSafety(config: unknown): ConfigWireOffender[];
|
|
82
|
+
/** Render a {@link ConfigWireOffender} list as the body of a build error — one line per offending key, most specific information first. */
|
|
83
|
+
export declare function formatConfigWireOffenders(configPath: string, offenders: readonly ConfigWireOffender[]): string;
|
|
84
|
+
//# sourceMappingURL=config-wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-wire.d.ts","sourceRoot":"","sources":["../../../src/discovery/sandbox/config-wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,KAAK,EAAE,MAAM,CAAC;CACf;AAiFD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,SAAK,GAAG,kBAAkB,EAAE,CAIvF;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,kBAAkB,EAAE,CAe1E;AAED,2IAA2I;AAC3I,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,SAAS,kBAAkB,EAAE,GACvC,MAAM,CAOR"}
|
|
@@ -10,4 +10,53 @@ export interface GenerateDriverOptions {
|
|
|
10
10
|
* never executed directly by the parent process.
|
|
11
11
|
*/
|
|
12
12
|
export declare function generateDriverSource(options: GenerateDriverOptions): string;
|
|
13
|
+
/**
|
|
14
|
+
* chant #1113 — generate the driver module that evaluates a project's
|
|
15
|
+
* `chant.config.ts` INSIDE the sandboxed child and hands back plain JSON.
|
|
16
|
+
*
|
|
17
|
+
* Same machinery as {@link generateDriverSource} above, deliberately: one
|
|
18
|
+
* literal-specifier dynamic `import()` esbuild can trace and inline, one IPC
|
|
19
|
+
* message back, `./child-errors.ts` for classification so a permission denial
|
|
20
|
+
* names the config file rather than leaking `ERR_ACCESS_DENIED`. The only
|
|
21
|
+
* difference is what crosses — a config is data, not an entity graph, so there
|
|
22
|
+
* is no naming/`AttrRef` step and no `EntitySetWire`; the child instead runs
|
|
23
|
+
* `./config-wire.ts`'s serializability scan and refuses to hand back a config
|
|
24
|
+
* that `JSON.stringify` would silently mangle.
|
|
25
|
+
*
|
|
26
|
+
* The child returns the raw module namespace's chosen export as-is — the
|
|
27
|
+
* `default ?? config ?? namespace` selection and Zod validation
|
|
28
|
+
* (`normalizeConfig`) stay in the parent, where they were, so `--sandbox`
|
|
29
|
+
* changes where the file is *evaluated* and nothing about how its result is
|
|
30
|
+
* interpreted.
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateConfigDriverSource(configPath: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* chant #1131 — generate the driver module that imports a project's
|
|
35
|
+
* `lint.policies` modules INSIDE the sandboxed child, runs their checks over
|
|
36
|
+
* the build result the parent hands it, and sends back plain
|
|
37
|
+
* `PostSynthDiagnostic`s.
|
|
38
|
+
*
|
|
39
|
+
* Same machinery again: literal-specifier dynamic `import()`s esbuild can trace
|
|
40
|
+
* and inline, `./child-errors.ts` for classification so a permission denial
|
|
41
|
+
* names the policy file, one IPC message back. Two things are specific to this
|
|
42
|
+
* one:
|
|
43
|
+
*
|
|
44
|
+
* - **It receives before it sends.** The run and config drivers are fully
|
|
45
|
+
* parameterized by their generated source; a policy check needs the finished
|
|
46
|
+
* build result, which is neither known at bundle time nor something to bake
|
|
47
|
+
* into a source literal. It arrives as one IPC message (see `./fork.ts`'s
|
|
48
|
+
* `send`). The `process.on("message", …)` registration is top-level and
|
|
49
|
+
* synchronous, so it is in place before the event loop can deliver anything
|
|
50
|
+
* — a message the parent sent before the child finished booting is queued on
|
|
51
|
+
* the channel, not lost.
|
|
52
|
+
* - **Checks run wrapped, not raw.** `runPostSynthChecks` (chant's own, from
|
|
53
|
+
* `../../lint/post-synth.ts`) is invoked ONCE over every check from every
|
|
54
|
+
* policy module, exactly as `cli/commands/build.ts` invokes it in-process —
|
|
55
|
+
* so the checks share one `PostSynthContext` and run in one order, and the
|
|
56
|
+
* diagnostics come back in the same sequence. The wrapper around each check
|
|
57
|
+
* is what makes a bad return value attributable: it scans that check's own
|
|
58
|
+
* output and throws a `PolicyWireError` naming the module the check was
|
|
59
|
+
* loaded from, rather than reporting an offending index in a merged array.
|
|
60
|
+
*/
|
|
61
|
+
export declare function generatePolicyDriverSource(policyPaths: readonly string[]): string;
|
|
13
62
|
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../../src/discovery/sandbox/driver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../../src/discovery/sandbox/driver.ts"],"names":[],"mappings":"AAiDA,MAAM,WAAW,qBAAqB;IACpC,qIAAqI;IACrI,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,oNAAoN;IACpN,SAAS,EAAE,MAAM,CAAC;CACnB;AAOD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAqF3E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CA6CrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAmGjF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place chant starts a sandboxed child process.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `./run.ts` by chant #1113, which added a SECOND thing that
|
|
5
|
+
* has to run behind the same boundary (`chant.config.ts` evaluation, see
|
|
6
|
+
* `./config-run.ts`). Both callers must get the identical `--permission`
|
|
7
|
+
* profile and the identical environment scrub — if the two drifted, the
|
|
8
|
+
* weaker one would silently become the boundary. Keeping the spawn itself in
|
|
9
|
+
* one function is the cheapest way to make "same profile" a fact rather than
|
|
10
|
+
* a claim.
|
|
11
|
+
*
|
|
12
|
+
* Isolation mechanics (verified on Node v24.13.1 — see the chant#1045 PR
|
|
13
|
+
* description for the full write-up):
|
|
14
|
+
* - `--permission --allow-fs-read=<bundle dir>,<project dir>[,<trusted
|
|
15
|
+
* external package dirs>]` — no filesystem write, no child-process, no
|
|
16
|
+
* worker-thread access. Bundling with esbuild first (`./bundle.ts`) means
|
|
17
|
+
* the child needs NO TypeScript loader (no `tsx`, so no `--allow-worker`
|
|
18
|
+
* and no writable temp dir either).
|
|
19
|
+
* - The env is a spawn-time scrub, not `--permission`: Node's Permission
|
|
20
|
+
* Model does not gate `process.env` at all (confirmed: every key stays
|
|
21
|
+
* readable even under `--permission`). See {@link SandboxForkOptions.env}.
|
|
22
|
+
* - Network egress is NOT addressed — Node has no flag for it. See
|
|
23
|
+
* `docs/.../architecture/sandbox.mdx` for the residual-risk statement.
|
|
24
|
+
*/
|
|
25
|
+
export interface SandboxForkOptions {
|
|
26
|
+
/** Absolute, realpath'd path to the bundled ESM entry file to run. */
|
|
27
|
+
bundlePath: string;
|
|
28
|
+
/** Absolute, realpath'd directory holding {@link bundlePath} — granted `--allow-fs-read`. */
|
|
29
|
+
bundleDir: string;
|
|
30
|
+
/** Absolute, realpath'd project directory — granted `--allow-fs-read`. */
|
|
31
|
+
projectRealpath: string;
|
|
32
|
+
/** Additional directories to grant `--allow-fs-read` (the resolved locations of `./bundle.ts`'s deliberately-unbundled trusted packages). */
|
|
33
|
+
externalReadPaths: readonly string[];
|
|
34
|
+
/**
|
|
35
|
+
* The child's ENTIRE environment. Callers pass an explicit, closed set —
|
|
36
|
+
* never a spread of `process.env`. `./run.ts` passes `PATH` only;
|
|
37
|
+
* `./config-run.ts` adds `CHANT_ENV` (see its doc for why that one
|
|
38
|
+
* variable, and only that one, is forwarded).
|
|
39
|
+
*/
|
|
40
|
+
env: Record<string, string>;
|
|
41
|
+
/** How long to wait for the child's one IPC message before killing it. */
|
|
42
|
+
timeoutMs: number;
|
|
43
|
+
/** What timed out / exited early, for the error message (e.g. `"sandboxed run"`). */
|
|
44
|
+
label: string;
|
|
45
|
+
/**
|
|
46
|
+
* chant #1131 — an optional payload sent to the child over the SAME IPC
|
|
47
|
+
* channel its response comes back on, immediately after the fork.
|
|
48
|
+
*
|
|
49
|
+
* The run and config children are fully described by their generated driver
|
|
50
|
+
* source, so they need nothing inbound. The policy child does: its input is
|
|
51
|
+
* the finished build result, which exists only after the parent has merged
|
|
52
|
+
* and serialized, long after the bundle was built. Sending it rather than
|
|
53
|
+
* baking it into a source literal keeps the bundle small (esbuild would
|
|
54
|
+
* otherwise parse a multi-megabyte literal) and keeps it off disk.
|
|
55
|
+
*
|
|
56
|
+
* Safe to send before the child has booted: `child.send` writes to the IPC
|
|
57
|
+
* pipe and Node queues the message until the child's channel is read, and
|
|
58
|
+
* the driver registers its `process.on("message", …)` synchronously at module
|
|
59
|
+
* top level — before the event loop can deliver anything. This is NOT a
|
|
60
|
+
* second protocol: same channel, same JSON, same one-message-back response.
|
|
61
|
+
*/
|
|
62
|
+
send?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Fork `bundlePath` under `--permission` with a scrubbed environment, and
|
|
66
|
+
* resolve with the first IPC message that satisfies `isResponse` (or reject
|
|
67
|
+
* on crash / timeout / fork error).
|
|
68
|
+
*/
|
|
69
|
+
export declare function forkSandboxed<T>(options: SandboxForkOptions, isResponse: (value: unknown) => value is T): Promise<T>;
|
|
70
|
+
//# sourceMappingURL=fork.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fork.d.ts","sourceRoot":"","sources":["../../../src/discovery/sandbox/fork.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,eAAe,EAAE,MAAM,CAAC;IACxB,6IAA6I;IAC7I,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;;;;;OAgBG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,OAAO,EAAE,kBAAkB,EAC3B,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,GACzC,OAAO,CAAC,CAAC,CAAC,CAwEZ"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PostSynthDiagnostic } from "../../lint/post-synth.js";
|
|
2
|
+
import { type EncodablePolicyBuildResult } from "./policy-wire.js";
|
|
3
|
+
export interface SandboxPolicyResult {
|
|
4
|
+
/** What the policy pack reported — plain data, validated inside the child before it crossed (see `./policy-wire.ts`'s `scanPolicyDiagnostics`). */
|
|
5
|
+
diagnostics: PostSynthDiagnostic[];
|
|
6
|
+
/** esbuild bundling wall-clock time. */
|
|
7
|
+
bundleMs: number;
|
|
8
|
+
/** Bundle size in bytes. */
|
|
9
|
+
bundleBytes: number;
|
|
10
|
+
/** Encoded build-result payload size in bytes — what crossed the IPC channel. */
|
|
11
|
+
payloadBytes: number;
|
|
12
|
+
}
|
|
13
|
+
export interface SandboxPolicyOptions {
|
|
14
|
+
/** Absolute paths to the project's `lint.policies` modules, in declaration order. */
|
|
15
|
+
policyPaths: readonly string[];
|
|
16
|
+
/** The merged, serialized build result the checks run over. */
|
|
17
|
+
buildResult: EncodablePolicyBuildResult;
|
|
18
|
+
/** The environment/stack this build was evaluated for (`--env`, else `ownership.env`) — becomes `ctx.env`. */
|
|
19
|
+
env?: string;
|
|
20
|
+
/** Directory the child is granted `--allow-fs-read` for: the project root (the `chant.config.*` directory, which `lint.policies` paths are resolved against). */
|
|
21
|
+
projectRoot: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Evaluate `policyPaths` against `buildResult` inside a sandboxed child.
|
|
25
|
+
*
|
|
26
|
+
* Throws — rather than degrading to an in-process run — when the policies
|
|
27
|
+
* cannot be evaluated inside the boundary or their diagnostics cannot cross it
|
|
28
|
+
* as JSON. Under `--sandbox` a policy pack that "almost" ran is not a safe
|
|
29
|
+
* thing to proceed with, and quietly falling back would give away the property
|
|
30
|
+
* the flag exists to provide.
|
|
31
|
+
*/
|
|
32
|
+
export declare function runPoliciesSandboxed(options: SandboxPolicyOptions): Promise<SandboxPolicyResult>;
|
|
33
|
+
//# sourceMappingURL=policy-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-run.d.ts","sourceRoot":"","sources":["../../../src/discovery/sandbox/policy-run.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAIjE,OAAO,EAGL,KAAK,0BAA0B,EAEhC,MAAM,eAAe,CAAC;AA+EvB,MAAM,WAAW,mBAAmB;IAClC,mJAAmJ;IACnJ,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,qFAAqF;IACrF,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,+DAA+D;IAC/D,WAAW,EAAE,0BAA0B,CAAC;IACxC,8GAA8G;IAC9G,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iKAAiK;IACjK,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA0DtG"}
|