@intentius/chant 0.124.56 → 0.124.58

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 (199) hide show
  1. package/dist/ci-audit/index.d.ts.map +1 -1
  2. package/dist/ci-audit/index.js +1 -2
  3. package/dist/ci-product-words.d.ts +47 -2
  4. package/dist/ci-product-words.d.ts.map +1 -1
  5. package/dist/ci-product-words.js +59 -1
  6. package/dist/ci-product.d.ts +26 -2
  7. package/dist/ci-product.d.ts.map +1 -1
  8. package/dist/ci-product.js +30 -7
  9. package/dist/cli/commands/init.d.ts +2 -0
  10. package/dist/cli/commands/init.d.ts.map +1 -1
  11. package/dist/cli/commands/init.js +1 -1
  12. package/dist/cli/handlers/build.d.ts.map +1 -1
  13. package/dist/cli/handlers/build.js +5 -1
  14. package/dist/cli/handlers/init.d.ts.map +1 -1
  15. package/dist/cli/handlers/init.js +16 -0
  16. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  17. package/dist/cli/handlers/lifecycle.js +14 -0
  18. package/dist/cli/handlers/pr.d.ts.map +1 -1
  19. package/dist/cli/handlers/pr.js +90 -35
  20. package/dist/cli/handlers/serve.d.ts.map +1 -1
  21. package/dist/cli/handlers/serve.js +9 -0
  22. package/dist/cli/main.d.ts.map +1 -1
  23. package/dist/cli/main.js +6 -2
  24. package/dist/cli/mcp/product-tools.d.ts +40 -7
  25. package/dist/cli/mcp/product-tools.d.ts.map +1 -1
  26. package/dist/cli/mcp/product-tools.js +59 -15
  27. package/dist/cli/mcp/read-only.d.ts +2 -1
  28. package/dist/cli/mcp/read-only.d.ts.map +1 -1
  29. package/dist/cli/mcp/read-only.js +2 -1
  30. package/dist/cli/mcp/server.d.ts +11 -0
  31. package/dist/cli/mcp/server.d.ts.map +1 -1
  32. package/dist/cli/mcp/server.js +15 -3
  33. package/dist/cli/mcp-config.d.ts +4 -1
  34. package/dist/cli/mcp-config.d.ts.map +1 -1
  35. package/dist/cli/mcp-config.js +6 -2
  36. package/dist/cli/parse-args.d.ts.map +1 -1
  37. package/dist/cli/parse-args.js +9 -0
  38. package/dist/cli/registry.d.ts +8 -0
  39. package/dist/cli/registry.d.ts.map +1 -1
  40. package/dist/components/auto-release.d.ts +5 -2
  41. package/dist/components/auto-release.d.ts.map +1 -1
  42. package/dist/components/auto-release.js +9 -4
  43. package/dist/components/capability.d.ts +10 -0
  44. package/dist/components/capability.d.ts.map +1 -1
  45. package/dist/components/deploy-units.d.ts +12 -0
  46. package/dist/components/deploy-units.d.ts.map +1 -1
  47. package/dist/components/deploy-units.js +20 -1
  48. package/dist/components/pr-pipeline.d.ts +64 -2
  49. package/dist/components/pr-pipeline.d.ts.map +1 -1
  50. package/dist/components/pr-pipeline.js +66 -5
  51. package/dist/components/product-pipeline.d.ts +18 -1
  52. package/dist/components/product-pipeline.d.ts.map +1 -1
  53. package/dist/components/product-pipeline.js +8 -2
  54. package/dist/components/row-lease.d.ts +22 -1
  55. package/dist/components/row-lease.d.ts.map +1 -1
  56. package/dist/components/row-lease.js +32 -6
  57. package/dist/e2e-harness/driver.d.ts.map +1 -1
  58. package/dist/e2e-harness/driver.js +97 -0
  59. package/dist/e2e-harness/forgejo.d.ts +5 -1
  60. package/dist/e2e-harness/forgejo.d.ts.map +1 -1
  61. package/dist/e2e-harness/forgejo.js +35 -0
  62. package/dist/e2e-harness/index.d.ts +7 -0
  63. package/dist/e2e-harness/index.d.ts.map +1 -1
  64. package/dist/e2e-harness/index.js +11 -2
  65. package/dist/e2e-harness/ports.d.ts +31 -0
  66. package/dist/e2e-harness/ports.d.ts.map +1 -1
  67. package/dist/e2e-harness/scenario.d.ts.map +1 -1
  68. package/dist/e2e-harness/scenario.js +9 -5
  69. package/dist/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
  70. package/dist/e2e-harness/schemas/index.d.ts +22 -1
  71. package/dist/e2e-harness/schemas/index.d.ts.map +1 -1
  72. package/dist/e2e-harness/schemas/index.js +1 -1
  73. package/dist/e2e-harness/steps.d.ts.map +1 -1
  74. package/dist/e2e-harness/steps.js +4 -0
  75. package/dist/lexicon.d.ts +9 -0
  76. package/dist/lexicon.d.ts.map +1 -1
  77. package/dist/lifecycle/git.d.ts +39 -3
  78. package/dist/lifecycle/git.d.ts.map +1 -1
  79. package/dist/lifecycle/git.js +223 -15
  80. package/dist/lifecycle/lock-rows.d.ts +23 -0
  81. package/dist/lifecycle/lock-rows.d.ts.map +1 -1
  82. package/dist/lifecycle/lock-rows.js +47 -8
  83. package/dist/lifecycle/resource-lock.d.ts +70 -0
  84. package/dist/lifecycle/resource-lock.d.ts.map +1 -1
  85. package/dist/lifecycle/resource-lock.js +241 -5
  86. package/dist/mcp/types.d.ts +9 -0
  87. package/dist/mcp/types.d.ts.map +1 -1
  88. package/dist/op/gate.js +21 -4
  89. package/dist/op/op-waves-release-port.js +1 -1
  90. package/dist/op/op-waves-release.d.ts +2 -1
  91. package/dist/op/op-waves-release.d.ts.map +1 -1
  92. package/dist/op/op-waves-run.d.ts +8 -0
  93. package/dist/op/op-waves-run.d.ts.map +1 -1
  94. package/dist/op/op-waves-run.js +101 -29
  95. package/dist/op/op-waves.d.ts +18 -0
  96. package/dist/op/op-waves.d.ts.map +1 -1
  97. package/dist/op/op-waves.js +16 -0
  98. package/dist/pr-loop.d.ts.map +1 -1
  99. package/dist/pr-loop.js +1 -2
  100. package/dist/release-floors.d.ts +1 -1
  101. package/dist/release-floors.js +1 -1
  102. package/dist/template-request/index.d.ts +9 -0
  103. package/dist/template-request/index.d.ts.map +1 -0
  104. package/dist/template-request/index.js +8 -0
  105. package/dist/template-request/request-body.d.ts +21 -0
  106. package/dist/template-request/request-body.d.ts.map +1 -0
  107. package/dist/template-request/request-body.js +86 -0
  108. package/dist/template-request/template-request.d.ts +100 -0
  109. package/dist/template-request/template-request.d.ts.map +1 -0
  110. package/dist/template-request/template-request.js +150 -0
  111. package/dist/template-request/template-request.schema.json +100 -0
  112. package/dist/template-request/template-spec.d.ts +83 -0
  113. package/dist/template-request/template-spec.d.ts.map +1 -0
  114. package/dist/template-request/template-spec.js +146 -0
  115. package/dist/template-request/template.schema.json +114 -0
  116. package/dist/template-request/validate.d.ts +4 -0
  117. package/dist/template-request/validate.d.ts.map +1 -0
  118. package/dist/template-request/validate.js +21 -0
  119. package/dist/wave-runtime.mjs +310 -300
  120. package/package.json +8 -1
  121. package/src/ci-audit/index.ts +1 -2
  122. package/src/ci-product-words.test.ts +23 -0
  123. package/src/ci-product-words.ts +68 -3
  124. package/src/ci-product.ts +36 -6
  125. package/src/cli/commands/init.ts +3 -1
  126. package/src/cli/handlers/build.ts +5 -1
  127. package/src/cli/handlers/init.ts +18 -0
  128. package/src/cli/handlers/lifecycle.ts +13 -0
  129. package/src/cli/handlers/pr-before-merge.test.ts +1 -1
  130. package/src/cli/handlers/pr-deploy-inputs.test.ts +1 -1
  131. package/src/cli/handlers/pr-endpoint.test.ts +1 -1
  132. package/src/cli/handlers/pr-green.test.ts +1 -1
  133. package/src/cli/handlers/pr-plan-comment-targets.test.ts +1 -1
  134. package/src/cli/handlers/pr-plan-flags.test.ts +1 -1
  135. package/src/cli/handlers/pr-plan-targets.test.ts +1 -1
  136. package/src/cli/handlers/pr-record.test.ts +34 -2
  137. package/src/cli/handlers/pr-waves-blocked.test.ts +1 -1
  138. package/src/cli/handlers/pr-waves.test.ts +1 -1
  139. package/src/cli/handlers/pr.test.ts +1 -1
  140. package/src/cli/handlers/pr.ts +86 -31
  141. package/src/cli/handlers/serve.ts +9 -0
  142. package/src/cli/main.ts +6 -2
  143. package/src/cli/mcp/product-tools.test.ts +57 -1
  144. package/src/cli/mcp/product-tools.ts +67 -15
  145. package/src/cli/mcp/read-only.ts +2 -1
  146. package/src/cli/mcp/server.ts +20 -5
  147. package/src/cli/mcp-config.test.ts +52 -2
  148. package/src/cli/mcp-config.ts +6 -3
  149. package/src/cli/parse-args.ts +7 -0
  150. package/src/cli/registry.ts +8 -0
  151. package/src/components/auto-release.test.ts +4 -2
  152. package/src/components/auto-release.ts +9 -5
  153. package/src/components/capability.ts +10 -0
  154. package/src/components/deploy-units.test.ts +18 -1
  155. package/src/components/deploy-units.ts +26 -1
  156. package/src/components/pr-pipeline.ts +99 -5
  157. package/src/components/product-actions.test.ts +76 -0
  158. package/src/components/product-pipeline.ts +21 -2
  159. package/src/components/row-lease.test.ts +61 -1
  160. package/src/components/row-lease.ts +48 -7
  161. package/src/e2e-harness/driver.test.ts +163 -0
  162. package/src/e2e-harness/driver.ts +86 -1
  163. package/src/e2e-harness/forgejo.ts +42 -1
  164. package/src/e2e-harness/index.ts +12 -2
  165. package/src/e2e-harness/ports.ts +33 -0
  166. package/src/e2e-harness/scenario.ts +8 -6
  167. package/src/e2e-harness/schemas/README.md +11 -2
  168. package/src/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
  169. package/src/e2e-harness/schemas/index.ts +5 -1
  170. package/src/e2e-harness/schemas.test.ts +44 -1
  171. package/src/e2e-harness/steps.ts +4 -0
  172. package/src/lexicon.ts +9 -0
  173. package/src/lifecycle/git.test.ts +155 -0
  174. package/src/lifecycle/git.ts +213 -17
  175. package/src/lifecycle/lock-rows.test.ts +6 -1
  176. package/src/lifecycle/lock-rows.ts +58 -7
  177. package/src/lifecycle/resource-lock-wait.test.ts +292 -0
  178. package/src/lifecycle/resource-lock.ts +261 -7
  179. package/src/mcp/types.ts +9 -0
  180. package/src/op/gate.test.ts +7 -5
  181. package/src/op/gate.ts +20 -4
  182. package/src/op/op-waves-after-plan.test.ts +1 -2
  183. package/src/op/op-waves-ledger-lock.test.ts +208 -0
  184. package/src/op/op-waves-release-port.ts +1 -1
  185. package/src/op/op-waves-release.ts +1 -1
  186. package/src/op/op-waves-run.ts +104 -29
  187. package/src/op/op-waves.ts +18 -0
  188. package/src/pr-loop-bundle.test.ts +0 -2
  189. package/src/pr-loop.ts +1 -2
  190. package/src/release-floors.ts +1 -1
  191. package/src/template-request/__fixtures__/request-body.md +41 -0
  192. package/src/template-request/index.ts +8 -0
  193. package/src/template-request/request-body.ts +91 -0
  194. package/src/template-request/template-request.schema.json +100 -0
  195. package/src/template-request/template-request.test.ts +316 -0
  196. package/src/template-request/template-request.ts +235 -0
  197. package/src/template-request/template-spec.ts +176 -0
  198. package/src/template-request/template.schema.json +114 -0
  199. package/src/template-request/validate.ts +28 -0
