@intentius/chant 0.124.59 → 0.124.61

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.
Files changed (82) hide show
  1. package/dist/cli/main.d.ts.map +1 -1
  2. package/dist/cli/main.js +16 -2
  3. package/dist/cli/parse-args.d.ts.map +1 -1
  4. package/dist/cli/parse-args.js +12 -0
  5. package/dist/cli/registry.d.ts +6 -0
  6. package/dist/cli/registry.d.ts.map +1 -1
  7. package/dist/components/capability.d.ts +11 -0
  8. package/dist/components/capability.d.ts.map +1 -1
  9. package/dist/lifecycle/wave-plans.d.ts +19 -0
  10. package/dist/lifecycle/wave-plans.d.ts.map +1 -1
  11. package/dist/lifecycle/wave-plans.js +25 -1
  12. package/dist/notify.d.ts +24 -2
  13. package/dist/notify.d.ts.map +1 -1
  14. package/dist/notify.js +16 -2
  15. package/dist/notify.schema.json +17 -1
  16. package/dist/op/gate-review.d.ts +1 -1
  17. package/dist/op/gate-review.d.ts.map +1 -1
  18. package/dist/op/index.d.ts +1 -0
  19. package/dist/op/index.d.ts.map +1 -1
  20. package/dist/op/index.js +1 -0
  21. package/dist/op/op-waves-capability.d.ts +2 -0
  22. package/dist/op/op-waves-capability.d.ts.map +1 -1
  23. package/dist/op/op-waves-capability.js +1 -0
  24. package/dist/op/op-waves-preview.d.ts +45 -0
  25. package/dist/op/op-waves-preview.d.ts.map +1 -0
  26. package/dist/op/op-waves-preview.js +37 -0
  27. package/dist/op/op-waves-run.d.ts +18 -0
  28. package/dist/op/op-waves-run.d.ts.map +1 -1
  29. package/dist/op/op-waves-run.js +40 -8
  30. package/dist/release-floors.d.ts +1 -1
  31. package/dist/release-floors.js +1 -1
  32. package/dist/wave-runtime.mjs +311 -310
  33. package/dist/workspace/ci-builds.d.ts +16 -4
  34. package/dist/workspace/ci-builds.d.ts.map +1 -1
  35. package/dist/workspace/ci-builds.js +10 -7
  36. package/dist/workspace/ci-green-cli.d.ts +12 -0
  37. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  38. package/dist/workspace/ci-green-cli.js +80 -6
  39. package/dist/workspace/ci-green-workflow.d.ts +11 -0
  40. package/dist/workspace/ci-green-workflow.d.ts.map +1 -1
  41. package/dist/workspace/ci-green-workflow.js +63 -1
  42. package/dist/workspace/ci-green.d.ts +130 -6
  43. package/dist/workspace/ci-green.d.ts.map +1 -1
  44. package/dist/workspace/ci-green.js +251 -24
  45. package/dist/workspace/declaration.d.ts +37 -0
  46. package/dist/workspace/declaration.d.ts.map +1 -1
  47. package/dist/workspace/declaration.js +29 -1
  48. package/dist/workspace/declaration.schema.json +44 -0
  49. package/dist/workspace/trust/ci-tag-statement.d.ts +1 -0
  50. package/dist/workspace/trust/ci-tag-statement.d.ts.map +1 -1
  51. package/dist/workspace/trust/ci-tag-statement.js +5 -1
  52. package/package.json +1 -1
  53. package/src/cli/main.ts +16 -2
  54. package/src/cli/parse-args.ts +9 -0
  55. package/src/cli/registry.ts +6 -0
  56. package/src/components/capability.ts +11 -0
  57. package/src/lifecycle/ledger-readers.test.ts +10 -0
  58. package/src/lifecycle/wave-plans.ts +41 -1
  59. package/src/notify.schema.json +17 -1
  60. package/src/notify.ts +30 -2
  61. package/src/op/gate-review.test.ts +1 -1
  62. package/src/op/gate-review.ts +1 -1
  63. package/src/op/index.ts +1 -0
  64. package/src/op/op-waves-capability.ts +3 -0
  65. package/src/op/op-waves-preview.test.ts +122 -5
  66. package/src/op/op-waves-preview.ts +70 -0
  67. package/src/op/op-waves-run.ts +58 -8
  68. package/src/op/op-waves.test.ts +11 -1
  69. package/src/release-floors.ts +1 -1
  70. package/src/workspace/ci-builds.ts +16 -7
  71. package/src/workspace/ci-green-builds.test.ts +83 -1
  72. package/src/workspace/ci-green-cli.ts +80 -6
  73. package/src/workspace/ci-green-lanes.test.ts +121 -0
  74. package/src/workspace/ci-green-merge-queue.test.ts +66 -0
  75. package/src/workspace/ci-green-notify.test.ts +166 -0
  76. package/src/workspace/ci-green-signed.test.ts +20 -0
  77. package/src/workspace/ci-green-workflow.test.ts +47 -1
  78. package/src/workspace/ci-green-workflow.ts +62 -1
  79. package/src/workspace/ci-green.ts +290 -26
  80. package/src/workspace/declaration.schema.json +44 -0
  81. package/src/workspace/declaration.ts +64 -2
  82. package/src/workspace/trust/ci-tag-statement.ts +5 -2
