@intentius/chant 0.124.62 → 0.124.64

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 (262) hide show
  1. package/dist/cli/handlers/approve.d.ts +26 -0
  2. package/dist/cli/handlers/approve.d.ts.map +1 -1
  3. package/dist/cli/handlers/approve.js +167 -18
  4. package/dist/cli/handlers/plan.d.ts +10 -0
  5. package/dist/cli/handlers/plan.d.ts.map +1 -0
  6. package/dist/cli/handlers/plan.js +71 -0
  7. package/dist/cli/handlers/pr.d.ts.map +1 -1
  8. package/dist/cli/handlers/pr.js +2 -1
  9. package/dist/cli/handlers/release.d.ts +11 -7
  10. package/dist/cli/handlers/release.d.ts.map +1 -1
  11. package/dist/cli/handlers/release.js +93 -20
  12. package/dist/cli/main.d.ts.map +1 -1
  13. package/dist/cli/main.js +48 -7
  14. package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
  15. package/dist/cli/mcp/workspace-tools.js +2 -1
  16. package/dist/cli/parse-args.d.ts.map +1 -1
  17. package/dist/cli/parse-args.js +43 -0
  18. package/dist/cli/registry.d.ts +18 -2
  19. package/dist/cli/registry.d.ts.map +1 -1
  20. package/dist/config.d.ts +50 -0
  21. package/dist/config.d.ts.map +1 -1
  22. package/dist/config.js +1 -0
  23. package/dist/gate-decision.d.ts +1 -1
  24. package/dist/gate-decision.d.ts.map +1 -1
  25. package/dist/gate-decision.js +4 -2
  26. package/dist/gate-statement.schema.json +46 -0
  27. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +20 -0
  28. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
  29. package/dist/lifecycle/__fixtures__/publish-fakes.js +119 -3
  30. package/dist/lifecycle/gate-ledger.d.ts +28 -5
  31. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  32. package/dist/lifecycle/gate-ledger.js +6 -0
  33. package/dist/lifecycle/gate-seal.d.ts +59 -7
  34. package/dist/lifecycle/gate-seal.d.ts.map +1 -1
  35. package/dist/lifecycle/gate-seal.js +68 -15
  36. package/dist/lifecycle/gate-statement.d.ts +95 -0
  37. package/dist/lifecycle/gate-statement.d.ts.map +1 -0
  38. package/dist/lifecycle/gate-statement.js +110 -0
  39. package/dist/lifecycle/gate-webauthn.d.ts +79 -0
  40. package/dist/lifecycle/gate-webauthn.d.ts.map +1 -0
  41. package/dist/lifecycle/gate-webauthn.js +105 -0
  42. package/dist/lifecycle/git.d.ts +1 -1
  43. package/dist/lifecycle/git.d.ts.map +1 -1
  44. package/dist/lifecycle/git.js +24 -19
  45. package/dist/lifecycle/ledger-remote.d.ts +37 -0
  46. package/dist/lifecycle/ledger-remote.d.ts.map +1 -0
  47. package/dist/lifecycle/ledger-remote.js +42 -0
  48. package/dist/lifecycle/plan-stale.d.ts +76 -0
  49. package/dist/lifecycle/plan-stale.d.ts.map +1 -0
  50. package/dist/lifecycle/plan-stale.js +120 -0
  51. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  52. package/dist/lifecycle/publish-credentials.d.ts.map +1 -1
  53. package/dist/lifecycle/publish-credentials.js +2 -0
  54. package/dist/lifecycle/publish-declaration.d.ts +107 -0
  55. package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
  56. package/dist/lifecycle/publish-declaration.js +110 -1
  57. package/dist/lifecycle/publish-forge.d.ts +5 -1
  58. package/dist/lifecycle/publish-forge.d.ts.map +1 -1
  59. package/dist/lifecycle/publish-forge.js +13 -4
  60. package/dist/lifecycle/publish-git-ssh.d.ts +82 -0
  61. package/dist/lifecycle/publish-git-ssh.d.ts.map +1 -0
  62. package/dist/lifecycle/publish-git-ssh.js +180 -0
  63. package/dist/lifecycle/publish-github.d.ts +69 -0
  64. package/dist/lifecycle/publish-github.d.ts.map +1 -0
  65. package/dist/lifecycle/publish-github.js +153 -0
  66. package/dist/lifecycle/publish-homebrew.d.ts +77 -0
  67. package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
  68. package/dist/lifecycle/publish-homebrew.js +265 -0
  69. package/dist/lifecycle/publish-marketplace.d.ts +85 -0
  70. package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
  71. package/dist/lifecycle/publish-marketplace.js +398 -0
  72. package/dist/lifecycle/publish-targets.d.ts +6 -0
  73. package/dist/lifecycle/publish-targets.d.ts.map +1 -1
  74. package/dist/lifecycle/publish-targets.js +15 -0
  75. package/dist/lifecycle/publish-tauri.d.ts +61 -0
  76. package/dist/lifecycle/publish-tauri.d.ts.map +1 -0
  77. package/dist/lifecycle/publish-tauri.js +181 -0
  78. package/dist/lifecycle/release-cut.d.ts +51 -5
  79. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  80. package/dist/lifecycle/release-cut.js +165 -16
  81. package/dist/lifecycle/release-publish.d.ts +18 -2
  82. package/dist/lifecycle/release-publish.d.ts.map +1 -1
  83. package/dist/lifecycle/release-publish.js +5 -0
  84. package/dist/lifecycle/release-revocation.d.ts +4 -3
  85. package/dist/lifecycle/release-revocation.d.ts.map +1 -1
  86. package/dist/lifecycle/release-revocation.js +5 -4
  87. package/dist/lifecycle/release-store.d.ts +32 -0
  88. package/dist/lifecycle/release-store.d.ts.map +1 -1
  89. package/dist/lifecycle/release-store.js +11 -0
  90. package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
  91. package/dist/lifecycle/snapshot-store.js +17 -9
  92. package/dist/lifecycle/test-passkey.d.ts +25 -0
  93. package/dist/lifecycle/test-passkey.d.ts.map +1 -0
  94. package/dist/lifecycle/test-passkey.js +39 -0
  95. package/dist/notify.d.ts +23 -3
  96. package/dist/notify.d.ts.map +1 -1
  97. package/dist/notify.js +8 -2
  98. package/dist/notify.schema.json +12 -3
  99. package/dist/op/gate.d.ts +1 -1
  100. package/dist/op/gate.d.ts.map +1 -1
  101. package/dist/op/gate.js +2 -1
  102. package/dist/pr-forge.d.ts +20 -0
  103. package/dist/pr-forge.d.ts.map +1 -1
  104. package/dist/pr-forge.js +87 -8
  105. package/dist/release-floors.d.ts +1 -1
  106. package/dist/release-floors.js +1 -1
  107. package/dist/wave-runtime.mjs +333 -331
  108. package/dist/workspace/ci-builds.d.ts +21 -0
  109. package/dist/workspace/ci-builds.d.ts.map +1 -1
  110. package/dist/workspace/ci-builds.js +14 -0
  111. package/dist/workspace/ci-green.d.ts +45 -2
  112. package/dist/workspace/ci-green.d.ts.map +1 -1
  113. package/dist/workspace/ci-green.js +123 -5
  114. package/dist/workspace/ci-quarantine-report.d.ts +80 -0
  115. package/dist/workspace/ci-quarantine-report.d.ts.map +1 -0
  116. package/dist/workspace/ci-quarantine-report.js +204 -0
  117. package/dist/workspace/ci-quarantine.d.ts +73 -0
  118. package/dist/workspace/ci-quarantine.d.ts.map +1 -0
  119. package/dist/workspace/ci-quarantine.js +170 -0
  120. package/dist/workspace/ci-serve.d.ts.map +1 -1
  121. package/dist/workspace/ci-serve.js +7 -4
  122. package/dist/workspace/class-data.d.ts +3 -1
  123. package/dist/workspace/class-data.d.ts.map +1 -1
  124. package/dist/workspace/class-data.js +4 -1
  125. package/dist/workspace/declaration.d.ts +45 -2
  126. package/dist/workspace/declaration.d.ts.map +1 -1
  127. package/dist/workspace/declaration.js +45 -2
  128. package/dist/workspace/declaration.schema.json +51 -3
  129. package/dist/workspace/forge-work.d.ts +76 -0
  130. package/dist/workspace/forge-work.d.ts.map +1 -0
  131. package/dist/workspace/forge-work.js +160 -0
  132. package/dist/workspace/identity-gate-rule.d.ts +3 -2
  133. package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
  134. package/dist/workspace/identity-gate-rule.js +5 -7
  135. package/dist/workspace/identity.d.ts +3 -2
  136. package/dist/workspace/identity.d.ts.map +1 -1
  137. package/dist/workspace/identity.js +6 -3
  138. package/dist/workspace/intent-cli.d.ts +3 -2
  139. package/dist/workspace/intent-cli.d.ts.map +1 -1
  140. package/dist/workspace/intent-cli.js +26 -5
  141. package/dist/workspace/intent-record.d.ts +3 -0
  142. package/dist/workspace/intent-record.d.ts.map +1 -1
  143. package/dist/workspace/intent-record.schema.json +32 -0
  144. package/dist/workspace/intent.d.ts +9 -0
  145. package/dist/workspace/intent.d.ts.map +1 -1
  146. package/dist/workspace/intent.js +2 -0
  147. package/dist/workspace/intent.schema.json +32 -0
  148. package/dist/workspace/kind-readers.d.ts.map +1 -1
  149. package/dist/workspace/kind-readers.js +2 -1
  150. package/dist/workspace/kinds.d.ts +6 -1
  151. package/dist/workspace/kinds.d.ts.map +1 -1
  152. package/dist/workspace/kinds.js +8 -3
  153. package/dist/workspace/plan-stale.schema.json +286 -0
  154. package/dist/workspace/release-candidates.d.ts +42 -7
  155. package/dist/workspace/release-candidates.d.ts.map +1 -1
  156. package/dist/workspace/release-candidates.js +64 -23
  157. package/dist/workspace/release-candidates.schema.json +55 -2
  158. package/dist/workspace/releases.schema.json +47 -0
  159. package/dist/workspace/trust/policy.d.ts +10 -0
  160. package/dist/workspace/trust/policy.d.ts.map +1 -1
  161. package/dist/workspace/trust/policy.js +19 -1
  162. package/dist/workspace/trust/run-commits.d.ts.map +1 -1
  163. package/dist/workspace/trust/run-commits.js +2 -1
  164. package/dist/workspace/trust/seal.d.ts.map +1 -1
  165. package/dist/workspace/trust/seal.js +34 -3
  166. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  167. package/dist/workspace/trust/trust-files.js +6 -1
  168. package/package.json +2 -1
  169. package/src/cli/handlers/approve-external-signature.test.ts +328 -0
  170. package/src/cli/handlers/approve.ts +206 -18
  171. package/src/cli/handlers/plan.ts +74 -0
  172. package/src/cli/handlers/pr.ts +2 -1
  173. package/src/cli/handlers/release.ts +84 -20
  174. package/src/cli/main.ts +48 -7
  175. package/src/cli/mcp/workspace-tools.ts +2 -1
  176. package/src/cli/parse-args.ts +33 -0
  177. package/src/cli/registry.ts +18 -2
  178. package/src/config.ts +8 -0
  179. package/src/gate-decision-bundle.test.ts +4 -2
  180. package/src/gate-decision.ts +11 -2
  181. package/src/gate-statement.schema.json +46 -0
  182. package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
  183. package/src/lifecycle/gate-ledger.ts +34 -5
  184. package/src/lifecycle/gate-seal.ts +86 -15
  185. package/src/lifecycle/gate-statement.ts +144 -0
  186. package/src/lifecycle/gate-webauthn.test.ts +77 -0
  187. package/src/lifecycle/gate-webauthn.ts +133 -0
  188. package/src/lifecycle/git.ts +23 -19
  189. package/src/lifecycle/ledger-remote.test.ts +183 -0
  190. package/src/lifecycle/ledger-remote.ts +46 -0
  191. package/src/lifecycle/plan-stale.test.ts +149 -0
  192. package/src/lifecycle/plan-stale.ts +172 -0
  193. package/src/lifecycle/publish-credentials.ts +2 -0
  194. package/src/lifecycle/publish-declaration.ts +116 -1
  195. package/src/lifecycle/publish-forge.ts +14 -4
  196. package/src/lifecycle/publish-git-ssh.ts +202 -0
  197. package/src/lifecycle/publish-github.ts +174 -0
  198. package/src/lifecycle/publish-homebrew.test.ts +358 -0
  199. package/src/lifecycle/publish-homebrew.ts +283 -0
  200. package/src/lifecycle/publish-marketplace.test.ts +406 -0
  201. package/src/lifecycle/publish-marketplace.ts +421 -0
  202. package/src/lifecycle/publish-resume.test.ts +40 -0
  203. package/src/lifecycle/publish-target-context.test.ts +2 -2
  204. package/src/lifecycle/publish-targets.test.ts +23 -0
  205. package/src/lifecycle/publish-targets.ts +15 -0
  206. package/src/lifecycle/publish-tauri.test.ts +163 -0
  207. package/src/lifecycle/publish-tauri.ts +198 -0
  208. package/src/lifecycle/release-cut-lane.test.ts +177 -0
  209. package/src/lifecycle/release-cut-override.test.ts +213 -0
  210. package/src/lifecycle/release-cut.ts +198 -17
  211. package/src/lifecycle/release-publish.ts +23 -3
  212. package/src/lifecycle/release-revocation.ts +5 -4
  213. package/src/lifecycle/release-store.ts +44 -0
  214. package/src/lifecycle/snapshot-store.ts +16 -9
  215. package/src/lifecycle/test-passkey.ts +55 -0
  216. package/src/notify-bundle.test.ts +3 -1
  217. package/src/notify.schema.json +12 -3
  218. package/src/notify.ts +20 -3
  219. package/src/op/gate.ts +2 -1
  220. package/src/override-gate-bundle.test.ts +2 -0
  221. package/src/pr-forge-bundle.test.ts +2 -2
  222. package/src/pr-forge.test.ts +38 -0
  223. package/src/pr-forge.ts +93 -11
  224. package/src/pr-requires.test.ts +9 -0
  225. package/src/release-floors.ts +1 -1
  226. package/src/stage-hooks-bundle.test.ts +2 -0
  227. package/src/wave-runtime-bundle.test.ts +3 -2
  228. package/src/workspace/ci-builds.ts +27 -0
  229. package/src/workspace/ci-green-stale.test.ts +193 -0
  230. package/src/workspace/ci-green.ts +137 -6
  231. package/src/workspace/ci-quarantine-report.test.ts +145 -0
  232. package/src/workspace/ci-quarantine-report.ts +234 -0
  233. package/src/workspace/ci-quarantine.test.ts +160 -0
  234. package/src/workspace/ci-quarantine.ts +188 -0
  235. package/src/workspace/ci-serve.ts +7 -4
  236. package/src/workspace/class-data.ts +5 -1
  237. package/src/workspace/declaration.schema.json +51 -3
  238. package/src/workspace/declaration.test.ts +1 -0
  239. package/src/workspace/declaration.ts +88 -5
  240. package/src/workspace/forge-work.test.ts +143 -0
  241. package/src/workspace/forge-work.ts +195 -0
  242. package/src/workspace/identity-gate-rule.ts +6 -8
  243. package/src/workspace/identity.ts +6 -3
  244. package/src/workspace/intent-cli.ts +24 -5
  245. package/src/workspace/intent-record.schema.json +32 -0
  246. package/src/workspace/intent-record.ts +3 -0
  247. package/src/workspace/intent.schema.json +32 -0
  248. package/src/workspace/intent.ts +9 -0
  249. package/src/workspace/kind-readers.ts +2 -1
  250. package/src/workspace/kinds.test.ts +13 -0
  251. package/src/workspace/kinds.ts +12 -3
  252. package/src/workspace/plan-stale.schema.json +286 -0
  253. package/src/workspace/release-candidates.schema.json +55 -2
  254. package/src/workspace/release-candidates.test.ts +77 -4
  255. package/src/workspace/release-candidates.ts +80 -23
  256. package/src/workspace/releases.schema.json +47 -0
  257. package/src/workspace/trust/gate-seal.test.ts +44 -0
  258. package/src/workspace/trust/policy.ts +24 -1
  259. package/src/workspace/trust/run-commits.ts +2 -1
  260. package/src/workspace/trust/seal.ts +35 -3
  261. package/src/workspace/trust/trust-files.test.ts +5 -0
  262. package/src/workspace/trust/trust-files.ts +15 -1