@@ -55,7 +55,7 @@ export function gitOpWaveReleasePort(opts: { cwd?: string; actor?: string } = {}
55
55
  if (got.recorded) {
56
56
  out.push({ recorded: true, env: req.env, component: req.component, digest: got.record.digest, ...(got.record.releaseDigest ? { releaseDigest: got.record.releaseDigest } : {}) });
57
57
  } else {
58
- out.push({ recorded: false, reason: got.reason === "error" ? got.error : got.detail ?? got.reason });
58
+ out.push({ recorded: false, reason: got.reason === "error" ? got.error : got.detail ?? got.reason, ...(got.reason === "error" && got.lost ? { lost: true as const } : {}) });
59
59
  }
60
60
  }
61
61
  return out;
@@ -59,7 +59,7 @@ export interface OpWaveReleaseRequest {
59
59
  /** How one record came out. */
60
60
  export type OpWaveReleaseOutcome =
61
61
  | { recorded: true; env: string; component: string; digest: string; releaseDigest?: string }
62
- | { recorded: false; reason: string };
62
+ | { recorded: false; reason: string; /** The record was written and its push never landed (plywood#22 finding 9). */ lost?: true };
63
63
 
64
64
  /** Where an op wave job's release records go (#4615). */
65
65
  export interface OpWaveReleasePort {
@@ -88,7 +88,7 @@ import type { TrustPolicy } from "../workspace/trust/policy";
88
88
  import type { GateSigners } from "../lifecycle/gate-seal";
89
89
  import { ciRunIdFromEnv } from "./gate-run-locator";
90
90
  import { appendRunRecord, DEFAULT_RUN_ENV } from "../lifecycle/run-ledger";
91
- import { pushLifecycleReport } from "../lifecycle/git";
91
+ import { LifecyclePushLostError, pushLifecycleRebasing } from "../lifecycle/git";
92
92
  import { resolveCiJob } from "../lifecycle/release-ledger";
93
93
  import type { OpRunPolicyRow, OpRunRecordInput, OpRunStepRecord, OpRunWave, OpRunWavePlan, OpRunWaveTarget } from "./runtime";
94
94
  import { foldPolicyRows, opWaveAfterPlanProblems, runOpWaveAfterPlanHooks, type OpWaveAfterPlanHook, type OpWaveAfterPlanRun } from "./op-waves-after-plan";
@@ -119,7 +119,6 @@ import {
119
119
  type OpWaveHolds,
120
120
  type OpWaveStepPlan,
121
121
  } from "./op-waves-capability";
122
- import { NEXT_RELEASE } from "../release-floors";
123
122
  import {
124
123
  changeInvolvement, quorumProblems, quorumRuleLine, quorumRulesFor, quorumWaiting, recordedReviewApprovals, ruleNeedsProof, samePrincipal, trustQuorumJudge,
125
124
  type GateQuorumJudge, type GateQuorumRule, type GateQuorumRuleProgress, type QuorumJudgement,
@@ -682,7 +681,7 @@ function pointAtBase(spec: OpWavesSpec, name: string, where: string): Pick<OpWav
682
681
  }
683
682
 
684
683
  /** The first chant whose op entry exports {@link opWavePlanPath} (terragucci#1304). */
685
- export const OP_WAVE_PLAN_PATH_FLOOR = NEXT_RELEASE;
684
+ export const OP_WAVE_PLAN_PATH_FLOOR = "0.124.56";
686
685
 
687
686
  /** Where a run's plan file goes: one target's plan, as opposed to {@link opWavePlansPath}, the wave's `plans.json`. */
688
687
  export function opWavePlanPath(spec: Pick<OpWavesSpec, "name">, wave: number, target: string): string {
@@ -790,6 +789,14 @@ export interface RunOpWaveOptions {
790
789
  lockGate?: string;
791
790
  /** Whether a run holding rows still runs (#4552). Default: the forge's answer, with the lease's age. */
792
791
  lockLiveness?: LockLiveness;
792
+ /**
793
+ * How long a wave on the `target` or `repo` grain waits for its rows, in
794
+ * seconds (ruling for ci-products 2026-10-28). Default `CHANT_LOCK_WAIT`,
795
+ * which the waves pipelines set from the job's timeout.
796
+ */
797
+ lockWaitSeconds?: number;
798
+ /** How often a waiting wave reads the rows file again, in ms. Default `CHANT_LOCK_POLL` seconds, else 10 s. */
799
+ lockPollMs?: number;
793
800
  /** Overrides the spec's `standDown` (#4581). */
794
801
  standDown?: boolean;
795
802
  /** How the job finds a newer commit on its branch (#4581). Default: fetch the branch from `origin` ({@link gitOpWaveNewerCommit}). */
@@ -833,7 +840,8 @@ export function gitOpWaveRunPort(opts?: { cwd?: string }): OpWaveRunPort {
833
840
  return {
834
841
  async append(record) {
835
842
  await appendRunRecord(record, opts);
836
- const { pushWarning } = await pushLifecycleReport(opts);
843
+ // plywood#22 finding 9: a push another writer beat replays on its tip and pushes again; one that never lands throws LifecyclePushLostError.
844
+ const { pushWarning } = await pushLifecycleRebasing(opts);
837
845
  return pushWarning ? { pushWarning } : {};
838
846
  },
839
847
  };
@@ -1100,36 +1108,88 @@ async function declaredLockGrain(cwd: string, base: string | undefined): Promise
1100
1108
  }
1101
1109
 
1102
1110
  /**
1103
- * Lease the rows of a wave's runs on the resource grain (#4552), before
1104
- * anything of the wave applies, all in one take. A held row makes the wave
1105
- * apply nothing with the `held` outcome, exit 5, naming the run that holds it.
1111
+ * Lease the rows of a wave's runs (#4552), before anything of the wave
1112
+ * applies. First the rows its runs on the `target` and `repo` grains wait
1113
+ * for (ruling for ci-products 2026-10-28, "Ledger lock"): a stock Pulumi
1114
+ * stack's `stack` row, a Terraform root's `root` row, the `repo` row. The
1115
+ * wave waits for them in the ledger's queue, oldest commit first, up to
1116
+ * `lockWaitSeconds` (`CHANT_LOCK_WAIT`, set from the job's timeout), and at
1117
+ * the deadline applies nothing with the `held` outcome, exit 5. Then the rows
1118
+ * of its runs on the resource grain, all in one take with no wait: a held row
1119
+ * makes the wave apply nothing with the `held` outcome, exit 5, naming the
1120
+ * run that holds it. A run whose plan changes nothing takes no row, and
1121
+ * outside a git work tree the waiting grains take none.
1106
1122
  */
1107
1123
  async function leaseWaveRows(
1108
1124
  options: RunOpWaveOptions,
1109
1125
  ctx: WaveContext,
1110
1126
  runs: readonly OpWaveRun[],
1111
1127
  ): Promise<{ release(): Promise<boolean> } | OpWaveApplyOutcome | { failed: string } | undefined> {
1112
- const rows = runs.flatMap((r) => {
1113
- const lock = ctx.steps?.get(r.target)?.lock;
1114
- return lock?.grain === "resource" ? lock.rows : [];
1128
+ const locks = runs.flatMap((r) => {
1129
+ const plan = ctx.steps?.get(r.target);
1130
+ return plan?.lock && !plan.empty ? [plan.lock] : [];
1115
1131
  });
1116
- if (rows.length === 0) return undefined;
1117
- const { leaseLockRows } = await import("../lifecycle/resource-lock");
1132
+ const rows = locks.flatMap((l) => (l.grain === "resource" ? l.rows : []));
1133
+ // Outside a git work tree no ledger holds a queue, so a waiting grain takes no row there, as `chant run --components` takes none.
1134
+ const queued = locks.flatMap((l) => (l.grain !== "resource" ? (l.queue ?? []) : []));
1135
+ const queue = queued.length > 0 && inGitWorkTree(ctx.cwd) ? queued : [];
1136
+ if (rows.length === 0 && queue.length === 0) return undefined;
1137
+ const { commitTimeOf, leaseLockRows, lockPollMs, lockWaitSeconds } = await import("../lifecycle/resource-lock");
1118
1138
  const { PR_APPLY_GATE } = await import("../pr-loop");
1119
1139
  const gate = options.lockGate ?? PR_APPLY_GATE;
1120
- let leased: Awaited<ReturnType<typeof leaseLockRows>>;
1121
- try {
1122
- leased = await leaseLockRows(gate, rows, { cwd: ctx.cwd, ...(options.lockLiveness ? { alive: options.lockLiveness } : {}) });
1123
- } catch (err) {
1124
- return { failed: `wave ${ctx.k} (${ctx.wave.name}): could not hold the rows its runs change in ${gate}, so nothing was applied: ${err instanceof Error ? err.message : String(err)}` };
1140
+ const label = `wave ${ctx.k} (${ctx.wave.name})`;
1141
+ const alive = options.lockLiveness ? { alive: options.lockLiveness } : {};
1142
+ const held: Array<{ release(): Promise<boolean> }> = [];
1143
+ const releaseAll = async () => {
1144
+ let ok = true;
1145
+ for (const l of held.reverse()) ok = (await l.release()) && ok;
1146
+ return ok;
1147
+ };
1148
+ const take = async (wanted: typeof rows, wait: boolean): Promise<OpWaveApplyOutcome | { failed: string } | undefined> => {
1149
+ if (wanted.length === 0) return undefined;
1150
+ let leased: Awaited<ReturnType<typeof leaseLockRows>>;
1151
+ try {
1152
+ const waitFor = wait
1153
+ ? {
1154
+ wait: {
1155
+ deadline: Date.now() + (options.lockWaitSeconds ?? lockWaitSeconds(process.env)) * 1000,
1156
+ pollMs: options.lockPollMs ?? lockPollMs(process.env),
1157
+ log: (line: string) => ctx.log(`${label}: ${line}`),
1158
+ ...(await commitTimeOf(options.head ?? "HEAD", ctx.cwd).then((t) => (t ? { commitAt: t } : {}))),
1159
+ },
1160
+ }
1161
+ : {};
1162
+ leased = await leaseLockRows(gate, wanted, { cwd: ctx.cwd, ...alive, ...waitFor });
1163
+ } catch (err) {
1164
+ return { failed: `${label}: could not hold the rows its runs change in ${gate}, so nothing was applied: ${err instanceof Error ? err.message : String(err)}` };
1165
+ }
1166
+ if (!leased.ok) {
1167
+ const first = leased.held[0]?.holder;
1168
+ const reason = leased.timedOut ? `LockWaitTimeoutError: ${leased.message}` : leased.message;
1169
+ return { outcome: "held", reason, ...(first ? { holder: { run: first.run, ...(first.url ? { url: first.url } : {}) } } : {}) };
1170
+ }
1171
+ for (const h of leased.tookOver) ctx.log(`${label}: took over the rows of run ${h.run}, which is gone`);
1172
+ const waited = leased.waited ? ` after waiting ${leased.waitedSeconds ?? 0}s` : "";
1173
+ ctx.log(`${label}: holds ${leased.lease.keys.length} row${leased.lease.keys.length === 1 ? "" : "s"} of ${gate}${waited} while it applies`);
1174
+ held.push(leased.lease);
1175
+ return undefined;
1176
+ };
1177
+ for (const [wanted, wait] of [[queue, true], [rows, false]] as const) {
1178
+ const stop = await take(wanted, wait);
1179
+ if (stop) {
1180
+ if (!(await releaseAll())) ctx.log(`${label}: could not let go of the rows it held; the next apply takes them over once this run is gone`);
1181
+ return stop;
1182
+ }
1125
1183
  }
1126
- if (!leased.ok) {
1127
- const first = leased.held[0]!.holder;
1128
- return { outcome: "held", reason: leased.message, holder: { run: first.run, ...(first.url ? { url: first.url } : {}) } };
1184
+ return { release: releaseAll };
1185
+ }
1186
+
1187
+ function inGitWorkTree(cwd: string): boolean {
1188
+ try {
1189
+ return execFileSync("git", ["rev-parse", "--is-inside-work-tree"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim() === "true";
1190
+ } catch {
1191
+ return false;
1129
1192
  }
1130
- for (const h of leased.tookOver) ctx.log(`wave ${ctx.k} (${ctx.wave.name}): took over the rows of run ${h.run}, which is gone`);
1131
- ctx.log(`wave ${ctx.k} (${ctx.wave.name}): holds ${leased.lease.keys.length} row${leased.lease.keys.length === 1 ? "" : "s"} of ${gate} while it applies`);
1132
- return leased.lease;
1133
1193
  }
1134
1194
 
1135
1195
  /** A wave's cost hold over its plans (#4545): each changing run priced, the sum against `approveAbove`. */
@@ -1782,12 +1842,14 @@ export async function runOpWave(options: RunOpWaveOptions): Promise<RunOpWaveRes
1782
1842
  try {
1783
1843
  result = await runOpWaveJob(options);
1784
1844
  } catch (err) {
1785
- const record = await recordOpWaveRun(options, started, { error: err });
1845
+ const { lost: _lost, ...record } = await recordOpWaveRun(options, started, { error: err });
1786
1846
  await closeOpWaveEvents(options, events, record);
1787
1847
  throw err;
1788
1848
  }
1789
- const record = await recordOpWaveRun(options, started, { result });
1849
+ const { lost, ...record } = await recordOpWaveRun(options, started, { result });
1790
1850
  await closeOpWaveEvents(options, events, record, result);
1851
+ // plywood#22 finding 9: a run record that never reached the remote fails a job that would have passed.
1852
+ if (lost !== undefined && result.exitCode === CHANT_EXIT.done) result.exitCode = CHANT_EXIT.failed;
1791
1853
  return result;
1792
1854
  }
1793
1855
 
@@ -1950,8 +2012,13 @@ export function opWaveRunRecord(
1950
2012
  };
1951
2013
  }
1952
2014
 
1953
- /** Append the job's run record (#4551). A failed write warns and never changes the job's exit code. */
1954
- async function recordOpWaveRun(options: RunOpWaveOptions, started: string, outcome: { result: RunOpWaveResult } | { error: unknown }): Promise<OpRunRecordInput> {
2015
+ /**
2016
+ * Append the job's run record (#4551). A failed write warns and never
2017
+ * changes the job's exit code, except a record whose push never landed
2018
+ * after its replays (`LifecyclePushLostError`, plywood#22 finding 9): that
2019
+ * fails the job by name, through `lost`.
2020
+ */
2021
+ async function recordOpWaveRun(options: RunOpWaveOptions, started: string, outcome: { result: RunOpWaveResult } | { error: unknown }): Promise<OpRunRecordInput & { lost?: string }> {
1955
2022
  const cwd = options.cwd ?? process.cwd();
1956
2023
  const port = options.runs ?? (options.gates ? undefined : gitOpWaveRunPort({ cwd }));
1957
2024
  const log = options.log ?? ((line: string) => console.error(line));
@@ -1971,7 +2038,12 @@ async function recordOpWaveRun(options: RunOpWaveOptions, started: string, outco
1971
2038
  const wrote = await port.append(record);
1972
2039
  if (wrote && wrote.pushWarning) log(`wave ${options.wave}: the run record was written and not pushed: ${wrote.pushWarning}`);
1973
2040
  } catch (err) {
1974
- log(`wave ${options.wave}: could not record the run on the run ledger: ${err instanceof Error ? err.message : String(err)}`);
2041
+ const message = err instanceof Error ? err.message : String(err);
2042
+ if (err instanceof LifecyclePushLostError) {
2043
+ log(`wave ${options.wave}: LifecyclePushLostError: the run record was written and never reached the remote, so the job fails: ${message}`);
2044
+ return Object.assign(record, { lost: message });
2045
+ }
2046
+ log(`wave ${options.wave}: could not record the run on the run ledger: ${message}`);
1975
2047
  }
1976
2048
  return record;
1977
2049
  }
@@ -3566,7 +3638,9 @@ async function applyStepRunsAtOnce(options: RunOpWaveOptions, ctx: WaveContext,
3566
3638
  /**
3567
3639
  * The release records of the runs this wave applied through its step
3568
3640
  * (#4615), one per run, on the environment ledger each names. A record that
3569
- * is not written is a line in the log; the job's exit code stays.
3641
+ * is not written is a line in the log and the job's exit code stays, except
3642
+ * one written whose push never landed after its replays (plywood#22 finding
3643
+ * 9), which fails the wave by name.
3570
3644
  */
3571
3645
  async function recordStepReleases(options: RunOpWaveOptions, ctx: WaveContext, decision: OpWaveDecision, runs: readonly OpWaveRun[]): Promise<void> {
3572
3646
  const { spec, k, wave, log, result } = ctx;
@@ -3601,6 +3675,7 @@ async function recordStepReleases(options: RunOpWaveOptions, ctx: WaveContext, d
3601
3675
  for (const [i, req] of requests.entries()) {
3602
3676
  const got = outcomes[i];
3603
3677
  if (got?.recorded) log(`${req.target}: recorded on the "${got.env}" release ledger as ${got.component} ${got.digest}${got.releaseDigest ? ` under release ${got.releaseDigest}` : ""}`);
3678
+ else if (got && !got.recorded && got.lost) failed(ctx, `${req.target}: applied, and LifecyclePushLostError: the release record for ${req.component} in "${req.env}" was written and never reached the remote, so the wave fails: ${got.reason}`);
3604
3679
  else log(`${req.target}: applied, and no release record was written for ${req.component} in "${req.env}": ${got?.reason ?? "the port gave no answer"}`);
3605
3680
  }
3606
3681
  }
@@ -651,6 +651,24 @@ export interface OpWavesDigest {
651
651
  over?: "all" | "changing";
652
652
  }
653
653
 
654
+ /**
655
+ * A wave job's default timeout in minutes (ruling for ci-products
656
+ * 2026-10-28, "Ledger lock"): three hours, a Forgejo runner's default, under
657
+ * GitHub's six. The generators write it on every wave job.
658
+ */
659
+ export const OP_WAVE_JOB_TIMEOUT_MINUTES = 180;
660
+
661
+ /**
662
+ * The job's timeout, and the `CHANT_LOCK_WAIT` a wave job carries: the
663
+ * seconds a run on the `target` or `repo` grain waits for its row on the
664
+ * ledger, five minutes under the job's timeout (at least one minute), so the
665
+ * wait gives up by name before the forge stops the job.
666
+ */
667
+ export function opWaveJobTimeout(minutes: number | undefined): { minutes: number; env: { CHANT_LOCK_WAIT: string } } {
668
+ const m = minutes !== undefined && Number.isFinite(minutes) && minutes > 0 ? Math.ceil(minutes) : OP_WAVE_JOB_TIMEOUT_MINUTES;
669
+ return { minutes: m, env: { CHANT_LOCK_WAIT: String(Math.max(60, (m - 5) * 60)) } };
670
+ }
671
+
654
672
  export const OP_WAVES_DIGEST_OVER = ["all", "changing"] as const;
655
673
 
656
674
  /** The default gate name pattern. */
@@ -45,8 +45,6 @@ describe("the pull-request loop bundle", () => {
45
45
  "packages/core/src/pr-migrations.ts",
46
46
  // The Pulumi URN rule (#4548, the may-appear rows): no imports.
47
47
  "packages/core/src/pulumi-urn.ts",
48
- // The next-release floor constant (#4480, #4626's narrowed floor): no imports.
49
- "packages/core/src/release-floors.ts",
50
48
  ]);
51
49
  // About 89 KB today, after the hooks line (#4288), the blocked set (#4291), the scheduled-run reads (#4289) the requires checks (#4301) and the migration notes (#4407), about 97 KB; with the group lines (#4446), about 100 KB.
52
50
  // 120 KB (122,880 bytes) is the ruled ceiling: raised from 110 KB by the maintainer ruling of 2026-10-27 on #4481. It is not a figure to lower by trimming note text.
package/src/pr-loop.ts CHANGED
@@ -47,7 +47,6 @@
47
47
  * `identity.gates` entry covers every member.
48
48
  */
49
49
 
50
- import { NEXT_RELEASE } from "./release-floors";
51
50
  import type { ChangeSetAction, ChangeSetDocument, ChangeSetEntry } from "./change-set";
52
51
  import { parsePulumiUrn, pulumiMayAppearParent } from "./pulumi-urn";
53
52
  import type { PrRequireOutcome } from "./pr-requires";
@@ -105,7 +104,7 @@ export const PR_REPORT_GROUPS_FLOOR = "0.124.54";
105
104
  export const PR_REPORT_LOCK_TARGETS_FLOOR = "0.124.55";
106
105
 
107
106
  /** The first chant whose report carries {@link PrReport.narrowed} (#4626). */
108
- export const PR_REPORT_NARROWED_FLOOR = NEXT_RELEASE;
107
+ export const PR_REPORT_NARROWED_FLOOR = "0.124.56";
109
108
 
110
109
  /** The first chant whose report carries {@link PrReport.crossStackEdges} (#4617). */
111
110
  export const PR_REPORT_CROSS_STACK_FLOOR = "0.124.55";
@@ -19,4 +19,4 @@
19
19
  * this constant to the next patch (#4501). The check fails while a floor
20
20
  * still names this constant after its version shipped.
21
21
  */
22
- export const NEXT_RELEASE = "0.124.56";
22
+ export const NEXT_RELEASE = "0.124.58";
@@ -0,0 +1,41 @@
1
+ ### terragucci request: app `orders` from bucket
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | Template | `acme/bucket/aws` |
6
+ | Version | `1.0.0` |
7
+ | Requested by | `alice` |
8
+ | Claimed by (as given by the client; the forge does not vouch for it) | `bob` |
9
+ | Through | an agent over MCP |
10
+
11
+ | Input | Value |
12
+ | --- | --- |
13
+ | `bucket_name` | `"orders-data"` |
14
+ | `readers` | `["svc-a","svc-b"]` |
15
+ | `tags` | `{"team":"pay\|ments"}` |
16
+
17
+ Nothing was applied or approved. This pull request only adds files; it is planned like any other, and a person reviews and merges it.
18
+
19
+ ```json https://intentius.io/chant/schemas/template-request/v1/template-request.schema.json
20
+ {
21
+ "$schema": "https://intentius.io/chant/schemas/template-request/v1/template-request.schema.json",
22
+ "contract": 1,
23
+ "kind": "app",
24
+ "template": "acme/bucket/aws",
25
+ "version": "1.0.0",
26
+ "app": "orders",
27
+ "inputs": {
28
+ "bucket_name": "orders-data",
29
+ "tags": {
30
+ "team": "pay|ments"
31
+ },
32
+ "readers": [
33
+ "svc-a",
34
+ "svc-b"
35
+ ]
36
+ },
37
+ "requestedBy": "alice",
38
+ "claimedBy": "bob",
39
+ "via": "mcp"
40
+ }
41
+ ```
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `@intentius/chant/template-request` (#4651): the template request
3
+ * document (template-request/v1), template.yml/v1 with its engine-neutral
4
+ * input kinds, the refusals, the branch and the pull request body.
5
+ */
6
+ export * from "./template-spec";
7
+ export * from "./template-request";
8
+ export * from "./request-body";
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The pull request body for a template request (#4651), and the read that
3
+ * recovers the request from it. The body names the template, the version,
4
+ * each input on its own row, the requester (and the claimed requester, when
5
+ * the client names one) and where the request came from,
6
+ * and says that nothing was applied or approved. The request itself follows
7
+ * in a fenced block whose info string is `json` and the schema id, so behold
8
+ * and an audit read it from the pull request without a second file.
9
+ */
10
+
11
+ import { activeProductWords, type CiProductWords } from "../ci-product-words";
12
+ import { TEMPLATE_REQUEST_SCHEMA_ID, templateName, validateTemplateRequest, type TemplateRequest, type TemplateRequestVia } from "./template-request";
13
+
14
+ const VIA: Record<TemplateRequestVia, string> = {
15
+ form: "the request form",
16
+ mcp: "an agent over MCP",
17
+ cli: "the command line",
18
+ };
19
+
20
+ /** Text in a table cell's code span, with `|` escaped so the row holds and a fence longer than any backticks inside. */
21
+ function code(text: string): string {
22
+ const escaped = text.replace(/\|/g, "\\|").replace(/\n/g, " ");
23
+ const ticks = Math.max(0, ...[...escaped.matchAll(/`+/g)].map((m) => m[0].length));
24
+ const fence = "`".repeat(ticks + 1);
25
+ return ticks > 0 ? `${fence} ${escaped} ${fence}` : `${fence}${escaped}${fence}`;
26
+ }
27
+
28
+ /** A fence longer than any run of backticks in `text`, at least three. */
29
+ function fenceFor(text: string): string {
30
+ const longest = Math.max(0, ...[...text.matchAll(/`+/g)].map((m) => m[0].length));
31
+ return "`".repeat(Math.max(3, longest + 1));
32
+ }
33
+
34
+ /** The request's pull request body, in the product's words (default: the active ones). */
35
+ export function requestBody(request: TemplateRequest, words: CiProductWords = activeProductWords()): string {
36
+ const what = request.kind === "addon" && request.addon !== undefined ? `add-on ${code(request.addon)} for app ${code(request.app)}` : `app ${code(request.app)}`;
37
+ const lines: string[] = [
38
+ `### ${words.product} request: ${what} from ${templateName(request.template)}`,
39
+ "",
40
+ "| | |",
41
+ "| --- | --- |",
42
+ `| Template | ${code(request.template)} |`,
43
+ `| Version | ${code(request.version)} |`,
44
+ `| Requested by | ${code(request.requestedBy)} |`,
45
+ ...(request.claimedBy !== undefined ? [`| Claimed by (as given by the client; the forge does not vouch for it) | ${code(request.claimedBy)} |`] : []),
46
+ `| Through | ${VIA[request.via]} |`,
47
+ "",
48
+ ];
49
+ const names = Object.keys(request.inputs).sort();
50
+ if (names.length > 0) {
51
+ lines.push("| Input | Value |", "| --- | --- |");
52
+ for (const name of names) lines.push(`| ${code(name)} | ${code(JSON.stringify(request.inputs[name]) ?? "null")} |`);
53
+ } else {
54
+ lines.push("The request gives no inputs; every input takes its default.");
55
+ }
56
+ const [, applied] = words.verbs.apply;
57
+ const [, planned] = words.verbs.plan;
58
+ lines.push(
59
+ "",
60
+ `Nothing was ${applied} or approved. This pull request only adds files; it is ${planned} like any other, and a person reviews and merges it.`,
61
+ "",
62
+ );
63
+ const json = JSON.stringify(request, null, 2);
64
+ const fence = fenceFor(json);
65
+ lines.push(`${fence}json ${TEMPLATE_REQUEST_SCHEMA_ID}`, json, fence, "");
66
+ return lines.join("\n");
67
+ }
68
+
69
+ /**
70
+ * The request a pull request body carries: the first fenced block whose info
71
+ * string is `json` and the template-request/v1 schema id, parsed and
72
+ * checked against the schema. Undefined when the body has no such block, or
73
+ * the block is not a valid request.
74
+ */
75
+ export function parseRequestBody(body: string): TemplateRequest | undefined {
76
+ const lines = body.replace(/\r\n/g, "\n").split("\n");
77
+ for (let i = 0; i < lines.length; i++) {
78
+ const open = /^(`{3,})json[ \t]+(\S+)[ \t]*$/.exec(lines[i]!);
79
+ if (!open || open[2] !== TEMPLATE_REQUEST_SCHEMA_ID) continue;
80
+ const fence = open[1]!;
81
+ const end = lines.findIndex((l, j) => j > i && l.trimEnd() === fence);
82
+ if (end < 0) return undefined;
83
+ try {
84
+ const doc: unknown = JSON.parse(lines.slice(i + 1, end).join("\n"));
85
+ return validateTemplateRequest(doc).length === 0 ? (doc as TemplateRequest) : undefined;
86
+ } catch {
87
+ return undefined;
88
+ }
89
+ }
90
+ return undefined;
91
+ }
@@ -0,0 +1,100 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://intentius.io/chant/schemas/template-request/v1/template-request.schema.json",
4
+ "title": "chant template request",
5
+ "description": "A request for an app, or an add-on to an app, made from one version of a template in a release catalog, version 1 of its contract. A product turns it into a pull request on the branch requestBranch names, with requestBody as the body; the body carries this document in a fenced block whose info string is `json` and this schema's id, so a reader recovers it from the pull request alone. checkTemplateRequest refuses a request against the catalog and the version's template.yml (template.schema.json). Readers ignore fields they do not know; a field is only ever added within a version.",
6
+ "type": "object",
7
+ "required": [
8
+ "$schema",
9
+ "contract",
10
+ "kind",
11
+ "template",
12
+ "version",
13
+ "app",
14
+ "inputs",
15
+ "requestedBy",
16
+ "via"
17
+ ],
18
+ "properties": {
19
+ "$schema": {
20
+ "const": "https://intentius.io/chant/schemas/template-request/v1/template-request.schema.json"
21
+ },
22
+ "contract": {
23
+ "const": 1
24
+ },
25
+ "kind": {
26
+ "enum": [
27
+ "app",
28
+ "addon"
29
+ ],
30
+ "description": "app: a new app. addon: an add-on to the app named in `app`, which must exist."
31
+ },
32
+ "template": {
33
+ "type": "string",
34
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*(/[A-Za-z0-9][A-Za-z0-9._-]*)*$",
35
+ "description": "The template's address, such as `acme/bucket/aws` (namespace, name, system). The branch uses its name: the second-to-last segment of an address with three or more, else the last."
36
+ },
37
+ "version": {
38
+ "type": "string",
39
+ "minLength": 1,
40
+ "description": "The version in the catalog, or its digest for a release that names no version."
41
+ },
42
+ "app": {
43
+ "type": "string",
44
+ "pattern": "^[a-z][a-z0-9-]{0,39}$",
45
+ "description": "The app's name: a lowercase letter, then up to 39 lowercase letters, digits and -."
46
+ },
47
+ "addon": {
48
+ "type": "string",
49
+ "pattern": "^[a-z][a-z0-9-]{0,39}$",
50
+ "description": "For kind addon: the add-on's name, with the same rule as `app`."
51
+ },
52
+ "inputs": {
53
+ "type": "object",
54
+ "description": "The values given, by input name. An input left out takes its default. A sensitive input is never here. In an add-on request, a string `app.<output>` names an output of the app's module, for an input of any kind; the engine's renderer resolves it. In an app request it is a plain string and is checked against the input's kind.",
55
+ "additionalProperties": true
56
+ },
57
+ "requestedBy": {
58
+ "type": "string",
59
+ "minLength": 1,
60
+ "description": "Who asked, as the forge vouches for it: the login of the run's actor, a person or the identity an agent runs as."
61
+ },
62
+ "claimedBy": {
63
+ "type": "string",
64
+ "minLength": 1,
65
+ "description": "The person the client says filled the form or asked the agent, when it names one. The forge does not vouch for it, so a reader shows it as claimed, next to requestedBy."
66
+ },
67
+ "via": {
68
+ "enum": [
69
+ "form",
70
+ "mcp",
71
+ "cli"
72
+ ],
73
+ "description": "Where the request came from: a form, an agent over MCP, or the command line."
74
+ }
75
+ },
76
+ "allOf": [
77
+ {
78
+ "if": {
79
+ "properties": {
80
+ "kind": {
81
+ "const": "addon"
82
+ }
83
+ }
84
+ },
85
+ "then": {
86
+ "properties": {
87
+ "addon": true
88
+ },
89
+ "required": [
90
+ "addon"
91
+ ]
92
+ },
93
+ "else": {
94
+ "properties": {
95
+ "addon": false
96
+ }
97
+ }
98
+ }
99
+ ]
100
+ }