@intentius/chant 0.124.60 → 0.124.62
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/main.d.ts.map +1 -1
- package/dist/cli/main.js +16 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +12 -0
- package/dist/cli/registry.d.ts +6 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/notify.d.ts +24 -2
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +16 -2
- package/dist/notify.schema.json +17 -1
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +310 -309
- package/dist/workspace/ci-builds.d.ts +16 -4
- package/dist/workspace/ci-builds.d.ts.map +1 -1
- package/dist/workspace/ci-builds.js +10 -7
- package/dist/workspace/ci-green-cli.d.ts +12 -0
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +80 -6
- package/dist/workspace/ci-green-workflow.d.ts +13 -0
- package/dist/workspace/ci-green-workflow.d.ts.map +1 -1
- package/dist/workspace/ci-green-workflow.js +72 -1
- package/dist/workspace/ci-green.d.ts +130 -6
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +250 -24
- package/dist/workspace/declaration.d.ts +37 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +29 -1
- package/dist/workspace/declaration.schema.json +44 -0
- package/dist/workspace/trust/ci-tag-statement.d.ts +1 -0
- package/dist/workspace/trust/ci-tag-statement.d.ts.map +1 -1
- package/dist/workspace/trust/ci-tag-statement.js +5 -1
- package/package.json +1 -1
- package/src/cli/main.ts +16 -2
- package/src/cli/parse-args.ts +9 -0
- package/src/cli/registry.ts +6 -0
- package/src/notify.schema.json +17 -1
- package/src/notify.ts +30 -2
- package/src/release-floors.ts +1 -1
- package/src/workspace/ci-builds.ts +16 -7
- package/src/workspace/ci-green-builds.test.ts +83 -1
- package/src/workspace/ci-green-cli.ts +80 -6
- package/src/workspace/ci-green-lanes.test.ts +121 -0
- package/src/workspace/ci-green-merge-queue.test.ts +66 -0
- package/src/workspace/ci-green-notify.test.ts +166 -0
- package/src/workspace/ci-green-signed.test.ts +20 -0
- package/src/workspace/ci-green-workflow.test.ts +56 -1
- package/src/workspace/ci-green-workflow.ts +71 -1
- package/src/workspace/ci-green.ts +289 -26
- package/src/workspace/declaration.schema.json +44 -0
- package/src/workspace/declaration.ts +64 -2
- package/src/workspace/trust/ci-tag-statement.ts +5 -2
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import { RETENTION_KINDS, type RetentionOverride } from "../lifecycle/retention-policy";
|
|
20
20
|
import { parseReportUrl } from "../pr-report-url";
|
|
21
|
+
import { notifyConfigProblem, type NotifyConfig } from "../notify";
|
|
21
22
|
import schema from "./declaration.schema.json" with { type: "json" };
|
|
22
23
|
import { routeConflicts } from "./ci-branches";
|
|
23
24
|
import { cloudIdentityProblems, IDENTITY_CLOUDS, type CloudIdentityDeclaration } from "../ci-identity";
|
|
@@ -274,9 +275,54 @@ export interface CiGreen {
|
|
|
274
275
|
* a runner key.
|
|
275
276
|
*/
|
|
276
277
|
source: CiSource;
|
|
278
|
+
/**
|
|
279
|
+
* Green lanes (#4662): named subsets of the phases, each with its own
|
|
280
|
+
* tags, so a deployable that needs only some phases is green without the
|
|
281
|
+
* rest. Absent when the declaration names none.
|
|
282
|
+
*/
|
|
283
|
+
lanes?: CiLane[];
|
|
284
|
+
/**
|
|
285
|
+
* Who the tick tells (#4645): `ci.red`, `ci.culprit` and `ci.green`, sent
|
|
286
|
+
* through notify as Op waves send theirs. Absent when the declaration sets none.
|
|
287
|
+
*/
|
|
288
|
+
notify?: NotifyConfig;
|
|
289
|
+
/**
|
|
290
|
+
* The branch takes changes through GitHub's merge queue (#4644): `ci
|
|
291
|
+
* workflow` adds the `merge_group` trigger to the workflows holding a
|
|
292
|
+
* phase that sets `build`, and writes `chant-merge-queue.yml`, whose
|
|
293
|
+
* `chant-verdict` job the queue's ruleset requires. Absent when unset.
|
|
294
|
+
*/
|
|
295
|
+
mergeQueue?: true;
|
|
296
|
+
pointer: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* One green lane (#4662): a commit that passes the lane's phases gets
|
|
301
|
+
* `ci/green-<name>/<sha>`, and one that later fails them `ci/revoked-<name>/<sha>`,
|
|
302
|
+
* judged from the same runs as `require`.
|
|
303
|
+
*/
|
|
304
|
+
export interface CiLane {
|
|
305
|
+
name: string;
|
|
306
|
+
/** The phases the lane needs, by name, in file order. Each is a declared phase. */
|
|
307
|
+
require: string[];
|
|
277
308
|
pointer: string;
|
|
278
309
|
}
|
|
279
310
|
|
|
311
|
+
/** A lane's tag prefixes (#4662): `ci/green-<lane>/` and `ci/revoked-<lane>/`. */
|
|
312
|
+
export function laneTagPrefixes(lane: string): { green: string; revoked: string } {
|
|
313
|
+
return { green: `ci/green-${lane}/`, revoked: `ci/revoked-${lane}/` };
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** The lane `name` of `green`, or a `declaration-invalid` error naming the lanes it declares. */
|
|
317
|
+
export function laneOf(green: CiGreen, name: string): CiLane {
|
|
318
|
+
const lane = green.lanes?.find((l) => l.name === name);
|
|
319
|
+
if (!lane) {
|
|
320
|
+
const declared = (green.lanes ?? []).map((l) => l.name);
|
|
321
|
+
throw new WorkspaceReadError("declaration-invalid", `ci.green declares no lane ${JSON.stringify(name)}${declared.length > 0 ? `; it declares ${declared.join(", ")}` : "; it declares none (ci.green.lanes)"}`);
|
|
322
|
+
}
|
|
323
|
+
return lane;
|
|
324
|
+
}
|
|
325
|
+
|
|
280
326
|
/** Where `ci tick` reads phase results (#4044): forge check runs, or chant Op runs. */
|
|
281
327
|
export type CiSource = "checks" | "runs";
|
|
282
328
|
|
|
@@ -1366,7 +1412,7 @@ function cloudIdentityOf(raw: CloudIdentityDeclaration, at: (pointer: string, ke
|
|
|
1366
1412
|
|
|
1367
1413
|
function ciOf(raw: unknown, at: (pointer: string, key?: boolean) => ErrorLocation): CiDeclaration | null {
|
|
1368
1414
|
if (raw === undefined) return null;
|
|
1369
|
-
const block = raw as { reportUrl?: string; workflow?: CiWorkflow; hooks?: unknown; identity?: { cloud?: CloudIdentityDeclaration }; branches?: Record<string, string[]>; labels?: Record<string, string[]>; locks?: CiLocks; lockGrain?: CiLockGrain; policy?: unknown; prEnvironment?: { template: string; ttl?: string; teardown?: { name?: string; command: string[]; lexicons?: string[] } }; green?: { branch: string | string[]; window?: string; phases: Record<string, string[] | { runs: string[]; skipped?: CiSkipped; build?: CiBuild }>; require: string[]; preMerge?: string[]; signedSince?: string; source?: CiSource } };
|
|
1415
|
+
const block = raw as { reportUrl?: string; workflow?: CiWorkflow; hooks?: unknown; identity?: { cloud?: CloudIdentityDeclaration }; branches?: Record<string, string[]>; labels?: Record<string, string[]>; locks?: CiLocks; lockGrain?: CiLockGrain; policy?: unknown; prEnvironment?: { template: string; ttl?: string; teardown?: { name?: string; command: string[]; lexicons?: string[] } }; green?: { branch: string | string[]; window?: string; phases: Record<string, string[] | { runs: string[]; skipped?: CiSkipped; build?: CiBuild }>; require: string[]; preMerge?: string[]; signedSince?: string; source?: CiSource; lanes?: Record<string, { require: string[] }>; notify?: NotifyConfig; mergeQueue?: boolean } };
|
|
1370
1416
|
const hooks = ciHooksOf(block.hooks, "/ci/hooks", at);
|
|
1371
1417
|
const policy = ciPolicyOf(block.policy, at);
|
|
1372
1418
|
const workflow = {
|
|
@@ -1428,8 +1474,24 @@ function ciOf(raw: unknown, at: (pointer: string, key?: boolean) => ErrorLocatio
|
|
|
1428
1474
|
at(`/ci/green/preMerge/${i}`),
|
|
1429
1475
|
);
|
|
1430
1476
|
}
|
|
1477
|
+
const lanes: CiLane[] = Object.entries(g.lanes ?? {}).map(([name, l]) => {
|
|
1478
|
+
const pointer = `/ci/green/lanes/${pointerToken(name)}`;
|
|
1479
|
+
for (const [i, phase] of l.require.entries()) {
|
|
1480
|
+
if (phases.some((p) => p.name === phase)) continue;
|
|
1481
|
+
throw new WorkspaceReadError(
|
|
1482
|
+
"declaration-invalid",
|
|
1483
|
+
`ci.green.lanes.${name}.require names the phase ${JSON.stringify(phase)}, which ci.green.phases does not declare; declared phases: ${phases.map((p) => p.name).join(", ")}`,
|
|
1484
|
+
at(`${pointer}/require/${i}`),
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
return { name, require: [...l.require], pointer };
|
|
1488
|
+
});
|
|
1489
|
+
if (g.notify !== undefined) {
|
|
1490
|
+
const problem = notifyConfigProblem(g.notify, "ci.green.notify");
|
|
1491
|
+
if (problem) throw new WorkspaceReadError("declaration-invalid", problem, at("/ci/green/notify"));
|
|
1492
|
+
}
|
|
1431
1493
|
const judged = Array.isArray(g.branch) ? g.branch : [g.branch];
|
|
1432
|
-
return { green: { branch: judged[0]!, ...(judged.length > 1 ? { branches: [...judged] } : {}), window: g.window ?? DEFAULT_CI_WINDOW, phases, require: [...g.require], ...(g.preMerge !== undefined ? { preMerge: [...g.preMerge] } : {}), signedSince: g.signedSince ?? null, source: g.source ?? "checks", pointer: "/ci/green" }, ...workflow, reportUrl };
|
|
1494
|
+
return { green: { branch: judged[0]!, ...(judged.length > 1 ? { branches: [...judged] } : {}), window: g.window ?? DEFAULT_CI_WINDOW, phases, require: [...g.require], ...(g.preMerge !== undefined ? { preMerge: [...g.preMerge] } : {}), signedSince: g.signedSince ?? null, source: g.source ?? "checks", ...(lanes.length > 0 ? { lanes } : {}), ...(g.notify !== undefined ? { notify: { ...g.notify, ...(g.notify.events ? { events: [...g.notify.events] } : {}) } } : {}), ...(g.mergeQueue === true ? { mergeQueue: true as const } : {}), pointer: "/ci/green" }, ...workflow, reportUrl };
|
|
1433
1495
|
}
|
|
1434
1496
|
|
|
1435
1497
|
function agentsOf(raw: unknown, members: Member[], at: (pointer: string, key?: boolean) => ErrorLocation): AgentDeclaration[] {
|
|
@@ -113,11 +113,11 @@ const normalise = (name: string): string => name.normalize("NFKC").trim().toLowe
|
|
|
113
113
|
*/
|
|
114
114
|
export function verifyCiTagStatement(
|
|
115
115
|
record: Record<string, unknown> | null,
|
|
116
|
-
expect: { sha: string; kind: "green" | "revoked"; branch: string },
|
|
116
|
+
expect: { sha: string; kind: "green" | "revoked"; branch: string; lane?: string },
|
|
117
117
|
runners: readonly RunnerKey[],
|
|
118
118
|
roles: Readonly<Record<string, readonly string[]>>,
|
|
119
119
|
): CiTagVerdict {
|
|
120
|
-
const tag = `ci/${expect.kind}/${expect.sha}`;
|
|
120
|
+
const tag = `ci/${expect.kind}${expect.lane !== undefined ? `-${expect.lane}` : ""}/${expect.sha}`;
|
|
121
121
|
if (record === null) return { status: "unsigned", reason: `${tag} has no JSON record in its annotation, so it carries no statement (a lightweight tag, or one made by hand)` };
|
|
122
122
|
const { statement: envelope, ...fields } = record;
|
|
123
123
|
if (envelope === undefined) return { status: "unsigned", reason: `${tag} carries no statement signed by a runner key` };
|
|
@@ -145,6 +145,9 @@ export function verifyCiTagStatement(
|
|
|
145
145
|
if (p.record.commit !== expect.sha) differs.push(`its record names commit ${p.record.commit.slice(0, 12)}`);
|
|
146
146
|
if (p.record.tag !== expect.kind) differs.push(`it signs a ${p.record.tag} tag`);
|
|
147
147
|
if (p.record.branch !== expect.branch) differs.push(`it is for branch ${p.record.branch}, and ci.green names ${expect.branch}`);
|
|
148
|
+
// #4662: a lane's statement says its lane, so it never counts as ci/green or as another lane's tag.
|
|
149
|
+
const signedLane = typeof (p.record as { lane?: unknown }).lane === "string" ? ((p.record as { lane?: string }).lane as string) : undefined;
|
|
150
|
+
if (signedLane !== expect.lane) differs.push(signedLane === undefined ? `it signs a ci/${p.record.tag} tag, not lane ${expect.lane}'s` : `it signs lane ${signedLane}'s tag${expect.lane !== undefined ? `, not lane ${expect.lane}'s` : ", not ci/" + p.record.tag}`);
|
|
148
151
|
if (canonicalJson(p.record) !== canonicalJson(fields)) differs.push("the annotation's record is not the one signed");
|
|
149
152
|
if (differs.length > 0) return { status: "mismatch", reason: `${tag} is signed by ${v.principal}, but the statement does not match the tag: ${differs.join("; ")}` };
|
|
150
153
|
return { status: "signed", signer: v.principal, keyid: v.keyid, reason: `signed by ${v.principal} (${CI_TAG_SIGNER_ROLE})` };
|