@@ -160,6 +160,46 @@ export interface ReleaseCut {
160
160
  * image tag a publish moves in place of `latest`. Absent for `latest`.
161
161
  */
162
162
  channel?: string;
163
+ /**
164
+ * The green lane the cut checked (#4692): the commit carried
165
+ * `ci/green-<lane>/<sha>` and no `ci/revoked-<lane>/<sha>`, in place of
166
+ * `ci/green/<sha>`. Absent on a cut that checked the full green tag.
167
+ */
168
+ lane?: string;
169
+ /**
170
+ * The commit was not green, and a person's override let the cut through
171
+ * (#4693). Absent on a cut of a green commit.
172
+ */
173
+ override?: ReleaseCutOverride;
174
+ }
175
+
176
+ /**
177
+ * The override a cut of a commit that was not green ran under (#4693): an
178
+ * override on `_gates/policy-override.jsonl`, written by a person the
179
+ * overriders file at base lists, which the cut spent.
180
+ */
181
+ export interface ReleaseCutOverride {
182
+ /** Always false: the commit had no green tag that counts. */
183
+ green: false;
184
+ /** The tag it lacked, `ci/green/<sha>` or `ci/green-<lane>/<sha>`. */
185
+ tag: string;
186
+ /** Who wrote the override. */
187
+ by: string;
188
+ /** When they wrote it. */
189
+ at: string;
190
+ /** Why, in their words. */
191
+ reason: string;
192
+ /** The override digest, binding the subject, the commit and the rule. */
193
+ digest: string;
194
+ /** Whether the override was sealed, as a release gate in identity.gates requires. */
195
+ sealed: boolean;
196
+ }
197
+
198
+ /** Whether `v` reads as a {@link ReleaseCutOverride}. */
199
+ function isCutOverride(v: unknown): v is ReleaseCutOverride {
200
+ if (!v || typeof v !== "object") return false;
201
+ const o = v as Record<string, unknown>;
202
+ return o.green === false && typeof o.tag === "string" && typeof o.by === "string" && typeof o.at === "string" && typeof o.reason === "string" && typeof o.digest === "string" && typeof o.sealed === "boolean";
163
203
  }
