@intentius/chant 0.51.0 → 0.52.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/cli/build-options.d.ts +68 -0
- package/dist/cli/build-options.d.ts.map +1 -0
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/run.d.ts +0 -21
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/lifecycle/change-set.d.ts +23 -0
- package/dist/lifecycle/change-set.d.ts.map +1 -1
- package/dist/lint/policy.d.ts +16 -0
- package/dist/lint/policy.d.ts.map +1 -1
- package/dist/op/local-executor.d.ts +15 -1
- package/dist/op/local-executor.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli/build-options.test.ts +101 -0
- package/src/cli/build-options.ts +109 -0
- package/src/cli/commands/build.ts +24 -53
- package/src/cli/handlers/lifecycle.test.ts +19 -0
- package/src/cli/handlers/lifecycle.ts +14 -7
- package/src/cli/handlers/run.test.ts +96 -0
- package/src/cli/handlers/run.ts +37 -1
- package/src/cli/main.ts +2 -0
- package/src/lifecycle/change-set.test.ts +144 -1
- package/src/lifecycle/change-set.ts +133 -11
- package/src/lint/policy-build-parity.test.ts +232 -0
- package/src/lint/policy.ts +51 -6
- package/src/op/local-executor.ts +28 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place chant assembles `build()`'s options for a project directory.
|
|
3
|
+
*
|
|
4
|
+
* chant #2002 — `chant build` (./commands/build.ts) and the `policyGate` Op
|
|
5
|
+
* step (../lint/policy.ts's `evaluateProjectPolicies`) both build the same
|
|
6
|
+
* directory, and each used to assemble that option object itself. The two lists
|
|
7
|
+
* drifted to nine options against two: the gate built with fold off (the path
|
|
8
|
+
* `chant build` retired as its default in #1134), without the project's config
|
|
9
|
+
* (so serializers lost their lexicon-scoped dialect settings and a policy
|
|
10
|
+
* reading `ctx.docs` inspected different documents), and without `buildRoots`
|
|
11
|
+
* (so config-declared roots contributed no entities at all). A gate can only
|
|
12
|
+
* decide on a build `chant build` would produce if the two are assembled from
|
|
13
|
+
* one place, so they are.
|
|
14
|
+
*
|
|
15
|
+
* Two functions rather than one because the *modes* are needed earlier than the
|
|
16
|
+
* rest: `chant build` arms sandboxed policy execution from the resolved
|
|
17
|
+
* `sandbox` before it loads any policy module, which happens before build-time
|
|
18
|
+
* parameters and the ownership marker exist. {@link resolveBuildModes} is that
|
|
19
|
+
* early half; {@link resolveProjectBuildOptions} takes its result and assembles
|
|
20
|
+
* everything `build()` is given.
|
|
21
|
+
*/
|
|
22
|
+
import { type ChantConfig } from "../config.js";
|
|
23
|
+
import type { LexiconPlugin } from "../lexicon.js";
|
|
24
|
+
import type { BuildOptions } from "../build.js";
|
|
25
|
+
import type { OwnershipMarker } from "../ownership.js";
|
|
26
|
+
import type { BuildParamProvenance } from "../provenance.js";
|
|
27
|
+
/** The resolved fold/sandbox execution modes for one build. */
|
|
28
|
+
export interface BuildModes {
|
|
29
|
+
/** #1022/#1134 — fold source modules statically; the default build path. */
|
|
30
|
+
fold: boolean;
|
|
31
|
+
/** #1045 Phase 2 — execute run-fallback files in a sandboxed child. */
|
|
32
|
+
sandbox: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve this build's execution modes: an explicit CLI flag wins over
|
|
36
|
+
* `chant.config.ts`'s `build.fold`/`build.sandbox`, which wins over the default
|
|
37
|
+
* (fold on, sandbox off). Callers with no flags to offer (the `policyGate` step)
|
|
38
|
+
* pass no overrides and get the project's own answer.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveBuildModes(config: ChantConfig, overrides?: {
|
|
41
|
+
fold?: boolean;
|
|
42
|
+
sandbox?: boolean;
|
|
43
|
+
}): BuildModes;
|
|
44
|
+
/** Inputs {@link resolveProjectBuildOptions} needs to assemble a build. */
|
|
45
|
+
export interface ProjectBuildOptionsInput {
|
|
46
|
+
/** The project's resolved config, from `loadChantConfigUpward`. */
|
|
47
|
+
config: ChantConfig;
|
|
48
|
+
/** Directory the config was found in — build roots are rooted here, not at a (possibly sourceDir-scoped) build path. */
|
|
49
|
+
configDir: string;
|
|
50
|
+
/** The lexicon plugins loaded for this build. */
|
|
51
|
+
plugins?: readonly LexiconPlugin[];
|
|
52
|
+
/** Resolved execution modes, from {@link resolveBuildModes}. */
|
|
53
|
+
modes: BuildModes;
|
|
54
|
+
/** The resolved ownership marker, when marking is on. */
|
|
55
|
+
ownership?: OwnershipMarker;
|
|
56
|
+
/** This build's resolved build-time parameters (#1064). */
|
|
57
|
+
buildParams?: BuildParamProvenance[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Assemble the option object `build()` takes for a project directory.
|
|
61
|
+
*
|
|
62
|
+
* Every option here is derived from the project (its config, its plugins, its
|
|
63
|
+
* resolved parameters) rather than from the command that asked, so two callers
|
|
64
|
+
* handing in the same project get byte-identical builds. A new option belongs
|
|
65
|
+
* in this function, never at a call site.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveProjectBuildOptions(input: ProjectBuildOptionsInput): BuildOptions;
|
|
68
|
+
//# sourceMappingURL=build-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-options.d.ts","sourceRoot":"","sources":["../../src/cli/build-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAA6C,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAExF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,+DAA+D;AAC/D,MAAM,WAAW,UAAU;IACzB,4EAA4E;IAC5E,IAAI,EAAE,OAAO,CAAC;IACd,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,SAAS,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAChD,UAAU,CAKZ;AAED,2EAA2E;AAC3E,MAAM,WAAW,wBAAwB;IACvC,mEAAmE;IACnE,MAAM,EAAE,WAAW,CAAC;IACpB,wHAAwH;IACxH,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,OAAO,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,gEAAgE;IAChE,KAAK,EAAE,UAAU,CAAC;IAClB,yDAAyD;IACzD,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,2DAA2D;IAC3D,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACtC;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,wBAAwB,GAAG,YAAY,CAgCxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AASnD,OAAO,EAAuC,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMrG;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB;IAC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B,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAiB1E;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAM9E;AAkBD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA+C/E"}
|
|
@@ -20,27 +20,6 @@ export declare function runOpLog(ctx: CommandContext): Promise<number>;
|
|
|
20
20
|
export declare function runOpSignal(ctx: CommandContext): Promise<number>;
|
|
21
21
|
/** `chant run cancel <name> [--components]` — cancels an Op workflow by default, or a component workflow when `--components` is passed (#589), mirroring `runOpSignal`'s id resolution. */
|
|
22
22
|
export declare function runOpCancel(ctx: CommandContext): Promise<number>;
|
|
23
|
-
/**
|
|
24
|
-
* `chant run <name>` dispatcher.
|
|
25
|
-
*
|
|
26
|
-
* Local mode is the default — it runs the Op in-process with no Temporal
|
|
27
|
-
* server. `--temporal` opts into a cluster (gates, schedules, durable resume).
|
|
28
|
-
* `--report` reads a past durable run and is therefore Temporal-only.
|
|
29
|
-
*
|
|
30
|
-
* `chant run --components <name|all>` (#585) is a separate target: discovered
|
|
31
|
-
* `Component` declarations dispatched through the interpret driver
|
|
32
|
-
* (`../../components/driver.ts`) rather than a `*.op.ts` Op. Checked first,
|
|
33
|
-
* mirroring `runGraph`'s `if (ctx.args.components) return
|
|
34
|
-
* runComponentGraph(ctx)` branch (../handlers/graph.ts).
|
|
35
|
-
*
|
|
36
|
-
* chant #1116 — `--report` with `--components` is checked and hard-errored
|
|
37
|
-
* before that dispatch. There is no preview/dry-run mode for the component
|
|
38
|
-
* driver: unlike the Op path (where `--report` reads a past Temporal run),
|
|
39
|
-
* `runOpComponents` has never read `ctx.args.report` at all, so the flag was
|
|
40
|
-
* silently ignored and the command fell through to a real dispatch — observed
|
|
41
|
-
* live reaching an actual cloud shell-out. Erroring here is the safe minimum
|
|
42
|
-
* called out on the issue; a real preview is future work.
|
|
43
|
-
*/
|
|
44
23
|
export declare function runOp(ctx: CommandContext): Promise<number>;
|
|
45
24
|
/**
|
|
46
25
|
* `chant run --components <name|all> [--env <env>] [--temporal]` (#585, and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/run.ts"],"names":[],"mappings":"AAIA,OAAO,EAA+C,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/run.ts"],"names":[],"mappings":"AAIA,OAAO,EAA+C,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAQ7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA8ClD,wBAAsB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM;;;;GAO5F;AA8BD,wBAAsB,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAgEpE;AAoFD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA6CtE;AAwCD,wBAAsB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA6CnE;AA2DD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAkCtE;AAID,2LAA2L;AAC3L,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BtE;AAgFD,wBAAsB,KAAK,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBhE;AA6ED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAuF1E;AA+OD;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAoFrE;AA+MD,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAMjE"}
|
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;AAoF9E;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA2TpD;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAMA,OAAO,EAAmC,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAoF9E;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA2TpD;AA0mBD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB5E"}
|
|
@@ -187,6 +187,29 @@ export interface GitlabMrReport {
|
|
|
187
187
|
}
|
|
188
188
|
/** Project a change set onto the GitLab MR plan widget shape. Pure. */
|
|
189
189
|
export declare function gitlabMrReport(cs: ChangeSet): GitlabMrReport;
|
|
190
|
+
/**
|
|
191
|
+
* Warning a plan should print when it carries a hole — a declared entity the
|
|
192
|
+
* lexicon could not observe (#1089). The `--json` and `--report gitlab-mr`
|
|
193
|
+
* shapes have no column for `unobserved`, so both the CLI (on stderr) and the
|
|
194
|
+
* `markdown` report (in the body, since a reviewer never sees a job's stderr)
|
|
195
|
+
* read this same wording rather than drifting apart. Empty when the plan has
|
|
196
|
+
* no hole. Same discipline as {@link disruptionNotices} in `./disruption`.
|
|
197
|
+
*/
|
|
198
|
+
export declare function unobservedPlanNotice(cs: ChangeSet): string[];
|
|
190
199
|
/** Human-readable render of a change set. Pure — returns a string. */
|
|
191
200
|
export declare function renderChangeSet(cs: ChangeSet): string;
|
|
201
|
+
/**
|
|
202
|
+
* Markdown projection of a change set (#1983) — sized for a PR/MR comment
|
|
203
|
+
* rather than a terminal. A scannable counts header, entries grouped by
|
|
204
|
+
* action and attributed to their lexicon, deltas in a fenced block, and any
|
|
205
|
+
* group past {@link MARKDOWN_FOLD_THRESHOLD} folded into a `<details>` so a
|
|
206
|
+
* large plan doesn't bury the comment. Pure — no ANSI, no I/O — and
|
|
207
|
+
* deterministic: same entry ordering as {@link renderChangeSet}.
|
|
208
|
+
*
|
|
209
|
+
* Both a hole (#1089) and an expensive verdict (#1665) are surfaced IN the
|
|
210
|
+
* body, not left to stderr the way `--json` and `--report gitlab-mr` leave
|
|
211
|
+
* them: a reviewer reading a comment never sees the job's log, so a plan
|
|
212
|
+
* carrying either must not read as clean.
|
|
213
|
+
*/
|
|
214
|
+
export declare function renderChangeSetMarkdown(cs: ChangeSet): string;
|
|
192
215
|
//# sourceMappingURL=change-set.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../../src/lifecycle/change-set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAY,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAyC,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,G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;;;;;OAUG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,4DAA4D;IAC5D,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,0GAA0G;IAC1G,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CA6GvG;AAID,gCAAgC;AAChC,wBAAgB,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAarE;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,EAAE,EAAE,SAAS,GAAG,cAAc,CAG5D;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,CAO5D;AAwBD,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CA2CrD;AA0CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAsC7D"}
|
package/dist/lint/policy.d.ts
CHANGED
|
@@ -25,12 +25,28 @@ export interface PolicyEvaluation {
|
|
|
25
25
|
* of the finding just vanishing.
|
|
26
26
|
*/
|
|
27
27
|
suppressed: PostSynthDiagnostic[];
|
|
28
|
+
/**
|
|
29
|
+
* chant #2002 — divergences between this evaluation and what `chant build`
|
|
30
|
+
* would do, named rather than left silent. Today that is a project whose
|
|
31
|
+
* resolved `build.sandbox` is `true`: the gate builds unsandboxed, because
|
|
32
|
+
* running it inside the boundary needs the per-execution arming decision
|
|
33
|
+
* tracked on #1157. Also written to stderr — the gate's caller is an
|
|
34
|
+
* activity wrapper that surfaces output, not a structured result.
|
|
35
|
+
*/
|
|
36
|
+
warnings: string[];
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
30
39
|
* Build a project and run its `lint.policies` over the resolved resources,
|
|
31
40
|
* standalone — used by the `policyGate` Op step to gate an apply on the same
|
|
32
41
|
* organizational policy `chant build` enforces. Loads the project's lexicons,
|
|
33
42
|
* builds, then runs the policy pack with `env` (explicit, else `ownership.env`).
|
|
43
|
+
*
|
|
44
|
+
* chant #2002 — "the same organizational policy `chant build` enforces" only
|
|
45
|
+
* holds if it is the same build. The build options are assembled by
|
|
46
|
+
* `../cli/build-options.ts`'s `resolveProjectBuildOptions`, the single function
|
|
47
|
+
* `chant build` also calls, rather than by a second list here; a build option
|
|
48
|
+
* added for one caller and not the other is what let a gate pass a build
|
|
49
|
+
* `chant build` fails.
|
|
34
50
|
*/
|
|
35
51
|
export declare function evaluateProjectPolicies(opts: {
|
|
36
52
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/lint/policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/lint/policy.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAIxE;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAuBpG;AAED,MAAM,WAAW,gBAAgB;IAC/B,yFAAyF;IACzF,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,2FAA2F;IAC3F,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC;;;;;;;OAOG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAwE5B"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* implementations and profiles are passed in (loaded dynamically by the CLI),
|
|
11
11
|
* so core never statically depends on `@intentius/chant-lexicon-temporal`.
|
|
12
12
|
*/
|
|
13
|
-
import type { OpConfig, GateStep } from "./types.js";
|
|
13
|
+
import type { OpConfig, ActivityStep, GateStep } from "./types.js";
|
|
14
14
|
import { type ActivityFn, type ActivityProfile } from "./activity-registry.js";
|
|
15
15
|
export interface StepRecord {
|
|
16
16
|
phase: string;
|
|
@@ -51,6 +51,20 @@ export declare function parseDuration(s: string): number;
|
|
|
51
51
|
/** Find the first gate step anywhere in the Op (phases + onFailure, including
|
|
52
52
|
* gates nested inside effect steps), if any. */
|
|
53
53
|
export declare function findGate(config: OpConfig): GateStep | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Find the first `policyGate` step anywhere in the Op (phases + `onFailure`,
|
|
56
|
+
* including steps nested inside effect steps), if any.
|
|
57
|
+
*
|
|
58
|
+
* chant #2003 — `--sandbox` is a GLOBAL flag (`../cli/registry.ts`), and
|
|
59
|
+
* `../cli/main.ts` arms the process-wide policy latch off it for every command,
|
|
60
|
+
* `chant run` included. A `policyGate` step then reaches `loadPolicyChecks`,
|
|
61
|
+
* which refuses while armed with a message written for a chant maintainer —
|
|
62
|
+
* shown to a user who passed a documented flag. The combination cannot be
|
|
63
|
+
* honoured until the gate can build and load policies inside the boundary
|
|
64
|
+
* (#1157), so both `chant run` paths pre-flight it with this and refuse before
|
|
65
|
+
* any phase executes, the same shape as {@link findGate}'s pre-flight.
|
|
66
|
+
*/
|
|
67
|
+
export declare function findPolicyGateStep(config: OpConfig): ActivityStep | undefined;
|
|
54
68
|
/**
|
|
55
69
|
* Execute an Op locally. Resolves with the run result on success; rejects with
|
|
56
70
|
* `OpRunFailure` (carrying the partial result) on terminal failure, after
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-executor.d.ts","sourceRoot":"","sources":["../../src/op/local-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"local-executor.d.ts","sourceRoot":"","sources":["../../src/op/local-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAmB,YAAY,EAAE,QAAQ,EAA8B,MAAM,SAAS,CAAC;AAC7G,OAAO,EAAmB,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAM7F,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,OAAO,CAAC;CACb;AAID,kFAAkF;AAClF,qBAAa,yBAA0B,SAAQ,KAAK;aACtB,UAAU,EAAE,MAAM;gBAAlB,UAAU,EAAE,MAAM;CAO/C;AAED,mFAAmF;AACnF,qBAAa,YAAa,SAAQ,KAAK;aACT,MAAM,EAAE,WAAW;gBAAnB,MAAM,EAAE,WAAW;CAIhD;AAmBD,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAU/C;AA8BD;gDACgD;AAChD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAY/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,CAa7E;AAiSD;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACzC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,WAAW,CAAC,CAgDtB"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chant #2002 — the shared build-option assembler. `chant build` and the
|
|
3
|
+
* `policyGate` step both call this; `../lint/policy-build-parity.test.ts`
|
|
4
|
+
* proves they stay in step, this file pins what the function itself resolves.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, test, expect } from "vitest";
|
|
7
|
+
import { createMockPlugin } from "@intentius/chant-test-utils";
|
|
8
|
+
import type { LexiconPlugin } from "../lexicon";
|
|
9
|
+
import type { ChantConfig } from "../config";
|
|
10
|
+
import { resolveBuildModes, resolveProjectBuildOptions } from "./build-options";
|
|
11
|
+
|
|
12
|
+
const config = (over: Record<string, unknown> = {}): ChantConfig => over as ChantConfig;
|
|
13
|
+
|
|
14
|
+
describe("resolveBuildModes", () => {
|
|
15
|
+
test("fold defaults on, sandbox defaults off (#1134 / #1045)", () => {
|
|
16
|
+
expect(resolveBuildModes(config())).toEqual({ fold: true, sandbox: false });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("the project config decides when no flag is given", () => {
|
|
20
|
+
expect(resolveBuildModes(config({ build: { fold: false, sandbox: true } })))
|
|
21
|
+
.toEqual({ fold: false, sandbox: true });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("an explicit flag wins over the config, in both directions", () => {
|
|
25
|
+
expect(resolveBuildModes(config({ build: { fold: false } }), { fold: true }).fold).toBe(true);
|
|
26
|
+
expect(resolveBuildModes(config({ build: { fold: true } }), { fold: false }).fold).toBe(false);
|
|
27
|
+
expect(resolveBuildModes(config(), { sandbox: true }).sandbox).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("resolveProjectBuildOptions", () => {
|
|
32
|
+
const modes = { fold: true, sandbox: false };
|
|
33
|
+
|
|
34
|
+
test("threads the project config through to the serializers", () => {
|
|
35
|
+
const projectConfig = config({ forgejo: { runnerLabels: { "ubuntu-latest": "docker-arm" } } });
|
|
36
|
+
const options = resolveProjectBuildOptions({ config: projectConfig, configDir: "/p", modes });
|
|
37
|
+
expect(options.config).toEqual(projectConfig);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("collects intrinsics and lexicon names from the loaded plugins", () => {
|
|
41
|
+
const intrinsic = { tag: "Sub", lexicon: "aws" } as never;
|
|
42
|
+
const plugins: LexiconPlugin[] = [
|
|
43
|
+
{ ...createMockPlugin({ name: "aws" }), intrinsics: () => [intrinsic] },
|
|
44
|
+
createMockPlugin({ name: "k8s" }),
|
|
45
|
+
];
|
|
46
|
+
const options = resolveProjectBuildOptions({ config: config(), configDir: "/p", plugins, modes });
|
|
47
|
+
expect(options.lexicons).toEqual(["aws", "k8s"]);
|
|
48
|
+
expect(options.intrinsics).toEqual([intrinsic]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("binds each plugin's buildRoots hook to the CONFIG dir, not the build path", async () => {
|
|
52
|
+
let seenRoot: string | undefined;
|
|
53
|
+
const plugins: LexiconPlugin[] = [
|
|
54
|
+
{
|
|
55
|
+
...createMockPlugin({ name: "cedar" }),
|
|
56
|
+
buildRoots: async (ctx) => {
|
|
57
|
+
seenRoot = ctx.projectRoot;
|
|
58
|
+
return { entities: new Map() };
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
const options = resolveProjectBuildOptions({ config: config(), configDir: "/project", plugins, modes });
|
|
63
|
+
expect(options.buildRoots).toHaveLength(1);
|
|
64
|
+
await options.buildRoots });
|
|
65
|
+
expect(seenRoot).toBe("/project");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("a plugin without a buildRoots hook contributes nothing", () => {
|
|
69
|
+
const options = resolveProjectBuildOptions({
|
|
70
|
+
config: config(),
|
|
71
|
+
configDir: "/p",
|
|
72
|
+
plugins: [createMockPlugin({ name: "k8s" })],
|
|
73
|
+
modes,
|
|
74
|
+
});
|
|
75
|
+
expect(options.buildRoots).toEqual([]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("no plugins at all is empty, never undefined-by-accident", () => {
|
|
79
|
+
const options = resolveProjectBuildOptions({ config: config(), configDir: "/p", modes });
|
|
80
|
+
expect(options.lexicons).toEqual([]);
|
|
81
|
+
expect(options.intrinsics).toEqual([]);
|
|
82
|
+
expect(options.buildRoots).toEqual([]);
|
|
83
|
+
expect(options.lexiconVersions).toEqual({});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("carries the resolved modes, ownership and build parameters verbatim", () => {
|
|
87
|
+
const ownership = { stack: "s", env: "prod" } as never;
|
|
88
|
+
const buildParams = [{ name: "env", value: "prod", source: "default" }] as never;
|
|
89
|
+
const options = resolveProjectBuildOptions({
|
|
90
|
+
config: config(),
|
|
91
|
+
configDir: "/p",
|
|
92
|
+
modes: { fold: false, sandbox: true },
|
|
93
|
+
ownership,
|
|
94
|
+
buildParams,
|
|
95
|
+
});
|
|
96
|
+
expect(options.fold).toBe(false);
|
|
97
|
+
expect(options.sandbox).toBe(true);
|
|
98
|
+
expect(options.ownership).toBe(ownership);
|
|
99
|
+
expect(options.buildParams).toBe(buildParams);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place chant assembles `build()`'s options for a project directory.
|
|
3
|
+
*
|
|
4
|
+
* chant #2002 — `chant build` (./commands/build.ts) and the `policyGate` Op
|
|
5
|
+
* step (../lint/policy.ts's `evaluateProjectPolicies`) both build the same
|
|
6
|
+
* directory, and each used to assemble that option object itself. The two lists
|
|
7
|
+
* drifted to nine options against two: the gate built with fold off (the path
|
|
8
|
+
* `chant build` retired as its default in #1134), without the project's config
|
|
9
|
+
* (so serializers lost their lexicon-scoped dialect settings and a policy
|
|
10
|
+
* reading `ctx.docs` inspected different documents), and without `buildRoots`
|
|
11
|
+
* (so config-declared roots contributed no entities at all). A gate can only
|
|
12
|
+
* decide on a build `chant build` would produce if the two are assembled from
|
|
13
|
+
* one place, so they are.
|
|
14
|
+
*
|
|
15
|
+
* Two functions rather than one because the *modes* are needed earlier than the
|
|
16
|
+
* rest: `chant build` arms sandboxed policy execution from the resolved
|
|
17
|
+
* `sandbox` before it loads any policy module, which happens before build-time
|
|
18
|
+
* parameters and the ownership marker exist. {@link resolveBuildModes} is that
|
|
19
|
+
* early half; {@link resolveProjectBuildOptions} takes its result and assembles
|
|
20
|
+
* everything `build()` is given.
|
|
21
|
+
*/
|
|
22
|
+
import { resolveFoldEnabled, resolveSandboxEnabled, type ChantConfig } from "../config";
|
|
23
|
+
import { collectBuildRootContributors, resolveLexiconVersions } from "./plugins";
|
|
24
|
+
import type { LexiconPlugin } from "../lexicon";
|
|
25
|
+
import type { BuildOptions } from "../build";
|
|
26
|
+
import type { OwnershipMarker } from "../ownership";
|
|
27
|
+
import type { BuildParamProvenance } from "../provenance";
|
|
28
|
+
|
|
29
|
+
/** The resolved fold/sandbox execution modes for one build. */
|
|
30
|
+
export interface BuildModes {
|
|
31
|
+
/** #1022/#1134 — fold source modules statically; the default build path. */
|
|
32
|
+
fold: boolean;
|
|
33
|
+
/** #1045 Phase 2 — execute run-fallback files in a sandboxed child. */
|
|
34
|
+
sandbox: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Resolve this build's execution modes: an explicit CLI flag wins over
|
|
39
|
+
* `chant.config.ts`'s `build.fold`/`build.sandbox`, which wins over the default
|
|
40
|
+
* (fold on, sandbox off). Callers with no flags to offer (the `policyGate` step)
|
|
41
|
+
* pass no overrides and get the project's own answer.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveBuildModes(
|
|
44
|
+
config: ChantConfig,
|
|
45
|
+
overrides?: { fold?: boolean; sandbox?: boolean },
|
|
46
|
+
): BuildModes {
|
|
47
|
+
return {
|
|
48
|
+
fold: resolveFoldEnabled(config, overrides?.fold),
|
|
49
|
+
sandbox: resolveSandboxEnabled(config, overrides?.sandbox),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Inputs {@link resolveProjectBuildOptions} needs to assemble a build. */
|
|
54
|
+
export interface ProjectBuildOptionsInput {
|
|
55
|
+
/** The project's resolved config, from `loadChantConfigUpward`. */
|
|
56
|
+
config: ChantConfig;
|
|
57
|
+
/** Directory the config was found in — build roots are rooted here, not at a (possibly sourceDir-scoped) build path. */
|
|
58
|
+
configDir: string;
|
|
59
|
+
/** The lexicon plugins loaded for this build. */
|
|
60
|
+
plugins?: readonly LexiconPlugin[];
|
|
61
|
+
/** Resolved execution modes, from {@link resolveBuildModes}. */
|
|
62
|
+
modes: BuildModes;
|
|
63
|
+
/** The resolved ownership marker, when marking is on. */
|
|
64
|
+
ownership?: OwnershipMarker;
|
|
65
|
+
/** This build's resolved build-time parameters (#1064). */
|
|
66
|
+
buildParams?: BuildParamProvenance[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Assemble the option object `build()` takes for a project directory.
|
|
71
|
+
*
|
|
72
|
+
* Every option here is derived from the project (its config, its plugins, its
|
|
73
|
+
* resolved parameters) rather than from the command that asked, so two callers
|
|
74
|
+
* handing in the same project get byte-identical builds. A new option belongs
|
|
75
|
+
* in this function, never at a call site.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveProjectBuildOptions(input: ProjectBuildOptionsInput): BuildOptions {
|
|
78
|
+
const { config, configDir, plugins, modes, ownership, buildParams } = input;
|
|
79
|
+
|
|
80
|
+
// #1039 — each loaded plugin's registered intrinsics (e.g. AWS's `Sub`), so
|
|
81
|
+
// a file using a registered intrinsic tagged template folds instead of
|
|
82
|
+
// unconditionally falling back to run. `intrinsics` is an optional plugin
|
|
83
|
+
// extension, hence the guard.
|
|
84
|
+
const intrinsics = plugins?.flatMap((plugin) => plugin.intrinsics?.() ?? []) ?? [];
|
|
85
|
+
|
|
86
|
+
// #1063 — the same loaded plugins, by NAME, are this build's allowlist for
|
|
87
|
+
// following a bare import specifier into a lexicon package (so `Azure`,
|
|
88
|
+
// `GCP`, `S3Actions`, `CI` fold as values).
|
|
89
|
+
const lexicons = plugins?.map((plugin) => plugin.name) ?? [];
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
ownership,
|
|
93
|
+
config: config as unknown as Record<string, unknown>,
|
|
94
|
+
fold: modes.fold,
|
|
95
|
+
sandbox: modes.sandbox,
|
|
96
|
+
intrinsics,
|
|
97
|
+
lexicons,
|
|
98
|
+
// chant #1442 — which lexicon VERSION interpreted each declaration.
|
|
99
|
+
lexiconVersions: resolveLexiconVersions(lexicons),
|
|
100
|
+
buildParams,
|
|
101
|
+
// #1548 piece 3 — config-declared build roots (kustomize dirs, committed
|
|
102
|
+
// ciphertext), rendered into entities by the owning lexicon's hook.
|
|
103
|
+
buildRoots: collectBuildRootContributors(
|
|
104
|
+
plugins,
|
|
105
|
+
config as unknown as Record<string, unknown>,
|
|
106
|
+
configDir,
|
|
107
|
+
),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -5,17 +5,15 @@ import {
|
|
|
5
5
|
resolveOwnershipEnv,
|
|
6
6
|
ownershipEnvDisagreement,
|
|
7
7
|
isOwnershipParamRef,
|
|
8
|
-
resolveFoldEnabled,
|
|
9
|
-
resolveSandboxEnabled,
|
|
10
8
|
resolveKnowledgeDir,
|
|
11
9
|
} from "../../config";
|
|
10
|
+
import { resolveBuildModes, resolveProjectBuildOptions } from "../build-options";
|
|
12
11
|
import { loadOkfBundle } from "../../okf-read";
|
|
13
12
|
import { unknownEnvError } from "../../env";
|
|
14
13
|
import type { OwnershipMarker } from "../../ownership";
|
|
15
14
|
import { resolveCliBuildParams } from "../build-params-cli";
|
|
16
15
|
import type { Serializer, SerializerResult } from "../../serializer";
|
|
17
16
|
import type { LexiconPlugin } from "../../lexicon";
|
|
18
|
-
import { resolveLexiconVersions, collectBuildRootContributors } from "../plugins";
|
|
19
17
|
import { runPostSynthChecks } from "../../lint/post-synth";
|
|
20
18
|
import { coreReceiptChecks } from "../../lint/receipt-checks";
|
|
21
19
|
import { coreOutputChecks } from "../../lint/output-checks";
|
|
@@ -182,15 +180,14 @@ export async function buildCommand(options: BuildOptions): Promise<BuildResult>
|
|
|
182
180
|
const configDir = loaded.configPath ? dirname(loaded.configPath) : infraPath;
|
|
183
181
|
const policies = config.lint?.policies ?? [];
|
|
184
182
|
|
|
185
|
-
// #1022/#1134
|
|
186
|
-
// (--fold/--no-fold) wins over `chant.config.ts`'s
|
|
187
|
-
// wins over the
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const sandbox = resolveSandboxEnabled(config, options.sandbox);
|
|
183
|
+
// #1022/#1134 (fold) and #1045 Phase 2 (sandbox) — an explicit CLI flag
|
|
184
|
+
// (--fold/--no-fold, --sandbox) wins over `chant.config.ts`'s
|
|
185
|
+
// `build.fold`/`build.sandbox`, which wins over the defaults (fold on,
|
|
186
|
+
// sandbox off). Resolved here rather than with the rest of the build
|
|
187
|
+
// options below because arming sandboxed policy execution has to happen
|
|
188
|
+
// before any policy module could be loaded — see #2002 in ../build-options.ts.
|
|
189
|
+
const modes = resolveBuildModes(config, { fold: options.fold, sandbox: options.sandbox });
|
|
190
|
+
const { fold, sandbox } = modes;
|
|
194
191
|
|
|
195
192
|
// #1131 — arm sandboxed policy execution from the RESOLVED value, before any
|
|
196
193
|
// policy module could be loaded. Resolved, not `options.sandbox`, because
|
|
@@ -301,48 +298,22 @@ export async function buildCommand(options: BuildOptions): Promise<BuildResult>
|
|
|
301
298
|
}
|
|
302
299
|
}
|
|
303
300
|
|
|
304
|
-
// #
|
|
305
|
-
//
|
|
306
|
-
//
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
// `GCP`, `S3Actions`, `CI` fold as values). A plugin's `name` is the
|
|
314
|
-
// lexicon name `loadPlugin()` was called with, which is exactly what
|
|
315
|
-
// `@intentius/chant-lexicon-<name>` was imported from — see
|
|
316
|
-
// ../plugins.ts and fold-import.ts's `lexiconPackageName`.
|
|
317
|
-
const lexicons = options.plugins?.map((plugin) => plugin.name) ?? [];
|
|
318
|
-
|
|
319
|
-
// chant #1442 — which lexicon VERSION interpreted each declaration. The
|
|
320
|
-
// declaration is fingerprinted by `hashProps`; the thing that turned it into
|
|
321
|
-
// output was not recorded at all, so a lexicon bump that changed emitted
|
|
322
|
-
// output left the build digest identical. Captured here because this is the
|
|
323
|
-
// layer that knows which lexicons were loaded — `build()` is given only
|
|
324
|
-
// their names.
|
|
325
|
-
const lexiconVersions = resolveLexiconVersions(lexicons);
|
|
326
|
-
|
|
327
|
-
// Run the build
|
|
328
|
-
const result = await build(infraPath, options.serializers, undefined, {
|
|
329
|
-
ownership,
|
|
330
|
-
config: config as unknown as Record<string, unknown>,
|
|
331
|
-
fold,
|
|
332
|
-
sandbox,
|
|
333
|
-
intrinsics,
|
|
334
|
-
lexicons,
|
|
335
|
-
lexiconVersions,
|
|
336
|
-
buildParams: paramsResolution.provenance,
|
|
337
|
-
// #1548 piece 3 — config-declared build roots (kustomize dirs), rendered
|
|
338
|
-
// into entities by the owning lexicon's hook. Rooted at the config dir,
|
|
339
|
-
// not the (possibly sourceDir-scoped) infra path.
|
|
340
|
-
buildRoots: collectBuildRootContributors(
|
|
341
|
-
options.plugins,
|
|
342
|
-
config as unknown as Record<string, unknown>,
|
|
301
|
+
// Run the build. #2002 — every option comes from the shared assembler
|
|
302
|
+
// (../build-options.ts), which `evaluateProjectPolicies` calls too, so the
|
|
303
|
+
// `policyGate` step decides on the same project this command builds.
|
|
304
|
+
const result = await build(
|
|
305
|
+
infraPath,
|
|
306
|
+
options.serializers,
|
|
307
|
+
undefined,
|
|
308
|
+
resolveProjectBuildOptions({
|
|
309
|
+
config,
|
|
343
310
|
configDir,
|
|
344
|
-
|
|
345
|
-
|
|
311
|
+
plugins: options.plugins,
|
|
312
|
+
modes,
|
|
313
|
+
ownership,
|
|
314
|
+
buildParams: paramsResolution.provenance,
|
|
315
|
+
}),
|
|
316
|
+
);
|
|
346
317
|
|
|
347
318
|
// #1022 — report per-file fold vs run so it's visible what still runs.
|
|
348
319
|
// #1424 — one line by default; the per-file lines and their reasons are
|
|
@@ -753,6 +753,25 @@ describe("runLifecyclePlan", () => {
|
|
|
753
753
|
expect(stdoutBuf.join("\n")).toContain("bucket");
|
|
754
754
|
});
|
|
755
755
|
|
|
756
|
+
// #1983 — `--report markdown` emits the reviewer-facing projection instead
|
|
757
|
+
// of the human render, same as `--report gitlab-mr` swaps in the widget JSON.
|
|
758
|
+
test("--report markdown emits the markdown projection instead of the human render", async () => {
|
|
759
|
+
buildMock.mockResolvedValue(makeBuildResult({ aws: ["bucket"] }));
|
|
760
|
+
const plugins: LexiconPlugin[] = [
|
|
761
|
+
createMockPlugin({ name: "aws", emulator: awsEmulatorStub, describeResources: staticDescribeResources({}) }),
|
|
762
|
+
];
|
|
763
|
+
const exit = await runLifecyclePlan({
|
|
764
|
+
args: makeArgs({ path: "plan", extraPositional: "prod", reportFile: "markdown" }),
|
|
765
|
+
plugins,
|
|
766
|
+
serializers: plugins.map((p) => p.serializer),
|
|
767
|
+
});
|
|
768
|
+
expect(exit).toBe(0);
|
|
769
|
+
const out = stdoutBuf.join("\n");
|
|
770
|
+
expect(out).toContain("## Plan for `prod`");
|
|
771
|
+
expect(out).toContain("### CREATE");
|
|
772
|
+
expect(out).toContain("- `bucket`");
|
|
773
|
+
});
|
|
774
|
+
|
|
756
775
|
// #1620 — the resolved read address rides plan entries the same way it rides
|
|
757
776
|
// the live diff. Regression: the plan path dropped the observation's queried
|
|
758
777
|
// map, so only unobserved rows ever carried an address while the docs
|