@@ -17,6 +17,7 @@
17
17
  */
18
18
  import { RETENTION_KINDS } from "../lifecycle/retention-policy.js";
19
19
  import { parseReportUrl } from "../pr-report-url.js";
20
+ import { notifyConfigProblem } from "../notify.js";
20
21
  import schema from "./declaration.schema.json" with { type: "json" };
21
22
  import { routeConflicts } from "./ci-branches.js";
22
23
  import { cloudIdentityProblems, IDENTITY_CLOUDS } from "../ci-identity.js";
@@ -84,6 +85,19 @@ export function greenBranches(green) {
84
85
  }
85
86
  /** The default `ci.green.window`. */
86
87
  export const DEFAULT_CI_WINDOW = "24h";
88
+ /** A lane's tag prefixes (#4662): `ci/green-<lane>/` and `ci/revoked-<lane>/`. */
89
+ export function laneTagPrefixes(lane) {
90
+ return { green: `ci/green-${lane}/`, revoked: `ci/revoked-${lane}/` };
91
+ }
92
+ /** The lane `name` of `green`, or a `declaration-invalid` error naming the lanes it declares. */
93
+ export function laneOf(green, name) {
94
+ const lane = green.lanes?.find((l) => l.name === name);
95
+ if (!lane) {
96
+ const declared = (green.lanes ?? []).map((l) => l.name);
97
+ 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)"}`);
98
+ }
99
+ return lane;
100
+ }
87
101
  /** The default `ci.prEnvironment.ttl`. */
88
102
  export const DEFAULT_PR_ENVIRONMENT_TTL = "72h";
89
103
  /** A renderer a diagram is pinned to (#2764): a closed list of tools chant does not run. */
@@ -668,8 +682,22 @@ function ciOf(raw, at) {
668
682
  continue;
669
683
  throw new WorkspaceReadError("declaration-invalid", `ci.green.preMerge names the phase ${JSON.stringify(name)}, which ci.green.phases does not declare; declared phases: ${phases.map((p) => p.name).join(", ")}`, at(`/ci/green/preMerge/${i}`));
670
684
  }
685
+ const lanes = Object.entries(g.lanes ?? {}).map(([name, l]) => {
686
+ const pointer = `/ci/green/lanes/${pointerToken(name)}`;
687
+ for (const [i, phase] of l.require.entries()) {
688
+ if (phases.some((p) => p.name === phase))
689
+ continue;
690
+ throw new WorkspaceReadError("declaration-invalid", `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(", ")}`, at(`${pointer}/require/${i}`));
691
+ }
692
+ return { name, require: [...l.require], pointer };
693
+ });
694
+ if (g.notify !== undefined) {
695
+ const problem = notifyConfigProblem(g.notify, "ci.green.notify");
696
+ if (problem)
697
+ throw new WorkspaceReadError("declaration-invalid", problem, at("/ci/green/notify"));
698
+ }
671
699
  const judged = Array.isArray(g.branch) ? g.branch : [g.branch];
672
- 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 };
700
+ 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 } : {}), pointer: "/ci/green" }, ...workflow, reportUrl };
673
701
  }