164
204
 
165
205
  /** The parts of a release a digest is computed from. */
@@ -377,6 +417,8 @@ export function parseCuts(text: string | null): { cuts: ReleaseCut[]; malformed:
377
417
  (c.signature === null || c.signature === undefined || typeof c.signature === "string") &&
378
418
  (c.runId === null || c.runId === undefined || typeof c.runId === "string") &&
379
419
  (c.channel === undefined || typeof c.channel === "string") &&
420
+ (c.lane === undefined || typeof c.lane === "string") &&
421
+ (c.override === undefined || isCutOverride(c.override)) &&
380
422
  (c.composed === undefined || (typeof c.composed === "object" && c.composed !== null && typeof c.composed.base === "string" && Array.isArray(c.composed.sources)));
381
423
  if (!ok) {
382
424
  malformed++;
@@ -459,6 +501,8 @@ export async function appendCut(
459
501
  signature: input.signature ?? null,
460
502
  ...(input.composed ? { composed: input.composed } : {}),
461
503
  ...(input.channel ? { channel: input.channel } : {}),
504
+ ...(input.lane ? { lane: input.lane } : {}),
505
+ ...(input.override ? { override: input.override } : {}),
462
506
  };
463
507
  const content = `${existing ? `${existing.replace(/\n$/, "")}\n` : ""}${JSON.stringify(cut, sortedJsonReplacer)}\n`;
464
508
  try {
@@ -71,6 +71,7 @@ import {
71
71
  type LedgerLocation,
72
72
  } from "./git";
73
73
  import { ledgerRecordingOff } from "./no-record";
74
+ import { chooseLedgerRemote, type LedgerRemoteChoice } from "./ledger-remote";
74
75
  import {
75
76
  INDEX_SCOPE_FILE,
76
77
  indexVersionName,
@@ -199,13 +200,15 @@ async function git(args: string[], opts: { cwd?: string; stdin?: string; env?: R
199
200
  return getRuntime().spawn(["git", ...args], { ...(opts.cwd ? { cwd: opts.cwd } : {}), ...(opts.stdin !== undefined ? { stdin: opts.stdin } : {}), env: { ...C_LOCALE, ...(opts.env ?? {}) } });
200
201
  }
201
202
 
202
- /** The remote a ref is pushed to: `origin` when it exists, else the first. */
203
- async function remoteOf(cwd?: string): Promise<string | null> {
203
+ /**
204
+ * The remote a ref is pushed to: the ledger's ({@link chooseLedgerRemote}),
205
+ * or null when there is none. A `CHANT_LIFECYCLE_REMOTE` that names no remote
206
+ * comes back as `failed`.
207
+ */
208
+ async function remoteOf(cwd?: string): Promise<LedgerRemoteChoice> {
204
209
  const result = await git(["remote"], { cwd });
205
210
  if (result.exitCode !== 0) return null;
206
- const names = result.stdout.trim().split("\n").map((n) => n.trim()).filter(Boolean);
207
- if (names.length === 0) return null;
208
- return names.includes("origin") ? "origin" : names[0];
211
+ return chooseLedgerRemote(result.stdout.trim().split("\n").map((n) => n.trim()).filter(Boolean));
209
212
  }
210
213
 
211
214
  /** `user.name`/`user.email` for a checkout that has none, as the ledger's own writes do (#2301). */
@@ -319,8 +322,10 @@ function trackingRefOf(ref: string): string {
319
322
  */
320
323
  export async function fetchRefFastForward(ref: string, opts?: { cwd?: string }): Promise<"fetched" | "no-remote" | "missing" | "kept" | "failed"> {
321
324
  const cwd = opts?.cwd;
322
- const remote = await remoteOf(cwd);
323
- if (!remote) return "no-remote";
325
+ const found = await remoteOf(cwd);
326
+ if (found === null) return "no-remote";
327
+ if ("failed" in found) return "failed";
328
+ const { remote } = found;
324
329
  const tracking = trackingRefOf(ref);
325
330
  const f = await git(["fetch", "--no-tags", remote, `+${ref}:${tracking}`], { cwd });
326
331
  if (f.exitCode !== 0) return /couldn't find remote ref|no such ref was fetched/i.test(f.stderr ?? "") ? "missing" : "failed";
@@ -355,8 +360,10 @@ export async function publishRef(
355
360
  if (ledgerRecordingOff()) return { status: "nothing", detail: "recording is off for this run" };
356
361
  const local = await readRefSha(ref, { cwd });
357
362
  if (!local) return { status: "nothing" };
358
- const remote = await remoteOf(cwd);
359
- if (!remote) return { status: "local", detail: "no remote configured" };
363
+ const found = await remoteOf(cwd);
364
+ if (found === null) return { status: "local", detail: "no remote configured" };
365
+ if ("failed" in found) return { status: "failed", detail: found.stderr };
366
+ const { remote } = found;
360
367
  const tracking = trackingRefOf(ref);
361
368
  for (let attempt = 1; attempt <= 3; attempt++) {
362
369
  const expected = await readRefSha(tracking, { cwd });
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Passkeys for tests (#4646): a key pair listed as `.chant/trust.json` lists
3
+ * one, and assertions built by hand the way an authenticator builds them.
4
+ */
5
+
6
+ import { createHash, generateKeyPairSync, sign, type KeyObject } from "node:crypto";
7
+ import { webAuthnChallenge, type PasskeySigner, type WebAuthnAssertion } from "./gate-webauthn";
8
+
9
+ export const RP = "example.com";
10
+ export const ORIGIN = "https://control.example.com";
11
+
12
+ export interface Passkey {
13
+ signer: PasskeySigner;
14
+ privateKey: KeyObject;
15
+ alg: "EdDSA" | "ES256";
16
+ }
17
+
18
+ /** A passkey for `principal`: a fresh key pair, listed as trust.json lists one. */
19
+ export function passkey(principal: string, id: string, alg: "EdDSA" | "ES256" = "EdDSA"): Passkey {
20
+ const { publicKey, privateKey } = alg === "EdDSA" ? generateKeyPairSync("ed25519") : generateKeyPairSync("ec", { namedCurve: "P-256" });
21
+ return {
22
+ signer: { principal, id, publicKey: publicKey.export({ format: "der", type: "spki" }).toString("base64url"), rpId: RP, origins: [ORIGIN] },
23
+ privateKey,
24
+ alg,
25
+ };
26
+ }
27
+
28
+ /** What an authenticator would return for `statement`, with each part open to change for a refusal. */
29
+ export function assert(
30
+ pk: Passkey,
31
+ statement: Buffer,
32
+ over: { type?: string; challenge?: string; origin?: string; rpId?: string; flags?: number; crossOrigin?: boolean } = {},
33
+ ): WebAuthnAssertion {
34
+ const clientData = Buffer.from(
35
+ JSON.stringify({
36
+ type: over.type ?? "webauthn.get",
37
+ challenge: over.challenge ?? webAuthnChallenge(statement),
38
+ origin: over.origin ?? ORIGIN,
39
+ ...(over.crossOrigin !== undefined ? { crossOrigin: over.crossOrigin } : {}),
40
+ }),
41
+ );
42
+ const authData = Buffer.concat([
43
+ createHash("sha256").update(over.rpId ?? RP).digest(),
44
+ Buffer.from([over.flags ?? 0x05]),
45
+ Buffer.from([0, 0, 0, 7]),
46
+ ]);
47
+ const signed = Buffer.concat([authData, createHash("sha256").update(clientData).digest()]);
48
+ const signature = sign(pk.alg === "EdDSA" ? null : "sha256", signed, pk.privateKey);
49
+ return {
50
+ id: pk.signer.id,
51
+ clientDataJSON: clientData.toString("base64url"),
52
+ authenticatorData: authData.toString("base64url"),
53
+ signature: signature.toString("base64url"),
54
+ };
55
+ }
@@ -39,7 +39,9 @@ describe("the notify bundle", () => {
39
39
  const { inputs, bytes, imports } = await bundle("notify.ts");
40
40
  expect(inputs).toEqual(["packages/core/src/notify-verify.ts", "packages/core/src/notify.ts"]);
41
41
  expect(imports).toEqual(["node:crypto"]);
42
- expect(bytes).toBeLessThan(16 * 1024);
42
+ // 17 KiB since ci.stale (#4678): the ci. events' names and headlines took it to 16.0 KiB, and the cap
43
+ // is there to catch a dependency pulled in, which would add far more than an event name.
44
+ expect(bytes).toBeLessThan(17 * 1024);
43
45
  });
44
46
 
45
47
  test("the verifier holds itself alone, and imports only node:crypto", async () => {
@@ -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", "ci.red", "ci.culprit", "ci.green"], "description": "The ci. events come from chant ci tick (#4645) and carry ci." },
11
+ "event": { "enum": ["waiting", "refused", "failed", "drift", "ci.red", "ci.culprit", "ci.green", "ci.quarantine-passed", "ci.stale"], "description": "The ci. events come from chant ci tick (#4645, ci.stale #4678), and ci.quarantine-passed from chant ci quarantine report (#4677), 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." },
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "ci": {
67
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.",
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, and since when it ends a stretch told ci.stale. ci.stale (#4678): commit is the branch's tip, since the oldest commit above the newest green one, lastGreen that green commit (absent when the tick found none), and hours the whole hours since since was committed.",
69
69
  "required": ["branch", "commit"],
70
70
  "properties": {
71
71
  "branch": { "type": "string" },
@@ -76,7 +76,16 @@
76
76
  "properties": { "name": { "type": "string" }, "id": { "type": ["integer", "null"] }, "conclusion": { "type": ["string", "null"] }, "url": { "type": ["string", "null"] } }
77
77
  },
78
78
  "culprit": { "type": "string" },
79
- "red": { "type": "string" }
79
+ "red": { "type": "string" },
80
+ "since": { "type": "string" },
81
+ "lastGreen": { "type": "string" },
82
+ "hours": { "type": "integer", "minimum": 0 },
83
+ "quarantine": {
84
+ "type": "object",
85
+ "description": "On ci.quarantine-passed (#4677): the quarantined test that passed in the scheduled run at commit, as ci.green.quarantine lists it, with phase. Sent by chant 0.124.63 and newer.",
86
+ "required": ["test", "issue", "until"],
87
+ "properties": { "test": { "type": "string" }, "file": { "type": "string" }, "issue": { "type": "string" }, "until": { "type": "string" } }
88
+ }
80
89
  }
81
90
  },
82
91
  "reportUrl": { "type": "string" },
package/src/notify.ts CHANGED
@@ -39,8 +39,12 @@ 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. 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;
42
+ /**
43
+ * 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,
44
+ * and a branch with no green commit for `staleAfter` hours (#4678);
45
+ * and from `chant ci quarantine report` (#4677): a quarantined test passed in the scheduled run.
46
+ */
47
+ export const NOTIFY_EVENTS = ["waiting", "refused", "failed", "drift", "ci.red", "ci.culprit", "ci.green", "ci.quarantine-passed", "ci.stale"] as const;
44
48
  export type NotifyEventKind = (typeof NOTIFY_EVENTS)[number];
45
49
 
46
50
  /** Where the run is: the CI run's page, the forge, the repository and commit. */
@@ -107,7 +111,13 @@ export interface NotifyEvent {
107
111
  * branch's newest decided commit, red after its one retry, with the phase and
108
112
  * run that failed. `ci.culprit`: `culprit` is the first red commit a bisect
109
113
  * found, for the red `commit`. `ci.green`: `commit` is green, and `red` the
110
- * commit whose `ci.red` this answers.
114
+ * commit whose `ci.red` this answers. `ci.quarantine-passed` (#4677):
115
+ * `commit` is the one the scheduled run tested, with the phase and the
116
+ * quarantined test that passed there. `ci.stale` (#4678): `commit` is the
117
+ * branch's tip, `since` the oldest commit above the newest green one,
118
+ * `lastGreen` that green commit, and `hours` how long since `since` was
119
+ * committed. A `ci.green` that ends a stretch told `ci.stale` names its
120
+ * `since` too.
111
121
  */
112
122
  export interface NotifyCi {
113
123
  branch: string;
@@ -116,6 +126,11 @@ export interface NotifyCi {
116
126
  failedRun?: { name: string; id: number | null; conclusion: string | null; url: string | null };
117
127
  culprit?: string;
118
128
  red?: string;
129
+ /** On `ci.quarantine-passed` (#4677): the quarantined test that passed, as `ci.green.quarantine` lists it. */
130
+ quarantine?: { test: string; file?: string; issue: string; until: string };
131
+ since?: string;
132
+ lastGreen?: string;
133
+ hours?: number;
119
134
  }
120
135
 
121
136
  /** What a product fills in; {@link makeNotifyEvent} adds the rest. */
@@ -179,6 +194,8 @@ const HEADLINE: Record<NotifyEventKind, string> = {
179
194
  "ci.red": "is red",
180
195
  "ci.culprit": "has a culprit",
181
196
  "ci.green": "is green again",
197
+ "ci.quarantine-passed": "passed a quarantined test",
198
+ "ci.stale": "has no green commit",
182
199
  };
183
200
 
184
201
  /** The first line of every chat message: `<source>: <summary>`, or what happened to what when there is no summary. */
package/src/op/gate.ts CHANGED
@@ -736,7 +736,7 @@ export function approvalsAnswering(
736
736
  /**
737
737
  * The line a run writes for an approval it carries from an alias (#3949):
738
738
  * the approval under `op`/`gate` at `now`, citing the line it came from.
739
- * The approver, plan, environment, relay and seal are the original's. A
739
+ * The approver, plan, environment, relay, binding (#4697) and seal are the original's. A
740
740
  * policy decision is left behind, since it was evaluated against another
741
741
  * gate, and so is a checkpoint digest, which moves onto `carriedFrom`: the
742
742
  * approver saw that checkpoint, not one this gate stores, so a carried
@@ -757,6 +757,7 @@ export function carriedApproval(r: GateResolutionRecord, op: string, gate: strin
757
757
  ...(r.origin ? { origin: r.origin } : {}),
758
758
  ...(r.sameOriginOverride ? { sameOriginOverride: true } : {}),
759
759
  approver: approverOf(r),
760
+ ...(r.binding !== undefined ? { binding: r.binding } : {}),
760
761
  ...(r.seal ? { seal: r.seal } : {}),
761
762
  carriedFrom: {
762
763
  op: r.op,
@@ -37,6 +37,8 @@ describe("the override-gate bundle", () => {
37
37
  "packages/core/src/intrinsic.ts",
38
38
  "packages/core/src/lifecycle/gate-ledger-select.ts",
39
39
  "packages/core/src/lifecycle/gate-seal.ts",
40
+ // A passkey's seal (#4646), checked with node:crypto.
41
+ "packages/core/src/lifecycle/gate-webauthn.ts",
40
42
  "packages/core/src/lifecycle/plan-digest.ts",
41
43
  "packages/core/src/op/gate-name.ts",
42
44
  "packages/core/src/override-gate.ts",
@@ -34,7 +34,7 @@ describe("the pr-forge bundle", () => {
34
34
  expect(inputs.filter((i) => pattern.test(i)), String(pattern)).toEqual([]);
35
35
  }
36
36
  expect(inputs.map((i) => i.replace(/^.*?packages\//, "packages/")).sort()).toEqual(["packages/core/src/pr-forge.ts"]);
37
- // About 55.9 KB today, after the pull request authors (#4000), pullRequestOpen for target locks (#4293), the four requires checks of an apply before merge (#4301) the approver filter (#4337) the approved fields (#4287) the plan job's GitLab note (#4328) and GitLab's open merge requests for stale notes (#4628).
38
- expect(result.outputFiles.reduce((n, f) => n + f.contents.byteLength, 0)).toBeLessThan(56 * 1024);
37
+ // About 58.5 KB today, after the pull request authors (#4000), pullRequestOpen for target locks (#4293), the four requires checks of an apply before merge (#4301) the approver filter (#4337) the approved fields (#4287) the plan job's GitLab note (#4328), GitLab's open merge requests for stale notes (#4628) and the issues a pull request closes (#4649).
38
+ expect(result.outputFiles.reduce((n, f) => n + f.contents.byteLength, 0)).toBeLessThan(60 * 1024);
39
39
  });
40
40
  });
@@ -17,6 +17,7 @@ import {
17
17
  FORGE_STATUS_STATES,
18
18
  githubForge,
19
19
  gitlabForge,
20
+ closingIssueRefs,
20
21
  statusStateFor,
21
22
  type ForgeFetch,
22
23
  type ForgeStatusState,
@@ -1063,3 +1064,40 @@ describe("setCommitStatus, a runner job's status (#4097)", () => {
1063
1064
  expect(gitlabForge({ apiBase: "https://gl/api/v4", project: "42", token: "t", fetch }).setCommitStatus).toBeUndefined();
1064
1065
  });
1065
1066
  });
1067
+
1068
+ describe("closingIssues, what a pull request closes (#4649)", () => {
1069
+ test("GitHub asks GraphQL once, keeping this repository's issues", async () => {
1070
+ const { fetch, calls } = fakeFetch({
1071
+ "POST /graphql": {
1072
+ data: { repository: { pullRequest: { closingIssuesReferences: { nodes: [{ number: 9, repository: { nameWithOwner: "acme/infra" } }, { number: 3, repository: { nameWithOwner: "Acme/Infra" } }, { number: 4, repository: { nameWithOwner: "acme/other" } }] } } } },
1073
+ },
1074
+ });
1075
+ expect(await githubForge({ apiBase: "https://api.github.com", repo: "acme/infra", token: "t0k", fetch }).closingIssues!(12)).toEqual([3, 9]);
1076
+ expect(calls).toHaveLength(1);
1077
+ expect(calls[0]).toMatchObject({ method: "POST", url: "https://api.github.com/graphql", body: { variables: { owner: "acme", name: "infra", pr: 12 } } });
1078
+ expect(calls[0].headers.Authorization).toBe("Bearer t0k");
1079
+ });
1080
+
1081
+ test("GitHub Enterprise Server's GraphQL is at /api/graphql, and a GraphQL error throws", async () => {
1082
+ const { fetch, calls } = fakeFetch({ "POST /api/graphql": { data: { repository: { pullRequest: null } }, errors: [{ message: "Could not resolve to a PullRequest with the number of 5." }] } });
1083
+ await expect(githubForge({ apiBase: "https://ghe.acme.io/api/v3", repo: "acme/infra", token: "t", fetch }).closingIssues!(5)).rejects.toThrow(/Could not resolve to a PullRequest/);
1084
+ expect(calls[0].url).toBe("https://ghe.acme.io/api/graphql");
1085
+ });
1086
+
1087
+ test("Forgejo reads the closing keywords in the pull request's body", async () => {
1088
+ const { fetch, calls } = fakeFetch({ "GET /api/v1/repos/acme/infra/pulls/7": { number: 7, body: "Closes #12.\nfixes: #3, Resolved #12, see #40, other/repo#5" } });
1089
+ expect(await forgejoForge({ apiBase: "https://code.acme.io/api/v1", repo: "acme/infra", host: "code.acme.io", token: "t", fetch }).closingIssues!(7)).toEqual([3, 12]);
1090
+ expect(calls).toHaveLength(1);
1091
+ });
1092
+
1093
+ test("GitLab asks closes_issues, leaving out another project's issue when the project is an id", async () => {
1094
+ const { fetch, calls } = fakeFetch({ "GET /api/v4/projects/42/merge_requests/5/closes_issues": [{ iid: 8, project_id: 42 }, { iid: 2, project_id: 42 }, { iid: 1, project_id: 7 }] });
1095
+ expect(await gitlabForge({ apiBase: "https://gitlab.com/api/v4", project: "42", token: "t", fetch }).closingIssues!(5)).toEqual([2, 8]);
1096
+ expect(calls).toHaveLength(1);
1097
+ });
1098
+
1099
+ test("closingIssueRefs reads the keywords GitHub and Forgejo honour", () => {
1100
+ expect(closingIssueRefs("close #1 closes #2 closed #3 fix #4 fixes #5 fixed #6 resolve #7 resolves #8 resolved #9")).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]);
1101
+ expect(closingIssueRefs("prefix #1, addresses #2, a/b#3 fixes a/b#4, unclosed #5")).toEqual([]);
1102
+ });
1103
+ });
package/src/pr-forge.ts CHANGED
@@ -303,6 +303,13 @@ export interface MergeResult {
303
303
  /** Statuses a forge answers a refused merge with: not allowed, head moved, conflict, invalid. */
304
304
  const MERGE_REFUSED = new Set([405, 406, 409, 422]);
305
305
 
306
+ /** A status to leave out of `prChecksPassed`: an exact name, or every name under an entry that ends in `/`. */
307
+ function ignoredStatus(ignore: readonly string[]): (name: string) => boolean {
308
+ const exact = new Set(ignore);
309
+ const under = ignore.filter((i) => i.endsWith("/"));
310
+ return (name) => exact.has(name) || under.some((i) => name.startsWith(i));
311
+ }
312
+
306
313
  /** A refused merge as a result, any other failure rethrown. */
307
314
  function refusedMerge(err: unknown): MergeResult {
308
315
  if (err instanceof ForgeApiError && MERGE_REFUSED.has(err.status)) {
@@ -426,6 +433,18 @@ export interface PrForge {
426
433
  labels?(pr: number): Promise<string[]>;
427
434
  /** Whether pull request `pr` is open, closed unmerged, or merged (#4298), for `pr-env sweep`. */
428
435
  pullRequestState?(pr: number): Promise<"open" | "closed" | "merged">;
436
+ /**
437
+ * The issues of this repository that pull request `pr` (merge request `pr`
438
+ * on GitLab) closes when it merges (#4649), ascending, without repeats. One
439
+ * call per pull request. GitHub answers from GraphQL's
440
+ * `closingIssuesReferences`, which holds both the closing keywords in the
441
+ * body and the issues linked by hand, so it needs a token. GitLab answers
442
+ * from `closes_issues`. Forgejo has no such call, so its pull request's body
443
+ * is read for the closing keywords it honours ({@link closingIssueRefs}).
444
+ * An issue in another repository is left out (on GitLab, when the client
445
+ * names its project by id).
446
+ */
447
+ closingIssues?(pr: number): Promise<number[]>;
429
448
  /**
430
449
  * Merge pull request `pr` only if its head is still `opts.sha`. A moved
431
450
  * head, a conflict or a branch rule the forge enforces comes back as
@@ -675,6 +694,19 @@ export class ForgeApiError extends Error {
675
694
  }
676
695
  }
677
696
 
697
+ /**
698
+ * The issues a pull request body closes by keyword, as Forgejo and GitHub
699
+ * read them: `close`, `closes`, `closed`, `fix`, `fixes`, `fixed`,
700
+ * `resolve`, `resolves` or `resolved`, any case, an optional colon, then
701
+ * `#<n>`. A reference to another repository (`owner/name#<n>`) is left out.
702
+ * Ascending, without repeats.
703
+ */
704
+ export function closingIssueRefs(body: string): number[] {
705
+ const out = new Set<number>();
706
+ for (const m of body.matchAll(/(?:^|[^\w/])(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?):?\s+#(\d+)\b/gi)) out.add(Number(m[1]));
707
+ return [...out].sort((a, b) => a - b);
708
+ }
709
+
678
710
  /** The forge answered 404. */
679
711
  const notFound = (err: unknown): boolean => err instanceof ForgeApiError && err.status === 404;
680
712
 
@@ -875,13 +907,12 @@ const GITLAB_DESCRIPTION = 255;
875
907
  /** Which of the two GitHub-shaped forges a client is talking to. */
876
908
  function githubShaped(kind: "github" | "forgejo", opts: GithubForgeOptions): GithubShapedForge {
877
909
  const host = (opts.host ?? "github.com").toLowerCase();
878
- const api = transport(
879
- opts.apiBase,
910
+ const headers =
880
911
  kind === "github"
881
912
  ? { ...(opts.token ? { Authorization: `Bearer ${opts.token}` } : {}), Accept: "application/vnd.github+json" }
882
- : { ...(opts.token ? { Authorization: `token ${opts.token}` } : {}), Accept: "application/json" },
883
- opts.fetch ?? (globalThis.fetch as unknown as ForgeFetch),
884
- );
913
+ : { ...(opts.token ? { Authorization: `token ${opts.token}` } : {}), Accept: "application/json" };
914
+ const fetchImpl = opts.fetch ?? (globalThis.fetch as unknown as ForgeFetch);
915
+ const api = transport(opts.apiBase, headers, fetchImpl);
885
916
  const repo = `/repos/${opts.repo}`;
886
917
  // GitHub pages with per_page (up to 100); Forgejo with limit (capped at 50 by default).
887
918
  const pageSize = kind === "github" ? 100 : 50;
@@ -1074,7 +1105,7 @@ function githubShaped(kind: "github" | "forgejo", opts: GithubForgeOptions): Git
1074
1105
  return base === tip ? pass(`${short(head)} contains ${into} at ${short(tip)}`) : refuse(`${short(head)} does not contain ${into} at ${short(tip)}`);
1075
1106
  },
1076
1107
  async prChecksPassed(_pr, head, ignore = []) {
1077
- const skip = new Set(ignore);
1108
+ const skip = ignoredStatus(ignore);
1078
1109
  const failing: string[] = [];
1079
1110
  const waiting: string[] = [];
1080
1111
  let count = 0;
@@ -1082,8 +1113,13 @@ function githubShaped(kind: "github" | "forgejo", opts: GithubForgeOptions): Git
1082
1113
  const combined = await api.call("GET", `${repo}/commits/${head}/status`);
1083
1114
  for (const st of isObject(combined) && Array.isArray(combined.statuses) ? combined.statuses : []) {
1084
1115
  const context = isObject(st) ? str(st.context) : undefined;
1085
- if (!context || skip.has(context)) continue;
1116
+ if (!context) continue;
1086
1117
  const state = str(st.state) ?? str(st.status) ?? "";
1118
+ // A status left out still shows the checks reported, unless it is what held them back.
1119
+ if (skip(context)) {
1120
+ if (state === "success") count++;
1121
+ continue;
1122
+ }
1087
1123
  count++;
1088
1124
  if (state === "failure" || state === "error" || state === "failed") failing.push(context);
1089
1125
  else if (state === "pending" || state === "running" || state === "") waiting.push(context);
@@ -1092,7 +1128,7 @@ function githubShaped(kind: "github" | "forgejo", opts: GithubForgeOptions): Git
1092
1128
  const runs = await api.call("GET", `${repo}/commits/${head}/check-runs?per_page=100`);
1093
1129
  for (const run of isObject(runs) && Array.isArray(runs.check_runs) ? runs.check_runs : []) {
1094
1130
  const name = (isObject(run) ? str(run.name) : undefined) ?? "a check";
1095
- if (skip.has(name) || !isObject(run)) continue;
1131
+ if (skip(name) || !isObject(run)) continue;
1096
1132
  count++;
1097
1133
  if (run.status !== "completed") waiting.push(name);
1098
1134
  else if (!["success", "neutral", "skipped"].includes(String(run.conclusion))) failing.push(name);
@@ -1230,6 +1266,34 @@ function githubShaped(kind: "github" | "forgejo", opts: GithubForgeOptions): Git
1230
1266
  const listed = await api.list(`${repo}/issues/${pr}/labels`, pageParams, pageSize);
1231
1267
  return listed.map((l) => (isObject(l) ? str(l.name) : undefined)).filter((n): n is string => n !== undefined);
1232
1268
  },
1269
+ async closingIssues(pr) {
1270
+ if (kind === "forgejo") {
1271
+ const p = await api.call("GET", `${repo}/pulls/${pr}`);
1272
+ return closingIssueRefs(isObject(p) ? (str(p.body) ?? "") : "");
1273
+ }
1274
+ // GitHub's REST API has no closing issues; GraphQL does, at /graphql on
1275
+ // github.com and /api/graphql on GitHub Enterprise Server.
1276
+ const root = opts.apiBase.replace(/\/+$/, "");
1277
+ const url = /\/api\/v3$/.test(root) ? `${root.slice(0, -"/v3".length)}/graphql` : `${root}/graphql`;
1278
+ const [owner, name] = opts.repo.split("/");
1279
+ const query =
1280
+ "query($owner:String!,$name:String!,$pr:Int!){repository(owner:$owner,name:$name){pullRequest(number:$pr){closingIssuesReferences(first:100){nodes{number repository{nameWithOwner}}}}}}";
1281
+ const res = await fetchImpl(url, { method: "POST", headers: { ...headers, "Content-Type": "application/json" }, body: JSON.stringify({ query, variables: { owner, name, pr } }) });
1282
+ const text = await res.text();
1283
+ if (!res.ok) throw new ForgeApiError("POST", url, res.status, text);
1284
+ const body: unknown = text ? JSON.parse(text) : null;
1285
+ const errors = isObject(body) && Array.isArray(body.errors) ? body.errors : [];
1286
+ if (errors.length > 0) throw new ForgeApiError("POST", url, res.status, errors.map((e) => (isObject(e) ? (str(e.message) ?? "") : "")).join("; "));
1287
+ const data = isObject(body) && isObject(body.data) && isObject(body.data.repository) ? body.data.repository : undefined;
1288
+ const refs = data && isObject(data.pullRequest) && isObject(data.pullRequest.closingIssuesReferences) ? data.pullRequest.closingIssuesReferences.nodes : undefined;
1289
+ const out = new Set<number>();
1290
+ for (const n of Array.isArray(refs) ? refs : []) {
1291
+ if (!isObject(n) || typeof n.number !== "number") continue;
1292
+ const there = isObject(n.repository) ? str(n.repository.nameWithOwner) : undefined;
1293
+ if (there === undefined || there.toLowerCase() === opts.repo.toLowerCase()) out.add(n.number);
1294
+ }
1295
+ return [...out].sort((a, b) => a - b);
1296
+ },
1233
1297
  async pullRequestState(pr) {
1234
1298
  const p = await api.call("GET", `${repo}/pulls/${pr}`);
1235
1299
  if (!isObject(p)) return "open";
@@ -1489,23 +1553,30 @@ export function gitlabForge(opts: GitlabForgeOptions): PrForge {
1489
1553
  return behind === 0 ? pass(`${short(head)} contains ${into}`) : refuse(`${short(head)} is ${behind} commit${behind === 1 ? "" : "s"} behind ${into}`);
1490
1554
  },
1491
1555
  async prChecksPassed(mr, head, ignore = []) {
1492
- const skip = new Set(ignore);
1556
+ const skip = ignoredStatus(ignore);
1493
1557
  // Each name's newest status; a job allowed to fail holds nothing back.
1494
1558
  const newest = new Map<string, Record<string, unknown>>();
1495
1559
  for (const st of await api.list(`${project}/repository/commits/${head}/statuses?all=true`, pageParams, 100)) {
1496
1560
  const name = isObject(st) ? str(st.name) : undefined;
1497
- if (!name || skip.has(name) || !isObject(st)) continue;
1561
+ if (!name || !isObject(st)) continue;
1498
1562
  const had = newest.get(name);
1499
1563
  if (!had || (num(st.id) ?? 0) > (num(had.id) ?? 0)) newest.set(name, st);
1500
1564
  }
1501
1565
  const failing: string[] = [];
1502
1566
  const waiting: string[] = [];
1567
+ let count = 0;
1503
1568
  for (const [name, st] of newest) {
1504
1569
  const state = str(st.status) ?? "";
1570
+ // A status left out still shows the checks reported, unless it is what held them back.
1571
+ if (skip(name)) {
1572
+ if (state === "success") count++;
1573
+ continue;
1574
+ }
1575
+ count++;
1505
1576
  if ((state === "failed" || state === "canceled") && st.allow_failure !== true) failing.push(name);
1506
1577
  else if (GITLAB_RUNNING.has(state)) waiting.push(name);
1507
1578
  }
1508
- return checksVerdict(`merge request !${mr}`, head, failing, waiting, newest.size);
1579
+ return checksVerdict(`merge request !${mr}`, head, failing, waiting, count);
1509
1580
  },
1510
1581
  async pullRequestOpen(mr) {
1511
1582
  try {
@@ -1635,6 +1706,17 @@ export function gitlabForge(opts: GitlabForgeOptions): PrForge {
1635
1706
  const m = await api.call("GET", `${notes}/${mr}`);
1636
1707
  return isObject(m) && Array.isArray(m.labels) ? m.labels.filter((l): l is string => typeof l === "string") : [];
1637
1708
  },
1709
+ async closingIssues(mr) {
1710
+ const listed = await api.list(`${notes}/${mr}/closes_issues`, pageParams, 100);
1711
+ // An issue of another project is left out when the project is named by id; by path, every one is kept, to spend no second call.
1712
+ const own = /^\d+$/.test(opts.project) ? Number(opts.project) : undefined;
1713
+ const out = new Set<number>();
1714
+ for (const i of listed) {
1715
+ if (!isObject(i) || typeof i.iid !== "number") continue;
1716
+ if (own === undefined || i.project_id === undefined || i.project_id === own) out.add(i.iid);
1717
+ }
1718
+ return [...out].sort((a, b) => a - b);
1719
+ },
1638
1720
  async pullRequestState(mr) {
1639
1721
  const m = await api.call("GET", `${notes}/${mr}`);
1640
1722
  if (!isObject(m)) return "open";
@@ -106,6 +106,15 @@ describe("github", () => {
106
106
  expect((await f("success", runs("failure")).prChecksPassed!(7, HEAD, ["chant/apply"])).reason).toBe("lint failed on aaaaaaaa");
107
107
  });
108
108
 
109
+ test("checks: an entry ending in / leaves out every status under it", async () => {
110
+ const f = forge({
111
+ [`GET ${repo}/commits/${HEAD}/status`]: { statuses: [{ context: "plywood/preview/shop/dev", state: "failure" }, { context: "ci/test", state: "success" }] },
112
+ [`GET ${repo}/commits/${HEAD}/check-runs`]: { check_runs: [] },
113
+ });
114
+ expect((await f.prChecksPassed!(7, HEAD, ["plywood/preview/"])).passed).toBe(true);
115
+ expect((await f.prChecksPassed!(7, HEAD, ["plywood/preview"])).passed).toBe(false);
116
+ });
117
+
109
118
  test("checks: nothing reported is pending", async () => {
110
119
  const f = forge({ [`GET ${repo}/commits/${HEAD}/status`]: { statuses: [] }, [`GET ${repo}/commits/${HEAD}/check-runs`]: { check_runs: [] } });
111
120
  expect(await f.prChecksPassed!(7, HEAD)).toMatchObject({ passed: false, pending: true });
@@ -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.62";
22
+ export const NEXT_RELEASE = "0.124.64";
@@ -29,6 +29,8 @@ describe("the stage-hooks bundle", () => {
29
29
  // The control repo's settings check (#4568, #4617), which the spec checks.
30
30
  "packages/core/src/control/dispatch.ts",
31
31
  "packages/core/src/lifecycle/gate-seal.ts",
32
+ // A passkey's seal (#4646), checked with node:crypto.
33
+ "packages/core/src/lifecycle/gate-webauthn.ts",
32
34
  "packages/core/src/notify-verify.ts",
33
35
  "packages/core/src/notify.ts",
34
36
  "packages/core/src/op/gate-point.ts",
@@ -64,7 +64,8 @@ describe("the wave-job runtime bundle (#3896)", () => {
64
64
  test("carries its version and stays small", () => {
65
65
  expect(built.text).toContain('"workspace points"');
66
66
  expect(built.text.startsWith("#!/usr/bin/env node\n")).toBe(true);
67
- // About 1.45 MB minified today (440 KB gzipped), zod's inlined schemas about 300 KB of it.
68
- expect(built.bytes).toBeLessThan(2 * 1024 * 1024);
67
+ // About 2.0 MB minified at #4678, which took it past 2 MiB; the declaration schema and zod's inlined
68
+ // schemas are a large part of it. The cap catches the 33 MB of the left-out packages, so 2.5 MiB keeps that.
69
+ expect(built.bytes).toBeLessThan(2.5 * 1024 * 1024);
69
70
  });
70
71
  });