@codyswann/lisa 4.101.9 → 4.101.11

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 (91) hide show
  1. package/all/copy-overwrite/scripts/check-third-party-review-evidence.mjs +124 -28
  2. package/all/copy-overwrite/scripts/lib/completion-proof-github.mjs +228 -30
  3. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +1 -1
  4. package/dist/cli/doctor-third-party-evidence-seed.d.ts +9 -2
  5. package/dist/cli/doctor-third-party-evidence-seed.d.ts.map +1 -1
  6. package/dist/cli/doctor-third-party-evidence-seed.js +64 -4
  7. package/dist/cli/doctor-third-party-evidence-seed.js.map +1 -1
  8. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  9. package/dist/core/lisa-owned-hash-ledger.js +12 -0
  10. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  11. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  12. package/dist/core/nightly-e2e-guard-behavior-certificate.js.map +1 -1
  13. package/dist/core/third-party-evidence-seed.d.ts +9 -1
  14. package/dist/core/third-party-evidence-seed.d.ts.map +1 -1
  15. package/dist/core/third-party-evidence-seed.js +41 -9
  16. package/dist/core/third-party-evidence-seed.js.map +1 -1
  17. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  18. package/dist/core/upstream-evidence-manifest.js +9 -4
  19. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  20. package/package.json +4 -4
  21. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  22. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  23. package/plugins/lisa-agy/plugin.json +1 -1
  24. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  26. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  27. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  30. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  31. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  32. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  33. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  35. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  37. package/plugins/lisa-expo-agy/plugin.json +1 -1
  38. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  39. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  42. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  43. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  44. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  45. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  48. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  49. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  51. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  52. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  53. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  56. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  58. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  59. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  63. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  65. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  66. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  68. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  70. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  72. package/plugins/lisa-rails-agy/plugin.json +1 -1
  73. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  74. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  77. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  79. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  80. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  83. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  84. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  86. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  87. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  88. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  89. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  91. package/typescript/create-only/.github/workflows/third-party-review-evidence.yml +34 -12
@@ -165,20 +165,33 @@
165
165
  * runs from the default branch, so the job's own check run lands on the
166
166
  * default branch's latest commit — never on the pull request head it judged.
167
167
  * `--publish` reads the verdict a `--json` run saved, and the exit code it
168
- * ended with, and creates ONE check run on that head: `success` for
168
+ * ended with, and creates a check run on that head: `success` for
169
169
  * `satisfied` and `substituted`, `failure` for `unsatisfied` and for
170
170
  * `pull-requests-unreadable`. A run with no head to show it on, or that cannot
171
171
  * change the answer, publishes nothing and says why. A missing or unparseable
172
172
  * verdict, an exit code other than the verdict's own, or a refused write fails
173
173
  * the mode, so broken machinery still shows on the job.
174
174
  *
175
+ * ## The verdict is published under every declared reviewer's name (#4738)
176
+ *
177
+ * The check run is named `🕵️ Third-party review evidence (<context>)`. The
178
+ * verdict covers every declared reviewer, so one is created for `--context`
179
+ * AND for each reviewer the checkout's config or the saved readings declare,
180
+ * each name once. Otherwise a red `(A)` stays red after B's later review makes
181
+ * the head acceptable, because B's run would update only `(B)`. An empty
182
+ * `--context` — a manual run that names no reviewer — adds the bare name; a
183
+ * manual run that names one overwrites that reviewer's stale check run, which
184
+ * is how a red check is cleared after a writer's substitute, since a comment
185
+ * wakes no run. Each refused write is reported and fails the mode; the other
186
+ * names are still written.
187
+ *
175
188
  * CLI:
176
189
  * node scripts/check-third-party-review-evidence.mjs --sha <sha> [--json]
177
190
  * [--context <context>] [--root <dir>] [--repo <owner/repo>]
178
191
  * [--arm [--vacuity-report <path>]]
179
192
  * node scripts/check-third-party-review-evidence.mjs --sha <sha>
180
193
  * --publish <saved-verdict.json> --prover-exit <code>
181
- * [--context <context>] [--repo <owner/repo>]
194
+ * [--context <context>] [--root <dir>] [--repo <owner/repo>]
182
195
  *
183
196
  * `--arm` answers the merge driver's arm gate instead (#4653): whether
184
197
  * auto-merge may be turned on for this head, and if not, what to do next.