674
702
  function agentsOf(raw, members, at) {
675
703
  const agents = (raw ?? []).map((a, i) => {
@@ -1901,6 +1901,50 @@
1901
1901
  "pattern": "^[0-9a-f]{40}([0-9a-f]{24})?$",
1902
1902
  "description": "Added by #4031, read by chant 0.124.28 and newer. The full sha of the first commit on branch whose ci/green and ci/revoked tags must carry a DSSE statement in their annotation, signed by a key .chant/trust.json at base lists under runners for a principal holding the runner role. A tag on a strict first-parent ancestor of this commit counts unsigned, so existing tags keep working; a tag on any other commit, this one included, needs a statement. Position in history decides, never a date, which whoever makes a commit or a tag sets. A reader refuses a sha that names no commit in its clone with declaration-invalid. Absent, no tag needs a statement. Since chant 0.124.32 (#4156) it covers Op run records the same way, when ci.green.source is runs: an unsigned run counts on a strict first-parent ancestor of this commit and needs a statement on any other, ci serve refuses to start without a runner key trusted at the target's head, and ci run and chant run warn about a run they leave unsigned. Absent, an unsigned run counts and nothing asks for a key."
1903
1903
  },
1904
+ "mergeQueue": {
1905
+ "type": "boolean",
1906
+ "description": "The branch takes changes through GitHub's merge queue (#4644). chant ci workflow adds the merge_group trigger (checks_requested) to each workflow holding a phase that sets build, and writes .github/workflows/chant-merge-queue.yml, whose chant-verdict job runs chant ci verdict --wait on the group's commit: it passes when every required phase passed there, judged as the tick judges, so the queue's ruleset requires that one check. The queue lands the commit its group tested, so the group's runs count for it; a later push run's skipped or cancelled attempt of the same job never replaces the group's decided one. A workflow holding a phase without build gets no trigger: add merge_group to it by hand. Written by chant 0.124.61 and newer, so a declaration that sets it sets minReader to 0.124.61 or newer."
1907
+ },
1908
+ "notify": {
1909
+ "type": "object",
1910
+ "description": "Who chant ci tick tells (#4645), as an Op waves spec's notify: each value names an environment variable, never a URL or a key. webhook and key: a signed chant.notify/v1 webhook; slack and teams: incoming webhooks; events: which to send, of ci.red, ci.culprit and ci.green (all three by default). ci.red: the branch's newest decided commit is red after its one retry. ci.culprit: a bisect named the first red commit. ci.green: the branch is green again after a ci.red. Each is sent once: the tick marks it in the commit's _ci record, so it needs chant/lifecycle, and it sends nothing when it can't write the records. Read by chant 0.124.61 and newer, so a declaration that sets it sets minReader to 0.124.61 or newer.",
1911
+ "properties": {
1912
+ "webhook": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
1913
+ "key": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
1914
+ "slack": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
1915
+ "teams": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
1916
+ "events": { "type": "array", "uniqueItems": true, "items": { "enum": ["ci.red", "ci.culprit", "ci.green"] } }
1917
+ },
1918
+ "additionalProperties": false
1919
+ },
1920
+ "lanes": {
1921
+ "type": "object",
1922
+ "minProperties": 1,
1923
+ "description": "Green lanes (#4662): named subsets of the phases, each with tags of its own, for a deployable that needs only some of them. A commit that passes a lane's phases gets ci/green-<lane>/<sha>, and a lane-green commit that later fails one gets ci/revoked-<lane>/<sha>, judged by the same tick from the same runs as require, with no runs of their own; the bisect and the retry stay per phase. ci/green/<sha> still follows require. chant ci last-green --lane <name> and chant ci base --lane <name> read a lane. A signed lane tag's statement names its lane, so it never counts as another lane's tag or as ci/green. Added in schema 1 by chant 0.124.61, so a declaration that uses it sets minReader to 0.124.61 or newer.",
1924
+ "propertyNames": {
1925
+ "type": "string",
1926
+ "pattern": "^[a-z0-9][a-z0-9-]*$"
1927
+ },
1928
+ "additionalProperties": {
1929
+ "type": "object",
1930
+ "required": ["require"],
1931
+ "properties": {
1932
+ "require": {
1933
+ "type": "array",
1934
+ "minItems": 1,
1935
+ "uniqueItems": true,
1936
+ "description": "The phases a commit must pass to be green in this lane, by name. Each must be a declared phase.",
1937
+ "items": {
1938
+ "$ref": "#/$defs/ciPhaseName"
1939
+ }
1940
+ }
1941
+ },
1942
+ "patternProperties": {
1943
+ "^x-": true
1944
+ },
1945
+ "additionalProperties": false
1946
+ }
1947
+ },
1904
1948
  "source": {
1905
1949
  "enum": [
1906
1950
  "checks",
@@ -98,5 +98,6 @@ export declare function verifyCiTagStatement(record: Record<string, unknown> | n
98
98
  sha: string;
99
99
  kind: "green" | "revoked";
100
100
  branch: string;
101
+ lane?: string;
101
102
  }, runners: readonly RunnerKey[], roles: Readonly<Record<string, readonly string[]>>): CiTagVerdict;
102
103
  //# sourceMappingURL=ci-tag-statement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ci-tag-statement.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/ci-tag-statement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAsD,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE/F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,gBAAgB,yCAAyC,CAAC;AAEvE,iGAAiG;AACjG,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAK3C,+GAA+G;AAC/G,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;kBAqBtB,CAAC;AACZ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,kDAAkD;AAClD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjH,4GAA4G;AAC5G,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,SAAS,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAOvF;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW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,EAAE,MAAM,CAAA;CAAE,EACjF,OAAO,EAAE,SAAS,SAAS,EAAE,EAC7B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,GACjD,YAAY,CAmCd"}
@@ -77,7 +77,7 @@ const normalise = (name) => name.normalize("NFKC").trim().toLowerCase();
77
77
  * `runner` role in `roles`. Never throws.
78
78
  */
79
79
  export function verifyCiTagStatement(record, expect, runners, roles) {
80
- const tag = `ci/${expect.kind}/${expect.sha}`;
80
+ const tag = `ci/${expect.kind}${expect.lane !== undefined ? `-${expect.lane}` : ""}/${expect.sha}`;
81
81
  if (record === null)
82
82
  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)` };
83
83
  const { statement: envelope, ...fields } = record;
@@ -115,6 +115,10 @@ export function verifyCiTagStatement(record, expect, runners, roles) {
115
115
  differs.push(`it signs a ${p.record.tag} tag`);
116
116
  if (p.record.branch !== expect.branch)
117
117
  differs.push(`it is for branch ${p.record.branch}, and ci.green names ${expect.branch}`);
118
+ // #4662: a lane's statement says its lane, so it never counts as ci/green or as another lane's tag.
119
+ const signedLane = typeof p.record.lane === "string" ? p.record.lane : undefined;
120
+ if (signedLane !== expect.lane)
121
+ 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}`);
118
122
  if (canonicalJson(p.record) !== canonicalJson(fields))
119
123
  differs.push("the annotation's record is not the one signed");
120
124
  if (differs.length > 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.124.59",
3
+ "version": "0.124.61",
4
4
  "description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
package/src/cli/main.ts CHANGED
@@ -286,11 +286,23 @@ CI:
286
286
  statuses, and each identity trusted to its own jobs.
287
287
  Read-only; exits 1 on a mismatch, and with
288
288
  --require-clouds on a cloud it had no credentials for.
289
- ci last-green [--json] [--from <rev>] The newest first-parent commit of
289
+ ci last-green [--json] [--lane <name>] [--from <rev>] The newest first-parent commit of
290
290
  ci.green's branch, or of --from, with a ci/green tag
291
- and no ci/revoked tag. Reads local tags only; fetch
291
+ and no ci/revoked tag (with --lane, the lane's
292
+ ci/green-<lane> tags). Reads local tags only; fetch
292
293
  them first. With ci.green.signedSince, a tag without a
293
294
  valid runner statement is ignored and reported.
295
+ ci base [--json] [--phase <name> | --lane <name>] [--from <rev>] The commit a path filter
296
+ diffs against under build: newest: the newest
297
+ first-parent ancestor of --from (HEAD) whose record
298
+ shows the phase (or every required phase) built and
299
+ passed on it, else a green tag. Fetch the tags and
300
+ chant/lifecycle first.
301
+ ci verdict [--commit <sha>] [--wait] A merge queue's verdict: exits 0
302
+ when every required phase passed on the commit
303
+ (GITHUB_SHA, else HEAD), judged from its check runs
304
+ as the tick judges; 1 when one failed; 3 while one is
305
+ pending, unless --wait reads again until none is.
294
306
  ci list [--json] [--limit <n>] [--since <rev>] [--forge github] [--source checks|runs]
295
307
  The first-parent commits of ci.green's branch within
296
308
  its window, newest first, each green, revoked or
@@ -1779,6 +1791,8 @@ export const commandRegistry: CommandDef[] = [
1779
1791
  { name: "e2e safe-run", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/e2e-safe-run")).runE2eSafeRun(ctx) },
1780
1792
  { name: "e2e", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/e2e-safe-run")).runE2eUnknown(ctx) },
1781
1793
  { name: "ci last-green", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-green-cli")).runCiLastGreen(ctx) },
1794
+ { name: "ci verdict", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-green-cli")).runCiVerdict(ctx) },
1795
+ { name: "ci base", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-green-cli")).runCiBase(ctx) },
1782
1796
  { name: "ci list", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-green-cli")).runCiList(ctx) },
1783
1797
  { name: "ci tick", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-green-cli")).runCiTick(ctx) },
1784
1798
  { name: "ci workflow", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-green-cli")).runCiWorkflow(ctx) },
@@ -1195,6 +1195,15 @@ export function parseArgs(args: string[]): ParsedArgs {
1195
1195
  result.resource = value;
1196
1196
  } else if (arg === "--since") {
1197
1197
  result.since = args[++i];
1198
+ } else if (arg === "--wait") {
1199
+ // `chant ci verdict --wait` (#4644): read the check runs again until no required phase is pending.
1200
+ result.ciWait = true;
1201
+ } else if (arg === "--lane") {
1202
+ // `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662): a green lane's tags and phases.
1203
+ result.lane = args[++i];
1204
+ } else if (arg === "--phase") {
1205
+ // `chant ci base --phase <name>` (#4643): the ci.green phase whose base to find.
1206
+ result.phase = args[++i];
1198
1207
  } else if (arg === "--audit-log") {
1199
1208
  // `chant audit-log attribute|unrecorded --audit-log aws[:<region>]` (#4632).
1200
1209
  const value = args[++i];
@@ -917,6 +917,12 @@ export interface ParsedArgs {
917
917
  op?: string;
918
918
  /** `chant operator log --since <iso>` (#2029) — only entries at or after this ISO-8601 instant. `chant workspace records --since <rev>` (#2673) — the revision to compare the records with. `chant workspace metrics --since <date>` (#4039) — the start of the window the metrics count. */
919
919
  since?: string;
920
+ /** `chant ci verdict --wait` (#4644) — read again until no required phase is pending. */
921
+ ciWait?: boolean;
922
+ /** `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662) — a ci.green lane. */
923
+ lane?: string;
924
+ /** `chant ci base --phase <name>` (#4643) — the ci.green phase whose base to find. */
925
+ phase?: string;
920
926
  /** `chant audit-log attribute|unrecorded --audit-log aws[:<region>]` (#4632): the cloud audit log to read. */
921
927
  auditLog?: string;
922
928
  /** `chant ledger`, `chant workspace records` and `chant workspace runs --where <field><op><value>` (#4363): typed filters, repeatable, all of which have to hold. */
@@ -153,6 +153,17 @@ export interface CapabilityPlan {
153
153
  * still counts toward the digest, with no entries.
154
154
  */
155
155
  changeSet?: ChangeSetPart;
156
+ /**
157
+ * The digest of each resource the plan changes, by the resource's address
158
+ * in the engine (a URN, a terraform address), with the values the engine
159
+ * made up while planning left out (plywood#55, plywood#56). A resource the
160
+ * plan leaves alone is not in it. A merged wave under `approvals.preview`
161
+ * compares these with the ones its pull request recorded, resource by
162
+ * resource, so a change another merge made to a resource the pull request
163
+ * never touched does not read as a moved plan. Absent: the member is
164
+ * compared as a whole by its `planDigest`.
165
+ */
166
+ resourceDigests?: Record<string, string>;
156
167
  /**
157
168
  * The outputs `run` will expose once it applies this plan (#3999), as far
158
169
  * as the plan can tell. A pull request's plan reads a dependent's
@@ -73,6 +73,16 @@ describe("wave plans readers", () => {
73
73
  expect(await listWavePlanSpecs(port)).toEqual(["other", "ship"]);
74
74
  });
75
75
 
76
+ test("the parser reads each run's resources, and a record from 0.124.59 without them (plywood#55)", () => {
77
+ const record = (members?: unknown) => JSON.stringify({ version: 1, name: "a", head: "b", timestamp: "t", waves: [{ wave: 1, name: "x", digest: "d", ...(members === undefined ? {} : { members }) }] });
78
+ expect(parseHeadPlans(record())!.waves[0]!.members).toBeUndefined();
79
+ const runs = [{ member: "shop/dev", planDigest: "p", resources: { "urn:a": "d1" } }, { member: "shop/qa", planDigest: "q", empty: true }];
80
+ expect(parseHeadPlans(record(runs))!.waves[0]!.members).toEqual(runs);
81
+ expect(parseHeadPlans(record("nope"))).toBeNull();
82
+ expect(parseHeadPlans(record([{ member: "m" }]))).toBeNull();
83
+ expect(parseHeadPlans(record([{ member: "m", planDigest: "p", resources: { a: 1 } }]))).toBeNull();
84
+ });
85
+
76
86
  test("the parser refuses a record of another shape", () => {
77
87
  expect(parseHeadPlans(null)).toBeNull();
78
88
  expect(parseHeadPlans("[]")).toBeNull();
@@ -25,6 +25,20 @@ export interface HeadPlans {
25
25
  waves: Array<HeadPlanWave>;
26
26
  }
27
27
 
28
+ /**
29
+ * One run's plan at the head (plywood#55), kept so a merged wave can compare
30
+ * the resources the pull request changed, and only those, with the ones it
31
+ * plans now. `resources` is the digest of each resource the plan changes, by
32
+ * address; a run whose plan gave none is compared as a whole by `planDigest`.
33
+ * `empty` is a plan that changes nothing.
34
+ */
35
+ export interface HeadPlanMember {
36
+ member: string;
37
+ planDigest: string;
38
+ resources?: Record<string, string>;
39
+ empty?: true;
40
+ }
41
+
28
42
  /**
29
43
  * One wave's plan at the head. `changes` and `destructive` (#4630) are the
30
44
  * plan's facts a gate policy reads: some run changes something, some run's
@@ -44,6 +58,12 @@ export interface HeadPlanWave {
44
58
  * approval against it.
45
59
  */
46
60
  changeSet?: string;
61
+ /**
62
+ * Each run's plan at the head (plywood#55). A record from chant 0.124.59
63
+ * has none: it holds the wave's set digest only, and a merged wave
64
+ * compares that whole digest, as it did.
65
+ */
66
+ members?: HeadPlanMember[];
47
67
  }
48
68
 
49
69
  /** Where {@link HeadPlans} for `head` live on `chant/lifecycle`: `_wave-plans/<name>/<head>.json`. */
@@ -71,8 +91,10 @@ export function parseHeadPlans(text: string | null): HeadPlans | null {
71
91
  const waves: HeadPlans["waves"] = [];
72
92
  for (const w of r.waves) {
73
93
  if (w === null || typeof w !== "object") return null;
74
- const { wave, name, digest, changes, destructive, changeSet } = w as Record<string, unknown>;
94
+ const { wave, name, digest, changes, destructive, changeSet, members } = w as Record<string, unknown>;
75
95
  if (typeof wave !== "number" || typeof name !== "string" || typeof digest !== "string") return null;
96
+ const runs = members === undefined ? undefined : parseHeadPlanMembers(members);
97
+ if (runs === null) return null;
76
98
  waves.push({
77
99
  wave,
78
100
  name,
@@ -80,11 +102,29 @@ export function parseHeadPlans(text: string | null): HeadPlans | null {
80
102
  ...(typeof changes === "boolean" ? { changes } : {}),
81
103
  ...(typeof destructive === "boolean" ? { destructive } : {}),
82
104
  ...(typeof changeSet === "string" && changeSet !== "" ? { changeSet } : {}),
105
+ ...(runs ? { members: runs } : {}),
83
106
  });
84
107
  }
85
108
  return { version: 1, name: r.name, head: r.head, timestamp: r.timestamp, waves };
86
109
  }
87
110
 
111
+ function parseHeadPlanMembers(value: unknown): HeadPlanMember[] | null {
112
+ if (!Array.isArray(value)) return null;
113
+ const out: HeadPlanMember[] = [];
114
+ for (const m of value) {
115
+ if (m === null || typeof m !== "object") return null;
116
+ const { member, planDigest, resources, empty } = m as Record<string, unknown>;
117
+ if (typeof member !== "string" || typeof planDigest !== "string") return null;
118
+ let digests: Record<string, string> | undefined;
119
+ if (resources !== undefined) {
120
+ if (resources === null || typeof resources !== "object" || Array.isArray(resources) || !Object.values(resources).every((d) => typeof d === "string")) return null;
121
+ digests = resources as Record<string, string>;
122
+ }
123
+ out.push({ member, planDigest, ...(digests ? { resources: digests } : {}), ...(empty === true ? { empty: true as const } : {}) });
124
+ }
125
+ return out;
126
+ }
127
+
88
128
  /** The record for `head` of the spec `name`, or null when none was recorded or it cannot be read. */
89
129
  export async function readHeadPlans(port: LedgerReadPort, name: string, head: string): Promise<HeadPlans | null> {
90
130
  const { dir, file } = headPlansPath(name, head);
@@ -8,7 +8,7 @@
8
8
  "properties": {
9
9
  "schema": { "const": "chant.notify/v1" },
10
10
  "id": { "type": "string", "minLength": 1, "description": "The same for every send of one event about one digest (else drift fingerprint, else commit), so a receiver can drop a repeat; random when there is none. The delivery header carries it too." },
11
- "event": { "enum": ["waiting", "refused", "failed", "drift"] },
11
+ "event": { "enum": ["waiting", "refused", "failed", "drift", "ci.red", "ci.culprit", "ci.green"], "description": "The ci. events come from chant ci tick (#4645) and carry ci." },
12
12
  "at": { "type": "string", "description": "When it was sent, ISO 8601 UTC." },
13
13
  "source": { "type": "string", "minLength": 1, "description": "The product that sent it: chant, terragucci, sql-yodeler." },
14
14
  "project": { "type": "string", "description": "What the run belongs to: the repository, or a name the product gives." },
@@ -63,6 +63,22 @@
63
63
  "pr": { "type": "integer" }
64
64
  }
65
65
  },
66
+ "ci": {
67
+ "type": "object",
68
+ "description": "On ci.red, ci.culprit and ci.green (#4645): the branch and commit. ci.red: the newest decided commit, red after its one retry, with phase and failedRun. ci.culprit: culprit, the first red commit a bisect found for the red commit. ci.green: red, the commit whose ci.red this answers.",
69
+ "required": ["branch", "commit"],
70
+ "properties": {
71
+ "branch": { "type": "string" },
72
+ "commit": { "type": "string" },
73
+ "phase": { "type": "string" },
74
+ "failedRun": {
75
+ "type": "object",
76
+ "properties": { "name": { "type": "string" }, "id": { "type": ["integer", "null"] }, "conclusion": { "type": ["string", "null"] }, "url": { "type": ["string", "null"] } }
77
+ },
78
+ "culprit": { "type": "string" },
79
+ "red": { "type": "string" }
80
+ }
81
+ },
66
82
  "reportUrl": { "type": "string" },
67
83
  "detail": { "type": "object", "description": "The product's own record of the outcome, carried whole (terragucci.outcome/v1)." }
68
84
  },
package/src/notify.ts CHANGED
@@ -39,8 +39,8 @@ export const NOTIFY_SCHEMA = "chant.notify/v1";
39
39
  /** The JSON Schema's `$id`. */
40
40
  export const NOTIFY_SCHEMA_ID = "https://intentius.io/chant/schemas/notify/v1/notify.schema.json";
41
41
 
42
- /** What happened. */
43
- export const NOTIFY_EVENTS = ["waiting", "refused", "failed", "drift"] as const;
42
+ /** What happened. The `ci.` events come from `chant ci tick` (#4645): a branch red after its retry, a bisect's culprit, the branch green again. */
43
+ export const NOTIFY_EVENTS = ["waiting", "refused", "failed", "drift", "ci.red", "ci.culprit", "ci.green"] as const;
44
44
  export type NotifyEventKind = (typeof NOTIFY_EVENTS)[number];
45
45
 
46
46
  /** Where the run is: the CI run's page, the forge, the repository and commit. */
@@ -93,6 +93,8 @@ export interface NotifyEvent {
93
93
  exitCode?: number;
94
94
  /** On `drift`: what moved. */
95
95
  drift?: { changed: string[]; missing?: string[]; failed?: string[]; fingerprint?: string };
96
+ /** On the `ci.` events (#4645): the branch and commit, and what failed or what was red. */
97
+ ci?: NotifyCi;
96
98
  run?: NotifyRun;
97
99
  /** A report page for the run. */
98
100
  reportUrl?: string;
@@ -100,6 +102,22 @@ export interface NotifyEvent {
100
102
  detail?: Record<string, unknown>;
101
103
  }
102
104
 
105
+ /**
106
+ * The tick's part of a `ci.` event (#4645). `ci.red`: `commit` is the
107
+ * branch's newest decided commit, red after its one retry, with the phase and
108
+ * run that failed. `ci.culprit`: `culprit` is the first red commit a bisect
109
+ * found, for the red `commit`. `ci.green`: `commit` is green, and `red` the
110
+ * commit whose `ci.red` this answers.
111
+ */
112
+ export interface NotifyCi {
113
+ branch: string;
114
+ commit: string;
115
+ phase?: string;
116
+ failedRun?: { name: string; id: number | null; conclusion: string | null; url: string | null };
117
+ culprit?: string;
118
+ red?: string;
119
+ }
120
+
103
121
  /** What a product fills in; {@link makeNotifyEvent} adds the rest. */
104
122
  export type NotifyFields = Omit<NotifyEvent, "schema" | "id" | "at" | "project" | "targets" | "run"> & {
105
123
  id?: string;
@@ -158,6 +176,9 @@ const HEADLINE: Record<NotifyEventKind, string> = {
158
176
  refused: "was refused",
159
177
  failed: "failed",
160
178
  drift: "drifted",
179
+ "ci.red": "is red",
180
+ "ci.culprit": "has a culprit",
181
+ "ci.green": "is green again",
161
182
  };
162
183
 
163
184
  /** The first line of every chat message: `<source>: <summary>`, or what happened to what when there is no summary. */
@@ -176,6 +197,13 @@ function facts(e: NotifyEvent): { title: string; value: string; link?: string }[
176
197
  if (e.drift.missing?.length) out.push({ title: "Missing", value: e.drift.missing.join(", ") });
177
198
  if (e.drift.failed?.length) out.push({ title: "Not refreshed", value: e.drift.failed.join(", ") });
178
199
  } else if (e.targets.length > 0) out.push({ title: "Targets", value: e.targets.join(", ") });
200
+ if (e.ci) {
201
+ out.push({ title: "Commit", value: `${e.ci.commit.slice(0, 12)} on ${e.ci.branch}` });
202
+ if (e.ci.phase) out.push({ title: "Phase", value: e.ci.failedRun ? `${e.ci.phase}: ${e.ci.failedRun.name} ${e.ci.failedRun.conclusion ?? ""}`.trimEnd() : e.ci.phase });
203
+ if (e.ci.failedRun?.url) out.push({ title: "Failed run", value: e.ci.failedRun.url, link: e.ci.failedRun.url });
204
+ if (e.ci.culprit) out.push({ title: "Culprit", value: e.ci.culprit.slice(0, 12) });
205
+ if (e.ci.red) out.push({ title: "Was red", value: e.ci.red.slice(0, 12) });
206
+ }
179
207
  if (e.digest) out.push({ title: "Digest", value: e.digest });
180
208
  if (e.approve) out.push({ title: e.approve.review ? "Or approve" : "Approve", value: e.approve.command });
181
209
  if (e.reason) out.push({ title: "Reason", value: e.reason });
@@ -178,7 +178,7 @@ describe("a pr-review wave (#3684)", () => {
178
178
  let written: unknown;
179
179
  const recorded = await recordOpWaveHeadPlans({ spec: spec("pr-review"), cwd: h.cwd, exec: h.exec, head: HEAD, now: "t", write: async (p) => void (written = p) });
180
180
  // #4630: the record keeps whether the wave changes anything and whether it is destructive.
181
- expect(recorded.waves).toEqual([{ wave: 1, name: "prod", digest: set(digest("a")), changes: true, destructive: false }]);
181
+ expect(recorded.waves).toEqual([{ wave: 1, name: "prod", digest: set(digest("a")), changes: true, destructive: false, members: [{ member: "prod", planDigest: digest("a") }] }]);
182
182
  expect(written).toEqual(recorded);
183
183
  });
184
184
  });
@@ -71,7 +71,7 @@ export function bothRules(a: GateApprovalRule | null, b: GateApprovalRule | null
71
71
  // ── pr-review ─────────────────────────────────────────────────────────────
72
72
 
73
73
  // The record and its reader live apart, so a bundle can import them without git (#3865).
74
- export { HEAD_PLANS_DIR, headPlansPath, type HeadPlans } from "../lifecycle/wave-plans";
74
+ export { HEAD_PLANS_DIR, headPlansPath, type HeadPlans, type HeadPlanMember } from "../lifecycle/wave-plans";
75
75
 
76
76
 
77
77
  /** The merged pull request's review, as a `pr-review` gate reads it. */
package/src/op/index.ts CHANGED
@@ -92,6 +92,7 @@ export {
92
92
  runOpWaveApplyHooks,
93
93
  opWaveResourceLines,
94
94
  } from "./op-waves-run";
95
+ export { movedSincePreview, shortAddress, type PlannedRunDigests } from "./op-waves-preview";
95
96
  export type {
96
97
  OpWaveBaseRules,
97
98
  OpWaveDecision,
@@ -116,6 +116,8 @@ export interface OpWaveStepPlan {
116
116
  /** The capability's member, the key `run` finds its artifact under. */
117
117
  member: string;
118
118
  planDigest: string;
119
+ /** The digest of each resource the plan changes, when the capability gave them (plywood#55). */
120
+ resources?: Record<string, string>;
119
121
  artifact?: unknown;
120
122
  part?: ChangeSetPart;
121
123
  empty: boolean;
@@ -166,6 +168,7 @@ export async function planOpWaveStep(
166
168
  target: run.target,
167
169
  member: planned.member,
168
170
  planDigest: planned.planDigest,
171
+ ...(planned.resourceDigests ? { resources: planned.resourceDigests } : {}),
169
172
  ...(planned.artifact !== undefined ? { artifact: planned.artifact } : {}),
170
173
  ...(planned.changeSet ? { part: planned.changeSet } : {}),
171
174
  ...effects,