@intentius/chant 0.124.84 → 0.124.86
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/bundle-check.d.ts +102 -0
- package/dist/bundle-check.d.ts.map +1 -0
- package/dist/bundle-check.js +310 -0
- package/dist/chant-install.d.ts +100 -0
- package/dist/chant-install.d.ts.map +1 -0
- package/dist/chant-install.js +158 -0
- package/dist/ci-commit.d.ts +19 -6
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +23 -4
- package/dist/ci-evidence-jobs.d.ts +54 -0
- package/dist/ci-evidence-jobs.d.ts.map +1 -0
- package/dist/ci-evidence-jobs.js +55 -0
- package/dist/ci-image.d.ts +274 -0
- package/dist/ci-image.d.ts.map +1 -0
- package/dist/ci-image.js +635 -0
- package/dist/ci-login.d.ts +150 -0
- package/dist/ci-login.d.ts.map +1 -0
- package/dist/ci-login.js +240 -0
- package/dist/ci-product.d.ts +16 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +17 -0
- package/dist/cli/commands/import-index.js +2 -2
- package/dist/cli/handlers/build.d.ts +8 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -4
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +57 -2
- package/dist/cli/handlers/ci-evidence.d.ts +3 -0
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -0
- package/dist/cli/handlers/ci-evidence.js +171 -0
- package/dist/cli/handlers/components.js +3 -3
- package/dist/cli/handlers/dead-guards.d.ts +3 -0
- package/dist/cli/handlers/dead-guards.d.ts.map +1 -0
- package/dist/cli/handlers/dead-guards.js +35 -0
- package/dist/cli/handlers/graph.js +4 -4
- package/dist/cli/handlers/lifecycle.d.ts +2 -1
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +5 -4
- package/dist/cli/handlers/local-chant.d.ts +16 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -0
- package/dist/cli/handlers/local-chant.js +109 -0
- package/dist/cli/handlers/operator.js +2 -2
- package/dist/cli/handlers/search.js +5 -5
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +38 -0
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +28 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/check-hooks.d.ts +49 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +64 -4
- package/dist/components/check-steps.d.ts +17 -0
- package/dist/components/check-steps.d.ts.map +1 -1
- package/dist/components/check-steps.js +37 -5
- package/dist/components/product-pipeline.d.ts +23 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +6 -2
- package/dist/components/product-plan.d.ts +137 -0
- package/dist/components/product-plan.d.ts.map +1 -0
- package/dist/components/product-plan.js +143 -0
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +2 -2
- package/dist/config.d.ts +39 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -3
- package/dist/dead-guards.d.ts +82 -0
- package/dist/dead-guards.d.ts.map +1 -0
- package/dist/dead-guards.js +436 -0
- package/dist/discovery/files.d.ts +3 -1
- package/dist/discovery/files.d.ts.map +1 -1
- package/dist/discovery/files.js +5 -3
- package/dist/drift-issue.d.ts +152 -0
- package/dist/drift-issue.d.ts.map +1 -0
- package/dist/drift-issue.js +167 -0
- package/dist/floor-table.d.ts +30 -0
- package/dist/floor-table.d.ts.map +1 -0
- package/dist/floor-table.data.d.ts +3 -0
- package/dist/floor-table.data.d.ts.map +1 -0
- package/dist/floor-table.data.js +178 -0
- package/dist/floor-table.js +56 -0
- package/dist/forge-flags.d.ts +90 -0
- package/dist/forge-flags.d.ts.map +1 -0
- package/dist/forge-flags.js +184 -0
- package/dist/lexicon.d.ts +69 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.d.ts +7 -1
- package/dist/lifecycle/gated-op.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.js +7 -4
- package/dist/local-chant.d.ts +98 -0
- package/dist/local-chant.d.ts.map +1 -0
- package/dist/local-chant.js +307 -0
- package/dist/op/activities/predict-behaviour.js +2 -2
- package/dist/op/op-waves-evidence-spec.d.ts +13 -0
- package/dist/op/op-waves-evidence-spec.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-spec.js +21 -0
- package/dist/op/op-waves-evidence.d.ts +38 -0
- package/dist/op/op-waves-evidence.d.ts.map +1 -0
- package/dist/op/op-waves-evidence.js +57 -0
- package/dist/op/op-waves-run.d.ts +4 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +24 -1
- package/dist/op/op-waves.d.ts +17 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +23 -0
- package/dist/op/schedule-overdue.d.ts +41 -9
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +154 -25
- package/dist/plan-summary.d.ts +25 -0
- package/dist/plan-summary.d.ts.map +1 -1
- package/dist/plan-summary.js +31 -0
- package/dist/pr-plan-note.d.ts +35 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +10 -0
- package/dist/pr-post.d.ts +23 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +125 -3
- package/dist/release-floors.d.ts +31 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +31 -1
- package/dist/state-migration.d.ts +24 -0
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +100 -5
- package/dist/wave-runtime.mjs +305 -298
- package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
- package/dist/workspace/lexicon-outputs.js +21 -7
- package/dist/workspace/reason-codes.d.ts +3 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +4 -0
- package/dist/workspace/ref-gate.schema.json +85 -0
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/search-contract.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.d.ts +51 -0
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence-report.js +102 -0
- package/dist/workspace/trust/check-evidence.d.ts +126 -0
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence.js +237 -0
- package/dist/workspace/trust/local-evidence.d.ts +120 -0
- package/dist/workspace/trust/local-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/local-evidence.js +259 -0
- package/dist/workspace/trust/policy.d.ts +84 -0
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +94 -1
- package/dist/workspace/trust/ref-gate-cli.d.ts +33 -0
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-cli.js +234 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts +38 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-fixture.js +97 -0
- package/dist/workspace/trust/ref-gate.d.ts +187 -0
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate.js +430 -0
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +18 -1
- package/package.json +1 -1
- package/src/bundle-check.test.ts +140 -0
- package/src/bundle-check.ts +352 -0
- package/src/chant-install.test.ts +112 -0
- package/src/chant-install.ts +179 -0
- package/src/ci-commit.test.ts +45 -0
- package/src/ci-commit.ts +38 -4
- package/src/ci-evidence-jobs.ts +67 -0
- package/src/ci-image.test.ts +506 -0
- package/src/ci-image.ts +822 -0
- package/src/ci-login.test.ts +235 -0
- package/src/ci-login.ts +307 -0
- package/src/ci-product.ts +18 -0
- package/src/cli/commands/__fixtures__/source-dir-include/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-root/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.test.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/app.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/infra/net.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/import-index.ts +2 -2
- package/src/cli/handlers/build-source-dir.test.ts +64 -0
- package/src/cli/handlers/build.ts +21 -4
- package/src/cli/handlers/ci-check.ts +56 -3
- package/src/cli/handlers/ci-evidence.ts +162 -0
- package/src/cli/handlers/components.ts +3 -3
- package/src/cli/handlers/dead-guards.ts +37 -0
- package/src/cli/handlers/graph.ts +4 -4
- package/src/cli/handlers/lifecycle.ts +5 -4
- package/src/cli/handlers/local-chant.ts +106 -0
- package/src/cli/handlers/operator.ts +2 -2
- package/src/cli/handlers/search.ts +5 -5
- package/src/cli/main.test.ts +7 -0
- package/src/cli/main.ts +38 -0
- package/src/cli/parse-args.ts +21 -0
- package/src/cli/registry.ts +16 -0
- package/src/components/check-evidence-stage.test.ts +80 -0
- package/src/components/check-hooks.ts +84 -4
- package/src/components/check-local-evidence-stage.test.ts +141 -0
- package/src/components/check-steps.ts +56 -6
- package/src/components/product-pipeline.ts +28 -3
- package/src/components/product-plan.test.ts +87 -0
- package/src/components/product-plan.ts +226 -0
- package/src/components/release-compile.ts +2 -2
- package/src/config.ts +44 -3
- package/src/dead-guards.test.ts +206 -0
- package/src/dead-guards.ts +446 -0
- package/src/discovery/files.ts +5 -3
- package/src/drift-issue-bundle.test.ts +31 -0
- package/src/drift-issue.test.ts +206 -0
- package/src/drift-issue.ts +274 -0
- package/src/fit-note.test.ts +44 -0
- package/src/floor-table.data.ts +180 -0
- package/src/floor-table.ts +77 -0
- package/src/forge-flags.test.ts +110 -0
- package/src/forge-flags.ts +208 -0
- package/src/gate-decision-bundle.test.ts +1 -0
- package/src/lexicon.ts +68 -0
- package/src/lifecycle/gated-op.ts +10 -5
- package/src/local-chant.e2e.test.ts +94 -0
- package/src/local-chant.test.ts +162 -0
- package/src/local-chant.ts +341 -0
- package/src/op/activities/predict-behaviour.ts +2 -2
- package/src/op/op-waves-evidence-spec.ts +24 -0
- package/src/op/op-waves-evidence.test.ts +130 -0
- package/src/op/op-waves-evidence.ts +57 -0
- package/src/op/op-waves-run.ts +25 -1
- package/src/op/op-waves.ts +31 -1
- package/src/op/schedule-overdue.test.ts +85 -0
- package/src/op/schedule-overdue.ts +162 -26
- package/src/plan-summary.ts +40 -0
- package/src/pr-plan-note.ts +34 -0
- package/src/pr-post-plan-note.test.ts +146 -0
- package/src/pr-post.ts +127 -3
- package/src/release-floors.ts +44 -1
- package/src/stage-hooks-bundle.test.ts +1 -0
- package/src/state-migration.test.ts +52 -1
- package/src/state-migration.ts +107 -5
- package/src/workspace/lexicon-outputs.ts +23 -6
- package/src/workspace/reason-codes.test.ts +3 -0
- package/src/workspace/reason-codes.ts +4 -0
- package/src/workspace/ref-gate.schema.json +85 -0
- package/src/workspace/trust/check-evidence-report.ts +106 -0
- package/src/workspace/trust/check-evidence.test.ts +133 -0
- package/src/workspace/trust/check-evidence.ts +257 -0
- package/src/workspace/trust/local-evidence.test.ts +127 -0
- package/src/workspace/trust/local-evidence.ts +266 -0
- package/src/workspace/trust/policy.ts +134 -1
- package/src/workspace/trust/ref-gate-cli.ts +244 -0
- package/src/workspace/trust/ref-gate-fixture.ts +125 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +76 -0
- package/src/workspace/trust/ref-gate.test.ts +247 -0
- package/src/workspace/trust/ref-gate.ts +538 -0
- package/src/workspace/trust/trust-files.test.ts +16 -0
- package/src/workspace/trust/trust-files.ts +41 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** A chant workspace package that can be packed: not private. */
|
|
2
|
+
export interface ChantPackage {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
/** Relative to the checkout: `packages/core`, `lexicons/k8s`. */
|
|
6
|
+
dir: string;
|
|
7
|
+
/** Its dependencies, peer and optional dependencies, by name. */
|
|
8
|
+
deps: string[];
|
|
9
|
+
}
|
|
10
|
+
interface Manifest {
|
|
11
|
+
name?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
private?: boolean;
|
|
14
|
+
workspaces?: string[] | {
|
|
15
|
+
packages?: string[];
|
|
16
|
+
};
|
|
17
|
+
dependencies?: Record<string, string>;
|
|
18
|
+
devDependencies?: Record<string, string>;
|
|
19
|
+
peerDependencies?: Record<string, string>;
|
|
20
|
+
optionalDependencies?: Record<string, string>;
|
|
21
|
+
chantLocal?: LocalChantMark;
|
|
22
|
+
}
|
|
23
|
+
/** The `chantLocal` field `chant dev local` writes into each installed copy's package.json. */
|
|
24
|
+
export interface LocalChantMark {
|
|
25
|
+
/** The checkout's commit, with `+dirty` when tracked files had changes. */
|
|
26
|
+
commit: string;
|
|
27
|
+
/** The checkout. */
|
|
28
|
+
dir: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class LocalChantError extends Error {
|
|
31
|
+
name: string;
|
|
32
|
+
}
|
|
33
|
+
/** The packable packages of a chant checkout, under `packages/` and `lexicons/`, by name. */
|
|
34
|
+
export declare function chantPackages(chantDir: string): Map<string, ChantPackage>;
|
|
35
|
+
/** The product's package.json files, relative to its root: the root's and each workspace package's. */
|
|
36
|
+
export declare function productManifests(productDir: string): string[];
|
|
37
|
+
/** Every `@intentius/chant*` the product's package.json files name in dependencies, devDependencies or peerDependencies. */
|
|
38
|
+
export declare function productChantNames(productDir: string): string[];
|
|
39
|
+
/**
|
|
40
|
+
* The packages to pack for `want` and their chant dependencies, each after
|
|
41
|
+
* the packages it depends on, ties by name. Throws on a name the checkout has
|
|
42
|
+
* no package for, and on a cycle.
|
|
43
|
+
*/
|
|
44
|
+
export declare function packOrder(pkgs: Map<string, ChantPackage>, want: Iterable<string>): ChantPackage[];
|
|
45
|
+
/** The fixed tarball name for a package, so a later run replaces it: `@intentius/chant-lexicon-k8s` is `intentius-chant-lexicon-k8s.tgz`. */
|
|
46
|
+
export declare const tarballName: (name: string) => string;
|
|
47
|
+
/**
|
|
48
|
+
* One package.json pointed at the tarballs: every dependency, devDependency
|
|
49
|
+
* and optionalDependency `local` names takes its `file:` spec. The root also
|
|
50
|
+
* gets every tarball as a devDependency, so npm replaces a copy only a lexicon
|
|
51
|
+
* reaches (a lexicon's own chant dependencies) instead of keeping a registry
|
|
52
|
+
* release of it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function pointAtTarballs(manifest: Manifest, local: Map<string, string>, isRoot: boolean): Manifest;
|
|
55
|
+
/** Each installed copy of a chant package under the product: `node_modules/@intentius/*` at the root, in each workspace package, and nested. Links (workspace packages) are left out. */
|
|
56
|
+
export declare function installedChantCopies(productDir: string): {
|
|
57
|
+
at: string;
|
|
58
|
+
name: string;
|
|
59
|
+
}[];
|
|
60
|
+
/** How a command runs: throws {@link LocalChantError} when it exits non-zero. */
|
|
61
|
+
export type Runner = (command: string, args: string[], cwd: string) => string;
|
|
62
|
+
/** Run a command with its stderr on ours and its stdout returned. */
|
|
63
|
+
export declare const defaultRunner: Runner;
|
|
64
|
+
export interface LocalChantOptions {
|
|
65
|
+
/** The product's root, where its package.json and lock are. */
|
|
66
|
+
productDir: string;
|
|
67
|
+
/** The chant checkout to pack. */
|
|
68
|
+
chantDir: string;
|
|
69
|
+
/** Chant packages to pack besides the ones the product names, such as a lexicon an image installs. */
|
|
70
|
+
with?: string[];
|
|
71
|
+
/** Run `npm ci` in the checkout when its lock changed since the last run (default true). */
|
|
72
|
+
install?: boolean;
|
|
73
|
+
log?: (line: string) => void;
|
|
74
|
+
run?: Runner;
|
|
75
|
+
}
|
|
76
|
+
export interface LocalChantResult {
|
|
77
|
+
mark: LocalChantMark;
|
|
78
|
+
/** What was packed, in pack order, with each tarball's path. */
|
|
79
|
+
packed: (ChantPackage & {
|
|
80
|
+
tarball: string;
|
|
81
|
+
})[];
|
|
82
|
+
/** How many installed copies were marked. */
|
|
83
|
+
marked: number;
|
|
84
|
+
/** The tarball directory, `<product>/.chant-local`. */
|
|
85
|
+
outDir: string;
|
|
86
|
+
}
|
|
87
|
+
/** Pack the chant checkout and install it into the product, leaving its package.json files and lock as they were. */
|
|
88
|
+
export declare function installLocalChant(opts: LocalChantOptions): LocalChantResult;
|
|
89
|
+
/** The installed chant copies that differ from what package-lock.json pins, or carry a `chantLocal` mark. */
|
|
90
|
+
export declare function lockMismatches(productDir: string): string[];
|
|
91
|
+
/** Go back to the pin: `npm ci`, then fail when an installed chant package is not what the lock pins. */
|
|
92
|
+
export declare function resetLocalChant(opts: {
|
|
93
|
+
productDir: string;
|
|
94
|
+
log?: (line: string) => void;
|
|
95
|
+
run?: Runner;
|
|
96
|
+
}): void;
|
|
97
|
+
export {};
|
|
98
|
+
//# sourceMappingURL=local-chant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-chant.d.ts","sourceRoot":"","sources":["../src/local-chant.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@intentius/chant/local-chant` (#4787): build a product against a chant
|
|
3
|
+
* checkout instead of its pinned release.
|
|
4
|
+
*
|
|
5
|
+
* terragucci and plywood each carried a 270-line `scripts/chant-local.sh`
|
|
6
|
+
* that did this, and sql-yodeler would have copied it. `chant dev local`
|
|
7
|
+
* runs these functions:
|
|
8
|
+
*
|
|
9
|
+
* 1. find the chant packages the product's package.json files name (and any
|
|
10
|
+
* `with`), plus the chant packages those depend on, in an order where each
|
|
11
|
+
* follows the packages it builds against ({@link packOrder});
|
|
12
|
+
* 2. `npm ci` in the checkout when its lock changed since the last run, then
|
|
13
|
+
* `npm pack` each package (its prepack builds it) into `.chant-local/` in
|
|
14
|
+
* the product, under a fixed name per package;
|
|
15
|
+
* 3. point every package.json of the product at the tarballs, run
|
|
16
|
+
* `npm install --no-save`, and put the manifests and package-lock.json
|
|
17
|
+
* back byte for byte, so the workspace gets the local build everywhere and
|
|
18
|
+
* git sees no change;
|
|
19
|
+
* 4. mark each installed copy's package.json with `chantLocal` (the commit and
|
|
20
|
+
* the checkout), which `checkBundle` and a reader use to tell the local
|
|
21
|
+
* build from the pin, and fail when a copy is not the local build.
|
|
22
|
+
*
|
|
23
|
+
* {@link resetLocalChant} goes back: `npm ci`, then a check that every
|
|
24
|
+
* installed chant package is the version the lock pins, with no mark.
|
|
25
|
+
*/
|
|
26
|
+
import { spawnSync } from "node:child_process";
|
|
27
|
+
import { createHash } from "node:crypto";
|
|
28
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
29
|
+
import { join, relative, resolve } from "node:path";
|
|
30
|
+
export class LocalChantError extends Error {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.name = "LocalChantError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const readManifest = (file) => JSON.parse(readFileSync(file, "utf8"));
|
|
37
|
+
const isChant = (name) => /^@intentius\/chant(?:-[a-z0-9-]+)?$/.test(name);
|
|
38
|
+
/** The packable packages of a chant checkout, under `packages/` and `lexicons/`, by name. */
|
|
39
|
+
export function chantPackages(chantDir) {
|
|
40
|
+
const out = new Map();
|
|
41
|
+
for (const top of ["packages", "lexicons"]) {
|
|
42
|
+
const base = join(chantDir, top);
|
|
43
|
+
if (!existsSync(base))
|
|
44
|
+
continue;
|
|
45
|
+
for (const d of readdirSync(base).sort()) {
|
|
46
|
+
const f = join(base, d, "package.json");
|
|
47
|
+
if (!existsSync(f))
|
|
48
|
+
continue;
|
|
49
|
+
const p = readManifest(f);
|
|
50
|
+
if (p.private || !p.name)
|
|
51
|
+
continue;
|
|
52
|
+
out.set(p.name, {
|
|
53
|
+
name: p.name,
|
|
54
|
+
version: p.version ?? "0.0.0",
|
|
55
|
+
dir: `${top}/${d}`,
|
|
56
|
+
deps: Object.keys({ ...p.dependencies, ...p.peerDependencies, ...p.optionalDependencies }),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
/** The product's package.json files, relative to its root: the root's and each workspace package's. */
|
|
63
|
+
export function productManifests(productDir) {
|
|
64
|
+
const root = readManifest(join(productDir, "package.json"));
|
|
65
|
+
const patterns = Array.isArray(root.workspaces) ? root.workspaces : (root.workspaces?.packages ?? []);
|
|
66
|
+
const out = ["package.json"];
|
|
67
|
+
for (const pattern of patterns) {
|
|
68
|
+
const clean = pattern.replace(/\/+$/, "");
|
|
69
|
+
const dirs = clean.endsWith("/*")
|
|
70
|
+
? (existsSync(join(productDir, clean.slice(0, -2))) ? readdirSync(join(productDir, clean.slice(0, -2))).sort().map((d) => `${clean.slice(0, -2)}/${d}`) : [])
|
|
71
|
+
: [clean];
|
|
72
|
+
for (const d of dirs)
|
|
73
|
+
if (existsSync(join(productDir, d, "package.json")))
|
|
74
|
+
out.push(`${d}/package.json`);
|
|
75
|
+
}
|
|
76
|
+
return [...new Set(out)];
|
|
77
|
+
}
|
|
78
|
+
/** Every `@intentius/chant*` the product's package.json files name in dependencies, devDependencies or peerDependencies. */
|
|
79
|
+
export function productChantNames(productDir) {
|
|
80
|
+
const out = new Set();
|
|
81
|
+
for (const f of productManifests(productDir)) {
|
|
82
|
+
const p = readManifest(join(productDir, f));
|
|
83
|
+
for (const n of Object.keys({ ...p.dependencies, ...p.devDependencies, ...p.peerDependencies }))
|
|
84
|
+
if (isChant(n))
|
|
85
|
+
out.add(n);
|
|
86
|
+
}
|
|
87
|
+
return [...out].sort();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The packages to pack for `want` and their chant dependencies, each after
|
|
91
|
+
* the packages it depends on, ties by name. Throws on a name the checkout has
|
|
92
|
+
* no package for, and on a cycle.
|
|
93
|
+
*/
|
|
94
|
+
export function packOrder(pkgs, want) {
|
|
95
|
+
const need = new Set();
|
|
96
|
+
const visit = (n) => {
|
|
97
|
+
if (need.has(n))
|
|
98
|
+
return;
|
|
99
|
+
const p = pkgs.get(n);
|
|
100
|
+
if (!p)
|
|
101
|
+
throw new LocalChantError(`the chant checkout has no package ${n}`);
|
|
102
|
+
need.add(n);
|
|
103
|
+
for (const d of p.deps)
|
|
104
|
+
if (pkgs.has(d))
|
|
105
|
+
visit(d);
|
|
106
|
+
};
|
|
107
|
+
for (const n of want)
|
|
108
|
+
visit(n);
|
|
109
|
+
const out = [];
|
|
110
|
+
const left = new Set(need);
|
|
111
|
+
while (left.size) {
|
|
112
|
+
const ready = [...left].filter((n) => !pkgs.get(n).deps.some((d) => d !== n && left.has(d))).sort();
|
|
113
|
+
if (!ready.length)
|
|
114
|
+
throw new LocalChantError(`dependency cycle among ${[...left].sort().join(", ")}`);
|
|
115
|
+
for (const n of ready) {
|
|
116
|
+
out.push(pkgs.get(n));
|
|
117
|
+
left.delete(n);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
/** The fixed tarball name for a package, so a later run replaces it: `@intentius/chant-lexicon-k8s` is `intentius-chant-lexicon-k8s.tgz`. */
|
|
123
|
+
export const tarballName = (name) => `${name.replace(/^@/, "").replace(/\//g, "-")}.tgz`;
|
|
124
|
+
/**
|
|
125
|
+
* One package.json pointed at the tarballs: every dependency, devDependency
|
|
126
|
+
* and optionalDependency `local` names takes its `file:` spec. The root also
|
|
127
|
+
* gets every tarball as a devDependency, so npm replaces a copy only a lexicon
|
|
128
|
+
* reaches (a lexicon's own chant dependencies) instead of keeping a registry
|
|
129
|
+
* release of it.
|
|
130
|
+
*/
|
|
131
|
+
export function pointAtTarballs(manifest, local, isRoot) {
|
|
132
|
+
const p = structuredClone(manifest);
|
|
133
|
+
for (const k of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
134
|
+
const deps = p[k];
|
|
135
|
+
if (!deps)
|
|
136
|
+
continue;
|
|
137
|
+
for (const n of Object.keys(deps))
|
|
138
|
+
if (local.has(n))
|
|
139
|
+
deps[n] = local.get(n);
|
|
140
|
+
}
|
|
141
|
+
if (isRoot) {
|
|
142
|
+
const extra = Object.fromEntries([...local].filter(([n]) => !(n in (p.dependencies ?? {})) && !(n in (p.optionalDependencies ?? {}))));
|
|
143
|
+
p.devDependencies = { ...p.devDependencies, ...extra };
|
|
144
|
+
}
|
|
145
|
+
return p;
|
|
146
|
+
}
|
|
147
|
+
/** Each installed copy of a chant package under the product: `node_modules/@intentius/*` at the root, in each workspace package, and nested. Links (workspace packages) are left out. */
|
|
148
|
+
export function installedChantCopies(productDir) {
|
|
149
|
+
const out = [];
|
|
150
|
+
const walk = (nm) => {
|
|
151
|
+
const scope = join(nm, "@intentius");
|
|
152
|
+
if (!existsSync(scope))
|
|
153
|
+
return;
|
|
154
|
+
for (const d of readdirSync(scope).sort()) {
|
|
155
|
+
const at = join(scope, d);
|
|
156
|
+
if (lstatSync(at).isSymbolicLink() || !existsSync(join(at, "package.json")))
|
|
157
|
+
continue;
|
|
158
|
+
walk(join(at, "node_modules"));
|
|
159
|
+
const name = `@intentius/${d}`;
|
|
160
|
+
if (isChant(name))
|
|
161
|
+
out.push({ at, name });
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
walk(join(productDir, "node_modules"));
|
|
165
|
+
for (const f of productManifests(productDir).slice(1))
|
|
166
|
+
walk(join(productDir, f.replace(/package\.json$/, ""), "node_modules"));
|
|
167
|
+
return out;
|
|
168
|
+
}
|
|
169
|
+
/** Run a command with its stderr on ours and its stdout returned. */
|
|
170
|
+
export const defaultRunner = (command, args, cwd) => {
|
|
171
|
+
const r = spawnSync(command, args, { cwd, stdio: ["ignore", "pipe", "inherit"], encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
|
|
172
|
+
if (r.error)
|
|
173
|
+
throw new LocalChantError(`${command} ${args.join(" ")} in ${cwd}: ${r.error.message}`);
|
|
174
|
+
if (r.status !== 0)
|
|
175
|
+
throw new LocalChantError(`${command} ${args.join(" ")} in ${cwd} exited ${r.status ?? r.signal}`);
|
|
176
|
+
return r.stdout;
|
|
177
|
+
};
|
|
178
|
+
/** The checkout's commit, with `+dirty` when tracked files have changes; `unknown` outside git. */
|
|
179
|
+
function checkoutMark(chantDir) {
|
|
180
|
+
const head = spawnSync("git", ["rev-parse", "HEAD"], { cwd: chantDir, encoding: "utf8" });
|
|
181
|
+
if (head.status !== 0)
|
|
182
|
+
return "unknown";
|
|
183
|
+
const status = spawnSync("git", ["status", "--porcelain", "--untracked-files=no"], { cwd: chantDir, encoding: "utf8" });
|
|
184
|
+
return `${head.stdout.trim()}${status.stdout.trim() ? "+dirty" : ""}`;
|
|
185
|
+
}
|
|
186
|
+
/** Pack the chant checkout and install it into the product, leaving its package.json files and lock as they were. */
|
|
187
|
+
export function installLocalChant(opts) {
|
|
188
|
+
const productDir = resolve(opts.productDir);
|
|
189
|
+
const chantDir = resolve(opts.chantDir);
|
|
190
|
+
const log = opts.log ?? ((l) => process.stderr.write(`chant dev local: ${l}\n`));
|
|
191
|
+
const run = opts.run ?? defaultRunner;
|
|
192
|
+
if (!existsSync(join(productDir, "package.json")))
|
|
193
|
+
throw new LocalChantError(`${productDir} has no package.json`);
|
|
194
|
+
if (!existsSync(join(chantDir, "packages/core/package.json")))
|
|
195
|
+
throw new LocalChantError(`${chantDir} is not a chant checkout (no packages/core/package.json)`);
|
|
196
|
+
const mark = { commit: checkoutMark(chantDir), dir: chantDir };
|
|
197
|
+
log(`chant at ${mark.commit} (${chantDir})`);
|
|
198
|
+
if (opts.install !== false) {
|
|
199
|
+
const lock = join(chantDir, "package-lock.json");
|
|
200
|
+
if (!existsSync(lock))
|
|
201
|
+
throw new LocalChantError(`${chantDir} has no package-lock.json to npm ci from`);
|
|
202
|
+
const sum = createHash("sha256").update(readFileSync(lock)).digest("hex");
|
|
203
|
+
const stamp = join(chantDir, "node_modules/.chant-dev-local");
|
|
204
|
+
if (!existsSync(stamp) || readFileSync(stamp, "utf8").trim() !== sum) {
|
|
205
|
+
log("npm ci in the chant checkout");
|
|
206
|
+
run("npm", ["ci", "--no-audit", "--no-fund"], chantDir);
|
|
207
|
+
writeFileSync(stamp, `${sum}\n`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const pkgs = chantPackages(chantDir);
|
|
211
|
+
const order = packOrder(pkgs, [...productChantNames(productDir), ...(opts.with ?? [])]);
|
|
212
|
+
if (!order.length)
|
|
213
|
+
throw new LocalChantError(`${productDir}'s package.json files name no @intentius/chant package`);
|
|
214
|
+
const outDir = join(productDir, ".chant-local");
|
|
215
|
+
mkdirSync(join(outDir, "manifests"), { recursive: true });
|
|
216
|
+
const packed = [];
|
|
217
|
+
for (const p of order) {
|
|
218
|
+
log(`packing ${p.dir}`);
|
|
219
|
+
const out = run("npm", ["pack", "--silent", "--pack-destination", outDir], join(chantDir, p.dir));
|
|
220
|
+
const file = out.trim().split("\n").pop()?.trim() ?? "";
|
|
221
|
+
if (!file || !existsSync(join(outDir, file)))
|
|
222
|
+
throw new LocalChantError(`npm pack in ${p.dir} wrote no tarball`);
|
|
223
|
+
const fixed = tarballName(p.name);
|
|
224
|
+
if (file !== fixed)
|
|
225
|
+
renameSync(join(outDir, file), join(outDir, fixed));
|
|
226
|
+
packed.push({ ...p, tarball: join(outDir, fixed) });
|
|
227
|
+
}
|
|
228
|
+
writeFileSync(join(outDir, "commit"), `${mark.commit}\n`);
|
|
229
|
+
writeFileSync(join(outDir, "packages.json"), `${JSON.stringify(packed.map((p) => ({ name: p.name, version: p.version, tarball: relative(productDir, p.tarball) })), null, 2)}\n`);
|
|
230
|
+
// The workspace packages pin chant too, so installing at the root alone
|
|
231
|
+
// would leave the pinned copies nested under packages/*/node_modules. Point
|
|
232
|
+
// every package.json at the tarballs for one install and put each file
|
|
233
|
+
// back afterwards, the lock with them. --legacy-peer-deps because the pinned
|
|
234
|
+
// lexicons still in the tree want the pinned core as a peer until npm
|
|
235
|
+
// replaces them.
|
|
236
|
+
const local = new Map(packed.map((p) => [p.name, `file:${p.tarball}`]));
|
|
237
|
+
const files = [...productManifests(productDir), ...(existsSync(join(productDir, "package-lock.json")) ? ["package-lock.json"] : [])];
|
|
238
|
+
const saved = new Map(files.map((f) => [f, readFileSync(join(productDir, f))]));
|
|
239
|
+
for (const [f, body] of saved)
|
|
240
|
+
writeFileSync(join(outDir, "manifests", f.replace(/\//g, "_")), body);
|
|
241
|
+
try {
|
|
242
|
+
for (const f of files) {
|
|
243
|
+
if (!f.endsWith("package.json"))
|
|
244
|
+
continue;
|
|
245
|
+
const p = pointAtTarballs(JSON.parse(saved.get(f).toString("utf8")), local, f === "package.json");
|
|
246
|
+
writeFileSync(join(productDir, f), `${JSON.stringify(p, null, 2)}\n`);
|
|
247
|
+
}
|
|
248
|
+
log(`installing ${packed.length} tarballs with npm install --no-save`);
|
|
249
|
+
run("npm", ["install", "--no-save", "--no-audit", "--no-fund", "--legacy-peer-deps"], productDir);
|
|
250
|
+
}
|
|
251
|
+
finally {
|
|
252
|
+
for (const [f, body] of saved)
|
|
253
|
+
writeFileSync(join(productDir, f), body);
|
|
254
|
+
}
|
|
255
|
+
const versions = new Map(packed.map((p) => [p.name, p.version]));
|
|
256
|
+
const bad = [];
|
|
257
|
+
let marked = 0;
|
|
258
|
+
for (const { at, name } of installedChantCopies(productDir)) {
|
|
259
|
+
if (!versions.has(name))
|
|
260
|
+
continue;
|
|
261
|
+
const f = join(at, "package.json");
|
|
262
|
+
const p = readManifest(f);
|
|
263
|
+
if (p.version !== versions.get(name)) {
|
|
264
|
+
bad.push(`${relative(productDir, at)} is ${p.version}, the checkout's is ${versions.get(name)}`);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
p.chantLocal = mark;
|
|
268
|
+
writeFileSync(f, `${JSON.stringify(p, null, 2)}\n`);
|
|
269
|
+
marked++;
|
|
270
|
+
}
|
|
271
|
+
if (bad.length)
|
|
272
|
+
throw new LocalChantError(`these installed copies are not the local build:\n ${bad.join("\n ")}`);
|
|
273
|
+
log(`marked ${marked} installed chant packages with ${mark.commit}`);
|
|
274
|
+
return { mark, packed, marked, outDir };
|
|
275
|
+
}
|
|
276
|
+
/** The installed chant copies that differ from what package-lock.json pins, or carry a `chantLocal` mark. */
|
|
277
|
+
export function lockMismatches(productDir) {
|
|
278
|
+
const dir = resolve(productDir);
|
|
279
|
+
const lockFile = join(dir, "package-lock.json");
|
|
280
|
+
if (!existsSync(lockFile))
|
|
281
|
+
return ["there is no package-lock.json"];
|
|
282
|
+
const lock = JSON.parse(readFileSync(lockFile, "utf8")).packages ?? {};
|
|
283
|
+
const bad = [];
|
|
284
|
+
for (const [at, entry] of Object.entries(lock)) {
|
|
285
|
+
if (!/(^|\/)node_modules\/@intentius\/chant[^/]*$/.test(at) || entry.link)
|
|
286
|
+
continue;
|
|
287
|
+
const f = join(dir, at, "package.json");
|
|
288
|
+
if (!existsSync(f)) {
|
|
289
|
+
bad.push(`${at} is missing`);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const p = readManifest(f);
|
|
293
|
+
if (p.version !== entry.version || p.chantLocal)
|
|
294
|
+
bad.push(`${at} is ${p.version}${p.chantLocal ? " (local build)" : ""}, the lock says ${entry.version}`);
|
|
295
|
+
}
|
|
296
|
+
return bad;
|
|
297
|
+
}
|
|
298
|
+
/** Go back to the pin: `npm ci`, then fail when an installed chant package is not what the lock pins. */
|
|
299
|
+
export function resetLocalChant(opts) {
|
|
300
|
+
const dir = resolve(opts.productDir);
|
|
301
|
+
const log = opts.log ?? ((l) => process.stderr.write(`chant dev local: ${l}\n`));
|
|
302
|
+
log("reinstalling the pinned versions with npm ci");
|
|
303
|
+
(opts.run ?? defaultRunner)("npm", ["ci", "--no-audit", "--no-fund"], dir);
|
|
304
|
+
const bad = lockMismatches(dir);
|
|
305
|
+
if (bad.length)
|
|
306
|
+
throw new LocalChantError(`node_modules does not match package-lock.json after npm ci:\n ${bad.join("\n ")}`);
|
|
307
|
+
}
|
|
@@ -116,7 +116,7 @@ export function declaredEdgeCoverage() {
|
|
|
116
116
|
* activity registry imports this module statically.
|
|
117
117
|
*/
|
|
118
118
|
export async function predictDeclared(projectPath, args) {
|
|
119
|
-
const { loadChantConfigUpward } = await import("../../config.js");
|
|
119
|
+
const { loadChantConfigUpward, resolveSourceDir } = await import("../../config.js");
|
|
120
120
|
const { loadPlugins, resolveProjectLexicons } = await import("../../cli/plugins.js");
|
|
121
121
|
const { build } = await import("../../build.js");
|
|
122
122
|
const { buildGraphIr } = await import("../../graph-ir.js");
|
|
@@ -127,7 +127,7 @@ export async function predictDeclared(projectPath, args) {
|
|
|
127
127
|
// only what its own entity types mean, so there is nothing to choose between
|
|
128
128
|
// and nothing to refuse when two lexicons both answer — they are additive.
|
|
129
129
|
const kinds = plugins.map((p) => p.behaviourKinds).filter((k) => k !== undefined);
|
|
130
|
-
const sourceDir =
|
|
130
|
+
const sourceDir = resolveSourceDir(projectPath, config);
|
|
131
131
|
const result = await build(sourceDir, plugins.map((p) => p.serializer));
|
|
132
132
|
if (result.errors.length > 0) {
|
|
133
133
|
const messages = result.errors.map((e) => (typeof e === "string" ? e : e.message ?? String(e)));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `evidence` of an Op waves spec (#4870), checked with no import, so the
|
|
3
|
+
* spec's readers in the bundles stay small. The runner side is
|
|
4
|
+
* ./op-waves-evidence.ts.
|
|
5
|
+
*/
|
|
6
|
+
/** `evidence` of an Op waves spec (#4870). */
|
|
7
|
+
export interface OpWavesEvidence {
|
|
8
|
+
/** The checks whose current evidence the applied commit needs, read at base. */
|
|
9
|
+
requires?: string[];
|
|
10
|
+
}
|
|
11
|
+
/** What is wrong with a spec's `evidence`, empty when nothing is. */
|
|
12
|
+
export declare function opWavesEvidenceProblems(raw: unknown): string[];
|
|
13
|
+
//# sourceMappingURL=op-waves-evidence-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op-waves-evidence-spec.d.ts","sourceRoot":"","sources":["../../src/op/op-waves-evidence-spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8CAA8C;AAC9C,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,qEAAqE;AACrE,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAU9D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `evidence` of an Op waves spec (#4870), checked with no import, so the
|
|
3
|
+
* spec's readers in the bundles stay small. The runner side is
|
|
4
|
+
* ./op-waves-evidence.ts.
|
|
5
|
+
*/
|
|
6
|
+
/** What is wrong with a spec's `evidence`, empty when nothing is. */
|
|
7
|
+
export function opWavesEvidenceProblems(raw) {
|
|
8
|
+
if (raw === undefined)
|
|
9
|
+
return [];
|
|
10
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
11
|
+
return ["`evidence` must be an object"];
|
|
12
|
+
const r = raw;
|
|
13
|
+
const problems = [];
|
|
14
|
+
for (const key of Object.keys(r))
|
|
15
|
+
if (key !== "requires")
|
|
16
|
+
problems.push(`\`evidence.${key}\` is not a setting; \`evidence\` takes \`requires\``);
|
|
17
|
+
if (r.requires !== undefined && (!Array.isArray(r.requires) || r.requires.some((c) => typeof c !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(c)))) {
|
|
18
|
+
problems.push("`evidence.requires` must be a list of check names (letters, digits, `.`, `_`, `:` and `-`, as `refs` in .chant/trust.json names them)");
|
|
19
|
+
}
|
|
20
|
+
return problems;
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check evidence in an Op waves job (#4870).
|
|
3
|
+
*
|
|
4
|
+
* - `evidence.requires` in the spec at base names the checks whose current
|
|
5
|
+
* evidence a wave's commit needs before anything in it is planned or
|
|
6
|
+
* applied, such as `["plan", "policy"]`, which the pull request's plan
|
|
7
|
+
* note job signed for the head's tree. A commit without it is refused,
|
|
8
|
+
* and the refusal names each missing check. Read at base, so a change
|
|
9
|
+
* cannot drop the rule for its own apply.
|
|
10
|
+
* - With a runner key in `CHANT_RUNNER_KEY`, the deciding job signs its own
|
|
11
|
+
* two named checks once the wave is planned: `plan:<wave>`, and
|
|
12
|
+
* `policy:<wave>` when `ci.policy` ran over the plans and denied nothing.
|
|
13
|
+
* They are attached under `refs/notes/chant/evidence` and pushed, where #4867's ref gate
|
|
14
|
+
* and a later wave read them.
|
|
15
|
+
*
|
|
16
|
+
* See ../workspace/trust/check-evidence.ts.
|
|
17
|
+
*/
|
|
18
|
+
import type { OpRunPolicyRow } from "./runtime.js";
|
|
19
|
+
export { opWavesEvidenceProblems, type OpWavesEvidence } from "./op-waves-evidence-spec.js";
|
|
20
|
+
/** Why the wave's commit is refused for want of evidence, or null. */
|
|
21
|
+
export declare function opWaveEvidenceRefusal(cwd: string, head: string, base: string, requires: readonly string[] | undefined): Promise<string | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Sign the wave's plan and policy checks when the job holds a runner key.
|
|
24
|
+
* Never fails the wave: a key the policy at base does not list, or a
|
|
25
|
+
* notes push that does not land, is a line in the log.
|
|
26
|
+
*/
|
|
27
|
+
export declare function signOpWaveChecks(input: {
|
|
28
|
+
cwd: string;
|
|
29
|
+
head: string;
|
|
30
|
+
base: string;
|
|
31
|
+
wave: string;
|
|
32
|
+
planDigest?: string;
|
|
33
|
+
policyRows: ReadonlyMap<string, OpRunPolicyRow>;
|
|
34
|
+
log: (line: string) => void;
|
|
35
|
+
env?: NodeJS.ProcessEnv;
|
|
36
|
+
push?: boolean;
|
|
37
|
+
}): Promise<string[]>;
|
|
38
|
+
//# sourceMappingURL=op-waves-evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op-waves-evidence.d.ts","sourceRoot":"","sources":["../../src/op/op-waves-evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAOzF,sEAAsE;AACtE,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGpJ;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAkBtQ"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check evidence in an Op waves job (#4870).
|
|
3
|
+
*
|
|
4
|
+
* - `evidence.requires` in the spec at base names the checks whose current
|
|
5
|
+
* evidence a wave's commit needs before anything in it is planned or
|
|
6
|
+
* applied, such as `["plan", "policy"]`, which the pull request's plan
|
|
7
|
+
* note job signed for the head's tree. A commit without it is refused,
|
|
8
|
+
* and the refusal names each missing check. Read at base, so a change
|
|
9
|
+
* cannot drop the rule for its own apply.
|
|
10
|
+
* - With a runner key in `CHANT_RUNNER_KEY`, the deciding job signs its own
|
|
11
|
+
* two named checks once the wave is planned: `plan:<wave>`, and
|
|
12
|
+
* `policy:<wave>` when `ci.policy` ran over the plans and denied nothing.
|
|
13
|
+
* They are attached under `refs/notes/chant/evidence` and pushed, where #4867's ref gate
|
|
14
|
+
* and a later wave read them.
|
|
15
|
+
*
|
|
16
|
+
* See ../workspace/trust/check-evidence.ts.
|
|
17
|
+
*/
|
|
18
|
+
import { execFileSync } from "node:child_process";
|
|
19
|
+
export { opWavesEvidenceProblems } from "./op-waves-evidence-spec.js";
|
|
20
|
+
import { CHECK_EVIDENCE_KEY_ENV, missingCheckEvidence, recordChecks, runnerKeyEvidenceSigner, signChecks } from "../workspace/trust/check-evidence.js";
|
|
21
|
+
function top(cwd) {
|
|
22
|
+
return execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
23
|
+
}
|
|
24
|
+
/** Why the wave's commit is refused for want of evidence, or null. */
|
|
25
|
+
export async function opWaveEvidenceRefusal(cwd, head, base, requires) {
|
|
26
|
+
if (!requires || requires.length === 0)
|
|
27
|
+
return null;
|
|
28
|
+
return missingCheckEvidence(top(cwd), head, base, requires);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Sign the wave's plan and policy checks when the job holds a runner key.
|
|
32
|
+
* Never fails the wave: a key the policy at base does not list, or a
|
|
33
|
+
* notes push that does not land, is a line in the log.
|
|
34
|
+
*/
|
|
35
|
+
export async function signOpWaveChecks(input) {
|
|
36
|
+
const pem = (input.env ?? process.env)[CHECK_EVIDENCE_KEY_ENV];
|
|
37
|
+
if (!pem)
|
|
38
|
+
return [];
|
|
39
|
+
try {
|
|
40
|
+
const repo = top(input.cwd);
|
|
41
|
+
const signer = runnerKeyEvidenceSigner(repo, input.base, pem);
|
|
42
|
+
const rows = [...input.policyRows.values()];
|
|
43
|
+
const checks = [{ check: `plan:${input.wave}`, ...(input.planDigest ? { claim: input.planDigest } : {}) }];
|
|
44
|
+
if (rows.length > 0 && rows.every((r) => r.result !== "denied"))
|
|
45
|
+
checks.push({ check: `policy:${input.wave}`, claim: JSON.stringify(rows) });
|
|
46
|
+
const signed = signChecks(repo, input.head, checks, signer);
|
|
47
|
+
const pushed = await recordChecks(repo, signed, { push: input.push !== false });
|
|
48
|
+
if (input.push !== false && !pushed.pushed && pushed.pushWarning)
|
|
49
|
+
input.log(`wave ${input.wave}: ${pushed.pushWarning}`);
|
|
50
|
+
input.log(`wave ${input.wave}: signed evidence for ${signed.map((s) => s.check).join(", ")} as ${signer.principal}`);
|
|
51
|
+
return signed.map((s) => s.check);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
input.log(`wave ${input.wave}: no check evidence signed: ${err instanceof Error ? err.message : String(err)}`);
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -529,6 +529,10 @@ export interface OpWaveBaseRules {
|
|
|
529
529
|
pullRequestGate?: string;
|
|
530
530
|
/** `approvals.preview` at base: the wave applies what the merged pull request's head recorded, or refuses (exit 4). */
|
|
531
531
|
preview?: boolean;
|
|
532
|
+
/** `evidence.requires` at base (#4870): the checks whose current evidence the wave's commit needs. */
|
|
533
|
+
evidenceRequires?: string[];
|
|
534
|
+
/** Set when `evidence` at base cannot be read: the wave fails rather than apply without the checks it asks for. */
|
|
535
|
+
evidenceRefused?: string;
|
|
532
536
|
}
|
|
533
537
|
/**
|
|
534
538
|
* The policy of wave `name`, as the spec file at `base` declares it. The
|