@@ -2170,6 +2183,60 @@ function writeArmDecision(verdict, { opts, io, out, repo, pulls, canWrite }) {
2170
2183
  /** The check run a verdict is published as, before a waking reviewer's name. */
2171
2184
  export const PUBLISHED_CHECK_NAME = "🕵️ Third-party review evidence";
2172
2185
 
2186
+ /**
2187
+ * The check run name a verdict is published under for one reviewer context.
2188
+ * @param {string} context - A reviewer context; empty for the bare name.
2189
+ * @returns {string} The check run name.
2190
+ */
2191
+ const publishedCheckName = context =>
2192
+ context ? `${PUBLISHED_CHECK_NAME} (${context})` : PUBLISHED_CHECK_NAME;
2193
+
2194
+ /**
2195
+ * Every reviewer context one publishing run publishes its verdict under
2196
+ * (#4738), the supplied one first and each once.
2197
+ *
2198
+ * The verdict covers every declared reviewer, so it is published under each
2199
+ * one's name: otherwise a red `(A)` stays red after B's later review makes the
2200
+ * head acceptable, because B's run updated only `(B)`. The declared reviewers
2201
+ * are the config's, joined by every context the saved readings name, so a
2202
+ * verdict saved with no readings — an unreadable pull-request list — still
2203
+ * reaches them. The supplied context is kept even when nothing declares it,
2204
+ * and an empty one (the manual path) is the bare name.
2205
+ * @param {object} options - The run.
2206
+ * @param {string} options.context - The context that woke the run; empty on the manual path.
2207
+ * @param {object} options.gates - The `gates` block of `.lisa.config.json`.
2208
+ * @param {ReadonlyArray<{context?: unknown}>} options.readings - The saved verdict's readings.
2209
+ * @returns {string[]} The contexts, deduplicated; "" stands for the bare name.
2210
+ */
2211
+ function publishedContexts({ context, gates, readings }) {
2212
+ const declared = [
2213
+ ...configuredReviewers({ gates }).map(reviewer => reviewer.context),
2214
+ ...readings
2215
+ .map(reading => reading?.context)
2216
+ .filter(named => typeof named === "string" && named !== ""),
2217
+ ];
2218
+ return [...new Set([context, ...declared])];
2219
+ }
2220
+
2221
+ /**
2222
+ * The `gates` block the publish step's checkout declares.
2223
+ *
2224
+ * It is only consulted to widen which names a verdict is published under, so
2225
+ * a config that cannot be read narrows the publication to the supplied name
2226
+ * and the saved readings' — today's behaviour — rather than failing a run
2227
+ * that already reached a verdict.
2228
+ * @param {string} root - The checkout's root.
2229
+ * @returns {object} The gates block, or none.
2230
+ */
2231
+ function publishingGates(root) {
2232
+ // probe-direction: neutral — no gate reads this; it only chooses which names an already-reached verdict is shown under.
2233
+ try {
2234
+ return readGates(root).gates;
2235
+ } catch {
2236
+ return {};
2237
+ }
2238
+ }
2239
+
2173
2240
  /**
2174
2241
  * The conclusion each published outcome carries on the head it judged.
2175
2242
  *
@@ -2263,7 +2330,7 @@ function savedVerdict(text, sha) {
2263
2330
  * @param {string} options.proverExit - The exit code the prover ended with.
2264
2331
  * @param {string} options.sha - The head the verdict judged.
2265
2332
  * @param {string} options.context - The reviewer that woke the run; empty on the manual path.
2266
- * @returns {{error: string}|{report: string, why: string}|{report: string, body: object}} The publication.
2333
+ * @returns {{error: string}|{report: string, why: string}|{report: string, body: object, readings: ReadonlyArray<ReportedReading>}} The publication: `body` is named for `context`.
2267
2334
  */
2268
2335
  export function verdictPublication({ text, proverExit, sha, context }) {
2269
2336
  if (proverExit !== "0" && proverExit !== "1") {
@@ -2298,10 +2365,9 @@ export function verdictPublication({ text, proverExit, sha, context }) {
2298
2365
  }
2299
2366
  return {
2300
2367
  report,
2368
+ readings: verdict.readings,
2301
2369
  body: {
2302
- name: context
2303
- ? `${PUBLISHED_CHECK_NAME} (${context})`
2304
- : PUBLISHED_CHECK_NAME,
2370
+ name: publishedCheckName(context),
2305
2371
  head_sha: sha,
2306
2372
  status: "completed",
2307
2373
  conclusion,
@@ -2335,11 +2401,14 @@ function refusalOf(error) {
2335
2401
  /**
2336
2402
  * Publish a saved verdict on the head it judged, and return the exit code.
2337
2403
  *
2338
- * 0 once the check run is created, or when nothing is to be published; 1
2339
- * when the verdict could not be read or trusted, or GitHub refused the write.
2340
- * The report goes to stdout and to the step summary either way.
2404
+ * The verdict is published under every name `publishedContexts` returns
2405
+ * (#4738). 0 once every check run is created, or when nothing is to be
2406
+ * published; 1 when the verdict could not be read or trusted, or GitHub
2407
+ * refused any one write — each refusal is reported, and the other names are
2408
+ * still attempted. The report goes to stdout and to the step summary either way.
2341
2409
  * @param {ReturnType<typeof parseArgs> & {sha: string}} opts - Parsed options.
2342
2410
  * @param {object} io - Injected side effects.
2411
+ * @param {object} [io.gates] - The gates block naming the declared reviewers, read from `--root` when absent.
2343
2412
  * @param {(path: string) => string} [io.readFile] - Reader for the saved verdict.
2344
2413
  * @param {(args: string[], input: string) => string} [io.gh] - Writer: `gh` with a request body on stdin.
2345
2414
  * @param {(text: string) => void} [io.appendSummary] - Appends to the job's step summary.
@@ -2381,7 +2450,31 @@ function publishVerdict(opts, io, out, err) {
2381
2450
  summarise(`Nothing published: ${plan.why}.\n`);
2382
2451
  return 0;
2383
2452
  }
2384
- const { name, conclusion } = plan.body;
2453
+ const contexts = publishedContexts({
2454
+ context: opts.context ?? "",
2455
+ gates: io.gates ?? publishingGates(opts.root),
2456
+ readings: plan.readings,
2457
+ });
2458
+ const write = checkRunWriter(opts, io, { out, err, summarise });
2459
+ // Every name is attempted, so one refusal leaves no other name stale; any
2460
+ // refusal still fails the job.
2461
+ const published = contexts.map(context =>
2462
+ write({ ...plan.body, name: publishedCheckName(context) })
2463
+ );
2464
+ return published.every(Boolean) ? 0 : 1;
2465
+ }
2466
+
2467
+ /**
2468
+ * A writer that creates one check run on the judged head and reports it.
2469
+ * @param {ReturnType<typeof parseArgs> & {sha: string}} opts - Parsed options.
2470
+ * @param {{gh?: (args: string[], input: string) => string}} io - Injected side effects.
2471
+ * @param {object} sinks - Where the outcome is reported.
2472
+ * @param {{write: (text: string) => void}} sinks.out - Stdout.
2473
+ * @param {{write: (text: string) => void}} sinks.err - Stderr.
2474
+ * @param {(text: string) => void} sinks.summarise - Step-summary writer.
2475
+ * @returns {(body: {name: string, conclusion: string}) => boolean} Creates one check run; true once GitHub accepted it.
2476
+ */
2477
+ function checkRunWriter(opts, io, { out, err, summarise }) {
2385
2478
  const repo = opts.repo ?? process.env.GITHUB_REPOSITORY ?? "";
2386
2479
  const gh =
2387
2480
  io.gh ??
@@ -2391,31 +2484,34 @@ function publishVerdict(opts, io, out, err) {
2391
2484
  input,
2392
2485
  stdio: ["pipe", "pipe", "pipe"],
2393
2486
  }));
2394
- // probe-direction: fail-closed — a write that was refused, or killed at its deadline, published nothing, so the job fails.
2395
- try {
2396
- if (!/^[^/\s]+\/[^/\s]+$/u.test(repo)) {
2397
- throw new Error(`repository must be owner/repo, not "${repo}"`);
2487
+ return body => {
2488
+ const { name, conclusion } = body;
2489
+ // probe-direction: fail-closed — a write that was refused, or killed at its deadline, published nothing, so the job fails.
2490
+ try {
2491
+ if (!/^[^/\s]+\/[^/\s]+$/u.test(repo)) {
2492
+ throw new Error(`repository must be owner/repo, not "${repo}"`);
2493
+ }
2494
+ gh(
2495
+ ["api", `repos/${repo}/check-runs`, "--method", "POST", "--input", "-"],
2496
+ JSON.stringify(body)
2497
+ );
2498
+ } catch (error) {
2499
+ err.write(
2500
+ `::error title=Review evidence verdict not published::The check run "${name}" was not published on ${opts.sha}: ${refusalOf(error)}. The verdict is not on the pull request head, so this job fails.\n`
2501
+ );
2502
+ return false;
2398
2503
  }
2399
- gh(
2400
- ["api", `repos/${repo}/check-runs`, "--method", "POST", "--input", "-"],
2401
- JSON.stringify(plan.body)
2402
- );
2403
- } catch (error) {
2404
- err.write(
2405
- `::error title=Review evidence verdict not published::The check run "${name}" was not published on ${opts.sha}: ${refusalOf(error)}. The verdict is not on the pull request head, so this job fails.\n`
2406
- );
2407
- return 1;
2408
- }
2409
- out.write(`Published "${name}" on ${opts.sha}: ${conclusion}.\n`);
2410
- summarise(`Published \`${name}\` on \`${opts.sha}\`: **${conclusion}**.\n`);
2411
- return 0;
2504
+ out.write(`Published "${name}" on ${opts.sha}: ${conclusion}.\n`);
2505
+ summarise(`Published \`${name}\` on \`${opts.sha}\`: **${conclusion}**.\n`);
2506
+ return true;
2507
+ };
2412
2508
  }
2413
2509
 
2414
2510
  /**
2415
2511
  * The CLI body.
2416
2512
  * @param {string[]} argv - Arguments after the script path.
2417
2513
  * @param {object} [io] - Injected side effects, for tests.
2418
- * @param {object} [io.gates] - The gates block, read from disk when absent.
2514
+ * @param {object} [io.gates] - The gates block, read from disk when absent; `--publish` reads it for the declared reviewers' names.
2419
2515
  * @param {(sha: string) => number[]|null} [io.pulls] - Head-pull-request reader; null when the read failed.
2420
2516
  * @param {(sha: string) => ReadonlyArray<object>|null} [io.statuses] - Status reader.
2421
2517
  * @param {(sha: string, context: string) => ReadonlyArray<RawCheckRun>|null} [io.checkRuns] -
@@ -153,6 +153,157 @@ export function isAcceptedEvidenceRelease(policy, tag) {
153
153
  );
154
154
  }
155
155
 
156
+ /** Lets gh >= 2.97 print a raw body holding terminal escape sequences. */
157
+ const ESCAPE_FLAG = "--allow-escape-sequences";
158
+ /** How gh < 2.97, which has no escape check, rejects that flag. */
159
+ const UNKNOWN_ESCAPE_FLAG = /unknown flag:? --allow-escape-sequences/;
160
+ const OCTET_STREAM = "Accept: application/octet-stream";
161
+ /** The longest stderr excerpt a read failure quotes. */
162
+ const STDERR_EXCERPT = 200;
163
+ const ESC = 0x1b;
164
+ /** Repository-relative read paths and the read each one is. */
165
+ const READ_KINDS = [
166
+ [/^releases\/assets\/\d+$/, "asset-metadata"],
167
+ [/^releases\/tags\//, "release"],
168
+ [/^releases\/\d+\/assets/, "release-assets"],
169
+ [/^collaborators\/[^/]+\/permission$/, "collaborator-permission"],
170
+ [/^compare\//, "compare"],
171
+ [/^pulls\//, "pull"],
172
+ [/^commits\//, "commit"],
173
+ [/^actions\/runs\//, "actions-run"],
174
+ [/^branches\//, "branch"],
175
+ [/^issues\/\d+\/comments/, "comments"],
176
+ [/^user$/, "user"],
177
+ ];
178
+
179
+ /**
180
+ * The endpoint a `gh api` argument vector reads: the first operand after
181
+ * `api` that is neither a flag nor a flag's value.
182
+ * @param {string[]} args - Exact `gh` argument vector.
183
+ * @returns {string} The endpoint, or "" when there is none.
184
+ */
185
+ function readPath(args) {
186
+ return (
187
+ args.find(
188
+ (value, index) =>
189
+ index > 0 &&
190
+ !value.startsWith("-") &&
191
+ !["--header", "-H"].includes(args[index - 1])
192
+ ) ?? ""
193
+ );
194
+ }
195
+
196
+ /**
197
+ * Text with terminal control removed: CSI escape sequences whole, every other
198
+ * C0/C1 control character except the newline. Scanned, not matched, so no
199
+ * control character has to appear in a pattern.
200
+ * @param {string} text - Untrusted diagnostics.
201
+ * @returns {string} The printable text and its newlines.
202
+ */
203
+ function stripControl(text) {
204
+ const kept = [];
205
+ // "text" | "escape" (just read ESC) | "csi" (inside ESC [ ... final).
206
+ // `[` is itself in the final-byte range, so the introducer must be consumed
207
+ // on its own or `ESC [31m` would leave `31m` glued to the next word.
208
+ let state = "text";
209
+ for (const character of text) {
210
+ const code = character.codePointAt(0);
211
+ if (state === "escape") {
212
+ state = code === 0x5b ? "csi" : "text";
213
+ continue;
214
+ }
215
+ if (state === "csi") {
216
+ if (code >= 0x40 && code <= 0x7e) state = "text";
217
+ continue;
218
+ }
219
+ if (code === ESC) state = "escape";
220
+ else if (code === 0x0a || (code >= 0x20 && (code < 0x7f || code > 0x9f)))
221
+ kept.push(character);
222
+ }
223
+ return kept.join("");
224
+ }
225
+
226
+ /**
227
+ * Stderr made safe to quote: control stripped, credentials redacted, first
228
+ * non-empty line only, bounded.
229
+ * @param {string} [stderr] - Raw `gh` diagnostics.
230
+ * @returns {string} One quotable line, possibly empty.
231
+ */
232
+ function quotableStderr(stderr) {
233
+ const line =
234
+ stripControl(String(stderr ?? ""))
235
+ // No word boundary: a token glued to preceding text must still redact.
236
+ .replace(/(?:gh[pousr]_|github_pat_)\w+/g, "[redacted]")
237
+ .split("\n")
238
+ .map(row => row.trim())
239
+ .find(Boolean) ?? "";
240
+ return line.length > STDERR_EXCERPT
241
+ ? `${line.slice(0, STDERR_EXCERPT)}…`
242
+ : line;
243
+ }
244
+
245
+ /**
246
+ * How a bounded `gh` run failed, or null when it completed in full.
247
+ * @param {object} result - The canonical runner's spawn result.
248
+ * @param {number} maxBuffer - The byte ceiling the read ran under.
249
+ * @returns {string|null} Exit, timeout, overflow or ceiling detail.
250
+ */
251
+ function readFailure(result, maxBuffer) {
252
+ const code = result.error?.code;
253
+ if (code === "ETIMEDOUT") return "timed out";
254
+ if (code === "ENOBUFS")
255
+ return `output exceeded the ${maxBuffer}-byte ceiling (ENOBUFS)`;
256
+ if (result.error) return `gh could not run (${code ?? result.error.message})`;
257
+ if (result.status !== 0)
258
+ return result.signal
259
+ ? `killed by ${result.signal}`
260
+ : `exit ${result.status}`;
261
+ if (Buffer.byteLength(result.stdout ?? "") > maxBuffer)
262
+ return `response exceeded the ${maxBuffer}-byte ceiling`;
263
+ return null;
264
+ }
265
+
266
+ /**
267
+ * Which read an endpoint is, for the operator.
268
+ * @param {string} target - Repository-relative endpoint ("" for the repository).
269
+ * @param {boolean} raw - Whether the read downloads raw asset bytes.
270
+ * @returns {string} A stable read kind.
271
+ */
272
+ function readKind(target, raw) {
273
+ if (raw) return "asset-download";
274
+ if (target === "") return "repository";
275
+ return READ_KINDS.find(([pattern]) => pattern.test(target))?.[1] ?? "api";
276
+ }
277
+
278
+ /**
279
+ * Name a failed read: what it was, where, and how it ended (#4773). Repository
280
+ * paths keep their ids, so the exact asset, PR or commit is identifiable.
281
+ * @param {object} read - The read that failed.
282
+ * @param {string} [read.kind] - Explicit kind, when the endpoint is ambiguous.
283
+ * @param {string[]} read.args - Exact `gh` argument vector.
284
+ * @param {string} read.root - `repos/<owner>/<repo>` of the transport.
285
+ * @param {string} read.failure - Exit, timeout, overflow or ceiling detail.
286
+ * @param {string} [read.stderr] - Raw `gh` diagnostics.
287
+ * @returns {string} One bounded, credential-free description.
288
+ */
289
+ function describeRead({ kind, args, root, failure, stderr }) {
290
+ const path = readPath(args);
291
+ const target = path.startsWith(`${root}/`)
292
+ ? path.slice(root.length + 1)
293
+ : path === root
294
+ ? ""
295
+ : path;
296
+ const http = /HTTP (\d{3})/.exec(stderr ?? "")?.[1];
297
+ const said = quotableStderr(stderr);
298
+ return [
299
+ `${kind ?? readKind(target, args.includes(OCTET_STREAM))} ${target || root}: ${failure}`,
300
+ http ? `HTTP ${http}` : "",
301
+ said ? `gh said: ${said}` : "",
302
+ ]
303
+ .filter(Boolean)
304
+ .join("; ");
305
+ }
306
+
156
307
  /** `/<owner>/<repo>/releases/download/<tag>/<asset>`, and nothing nested. */
157
308
  const DOWNLOAD_PATH = /^\/([^/]+\/[^/]+)\/releases\/download\/([^/]+)\/[^/]+$/;
158
309
 
@@ -163,24 +314,81 @@ export function githubProofTransport(run, repository, policy = {}) {
163
314
  "The implementation repository is not canonical."
164
315
  );
165
316
  const root = `repos/${repository}`;
166
- function call(args, options = {}) {
167
- const maxBuffer = options.maxBuffer ?? MAX_NATIVE_JSON_BYTES;
317
+ /**
318
+ * Run one bounded `gh` read and report, rather than throw, how it ended.
319
+ * @param {string[]} args - Exact `gh` argument vector.
320
+ * @param {object} [options] - Runner options plus an optional `kind`.
321
+ * @returns {{result: object, failure: string|null}} The run and, when it
322
+ * failed, a description naming the read.
323
+ */
324
+ function attempt(args, options = {}) {
325
+ const { kind, ...runOptions } = options;
326
+ const maxBuffer = runOptions.maxBuffer ?? MAX_NATIVE_JSON_BYTES;
168
327
  const result = run("gh", args, {
169
328
  allowFailure: true,
329
+ ...runOptions,
170
330
  maxBuffer,
171
- ...options,
172
331
  });
173
- if (
174
- result.status !== 0 ||
175
- result.error ||
176
- Buffer.byteLength(result.stdout ?? "") > maxBuffer
177
- )
332
+ const failure = readFailure(result, maxBuffer);
333
+ return {
334
+ result,
335
+ failure:
336
+ failure &&
337
+ describeRead({ kind, args, root, failure, stderr: result.stderr }),
338
+ };
339
+ }
340
+ /** The bytes of a completed read; a failed one names itself (#4773). */
341
+ function settle({ result, failure }) {
342
+ if (failure)
178
343
  throw new CompletionProofError(
179
344
  READ_ERROR,
180
- "A required GitHub completion-proof read did not complete; restore repository access and retry canonical Verify/evidence."
345
+ `A required GitHub completion-proof read did not complete (${failure}); restore repository access and retry canonical Verify/evidence.`
181
346
  );
182
347
  return result.stdout;
183
348
  }
349
+ /**
350
+ * One bounded `gh` read.
351
+ * @param {string[]} args - Exact `gh` argument vector.
352
+ * @param {object} [options] - Runner options; `kind` names the read when
353
+ * its endpoint alone does not.
354
+ * @returns {string|Buffer} The complete response.
355
+ */
356
+ function call(args, options = {}) {
357
+ return settle(attempt(args, options));
358
+ }
359
+ // gh >= 2.97 needs the flag and gh < 2.97 rejects it. Assumed supported
360
+ // until gh rejects it once; remembered for this transport's later downloads.
361
+ let escapeFlagSupported = true;
362
+ /**
363
+ * Download a release asset's raw bytes on either side of gh's
364
+ * escape-sequence check (GHSA-3m3g-3wcr-px46, gh v2.97.0). Since then
365
+ * `gh api` refuses to print a raw body holding terminal escape sequences
366
+ * without `--allow-escape-sequences`, so an ANSI-coloured test log failed
367
+ * every terminal transition on CI's gh while an older local gh, which
368
+ * rejects the flag, read it fine (CodySwannGT/lisa#4773). The bytes go to a
369
+ * Buffer and are hashed, never to a terminal, so allowing them is safe.
370
+ * @param {number} id - Native asset identifier.
371
+ * @param {number} max - Byte ceiling for this attachment.
372
+ * @returns {Buffer} The raw asset bytes.
373
+ */
374
+ function downloadAsset(id, max) {
375
+ const args = [
376
+ "api",
377
+ `${root}/releases/assets/${id}`,
378
+ "--header",
379
+ OCTET_STREAM,
380
+ ];
381
+ const options = { binary: true, maxBuffer: max };
382
+ if (escapeFlagSupported) {
383
+ const flagged = attempt([...args, ESCAPE_FLAG], options);
384
+ const rejected =
385
+ flagged.result.status !== 0 &&
386
+ UNKNOWN_ESCAPE_FLAG.test(flagged.result.stderr ?? "");
387
+ if (!rejected) return settle(flagged);
388
+ escapeFlagSupported = false;
389
+ }
390
+ return call(args, options);
391
+ }
184
392
  function json(path, paginated = false) {
185
393
  requireProof(
186
394
  path.startsWith(`${root}/`) || path === root,
@@ -202,7 +410,7 @@ export function githubProofTransport(run, repository, policy = {}) {
202
410
  if (error instanceof CompletionProofError) throw error;
203
411
  throw new CompletionProofError(
204
412
  READ_ERROR,
205
- "A required GitHub proof response is not complete JSON."
413
+ `A required GitHub proof response is not complete JSON (${describeRead({ args: ["api", path], root, failure: "unparseable response" })}).`
206
414
  );
207
415
  }
208
416
  }
@@ -296,19 +504,17 @@ export function githubProofTransport(run, repository, policy = {}) {
296
504
  row.type === "Bot" &&
297
505
  row.repository_id === repositoryId
298
506
  );
299
- const result = run(
300
- "gh",
301
- [
302
- "api",
303
- `${root}/collaborators/${encodeURIComponent(user.login)}/permission`,
304
- ],
305
- { allowFailure: true, maxBuffer: MAX_NATIVE_JSON_BYTES }
306
- );
307
- if (result.status !== 0) {
308
- if (/HTTP 404/.test(result.stderr ?? "")) return false;
507
+ const read = attempt([
508
+ "api",
509
+ `${root}/collaborators/${encodeURIComponent(user.login)}/permission`,
510
+ ]);
511
+ const { result } = read;
512
+ if (read.failure) {
513
+ if (result.status !== 0 && /HTTP 404/.test(result.stderr ?? ""))
514
+ return false;
309
515
  throw new CompletionProofError(
310
516
  READ_ERROR,
311
- "The native proof publisher's repository authority could not be read."
517
+ `The native proof publisher's repository authority could not be read (${read.failure}).`
312
518
  );
313
519
  }
314
520
  let permission;
@@ -358,15 +564,7 @@ export function githubProofTransport(run, repository, policy = {}) {
358
564
  isAcceptedEvidenceRelease(policy, download[2]),
359
565
  `The proof attachment is outside the implementation repository's accepted evidence releases (${acceptedEvidenceReleases(policy).join(", ")}).`
360
566
  );
361
- const bytes = call(
362
- [
363
- "api",
364
- `${root}/releases/assets/${id}`,
365
- "--header",
366
- "Accept: application/octet-stream",
367
- ],
368
- { binary: true, maxBuffer: max }
369
- );
567
+ const bytes = downloadAsset(id, max);
370
568
  requireProof(
371
569
  Buffer.isBuffer(bytes) && bytes.length === metadata.size,
372
570
  "The proof attachment download is incomplete."
@@ -119,7 +119,7 @@
119
119
  "children": []
120
120
  },
121
121
  "lib/completion-proof-github.mjs": {
122
- "sha256": "bcd6a03ad609375b886a45e7af31670b49f1bc4888de1e2f31eb86c44ad56204",
122
+ "sha256": "e8152fec3b77c3d9b79358f7972b60e4ea0d0ed32618aff614bc787875ddfb92",
123
123
  "staticImports": [
124
124
  "lib/completion-proof-shape.mjs"
125
125
  ],
@@ -3,6 +3,11 @@ import type { DoctorCheck } from "./doctor.js";
3
3
  import { EVIDENCE_STEPS_LINES } from "./doctor-third-party-evidence-steps.js";
4
4
  /** Name of the check as doctor reports it. */
5
5
  export declare const THIRD_PARTY_EVIDENCE_SEED_CHECK_NAME = "Third-party review evidence wakes on check runs?";
6
+ /**
7
+ * The `workflow_dispatch` input that lets a manual run name the reviewer whose
8
+ * stale check run it brings up to date, beside the existing `sha:` input.
9
+ */
10
+ export declare const DISPATCH_CONTEXT_INPUT_LINES: readonly [" context:", " description: 'Optional. One reviewer context (its status or check-run name, matched exactly against a declared reviewer; anything else publishes nothing) whose check run to bring up to date. Empty republishes every declared reviewer and the bare name'", " required: false", " type: string"];
6
11
  /** The trigger lines to add under `on:`. */
7
12
  export declare const CHECK_RUN_TRIGGER_LINES: readonly [" check_run:", " types: [completed]"];
8
13
  /**
@@ -14,9 +19,11 @@ export declare const CHECKS_WRITE_LINE = " checks: write";
14
19
  export declare const PERMISSIONS_BLOCK_LINES: readonly ["permissions:", " contents: read", " statuses: read", " checks: write", " pull-requests: read"];
15
20
  export { EVIDENCE_STEPS_LINES };
16
21
  /** The values that carry the run's commit and reviewer to the prover. */
17
- export declare const RUN_IDENTITY_LINES: readonly [" env:", " EVIDENCE_SHA: ${{ github.event.check_run.head_sha || github.event.sha || inputs.sha }}", " EVIDENCE_CONTEXT: ${{ github.event.check_run.name || github.event.context }}"];
22
+ export declare const RUN_IDENTITY_LINES: readonly [" env:", " EVIDENCE_SHA: ${{ github.event.check_run.head_sha || github.event.sha || inputs.sha }}", " EVIDENCE_CONTEXT: ${{ github.event.check_run.name || github.event.context || inputs.context }}"];
18
23
  /** The concurrency key that keeps one run from cancelling another's verdict. */
19
- export declare const CONCURRENCY_GROUP_LINE = " group: third-party-review-evidence-${{ github.event_name }}-${{ github.event.check_run.head_sha || github.event.sha || inputs.sha }}-${{ github.event.check_run.name || github.event.context }}";
24
+ export declare const CONCURRENCY_GROUP_LINE = " group: third-party-review-evidence-${{ github.event_name }}-${{ github.event.check_run.head_sha || github.event.sha || inputs.sha }}-${{ github.event.check_run.name || github.event.context || inputs.context }}";
25
+ /** The whole top-level `concurrency:` block, as the seed ships it. */
26
+ export declare const CONCURRENCY_BLOCK_LINES: readonly ["concurrency:", " group: third-party-review-evidence-${{ github.event_name }}-${{ github.event.check_run.head_sha || github.event.sha || inputs.sha }}-${{ github.event.check_run.name || github.event.context || inputs.context }}", " cancel-in-progress: true"];
20
27
  /**
21
28
  * The operator-facing finding and its exact remedy.
22
29
  * @param reading - What the copy does
@@ -1 +1 @@
1
- {"version":3,"file":"doctor-third-party-evidence-seed.d.ts","sourceRoot":"","sources":["../../src/cli/doctor-third-party-evidence-seed.ts"],"names":[],"mappings":"AAmCA,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9E,8CAA8C;AAC9C,eAAO,MAAM,oCAAoC,qDACG,CAAC;AAwBrD,4CAA4C;AAC5C,eAAO,MAAM,uBAAuB,qDAG1B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,2EAA2E;AAC3E,eAAO,MAAM,uBAAuB,+GAM1B,CAAC;AAEX,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,6MAIrB,CAAC;AAEX,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,sMAA2G,CAAC;AAuJ/I;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAOtE;AAED;;;;;;;;;GASG;AACH,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,CAAC,CAiCtB"}
1
+ {"version":3,"file":"doctor-third-party-evidence-seed.d.ts","sourceRoot":"","sources":["../../src/cli/doctor-third-party-evidence-seed.ts"],"names":[],"mappings":"AA0CA,OAAO,EAOL,KAAK,mBAAmB,EACzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9E,8CAA8C;AAC9C,eAAO,MAAM,oCAAoC,qDACG,CAAC;AAwBrD;;;GAGG;AACH,eAAO,MAAM,4BAA4B,uVAK/B,CAAC;AAEX,4CAA4C;AAC5C,eAAO,MAAM,uBAAuB,qDAG1B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,2EAA2E;AAC3E,eAAO,MAAM,uBAAuB,+GAM1B,CAAC;AAEX,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,+NAIrB,CAAC;AAEX,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,wNAA2G,CAAC;AAE/I,sEAAsE;AACtE,eAAO,MAAM,uBAAuB,gRAI1B,CAAC;AA8LX;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAOtE;AAED;;;;;;;;;GASG;AACH,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,CAAC,CAiCtB"}