@intentius/chant 0.124.3 → 0.124.5

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/src/op/index.ts CHANGED
@@ -66,8 +66,10 @@ export {
66
66
  opWaveRecordPath,
67
67
  opWaveShare,
68
68
  } from "./op-waves";
69
- export type { OpWave, OpWaveApplyHooksRunner, OpWaveGatePolicy, OpWaveHook, OpWaveHookFailure, OpWaveHookMoment, OpWaveHooks, OpWaveJob, OpWaveRun, OpWavesDigest, OpWavesSpec } from "./op-waves";
69
+ export type { OpWave, OpWaveApplyHooksRunner, OpWaveGatePolicy, OpWaveHook, OpWaveHookFailure, OpWaveHookMoment, OpWaveHooks, OpWaveJob, OpWaveRun, OpWavesDigest, OpWavesOverride, OpWavesSpec } from "./op-waves";
70
70
  export {
71
+ OP_WAVE_APPLY_OUTCOMES,
72
+ OP_WAVE_MAX_REPLANS,
71
73
  opWaveHooksAtBase,
72
74
  opWaveNeedsApproval,
73
75
  opWavePlansPath,
@@ -84,7 +86,10 @@ export type {
84
86
  OpWaveBaseRules,
85
87
  OpWaveDecision,
86
88
  OpWaveApplyHooksRun,
89
+ OpWaveApplyOutcome,
87
90
  OpWaveExec,
91
+ OpWaveHeldOn,
92
+ OpWaveHoldRequest,
88
93
  OpWaveHookOutcome,
89
94
  OpWaveHookRun,
90
95
  OpWaveHooksFile,
@@ -5,7 +5,10 @@
5
5
  * approval command, the digest and, under `pr-review`, the pull request to
6
6
  * review. A share job that refused a run whose plan moved (exit 4) sends
7
7
  * `refused`. A wave whose plan, apply or stage hook failed (exit 1) sends
8
- * `failed`. A share job of a waiting wave sends nothing, since its deciding
8
+ * `failed`. A wave the product's policy refused (exit 7, #3821) sends
9
+ * `refused` with the runs it denied, and one whose apply was held by another
10
+ * run (exit 5) sends `refused` with status `held`; one that stood down for a
11
+ * newer run (exit 6) sends nothing. A share job of a waiting wave sends nothing, since its deciding
9
12
  * job already did, unless a hook in the share job itself held it (#3762). Delivery is `../notify.ts`: it never throws, and the job's exit code
10
13
  * is what the wave decided.
11
14
  */
@@ -46,13 +49,42 @@ export function opWaveNotifyFields(spec: OpWavesSpec, k: number, outcome: OpWave
46
49
  summary: `${label} waits for an approval`,
47
50
  targets: decision.members.map((m) => m.member),
48
51
  approve: { command: decision.approve ?? `chant approve ${decision.op} ${decision.gate} --plan ${decision.digest}`, ...review },
49
- ...(decision.heldBy?.length
52
+ ...(decision.heldOn
53
+ ? { reason: `held on ${decision.heldOn.op} / ${decision.heldOn.gate} by ${decision.heldOn.hook}` }
54
+ : decision.heldBy?.length
50
55
  ? { reason: `held by ${decision.heldBy.join(", ")}` }
51
56
  : decision.review?.reason
52
57
  ? { reason: decision.review.reason }
53
58
  : {}),
54
59
  };
55
60
  }
61
+ if (result.exitCode === 7 && decision?.refused) {
62
+ // #3821: the product's policy denied a run, and no override counts for it.
63
+ return {
64
+ ...base,
65
+ event: "refused",
66
+ status: decision.refused.reason === "override-moved" ? "override-moved" : "denied",
67
+ summary: `${label} refused: the policy denied ${decision.refused.runs.join(", ")}`,
68
+ targets: decision.refused.runs,
69
+ reason:
70
+ decision.refused.reason === "override-moved"
71
+ ? "an override stands for an earlier plan or other rules, so it counts for nothing"
72
+ : "the policy denied these runs, and no override counts for them",
73
+ };
74
+ }
75
+ // #3821: an apply that stood down for a newer run is no news; one held by another run is refused.
76
+ if (result.exitCode === 6 && result.outcome?.outcome === "stood-down") return undefined;
77
+ if (result.exitCode === 5 && result.outcome?.outcome === "held") {
78
+ const holder = result.outcome.holder;
79
+ return {
80
+ ...base,
81
+ event: "refused",
82
+ status: "held",
83
+ summary: `${label} applied nothing: another run${holder ? ` (${holder.run})` : ""} holds what it changes`,
84
+ targets: decision?.members.map((m) => m.member) ?? [],
85
+ reason: result.outcome.reason ?? `another run${holder ? `, ${holder.run},` : ""} holds what the apply changes; apply again once it is done`,
86
+ };
87
+ }
56
88
  if (result.exitCode === 4) {
57
89
  return {
58
90
  ...base,