rungate 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gates/.gate-salt +1 -0
- package/gates/SCHEMA-GUIDE.md +485 -0
- package/gates/ac-quality.test.ts +106 -0
- package/gates/adversarial.test.ts +283 -0
- package/gates/brief-assembler.test.ts +487 -0
- package/gates/brief-assembler.ts +448 -0
- package/gates/bunfig.toml +2 -0
- package/gates/chain.test.ts +91 -0
- package/gates/e2e-smoke.test.ts +234 -0
- package/gates/error-classifier.test.ts +250 -0
- package/gates/error-classifier.ts +99 -0
- package/gates/gate-executor.ts +3071 -0
- package/gates/orchestrator.test.ts +968 -0
- package/gates/orchestrator.ts +827 -0
- package/gates/preload.ts +89 -0
- package/gates/prompts/ac-adversary.md +20 -0
- package/gates/prompts/evidence-validator.md +22 -0
- package/gates/prompts/prove-reproducer.md +53 -0
- package/gates/prompts.sha256 +3 -0
- package/gates/prove.test.ts +164 -0
- package/gates/rook-state.test.ts +108 -0
- package/gates/run-attribution.ts +290 -0
- package/gates/run-gate.ts +163 -0
- package/gates/schema-parity.test.ts +378 -0
- package/gates/schema.ts +1209 -0
- package/gates/self-heal.test.ts +511 -0
- package/gates/self-heal.ts +125 -0
- package/gates/ship-orchestrator.test.ts +399 -0
- package/gates/ship-orchestrator.ts +384 -0
- package/gates/spec-compliance-probe.ts +159 -0
- package/gates/test-fixtures/broken-no-environments.json +110 -0
- package/gates/test-fixtures/consumer-directory-layout.json +90 -0
- package/gates/test-fixtures/valid-standard.json +91 -0
- package/gates/test-utils.ts +43 -0
- package/gates/typecheck-gate.ts +111 -0
- package/gates/witness.ts +349 -0
- package/gates/workflow.test.ts +2018 -0
- package/hooks/ActionVerificationGate.hook.ts +96 -0
- package/hooks/AgentBriefGuard.hook.ts +38 -0
- package/hooks/AgentVerdictCapture.hook.ts +87 -0
- package/hooks/AutoVerifyGate.hook.ts +79 -0
- package/hooks/BashToolGuard.hook.ts +65 -0
- package/hooks/BashWriteGuard.hook.ts +60 -0
- package/hooks/CommitEnforcement.hook.ts +130 -0
- package/hooks/DocHygiene.hook.ts +148 -0
- package/hooks/GateEnforcement.hook.ts +58 -0
- package/hooks/GateResultProtection.hook.ts +95 -0
- package/hooks/HarnessAFKGate.hook.ts +85 -0
- package/hooks/HookCurrency.hook.ts +99 -0
- package/hooks/IssueCloseGuard.hook.ts +149 -0
- package/hooks/MergeGuard.hook.ts +58 -0
- package/hooks/PostCompact.hook.ts +60 -0
- package/hooks/ProjectStateSync.hook.ts +103 -0
- package/hooks/SkillGuard.hook.ts +69 -0
- package/hooks/SpecConformityTrigger.hook.ts +43 -0
- package/hooks/SpecSCGuard.hook.ts +123 -0
- package/hooks/StaleTTLCleanup.hook.ts +141 -0
- package/hooks/TaskCompleted.hook.ts +51 -0
- package/hooks/TeamInit.hook.ts +85 -0
- package/hooks/TestSuiteGuard.hook.ts +70 -0
- package/hooks/TestSuiteRelease.hook.ts +85 -0
- package/hooks/TopLevelCdGuard.hook.ts +108 -0
- package/hooks/VerifyPhaseLock.hook.ts +84 -0
- package/hooks/WorkflowStateGuard.hook.ts +64 -0
- package/hooks/lib/agent-config.json +9 -0
- package/hooks/lib/agentDetection.ts +201 -0
- package/hooks/lib/comment-template.ts +86 -0
- package/hooks/lib/findWorkflow.ts +101 -0
- package/hooks/lib/parseStdin.ts +37 -0
- package/hooks/lib/paths.ts +111 -0
- package/hooks/lib/utils.ts +338 -0
- package/lib/affected-tests.ts +29 -0
- package/lib/bash-write-guard.ts +627 -0
- package/lib/branch-cleanup.ts +279 -7
- package/lib/config-trackable.ts +9 -0
- package/lib/distribution-currency.ts +55 -5
- package/lib/failure-intake.ts +7 -1
- package/lib/gate-enforcement.ts +360 -38
- package/lib/gate-names.ts +72 -0
- package/lib/gate-result-protection.ts +437 -0
- package/lib/generators/code-map.ts +55 -4
- package/lib/generators/types.ts +27 -1
- package/lib/intake-sources.ts +380 -0
- package/lib/js-top-level-code.ts +20 -2
- package/lib/junit-checks.ts +239 -1
- package/lib/late-env-spawn.ts +331 -0
- package/lib/launch-base.ts +128 -5
- package/lib/package-closure.ts +114 -0
- package/lib/paths.ts +96 -3
- package/lib/phase2-decomposition.ts +1 -1
- package/lib/published-artifact.ts +162 -18
- package/lib/sc-id-cross-tree.ts +84 -8
- package/lib/scaffold/ai-review-findings.ts +149 -4
- package/lib/scaffold/ai-review-step.ts +1006 -132
- package/lib/scaffold/defaults.ts +82 -1
- package/lib/scaffold/steps.ts +642 -54
- package/lib/scanner.ts +4 -2
- package/lib/security-verdict.ts +1 -1
- package/lib/shell-path-interpolation.ts +594 -0
- package/lib/text-dependents.ts +875 -0
- package/lib/transcript-checker.ts +6 -0
- package/lib/workflow-security.ts +29 -0
- package/lib/workflow-taint.ts +732 -0
- package/lib/worktree-cleanup.ts +65 -38
- package/lib/worktree-repo.ts +32 -2
- package/package.json +4 -1
- package/scripts/check-installed-hook-currency.ts +825 -0
- package/scripts/generate-code-map.ts +13 -8
|
@@ -33,6 +33,27 @@
|
|
|
33
33
|
* how a consumer opts in, and it is matched against the exact string `true`
|
|
34
34
|
* — not `TRUE`, not `1`, not a prefix. A loose reading of a variable that
|
|
35
35
|
* turns a gate on is a gate that turns itself on by accident.
|
|
36
|
+
*
|
|
37
|
+
* ## The flag's remit, and where it stops (#1180)
|
|
38
|
+
*
|
|
39
|
+
* That paragraph is about a tree with NO CREDENTIAL. It was also, until
|
|
40
|
+
* #1180, the only thing standing between a green check and a review that
|
|
41
|
+
* never ran: every unmeasured state consulted the flag and exited 0 when it
|
|
42
|
+
* was unset, and on this repository it has never been set. `ai-review`
|
|
43
|
+
* reported SUCCESS in 14 seconds on PR #1154 having read nothing, as one of
|
|
44
|
+
* two required checks on an auto-merging repository.
|
|
45
|
+
*
|
|
46
|
+
* The split is now by whether a review was ATTEMPTED:
|
|
47
|
+
*
|
|
48
|
+
* * **No credential, or no mode at all** — nothing was attempted. The flag
|
|
49
|
+
* still decides, unchanged, for the reason above.
|
|
50
|
+
* * **A credential resolved and the action ran** — something was attempted
|
|
51
|
+
* and produced no payload. That FAILS on every tree, with no flag.
|
|
52
|
+
*
|
|
53
|
+
* The pull request this is guaranteed to catch is the one that EDITS this
|
|
54
|
+
* workflow, which the action refuses to review — the change most likely to
|
|
55
|
+
* need a review was the change silently exempt from it.
|
|
56
|
+
* `AI_REVIEW_OVERRIDE_LABEL` keeps that from being a lockout.
|
|
36
57
|
*/
|
|
37
58
|
|
|
38
59
|
/**
|
|
@@ -189,6 +210,40 @@ export const AI_REVIEW_REQUIRE_VAR = "RUNGATE_REQUIRE_AI_REVIEW";
|
|
|
189
210
|
/** The exact value of that variable which turns the refusal on. */
|
|
190
211
|
export const AI_REVIEW_REQUIRE_VALUE = "true";
|
|
191
212
|
|
|
213
|
+
/**
|
|
214
|
+
* The pull-request label that waives a no-payload refusal, for ONE pull
|
|
215
|
+
* request, on the record (#1180).
|
|
216
|
+
*
|
|
217
|
+
* **Why a waiver has to exist.** The refusal is unconditional, and the action
|
|
218
|
+
* refuses to run when `AI_REVIEW_WORKFLOW_FILE` differs from the copy on the
|
|
219
|
+
* default branch — so a pull request that edits the workflow produces no
|
|
220
|
+
* payload by design. With `enforce_admins` on, no waiver means the one file
|
|
221
|
+
* the gate depends on can never be changed again, including to fix it.
|
|
222
|
+
*
|
|
223
|
+
* **Why a label and not a variable.** The state #1180 is about is a gate whose
|
|
224
|
+
* safety depends on a repository variable nobody set; a second variable is the
|
|
225
|
+
* same shape, a standing bypass no pull request has to mention. A label is
|
|
226
|
+
* scoped to one pull request, carries the account that applied it in the
|
|
227
|
+
* timeline, and is named in the annotation — so "waived" and "passed" are
|
|
228
|
+
* different sentences in the check output. Applying it needs write access,
|
|
229
|
+
* which a fork contributor does not have.
|
|
230
|
+
*
|
|
231
|
+
* **Why `contains()` and not a parse.** The runner evaluates the filter before
|
|
232
|
+
* the step starts and binds the literal `true` or `false`, so the bash side is
|
|
233
|
+
* the exact-string compare `AI_REVIEW_REQUIRE_VAR` already uses and no label
|
|
234
|
+
* text reaches the runner. Reading `GITHUB_EVENT_PATH` instead would put the
|
|
235
|
+
* pull request's own title and body — which the branch under review controls —
|
|
236
|
+
* in front of a text match that waives the review. On an event with no pull
|
|
237
|
+
* request the filter yields nothing and `contains` yields `false`.
|
|
238
|
+
*/
|
|
239
|
+
export const AI_REVIEW_OVERRIDE_LABEL = "ai-review-override";
|
|
240
|
+
|
|
241
|
+
/** The environment variable the label reading is bound to. */
|
|
242
|
+
export const AI_REVIEW_OVERRIDE_VAR = "AI_REVIEW_OVERRIDE";
|
|
243
|
+
|
|
244
|
+
/** The exact value of that variable which waives the refusal. */
|
|
245
|
+
export const AI_REVIEW_OVERRIDE_VALUE = "true";
|
|
246
|
+
|
|
192
247
|
/** The step's `id:`, so a later step can read `steps.<id>.outputs.mode`. */
|
|
193
248
|
export const AI_REVIEW_AUTH_STEP_ID = "ai-review-auth";
|
|
194
249
|
|
|
@@ -209,10 +264,9 @@ export const AI_REVIEW_JOB = "ai-review";
|
|
|
209
264
|
/**
|
|
210
265
|
* Whether anything in the generated job READS the findings payload (#675).
|
|
211
266
|
*
|
|
212
|
-
* `
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* is a green check.
|
|
267
|
+
* `true` since #1013, and the one position that says so. The verdict step's
|
|
268
|
+
* success branch runs `AI_REVIEW_FINDINGS_COMMAND` over the payload and exits
|
|
269
|
+
* on what it returns, so a blocking finding fails the check.
|
|
216
270
|
*
|
|
217
271
|
* It is a constant rather than two sentences because two places describe this
|
|
218
272
|
* state: `buildReviewRunScript`'s warning, which tells an operator mid-run,
|
|
@@ -222,16 +276,113 @@ export const AI_REVIEW_JOB = "ai-review";
|
|
|
222
276
|
* enforcement over a job that has none. `test/ai-review-outcomes-header.test.ts`
|
|
223
277
|
* holds them to this.
|
|
224
278
|
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
279
|
+
* It does NOT claim the adjudicator ran on any particular runner. That is a
|
|
280
|
+
* per-run reading, and the step takes it per run — see
|
|
281
|
+
* `AI_REVIEW_OUTCOME_LINE`.
|
|
227
282
|
*/
|
|
228
|
-
export const AI_REVIEW_FINDINGS_ADJUDICATED =
|
|
283
|
+
export const AI_REVIEW_FINDINGS_ADJUDICATED = true;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The npm package the generated job fetches the adjudicator from (#1013).
|
|
287
|
+
*
|
|
288
|
+
* The job runs `bunx <package>@<generating version> <command> <payload>` and
|
|
289
|
+
* nothing else. Three routes to running the reader were measured on #1013 and
|
|
290
|
+
* this is the only one that is not a security regression:
|
|
291
|
+
*
|
|
292
|
+
* - `bun install` from the checkout executes the pull request's own dependency
|
|
293
|
+
* graph in a job holding `id-token: write`. `ai-review-restore-untrusted`
|
|
294
|
+
* restores nine paths from the base and `package.json`/`bun.lock` are not
|
|
295
|
+
* among them, and `--ignore-scripts` does not help when the next line runs
|
|
296
|
+
* `node_modules/.bin/rungate`, which that manifest names.
|
|
297
|
+
* - `bun bin/rungate.ts` from the checkout runs the branch's own code in the
|
|
298
|
+
* one job whose design is that the reviewer READS the branch.
|
|
299
|
+
* - `bunx <package>@<version>` reads no consumer manifest, writes no
|
|
300
|
+
* `node_modules` into the workspace, and names its version in the generated
|
|
301
|
+
* file, so it cannot drift without the file changing.
|
|
302
|
+
*
|
|
303
|
+
* The version is the GENERATING version, passed in rather than read here —
|
|
304
|
+
* this module has no relative imports (see `AiReviewActionRefs`). A tree whose
|
|
305
|
+
* version is not yet on the registry emits a command that cannot resolve, and
|
|
306
|
+
* that is the same correct-but-not-yet-resolvable output `harnessDevDepRange`
|
|
307
|
+
* in `lib/scaffold/steps.ts` has emitted since #364. It is not silent: a
|
|
308
|
+
* command that could not run produces no `AI_REVIEW_OUTCOME_LINE`, and the
|
|
309
|
+
* step reports UNMEASURED rather than reading the exit code as a verdict.
|
|
310
|
+
*/
|
|
311
|
+
export const AI_REVIEW_ADJUDICATOR_PACKAGE = "rungate";
|
|
312
|
+
|
|
313
|
+
/** The subcommand inside it. Registered in `lib/cli-commands.ts`. */
|
|
314
|
+
export const AI_REVIEW_FINDINGS_COMMAND = "ai-review-findings";
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The line the adjudicator prints BEFORE it decides anything — the proof that
|
|
318
|
+
* it ran at all (#1013).
|
|
319
|
+
*
|
|
320
|
+
* The exit code cannot carry that proof. `AI_REVIEW_REQUIRED_EXIT` is `1`, and
|
|
321
|
+
* so is a `bunx` that could not resolve the package, a `bun` that is not on the
|
|
322
|
+
* runner, and a dispatcher that threw. Reading `1` as "the review refused"
|
|
323
|
+
* makes an UNINSTALLABLE adjudicator indistinguishable from a blocking finding,
|
|
324
|
+
* and the obvious repair for a check that fails on every pull request is to
|
|
325
|
+
* delete it. So the step requires this line in the output before it treats the
|
|
326
|
+
* exit code as a verdict, and reports UNMEASURED when it is absent.
|
|
327
|
+
*
|
|
328
|
+
* Declared here and imported by `./ai-review-findings`, which prints it, so the
|
|
329
|
+
* printer and the bash that greps for it are one string. Two spellings that
|
|
330
|
+
* agree today is #295: the reader asked for a key no writer produced, every run
|
|
331
|
+
* came back empty, and empty read as clean.
|
|
332
|
+
*/
|
|
333
|
+
export const AI_REVIEW_OUTCOME_LINE = "ai-review findings outcome:";
|
|
229
334
|
|
|
230
335
|
export const AI_REVIEW_AUTH_STEP_NAME = "Detect AI review credentials";
|
|
231
336
|
|
|
232
337
|
/** The annotation title, shared by the warning and the refusal. */
|
|
233
338
|
export const AI_REVIEW_UNMEASURED_TITLE = "AI review UNMEASURED";
|
|
234
339
|
|
|
340
|
+
/**
|
|
341
|
+
* The title carried by a run that was UNMEASURED and passed anyway, because
|
|
342
|
+
* `AI_REVIEW_OVERRIDE_LABEL` was on the pull request (#1180).
|
|
343
|
+
*
|
|
344
|
+
* Its own title: a waived run is a THIRD state, green like CLEAN and measured
|
|
345
|
+
* like neither, and #1180 asks that a reader of the check list can tell them
|
|
346
|
+
* apart. Sharing the UNMEASURED title would make the waiver the one transition
|
|
347
|
+
* in this job with no name of its own.
|
|
348
|
+
*/
|
|
349
|
+
export const AI_REVIEW_WAIVED_TITLE = "AI review WAIVED";
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* The title that says a review was READ, carried by the one branch that can
|
|
353
|
+
* only be reached by reading one (#1087).
|
|
354
|
+
*
|
|
355
|
+
* Everything else this step emits is an absence. A green `ai-review` meant
|
|
356
|
+
* "no `AI_REVIEW_UNMEASURED_TITLE` warning came back", and absence is the
|
|
357
|
+
* weakest evidence this file accepts anywhere else — it is the Silent Default
|
|
358
|
+
* Substitution the module header is about, applied to the gate's own result.
|
|
359
|
+
* Three conditions emit that title (the report step, #989's restored-base
|
|
360
|
+
* reading, and whatever is split off next), #1110 showed a state that emits
|
|
361
|
+
* NO annotation at all, and a skipped action emits none either. So the
|
|
362
|
+
* absence has at least four causes and cannot be read backwards into "a
|
|
363
|
+
* review happened".
|
|
364
|
+
*
|
|
365
|
+
* Measured over the 22 `ai-review` runs that completed between #1076 merging
|
|
366
|
+
* at 01:54:48Z and 03:09:36Z on 2026-10-22: **22 green, 9 adjudicated, 8
|
|
367
|
+
* skipped by the action's workflow validation, 5 green with neither** — and
|
|
368
|
+
* telling those apart took a full log download per run plus a regex on the
|
|
369
|
+
* timestamped line, because `gh run view --log` echoes the whole `run:`
|
|
370
|
+
* script and an unfiltered grep finds every branch that did NOT execute. The
|
|
371
|
+
* fleet query in #1087 counted that echo twice before this was noticed.
|
|
372
|
+
*
|
|
373
|
+
* A `::notice` is the cheapest thing that is readable from outside the job:
|
|
374
|
+
* it lands in `check-runs/<id>/annotations` beside the conclusion, which is
|
|
375
|
+
* what a required check's consumers already read. With it, green-plus-this
|
|
376
|
+
* is an adjudicated CLEAN, green-without is a review that did not happen,
|
|
377
|
+
* red-plus-this is a verdict, and red-without is a job that broke before the
|
|
378
|
+
* verdict — four states, no log parsing.
|
|
379
|
+
*
|
|
380
|
+
* Distinct from `AI_REVIEW_UNMEASURED_TITLE` and not a substring of it in
|
|
381
|
+
* either direction, for the reason #1105 gave: a reader that greps titles
|
|
382
|
+
* conflates a title that contains another.
|
|
383
|
+
*/
|
|
384
|
+
export const AI_REVIEW_ADJUDICATED_TITLE = "AI review adjudicated";
|
|
385
|
+
|
|
235
386
|
/** The reporting step's `id:`. Separate from the auth step, so each has one job. */
|
|
236
387
|
export const AI_REVIEW_RUN_STEP_ID = "ai-review-run";
|
|
237
388
|
|
|
@@ -730,6 +881,30 @@ export interface AiReviewActionRefs {
|
|
|
730
881
|
auth: string;
|
|
731
882
|
/** `actionRef("anthropics/claude-code-action")`, declared by `lib/claude-code-action.ts`. */
|
|
732
883
|
review: string;
|
|
884
|
+
/**
|
|
885
|
+
* `actionRef("oven-sh/setup-bun")` from `lib/workflow-actions.ts` (#1013).
|
|
886
|
+
*
|
|
887
|
+
* The adjudicator is `bunx`, and a GitHub-hosted runner has no bun. The
|
|
888
|
+
* step that installs it is the only thing standing between a consumer's
|
|
889
|
+
* first scaffold and an adjudication that silently cannot start.
|
|
890
|
+
*/
|
|
891
|
+
setupBun: string;
|
|
892
|
+
/**
|
|
893
|
+
* That step's `with:` body, from `setupBunWith(declaredBunVersion(root))`.
|
|
894
|
+
*
|
|
895
|
+
* Rendered by the caller rather than here, and NOT optional. #622: the bun
|
|
896
|
+
* version had four positions and three spellings, and `lib/bun-version.ts`
|
|
897
|
+
* is now the single declaration every generated `setup-bun` resolves from —
|
|
898
|
+
* `test/bun-version-agreement.test.ts` AC-3 and
|
|
899
|
+
* `test/bun-version-moving-tag.test.ts` count the steps under
|
|
900
|
+
* `.github/workflows` and refuse one that names a version of its own, or
|
|
901
|
+
* none at all. A step emitted here without it is that defect reinstated in
|
|
902
|
+
* the one job that cannot afford a runtime surprise.
|
|
903
|
+
*
|
|
904
|
+
* Indented for the step body as the builder writes it — the whole block is
|
|
905
|
+
* re-indented by `indent` on the way out, like every script above.
|
|
906
|
+
*/
|
|
907
|
+
setupBunWith: string;
|
|
733
908
|
}
|
|
734
909
|
|
|
735
910
|
/**
|
|
@@ -940,10 +1115,30 @@ export const AI_REVIEW_FINDINGS_PATH_VAR = "AI_REVIEW_FINDINGS_PATH";
|
|
|
940
1115
|
*/
|
|
941
1116
|
export const AI_REVIEW_EXECUTION_FILE_VAR = "AI_REVIEW_EXECUTION_FILE";
|
|
942
1117
|
|
|
1118
|
+
/**
|
|
1119
|
+
* The execution file's denial counter, as the report step matches it (#1087).
|
|
1120
|
+
*
|
|
1121
|
+
* One spelling, because the route block greps it three times — for the key's
|
|
1122
|
+
* presence, for a zero, and implicitly for everything else — and three
|
|
1123
|
+
* literals would be three things to get subtly out of step with each other.
|
|
1124
|
+
*
|
|
1125
|
+
* It is the pinned action's own field name, written by the SDK into the file
|
|
1126
|
+
* `setExecutionFileOutputIfPresent` names. Matched as TEXT rather than parsed,
|
|
1127
|
+
* for the reason the turn-budget branch beside it states: a runner is not
|
|
1128
|
+
* guaranteed `jq`, and the cost of a false match here is a different
|
|
1129
|
+
* explanatory sentence, never a different exit code.
|
|
1130
|
+
*/
|
|
1131
|
+
export const AI_REVIEW_DENIALS_KEY = "permission_denials_count";
|
|
1132
|
+
|
|
943
1133
|
export const AI_REVIEW_PREPARE_STEP_ID = "ai-review-prepare";
|
|
944
1134
|
|
|
945
1135
|
export const AI_REVIEW_PREPARE_STEP_NAME = "Choose a findings path outside the checkout";
|
|
946
1136
|
|
|
1137
|
+
/** The step that puts `bunx` on the runner, so the verdict can adjudicate (#1013). */
|
|
1138
|
+
export const AI_REVIEW_SETUP_BUN_STEP_ID = "ai-review-setup-bun";
|
|
1139
|
+
|
|
1140
|
+
export const AI_REVIEW_SETUP_BUN_STEP_NAME = "Install bun for the findings adjudicator";
|
|
1141
|
+
|
|
947
1142
|
/** The basename, nonce aside. One spelling, so the glob and the write agree. */
|
|
948
1143
|
export const AI_REVIEW_FINDINGS_BASENAME = "ai-review-findings";
|
|
949
1144
|
|
|
@@ -1719,6 +1914,58 @@ export const AI_REVIEW_RUNTIME_CONFIG_UNMEASURED =
|
|
|
1719
1914
|
`This run is UNMEASURED at these paths, which is not the same as a run ` +
|
|
1720
1915
|
`in which the reviewer did not write to them. Paths`;
|
|
1721
1916
|
|
|
1917
|
+
/**
|
|
1918
|
+
* The annotation title the reading above carries, and why it is NOT
|
|
1919
|
+
* `AI_REVIEW_UNMEASURED_TITLE` (#1087).
|
|
1920
|
+
*
|
|
1921
|
+
* ## The measurement that went wrong
|
|
1922
|
+
*
|
|
1923
|
+
* Two steps emitted one title. The report step says `AI review UNMEASURED`
|
|
1924
|
+
* when it cannot say a review happened at all; the drift step said the same
|
|
1925
|
+
* words about a run in which the review DID happen, was adjudicated, and one
|
|
1926
|
+
* named sub-reading — the runtime's own config under `$HOME` — could not be
|
|
1927
|
+
* taken. Those are not the same claim and only one of them is about whether
|
|
1928
|
+
* the pull request was reviewed.
|
|
1929
|
+
*
|
|
1930
|
+
* The consequence was a fleet query, run over this repository's own history:
|
|
1931
|
+
*
|
|
1932
|
+
* ```
|
|
1933
|
+
* gh api repos/<o>/<r>/check-runs/$JID/annotations \
|
|
1934
|
+
* --jq '[.[]|select(.title=="AI review UNMEASURED")]|length'
|
|
1935
|
+
* → of 30 most recent GREEN ai-review runs: real=0 unmeasured=30
|
|
1936
|
+
* ```
|
|
1937
|
+
*
|
|
1938
|
+
* read as "0 of 30 green runs produced a review". Classifying the same runs
|
|
1939
|
+
* by MESSAGE instead of title: 29 of 40 were this reading, and 17 of them had
|
|
1940
|
+
* written a real findings payload. The three newest carried `ai-review
|
|
1941
|
+
* findings outcome: CLEAN` beside the annotation that was being counted as
|
|
1942
|
+
* its absence. The gate was working and the count said it had never run.
|
|
1943
|
+
*
|
|
1944
|
+
* ## Why a title and not a level
|
|
1945
|
+
*
|
|
1946
|
+
* Both readings are `::warning`, both exit 0, and neither should change: the
|
|
1947
|
+
* runtime-config blind spot is real and naming it is #871's whole point.
|
|
1948
|
+
* Nothing here is quieter than it was — the message is unchanged, the
|
|
1949
|
+
* annotation still appears on every run that earns it. What changes is that a
|
|
1950
|
+
* reader counting one title is no longer counting the other.
|
|
1951
|
+
*
|
|
1952
|
+
* ## The boundary, stated, because the next reading has to pick a side
|
|
1953
|
+
*
|
|
1954
|
+
* This title is for "the review happened and a NAMED sub-reading could not be
|
|
1955
|
+
* taken". `AI_REVIEW_UNMEASURED_TITLE` stays on everything that means "this
|
|
1956
|
+
* job cannot say a review happened" — including the drift step's own
|
|
1957
|
+
* no-usable-`$HOME` branch, which is unmeasured about the reviewer rather
|
|
1958
|
+
* than about a path list, and keeps the original title for exactly that
|
|
1959
|
+
* reason.
|
|
1960
|
+
*
|
|
1961
|
+
* It does not contain `AI_REVIEW_UNMEASURED_TITLE` as a substring, so a
|
|
1962
|
+
* reader who greps rather than compares is separated too. That is deliberate
|
|
1963
|
+
* and `test/ai-review-outside-reading.test.ts` asserts it, because a title
|
|
1964
|
+
* that merely extends the other would read as fixed while leaving every
|
|
1965
|
+
* `grep -c` in the same state.
|
|
1966
|
+
*/
|
|
1967
|
+
export const AI_REVIEW_RUNTIME_CONFIG_TITLE = "AI review runtime config UNMEASURED";
|
|
1968
|
+
|
|
1722
1969
|
/**
|
|
1723
1970
|
* The reviewer's turn budget. One declaring position; see `aiReviewClaudeArgs`.
|
|
1724
1971
|
*
|
|
@@ -2069,7 +2316,7 @@ export function buildOutcomesHeader(
|
|
|
2069
2316
|
const unenforced = adjudicated
|
|
2070
2317
|
? ""
|
|
2071
2318
|
: `#\n# NOT YET: the first outcome is not enforced. The findings reader exists\n` +
|
|
2072
|
-
`# and is reachable as \`rungate ${
|
|
2319
|
+
`# and is reachable as \`rungate ${AI_REVIEW_FINDINGS_COMMAND}\`, and no step in this job runs\n` +
|
|
2073
2320
|
`# it (#675) — so a blocking finding is reported in the comments and the\n` +
|
|
2074
2321
|
`# check is green. The job says so on every run rather than exiting 0 in\n` +
|
|
2075
2322
|
`# silence; "reviewed, and nobody read the result" is its own state.\n`;
|
|
@@ -2124,6 +2371,14 @@ export function aiReviewScaffoldAction(vertex: VertexCiDecision): string {
|
|
|
2124
2371
|
* safe because every variable is read through `${X:-}` — an unset GitHub
|
|
2125
2372
|
* secret interpolates to the empty string, so absent and empty have to be the
|
|
2126
2373
|
* same case anyway.
|
|
2374
|
+
*
|
|
2375
|
+
* "No `set -e`" describes what this generator WRITES, not the shell the step
|
|
2376
|
+
* RUNS IN (#1110). GitHub's default for a `run:` step is `/usr/bin/bash -e
|
|
2377
|
+
* {0}`, so `-e` is on in every generated step whether or not the text says
|
|
2378
|
+
* so. A condition is unaffected — `-e` does not fire inside `if`, `&&`, `||`
|
|
2379
|
+
* or `!` — but a standalone statement that may exit non-zero is a shell that
|
|
2380
|
+
* dies there. `buildReviewRunScript`'s adjudication is the one such statement
|
|
2381
|
+
* in this file and it carries the full account.
|
|
2127
2382
|
*/
|
|
2128
2383
|
export function buildAuthDetectScript(vertex: VertexCiDecision): string {
|
|
2129
2384
|
// Vertex is a GENERATED LITERAL, not a runtime reading. The provider is
|
|
@@ -2375,6 +2630,13 @@ Every one of those member names is required on every finding. A finding
|
|
|
2375
2630
|
missing \`${f.file}\` or \`${f.summary}\` reaches a maintainer as an annotation
|
|
2376
2631
|
naming no code and no defect, which is the same as not reporting it.
|
|
2377
2632
|
|
|
2633
|
+
On a finding whose severity BLOCKS, that requirement is now read back and
|
|
2634
|
+
enforced: a blocking finding missing any of \`${f.file}\`, \`${f.line}\`,
|
|
2635
|
+
\`${f.summary}\` or \`${f.failureScenario}\` — absent, null or blank — makes the
|
|
2636
|
+
whole review unreadable and fails the job as UNMEASURED. So do not raise a
|
|
2637
|
+
finding to ${blocking} unless you can name the file and the line it is on.
|
|
2638
|
+
Say it at a non-blocking severity instead, or read further until you can.
|
|
2639
|
+
|
|
2378
2640
|
Rules for the payload, each of which a later step enforces:
|
|
2379
2641
|
|
|
2380
2642
|
- Severities ${blocking} block the pull request. Severities ${passive} do not.
|
|
@@ -2517,7 +2779,47 @@ export const AI_REVIEW_APP_INSTALL_CAUSE =
|
|
|
2517
2779
|
`${AI_REVIEW_APP_INSTALL_URL} and re-run. This job cannot read that log, ` +
|
|
2518
2780
|
`so it is naming a likely cause and not reporting a measured one.`;
|
|
2519
2781
|
|
|
2520
|
-
|
|
2782
|
+
/**
|
|
2783
|
+
* The step that says which of the states above this run is in.
|
|
2784
|
+
*
|
|
2785
|
+
* ## Reading the log these messages send you to, without being lied to (#1087)
|
|
2786
|
+
*
|
|
2787
|
+
* Several routes here end in "search the step's log for X". Whoever follows
|
|
2788
|
+
* that instruction will reach for:
|
|
2789
|
+
*
|
|
2790
|
+
* ```
|
|
2791
|
+
* gh run view <id> -R <owner>/<repo> --log
|
|
2792
|
+
* ```
|
|
2793
|
+
*
|
|
2794
|
+
* and that output contains **every branch of every `if` in this file**,
|
|
2795
|
+
* whether or not it ran. The runner echoes each step's whole script back
|
|
2796
|
+
* before executing it, one line at a time, each prefixed with a literal
|
|
2797
|
+
* `^[[36;1m` (ESC `[36;1m`, cyan). So an unfiltered `grep` over it reports
|
|
2798
|
+
* code as though it were output: grepping for `mode=none` returns a hit on
|
|
2799
|
+
* every run, because the line is in the script that prints `mode=vertex`.
|
|
2800
|
+
*
|
|
2801
|
+
* Filter the echo before reading anything:
|
|
2802
|
+
*
|
|
2803
|
+
* ```
|
|
2804
|
+
* gh run view <id> -R <o>/<r> --log | perl -ne 'print unless /\Q^[[36;1m\E/'
|
|
2805
|
+
* ```
|
|
2806
|
+
*
|
|
2807
|
+
* Note the `^[` there is two literal characters in the downloaded bytes, not
|
|
2808
|
+
* an escape — `grep -F $'\e[36;1m'` matches nothing against it, which is the
|
|
2809
|
+
* failure that looks like "the filter is not needed".
|
|
2810
|
+
*
|
|
2811
|
+
* This cost two readers of #1087 a wrong conclusion each: one relayed
|
|
2812
|
+
* `mode=none` as a missing credential off an echoed line, and one spent a
|
|
2813
|
+
* pass reading the generated script as though it were the run. It is written
|
|
2814
|
+
* here rather than in a rules file because the people who hit it are the
|
|
2815
|
+
* people these annotations have just sent to the log.
|
|
2816
|
+
*/
|
|
2817
|
+
export function buildReviewRunScript(version: string): string {
|
|
2818
|
+
// The exact command the success branch runs. Built here so the comments
|
|
2819
|
+
// below and the bash are one string, and so a test can name it.
|
|
2820
|
+
const adjudicator =
|
|
2821
|
+
`bunx ${AI_REVIEW_ADJUDICATOR_PACKAGE}@${version} ${AI_REVIEW_FINDINGS_COMMAND}`;
|
|
2822
|
+
|
|
2521
2823
|
// The DECLINED route, and the only one of the five below on which the
|
|
2522
2824
|
// app-install cause can be true: no execution file means the action never
|
|
2523
2825
|
// got far enough to write one (#826).
|
|
@@ -2541,15 +2843,23 @@ export function buildReviewRunScript(): string {
|
|
|
2541
2843
|
// asserted the opposite without stat'ing the path — this branch is reached
|
|
2542
2844
|
// before the success branch's `-s` test, so nothing had ever looked. The
|
|
2543
2845
|
// verdict does not soften: an action that did not complete has not produced
|
|
2544
|
-
// a review whose payload can be trusted
|
|
2846
|
+
// a review whose payload can be trusted.
|
|
2847
|
+
//
|
|
2848
|
+
// The adjudicator is NOT run here, and that is deliberate (#1013). It
|
|
2849
|
+
// adjudicates a COMPLETED review; a payload left behind by an action that
|
|
2850
|
+
// died is a partial document, and reading it would turn "the review was cut
|
|
2851
|
+
// short" into "the review found nothing" — a half-written findings array is
|
|
2852
|
+
// indistinguishable from a clean one.
|
|
2545
2853
|
const pendingPayload =
|
|
2546
2854
|
`The review action (#631) did not complete, and yet a findings payload ` +
|
|
2547
2855
|
`IS present at the path this job gave the reviewer. So the reviewer ran ` +
|
|
2548
2856
|
`and wrote a result, and the action failed around it. The payload is NOT ` +
|
|
2549
|
-
`adjudicated —
|
|
2550
|
-
`
|
|
2551
|
-
`
|
|
2552
|
-
`
|
|
2857
|
+
`adjudicated — the adjudicator reads a review that COMPLETED, and a ` +
|
|
2858
|
+
`partially written findings list is indistinguishable from a clean one — ` +
|
|
2859
|
+
`and a run whose action did not complete is not a run whose review can ` +
|
|
2860
|
+
`be trusted to be whole. Read the execution file and the action's own log ` +
|
|
2861
|
+
`before treating that file as a verdict. This check is UNMEASURED, not a ` +
|
|
2862
|
+
`passing review.`;
|
|
2553
2863
|
|
|
2554
2864
|
// The measured overshoot. `base-action/src/run-claude-sdk.ts` at the pinned
|
|
2555
2865
|
// SHA writes the execution file at `:222` and only then throws at `:249`
|
|
@@ -2595,33 +2905,102 @@ export function buildReviewRunScript(): string {
|
|
|
2595
2905
|
`beyond that this job cannot say which route produced the failure. This ` +
|
|
2596
2906
|
`check is UNMEASURED, not a passing review.`;
|
|
2597
2907
|
|
|
2908
|
+
// #1180, and unconditional for the same reason `skippedRefusal` is. This
|
|
2909
|
+
// branch is further from a pass than that one — the action did not even
|
|
2910
|
+
// exit zero — so a tree on which the payload-less SUCCESS fails and the
|
|
2911
|
+
// payload-less FAILURE passes would be refusing the better-behaved of two
|
|
2912
|
+
// identical outcomes.
|
|
2598
2913
|
const refusal =
|
|
2599
|
-
|
|
2600
|
-
`
|
|
2601
|
-
`
|
|
2602
|
-
`
|
|
2914
|
+
`The review action (#631) did not complete, so this pull request has no ` +
|
|
2915
|
+
`AI review. Failing rather than reporting a green check for a review ` +
|
|
2916
|
+
`that never happened. This refusal does NOT consult ` +
|
|
2917
|
+
`${AI_REVIEW_REQUIRE_VAR} — that flag is for a tree with no credential, ` +
|
|
2918
|
+
`and a credential resolved here (#1180). Read the route above for what ` +
|
|
2919
|
+
`the action got as far as doing; label the pull request ` +
|
|
2920
|
+
`'${AI_REVIEW_OVERRIDE_LABEL}' to waive this ONE check on the record if ` +
|
|
2921
|
+
`a human is going to read the diff instead.`;
|
|
2922
|
+
|
|
2923
|
+
const waived =
|
|
2924
|
+
`This pull request carries the '${AI_REVIEW_OVERRIDE_LABEL}' label, so ` +
|
|
2925
|
+
`the refusal above is WAIVED and this check passes having measured ` +
|
|
2926
|
+
`nothing. The review action did not complete; no AI review was read on ` +
|
|
2927
|
+
`this pull request and this is not one. A human applied the label and ` +
|
|
2928
|
+
`the pull request's timeline records which account and when. Remove the ` +
|
|
2929
|
+
`label to put the refusal back.`;
|
|
2603
2930
|
|
|
2604
2931
|
// The third state, and the one most easily mistaken for a pass: the
|
|
2605
|
-
// reviewer ran, wrote a payload, and
|
|
2606
|
-
//
|
|
2607
|
-
//
|
|
2608
|
-
//
|
|
2932
|
+
// reviewer ran, wrote a payload, and the ADJUDICATOR could not run over it
|
|
2933
|
+
// (#1013). Not "nobody wired it" — the command is right there in the step —
|
|
2934
|
+
// but "the command this step named produced no reading".
|
|
2935
|
+
//
|
|
2936
|
+
// It is a distinct state from every other UNMEASURED here, and the
|
|
2937
|
+
// discriminator is `${AI_REVIEW_OUTCOME_LINE}` rather than the exit code:
|
|
2938
|
+
// `${AI_REVIEW_REQUIRED_EXIT}` is 1 and so is a `bunx` that could not
|
|
2939
|
+
// resolve the package, so the code alone cannot tell a refusal from a
|
|
2940
|
+
// command that never started.
|
|
2941
|
+
//
|
|
2942
|
+
// **IT FAILS, and it does not consult ${AI_REVIEW_REQUIRE_VAR}.** The first
|
|
2943
|
+
// cut of #1013 ran this through that flag like every other unmeasured state
|
|
2944
|
+
// in the file, and that was wrong in a way worth writing down, because the
|
|
2945
|
+
// flag reads as if it covers this.
|
|
2609
2946
|
//
|
|
2610
|
-
//
|
|
2611
|
-
//
|
|
2612
|
-
//
|
|
2613
|
-
//
|
|
2947
|
+
// What the flag is for is a tree that has NEVER CONFIGURED A CREDENTIAL:
|
|
2948
|
+
// nothing was attempted, nobody promised a review, and
|
|
2949
|
+
// `.claude/rules/config-access.md` argues — correctly — that a first
|
|
2950
|
+
// scaffold should say so rather than go red. That reasoning does not reach
|
|
2951
|
+
// here. Reaching this line means the action completed AND a findings
|
|
2952
|
+
// payload is on disk: a review WAS attempted, the reviewer DID write a
|
|
2953
|
+
// result, and the only thing missing is this job's own reading of it. A
|
|
2954
|
+
// payload nobody adjudicated and a payload adjudicated clean are then
|
|
2955
|
+
// indistinguishable from outside the job — which is a green required check
|
|
2956
|
+
// over an unread `critical`, the exact state #1013 exists to end.
|
|
2957
|
+
//
|
|
2958
|
+
// The cost of failing closed is named rather than waved at: a registry
|
|
2959
|
+
// outage reds every pull request in the repository until it clears. That is
|
|
2960
|
+
// the right direction for a REQUIRED check — "I could not measure" is a
|
|
2961
|
+
// failure, not a pass — and the annotation names the cause precisely so an
|
|
2962
|
+
// operator can tell an outage from their own code. The argument for warning
|
|
2963
|
+
// instead was that a check which is red on every pull request gets deleted;
|
|
2964
|
+
// that argument proves too much, because it is an argument against ever
|
|
2965
|
+
// failing closed.
|
|
2614
2966
|
const unadjudicated =
|
|
2615
|
-
`The AI review completed and wrote a findings payload,
|
|
2616
|
-
`
|
|
2617
|
-
`
|
|
2618
|
-
`
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
`
|
|
2623
|
-
`
|
|
2624
|
-
`
|
|
2967
|
+
`The AI review completed and wrote a findings payload, and the step that ` +
|
|
2968
|
+
`adjudicates it produced no reading: '${adjudicator}' printed no ` +
|
|
2969
|
+
`'${AI_REVIEW_OUTCOME_LINE}' line, so it did not run. The payload is ` +
|
|
2970
|
+
`therefore UNMEASURED — not clean. Failing rather than reporting a green ` +
|
|
2971
|
+
`check for a review whose findings nobody read; a blocking finding and an ` +
|
|
2972
|
+
`adjudication that never happened look identical from outside this job. ` +
|
|
2973
|
+
`This is NOT the ${AI_REVIEW_REQUIRE_VAR} case: that flag is for a tree ` +
|
|
2974
|
+
`with no credential, where no review was attempted. One was attempted ` +
|
|
2975
|
+
`here and its result is sitting at the findings path unread. The usual ` +
|
|
2976
|
+
`causes are that ${AI_REVIEW_ADJUDICATOR_PACKAGE}@${version} is not on ` +
|
|
2977
|
+
`the registry, that bun is not on this runner, or that the registry was ` +
|
|
2978
|
+
`unreachable — the command's own output is printed above this line.`;
|
|
2979
|
+
|
|
2980
|
+
// #1087. The sentence that travels with the positive reading. It names what
|
|
2981
|
+
// the ABSENCE of this annotation means, because that is the half a reader
|
|
2982
|
+
// gets wrong: on a green run it was being read as "the review was clean".
|
|
2983
|
+
//
|
|
2984
|
+
// Two words this sentence may not spell, both for reasons older than it:
|
|
2985
|
+
//
|
|
2986
|
+
// - the other title's, because `test/ai-review-workflow.test.ts` AC-9a
|
|
2987
|
+
// asserts a clean adjudication's output contains no "UNMEASURED"
|
|
2988
|
+
// anywhere, and prose here that used the term would make an operator's
|
|
2989
|
+
// `grep` on a green run report a state that did not occur;
|
|
2990
|
+
// - the action's skip sentence unhyphenated, because
|
|
2991
|
+
// `test/ai-review-payload-reading.test.ts` AC-6 refuses that phrase
|
|
2992
|
+
// anywhere in this script — the reading must never depend on upstream
|
|
2993
|
+
// log prose, and the check cannot tell a grep from a mention. `skipped`
|
|
2994
|
+
// above hyphenates for the same reason.
|
|
2995
|
+
const adjudicatedEvidence =
|
|
2996
|
+
`read from the findings payload by '${adjudicator}', whose exit code is ` +
|
|
2997
|
+
`this step's. This annotation is the only one this job emits that an ` +
|
|
2998
|
+
`unread payload cannot produce — the branch is entered on the outcome ` +
|
|
2999
|
+
`line and nothing else — so a run carrying this title had a review AND a ` +
|
|
3000
|
+
`verdict on it. Its ABSENCE on a green run is not a clean review: it ` +
|
|
3001
|
+
`means no payload was written, or the action skipped itself on its own ` +
|
|
3002
|
+
`workflow-validation guard, or the step died before the reading — none ` +
|
|
3003
|
+
`of which measured anything.`;
|
|
2625
3004
|
|
|
2626
3005
|
// The FOURTH state, and the reason the third one had to be split (#816):
|
|
2627
3006
|
// the action exited ZERO having not reviewed anything.
|
|
@@ -2659,11 +3038,35 @@ export function buildReviewRunScript(): string {
|
|
|
2659
3038
|
`adds it, is skipped by design. This check is UNMEASURED, not a passing ` +
|
|
2660
3039
|
`review.`;
|
|
2661
3040
|
|
|
3041
|
+
// #1180. No longer mentions ${AI_REVIEW_REQUIRE_VAR}, because the refusal no
|
|
3042
|
+
// longer consults it — see the module header for the split. #1013's
|
|
3043
|
+
// neighbouring branch already says the half of it that was true then: "a
|
|
3044
|
+
// payload exists, so a review was attempted; nobody read it is a failure on
|
|
3045
|
+
// every tree, not an opt-in". A payload nobody WROTE is the same fact one
|
|
3046
|
+
// state earlier, and this is it.
|
|
2662
3047
|
const skippedRefusal =
|
|
2663
|
-
|
|
2664
|
-
`
|
|
2665
|
-
`
|
|
2666
|
-
`
|
|
3048
|
+
`The review action exited successfully WITHOUT writing a findings ` +
|
|
3049
|
+
`payload, so this pull request has no AI review. Failing rather than ` +
|
|
3050
|
+
`reporting a green check for a review that never ran: a required check ` +
|
|
3051
|
+
`that passes when the reviewer did not run is not a gate. This refusal ` +
|
|
3052
|
+
`does NOT consult ${AI_REVIEW_REQUIRE_VAR} — that flag is for a tree with ` +
|
|
3053
|
+
`no credential, where no review was ATTEMPTED; one was attempted here and ` +
|
|
3054
|
+
`it produced nothing (#1180). If the reviewer declined because this pull ` +
|
|
3055
|
+
`request edits ${AI_REVIEW_WORKFLOW_FILE}, which it refuses to review ` +
|
|
3056
|
+
`against a copy that differs from the default branch, label the pull ` +
|
|
3057
|
+
`request '${AI_REVIEW_OVERRIDE_LABEL}' to waive this ONE check on the ` +
|
|
3058
|
+
`record and have a human read the diff instead.`;
|
|
3059
|
+
|
|
3060
|
+
// The waiver's own sentence: what was waived, and by what. A warning that
|
|
3061
|
+
// does not say what happened is a warning nobody can act on
|
|
3062
|
+
// (`.claude/rules/config-access.md`).
|
|
3063
|
+
const skippedWaived =
|
|
3064
|
+
`This pull request carries the '${AI_REVIEW_OVERRIDE_LABEL}' label, so ` +
|
|
3065
|
+
`the refusal above is WAIVED and this check passes having measured ` +
|
|
3066
|
+
`nothing. The reviewer wrote no findings payload; no AI review was read ` +
|
|
3067
|
+
`on this pull request and this is not one. A human applied the label and ` +
|
|
3068
|
+
`the pull request's timeline records which account and when. Remove the ` +
|
|
3069
|
+
`label to put the refusal back.`;
|
|
2667
3070
|
|
|
2668
3071
|
// #826: WHICH of three routes produced the empty payload, measured.
|
|
2669
3072
|
//
|
|
@@ -2684,15 +3087,52 @@ export function buildReviewRunScript(): string {
|
|
|
2684
3087
|
// what keeps it from being the second decider the comment above declines to
|
|
2685
3088
|
// build, and it is asserted in `test/ai-review-route-reading.test.ts`
|
|
2686
3089
|
// (AC-B5) rather than left as an intention.
|
|
2687
|
-
|
|
3090
|
+
// #1087. The three sentences below replace ONE that guessed. It read
|
|
3091
|
+
// "a reviewer that ran and wrote nothing is usually one that could not
|
|
3092
|
+
// write to the findings path", and the execution files say otherwise:
|
|
3093
|
+
// every cause-B run sampled on this repository reported
|
|
3094
|
+
// `permission_denials_count: 0` — runs 39707821002 (22 turns), 39708155573
|
|
3095
|
+
// (40), 39707657746 (43), 39707621271 (47) and 39708162846 (51). The guess
|
|
3096
|
+
// cost two readers a dead end before anyone stat'ed the number it was
|
|
3097
|
+
// guessing about, which is this file's own standing complaint about a
|
|
3098
|
+
// default substituted for a reading, made about its own prose.
|
|
3099
|
+
//
|
|
3100
|
+
// So the denial count is READ, by the same text match the turn-budget
|
|
3101
|
+
// branch above uses and for the same reason: a runner is not guaranteed
|
|
3102
|
+
// `jq`, and a false match here costs a different explanatory sentence
|
|
3103
|
+
// rather than a different verdict. Three states and not two — a file that
|
|
3104
|
+
// does not carry the key at all is not a file reporting zero, and calling
|
|
3105
|
+
// it zero would be the substitution this branch exists to stop making.
|
|
3106
|
+
const executedNoDenials =
|
|
2688
3107
|
`The review action exited successfully WITHOUT writing a findings ` +
|
|
2689
3108
|
`payload, so no AI review ran on this pull request — and the reviewer ` +
|
|
2690
3109
|
`DID execute: the action wrote an execution file, so this is NOT the ` +
|
|
2691
3110
|
`case where it declined before running, and nothing about the workflow ` +
|
|
2692
|
-
`file is worth checking.
|
|
2693
|
-
`
|
|
2694
|
-
`
|
|
2695
|
-
`
|
|
3111
|
+
`file is worth checking. Its execution file reports ` +
|
|
3112
|
+
`permission_denials_count 0, so the reviewer was never refused a call: ` +
|
|
3113
|
+
`access to the findings path is NOT the cause and reading it as one is a ` +
|
|
3114
|
+
`dead end (#1087). Read the execution file for the turn count and what ` +
|
|
3115
|
+
`the reviewer spent its turns on instead. This check is UNMEASURED, not ` +
|
|
3116
|
+
`a passing review.`;
|
|
3117
|
+
|
|
3118
|
+
const executedDenied =
|
|
3119
|
+
`The review action exited successfully WITHOUT writing a findings ` +
|
|
3120
|
+
`payload, so no AI review ran on this pull request — and the reviewer ` +
|
|
3121
|
+
`DID execute: the action wrote an execution file, and that file reports ` +
|
|
3122
|
+
`a NON-ZERO permission_denials_count, so the reviewer was refused at ` +
|
|
3123
|
+
`least one call. Read the denials in the execution file: a reviewer ` +
|
|
3124
|
+
`refused its own output file is the one case where the findings path, ` +
|
|
3125
|
+
`which is outside the checkout, is worth checking. This check is ` +
|
|
3126
|
+
`UNMEASURED, not a passing review.`;
|
|
3127
|
+
|
|
3128
|
+
const executedDenialsUnknown =
|
|
3129
|
+
`The review action exited successfully WITHOUT writing a findings ` +
|
|
3130
|
+
`payload, so no AI review ran on this pull request — and the reviewer ` +
|
|
3131
|
+
`DID execute: the action wrote an execution file. That file carries no ` +
|
|
3132
|
+
`permission_denials_count, so whether the reviewer was refused anything ` +
|
|
3133
|
+
`is UNMEASURED too and this job will not guess at it (#1087). Read the ` +
|
|
3134
|
+
`execution file and the action's own log. This check is UNMEASURED, not ` +
|
|
3135
|
+
`a passing review.`;
|
|
2696
3136
|
|
|
2697
3137
|
const exhausted =
|
|
2698
3138
|
`The review action exited successfully WITHOUT writing a findings ` +
|
|
@@ -2848,12 +3288,123 @@ if [ "\${AI_REVIEW_ACTION_OUTCOME:-}" = success ]; then
|
|
|
2848
3288
|
# is the honest direction: the prepare step did not run, so nobody can say a
|
|
2849
3289
|
# review happened.
|
|
2850
3290
|
if [ -s "\${${AI_REVIEW_FINDINGS_PATH_VAR}:-}" ]; then
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
3291
|
+
# #1013. The adjudication, and the ONLY branch in this file whose exit
|
|
3292
|
+
# code comes from something other than this script.
|
|
3293
|
+
#
|
|
3294
|
+
# Resolved inside \`run:\`, never in an \`if:\`. A step skipped by \`if:\`
|
|
3295
|
+
# reports *skipped*, and a skipped required check can be treated as
|
|
3296
|
+
# satisfied — the module header's standing rule, and it applies hardest
|
|
3297
|
+
# here, where the thing being skipped is the verdict.
|
|
3298
|
+
#
|
|
3299
|
+
# Both streams are captured: the reader writes its \`::error\` annotation
|
|
3300
|
+
# to stderr and the outcome line to stdout, and this branch needs to read
|
|
3301
|
+
# the second while still SHOWING the first. The output is re-printed
|
|
3302
|
+
# verbatim rather than through \`escape_annotation\` — the reader escapes
|
|
3303
|
+
# its own annotation payloads (one escaper, in \`ai-review-findings.ts\`),
|
|
3304
|
+
# and escaping it twice turns \`%\` into \`%2525\` and the annotation into
|
|
3305
|
+
# noise.
|
|
3306
|
+
#
|
|
3307
|
+
# RUN FROM THE PAYLOAD'S OWN DIRECTORY, not from the checkout. \`bunx\`
|
|
3308
|
+
# resolves \`bunfig.toml\`, \`.npmrc\`, \`package.json\` and \`node_modules\`
|
|
3309
|
+
# by walking UP from the working directory, and a step's working directory
|
|
3310
|
+
# is \${GITHUB_WORKSPACE} — the tree under review. A branch that adds a
|
|
3311
|
+
# \`bunfig.toml\` naming its own registry, or a \`node_modules/.bin\`
|
|
3312
|
+
# entry, would choose what this credentialed job executes. On THIS
|
|
3313
|
+
# repository the trigger is \`pull_request\`, so a fork gets no secrets and
|
|
3314
|
+
# the attacker would need push access; this file is a GENERATOR, and the
|
|
3315
|
+
# job it writes lands in consumer repositories whose trigger and trust
|
|
3316
|
+
# settings nobody here can see. The consumer is the threat model.
|
|
3317
|
+
#
|
|
3318
|
+
# The payload's directory is the right cwd and needs no new wiring: the
|
|
3319
|
+
# prepare step puts it under \${RUNNER_TEMP} and REFUSES the run if that
|
|
3320
|
+
# is unset, so it is outside the checkout by construction rather than by
|
|
3321
|
+
# convention. A \`cd\` that fails takes the subshell non-zero with no
|
|
3322
|
+
# outcome line, which the reading below fails closed on.
|
|
3323
|
+
#
|
|
3324
|
+
# \`|| adjudicated=\$?\` AND NOT A PLAIN ASSIGNMENT (#1110). The module
|
|
3325
|
+
# header says "No \`set -e\`", and that is true of what this generator
|
|
3326
|
+
# WRITES and false of what the runner SUPPLIES: GitHub's default shell for
|
|
3327
|
+
# a \`run:\` step is \`/usr/bin/bash -e {0}\`, which every job log echoes.
|
|
3328
|
+
# Under \`-e\` an assignment whose value is a command substitution takes
|
|
3329
|
+
# the substitution's status, and a non-zero status aborts the shell ON
|
|
3330
|
+
# THIS LINE — so \`adjudicated=\$?\`, the \`printf\`, the \`case\` and the
|
|
3331
|
+
# UNMEASURED annotation below were all unreachable for every non-zero
|
|
3332
|
+
# adjudication, which is EVERY blocking finding and EVERY failure to
|
|
3333
|
+
# start. Measured on run 39711570020: 1.8s, no stdout at all, exit 1.
|
|
3334
|
+
# An uninstallable adjudicator was worse still — the shell died carrying
|
|
3335
|
+
# the adjudicator's own 127 out of the job, past the mapped exit
|
|
3336
|
+
# ${AI_REVIEW_REQUIRED_EXIT} entirely.
|
|
3337
|
+
#
|
|
3338
|
+
# \`||\` puts the substitution where \`-e\` does not fire, so the exit code
|
|
3339
|
+
# becomes DATA for the reading below instead of control flow. Everything
|
|
3340
|
+
# downstream was already correct; it had simply never run.
|
|
3341
|
+
#
|
|
3342
|
+
# \`adjudicated\` is seeded first: on the success path the \`||\` branch
|
|
3343
|
+
# does not execute, and an unset variable there would make a clean
|
|
3344
|
+
# adjudication read as an empty string rather than as 0.
|
|
3345
|
+
adjudicated=0
|
|
3346
|
+
adjudication=\$(cd "\$(dirname "\${${AI_REVIEW_FINDINGS_PATH_VAR}}")" && ${adjudicator} "\${${AI_REVIEW_FINDINGS_PATH_VAR}}" 2>&1) || adjudicated=\$?
|
|
3347
|
+
printf '%s\\n' "\${adjudication}"
|
|
3348
|
+
|
|
3349
|
+
# DID IT RUN, asked before WHAT IT SAID. Without this line a registry that
|
|
3350
|
+
# is down, a runner without bun and a review carrying a \`critical\` all
|
|
3351
|
+
# exit 1 and all read as a blocked pull request.
|
|
3352
|
+
#
|
|
3353
|
+
# The code is MAPPED rather than passed through, so every non-zero exit in
|
|
3354
|
+
# this script is still the one exported constant — \`test/ai-review-
|
|
3355
|
+
# scaffold.test.ts\` AC-6b refuses a literal here, and a bare
|
|
3356
|
+
# \`exit \${adjudicated}\` would be a refusal the mutation that zeroes
|
|
3357
|
+
# \${AI_REVIEW_REQUIRED_EXIT} could not reach. It re-states the same value
|
|
3358
|
+
# rather than adding one: the reader's own refusals already route through
|
|
3359
|
+
# that constant (\`test/ai-review-exit-binding.test.ts\`), so the only
|
|
3360
|
+
# thing this widens is a reader that ran and died some other way, which is
|
|
3361
|
+
# a refusal too.
|
|
3362
|
+
case "\${adjudication}" in
|
|
3363
|
+
*"${AI_REVIEW_OUTCOME_LINE}"*)
|
|
3364
|
+
# THE POSITIVE READING (#1087), emitted inside the arm and above both
|
|
3365
|
+
# exits, so it is carried by a blocking verdict as well as a clean
|
|
3366
|
+
# one. What it distinguishes is not CLEAN from BLOCKED — the exit code
|
|
3367
|
+
# already does that — but "a verdict" from "no verdict", which nothing
|
|
3368
|
+
# outside this job could tell apart while every terminal state was
|
|
3369
|
+
# either a shared-title warning or silence.
|
|
3370
|
+
#
|
|
3371
|
+
# The outcome line is lifted out of the captured output rather than
|
|
3372
|
+
# re-derived: \`\${adjudication}\` is what the reader actually printed,
|
|
3373
|
+
# and a second spelling of the verdict computed here could disagree
|
|
3374
|
+
# with the exit code this step is about to use (#295).
|
|
3375
|
+
#
|
|
3376
|
+
# Lifted by PARAMETER EXPANSION and not by \`grep | head\`, for two
|
|
3377
|
+
# independent reasons. \`test/ai-review-security-repairs.test.ts\`
|
|
3378
|
+
# AC-14a refuses any \`\$(\` in an annotation that is not
|
|
3379
|
+
# \`escape_annotation\` — the encoder is the one command an annotation
|
|
3380
|
+
# may run, and a pipeline inside its argument is a second one. And an
|
|
3381
|
+
# expansion has no exit status to abort on: a \`grep\` that matched
|
|
3382
|
+
# nothing exits 1, which under the runner's \`bash -e\` would kill the
|
|
3383
|
+
# step between the adjudication and the verdict, which is #1110
|
|
3384
|
+
# exactly. The two-step form takes everything after the marker, then
|
|
3385
|
+
# everything before the first newline, then puts the marker back.
|
|
3386
|
+
#
|
|
3387
|
+
# \`escape_annotation\` IS applied here, where the comment above
|
|
3388
|
+
# declines it for the reader's own \`::error\` payload. The difference
|
|
3389
|
+
# is whose string it is: that one arrives pre-escaped and escaping it
|
|
3390
|
+
# twice turns \`%\` into \`%2525\`, while this one is assembled by this
|
|
3391
|
+
# step out of a line the reader never escaped.
|
|
3392
|
+
verdict="\${adjudication#*${AI_REVIEW_OUTCOME_LINE}}"
|
|
3393
|
+
verdict="${AI_REVIEW_OUTCOME_LINE}\${verdict%%\$'\\n'*}"
|
|
3394
|
+
echo "::notice title=${AI_REVIEW_ADJUDICATED_TITLE}::$(escape_annotation "\${verdict}") — ${adjudicatedEvidence}"
|
|
3395
|
+
if [ "\${adjudicated}" = 0 ]; then
|
|
3396
|
+
exit 0
|
|
3397
|
+
fi
|
|
3398
|
+
exit ${AI_REVIEW_REQUIRED_EXIT}
|
|
3399
|
+
;;
|
|
3400
|
+
esac
|
|
3401
|
+
|
|
3402
|
+
# NO ${AI_REVIEW_REQUIRE_VAR} CHECK HERE, deliberately — see the sentence
|
|
3403
|
+
# this prints. A payload exists, so a review was attempted; "nobody read
|
|
3404
|
+
# it" is a failure on every tree, not an opt-in. The flag still governs
|
|
3405
|
+
# every branch above and below, where nothing was attempted at all.
|
|
3406
|
+
echo "::error title=${AI_REVIEW_UNMEASURED_TITLE}::${unadjudicated}" >&2
|
|
3407
|
+
exit ${AI_REVIEW_REQUIRED_EXIT}
|
|
2857
3408
|
fi
|
|
2858
3409
|
|
|
2859
3410
|
# Which route, and nothing else. \`route\` is a string this block prints; no
|
|
@@ -2867,8 +3418,28 @@ if [ "\${AI_REVIEW_ACTION_OUTCOME:-}" = success ]; then
|
|
|
2867
3418
|
# different explanatory sentence rather than a different verdict.
|
|
2868
3419
|
if grep -qE '"subtype"[[:space:]]*:[[:space:]]*"error_max_turns"' "\${${AI_REVIEW_EXECUTION_FILE_VAR}}"; then
|
|
2869
3420
|
route="${exhausted}"
|
|
3421
|
+
elif ! grep -qE '"${AI_REVIEW_DENIALS_KEY}"[[:space:]]*:' "\${${AI_REVIEW_EXECUTION_FILE_VAR}}"; then
|
|
3422
|
+
# Asked FIRST, because the two readings below are both about a number
|
|
3423
|
+
# that may not be there, and "absent" answered last is "absent" reported
|
|
3424
|
+
# as whichever branch fell through to it.
|
|
3425
|
+
route="${executedDenialsUnknown}"
|
|
3426
|
+
elif grep -qE '"${AI_REVIEW_DENIALS_KEY}"[[:space:]]*:[[:space:]]*0[[:space:]]*(,|\}|$)' "\${${AI_REVIEW_EXECUTION_FILE_VAR}}"; then
|
|
3427
|
+
# The end-anchor is \`(,|}|$)\` and the \`$\` is the whole of it. grep is
|
|
3428
|
+
# LINE-based: it strips the newline before matching, so in the
|
|
3429
|
+
# pretty-printed file the action actually writes — where this field is
|
|
3430
|
+
# the last member of the result object — the character after \`0\` is the
|
|
3431
|
+
# end of the line and nothing else. A \`[,}]\` class alone therefore
|
|
3432
|
+
# fails to match a genuine zero, which is the failing direction: the
|
|
3433
|
+
# zero route would be unreachable and every executed run would report
|
|
3434
|
+
# denials it did not have.
|
|
3435
|
+
#
|
|
3436
|
+
# That is not a hypothetical. The first draft of this branch was
|
|
3437
|
+
# \`[,}]\`, and \`test/ai-review-route-reading.test.ts\` AC-C4 caught it by
|
|
3438
|
+
# pairing the three routes and finding two of them printing one
|
|
3439
|
+
# sentence. The trailing \`,\` and \`}\` are kept for a compact file.
|
|
3440
|
+
route="${executedNoDenials}"
|
|
2870
3441
|
else
|
|
2871
|
-
route="${
|
|
3442
|
+
route="${executedDenied}"
|
|
2872
3443
|
fi
|
|
2873
3444
|
elif [ -n "\${${AI_REVIEW_EXECUTION_FILE_VAR}:-}" ]; then
|
|
2874
3445
|
# Named but unreadable. Reporting that as the declined route would be a
|
|
@@ -2878,11 +3449,20 @@ if [ "\${AI_REVIEW_ACTION_OUTCOME:-}" = success ]; then
|
|
|
2878
3449
|
fi
|
|
2879
3450
|
|
|
2880
3451
|
echo "::warning title=${AI_REVIEW_UNMEASURED_TITLE}::$(escape_annotation "\${route}")"
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
3452
|
+
|
|
3453
|
+
# #1180. NO \${${AI_REVIEW_REQUIRE_VAR}} CHECK HERE — the refusal below is
|
|
3454
|
+
# unconditional. The flag governs the branches ABOVE, where no credential
|
|
3455
|
+
# resolved and no review was attempted; by here one was, and produced
|
|
3456
|
+
# nothing. The waiver is the label, which is per pull request and recorded,
|
|
3457
|
+
# and it is read AFTER the warning so that a waived run still carries the
|
|
3458
|
+
# route that explains what it waived.
|
|
3459
|
+
if [ "\${${AI_REVIEW_OVERRIDE_VAR}:-}" = "${AI_REVIEW_OVERRIDE_VALUE}" ]; then
|
|
3460
|
+
echo "::warning title=${AI_REVIEW_WAIVED_TITLE}::${skippedWaived}"
|
|
3461
|
+
exit 0
|
|
2884
3462
|
fi
|
|
2885
|
-
|
|
3463
|
+
|
|
3464
|
+
echo "::error title=${AI_REVIEW_UNMEASURED_TITLE}::${skippedRefusal}" >&2
|
|
3465
|
+
exit ${AI_REVIEW_REQUIRED_EXIT}
|
|
2886
3466
|
fi
|
|
2887
3467
|
|
|
2888
3468
|
# #826. The action did not complete. WHICH of five states that is, read from
|
|
@@ -2919,12 +3499,14 @@ fi
|
|
|
2919
3499
|
|
|
2920
3500
|
echo "::warning title=${AI_REVIEW_UNMEASURED_TITLE}::$(escape_annotation "\${route}")"
|
|
2921
3501
|
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
3502
|
+
# #1180, and unconditional for the reason the success branch above states.
|
|
3503
|
+
if [ "\${${AI_REVIEW_OVERRIDE_VAR}:-}" = "${AI_REVIEW_OVERRIDE_VALUE}" ]; then
|
|
3504
|
+
echo "::warning title=${AI_REVIEW_WAIVED_TITLE}::${waived}"
|
|
3505
|
+
exit 0
|
|
2925
3506
|
fi
|
|
2926
3507
|
|
|
2927
|
-
|
|
3508
|
+
echo "::error title=${AI_REVIEW_UNMEASURED_TITLE}::${refusal}" >&2
|
|
3509
|
+
exit ${AI_REVIEW_REQUIRED_EXIT}
|
|
2928
3510
|
`;
|
|
2929
3511
|
}
|
|
2930
3512
|
|
|
@@ -3216,6 +3798,27 @@ export const AI_REVIEW_UNTRUSTED_PATHS: readonly string[] = [
|
|
|
3216
3798
|
// one. Both are needed and neither covers the other.
|
|
3217
3799
|
".gitignore",
|
|
3218
3800
|
".gitattributes",
|
|
3801
|
+
// #1013 review. Not an instruction and not an input to the measurement —
|
|
3802
|
+
// this one selects the INTERPRETER. The job's `setup-bun` step reads this
|
|
3803
|
+
// file out of the checkout to decide which bun to install, and that bun
|
|
3804
|
+
// then runs the findings adjudicator inside a credentialed job. A branch
|
|
3805
|
+
// that edits it is choosing the runtime its own reviewer executes.
|
|
3806
|
+
//
|
|
3807
|
+
// Spelled as a literal because this module has no relative imports (see
|
|
3808
|
+
// `AiReviewActionRefs`), so it cannot read `BUN_VERSION_FILE` from
|
|
3809
|
+
// `lib/bun-version.ts`. That makes it a second position for one name, and
|
|
3810
|
+
// the repair is a test rather than a comment: `test/ai-review-untrusted-
|
|
3811
|
+
// restore.test.ts` compares this entry to that constant, so the two cannot
|
|
3812
|
+
// drift apart silently.
|
|
3813
|
+
//
|
|
3814
|
+
// The sibling bun/npm resolution files — `bunfig.toml`, `.npmrc`,
|
|
3815
|
+
// `package.json`, `bun.lock`, `node_modules` — are deliberately NOT here.
|
|
3816
|
+
// The adjudicator runs with its working directory under `RUNNER_TEMP`, and
|
|
3817
|
+
// bun resolves those by walking up from the working directory, so none of
|
|
3818
|
+
// them is on its path at all. Restoring `package.json` would additionally
|
|
3819
|
+
// change WHAT THE REVIEWER READS, which #1013's body flags as a separate
|
|
3820
|
+
// decision and not one to make in passing.
|
|
3821
|
+
".bun-version",
|
|
3219
3822
|
];
|
|
3220
3823
|
|
|
3221
3824
|
export const AI_REVIEW_RESTORE_STEP_ID = "ai-review-restore-untrusted";
|
|
@@ -3367,7 +3970,19 @@ base_remote="refs/remotes/origin/\${base_ref}"
|
|
|
3367
3970
|
|
|
3368
3971
|
# Through the environment, never \`-c\`: a value passed with \`-c\` is in the
|
|
3369
3972
|
# command line of the git process and readable by anything that can run \`ps\`.
|
|
3370
|
-
|
|
3973
|
+
#
|
|
3974
|
+
# Wrapped in \`if !\` rather than left a bare assignment, which is the idiom the
|
|
3975
|
+
# fetch below already uses and for the same reason (#1116). GitHub runs this
|
|
3976
|
+
# step as \`bash -e\`, and with \`pipefail\` set an assignment from a pipeline
|
|
3977
|
+
# takes the pipeline's status, so any failure here would abort the step on
|
|
3978
|
+
# this line: no annotation, no exit code of ours, nothing on stdout. That is
|
|
3979
|
+
# the shape of #1110. These three commands are local and a failure is remote,
|
|
3980
|
+
# but "this cannot fail" is exactly what was believed about the adjudication
|
|
3981
|
+
# until an npm 503 falsified it.
|
|
3982
|
+
if ! ${AI_REVIEW_GIT_AUTH_VAR}="AUTHORIZATION: basic $(printf 'x-access-token:%s' "\${GITHUB_TOKEN:-}" | base64 | tr -d '\\n')"; then
|
|
3983
|
+
echo "::error title=AI review modified the tree::could not build the credential header used to fetch the pull request base, so the untrusted paths were NOT restored and this run is UNMEASURED." >&2
|
|
3984
|
+
exit ${AI_REVIEW_REQUIRED_EXIT}
|
|
3985
|
+
fi
|
|
3371
3986
|
export ${AI_REVIEW_GIT_AUTH_VAR}
|
|
3372
3987
|
|
|
3373
3988
|
# Checked on its own line, never captured into an assignment, for the reason
|
|
@@ -3804,55 +4419,136 @@ export const AI_REVIEW_IGNORED_READING = "--ignored=matching";
|
|
|
3804
4419
|
* - **It names a SHA-pinned dependency's documented scratch**, not a class of
|
|
3805
4420
|
* paths and not anything in this repository.
|
|
3806
4421
|
*
|
|
3807
|
-
* ##
|
|
4422
|
+
* ## What the exemption used to cost, and no longer does (#1071)
|
|
3808
4423
|
*
|
|
3809
|
-
*
|
|
3810
|
-
*
|
|
3811
|
-
*
|
|
3812
|
-
*
|
|
3813
|
-
*
|
|
4424
|
+
* `continue` on this entry did not drop a line — it dropped the ONLY line.
|
|
4425
|
+
* `matching` collapses the whole ignored subtree to `!! .claude-pr/`, so
|
|
4426
|
+
* exempting that entry left the reading EMPTY and the drift step with nothing
|
|
4427
|
+
* to compare: `.claude-pr/EVIL.md` was invisible at any depth. The exemption
|
|
4428
|
+
* stays, because the action still creates and ignores this directory
|
|
4429
|
+
* mid-review and nothing separates it from a plant. What changed is that the
|
|
4430
|
+
* reader now descends one level instead of returning — see
|
|
4431
|
+
* `AI_REVIEW_SCRATCH_SCAN_LIMIT`.
|
|
3814
4432
|
*/
|
|
3815
4433
|
export const AI_REVIEW_ACTION_SCRATCH = ".claude-pr/";
|
|
3816
4434
|
|
|
3817
4435
|
/**
|
|
3818
|
-
*
|
|
4436
|
+
* How many entries of the exempted scratch the reader will report (#1071).
|
|
4437
|
+
*
|
|
4438
|
+
* ## The hole this bounds, and why descending one level closes it
|
|
4439
|
+
*
|
|
4440
|
+
* The exemption above is unavoidable and the entry it exempts is the whole
|
|
4441
|
+
* reading, so everything under `.claude-pr/` was invisible. Closing that
|
|
4442
|
+
* cannot mean "report the scratch's contents": the action fills it mid-review
|
|
4443
|
+
* and the baseline was taken before, so every file in it is an addition and
|
|
4444
|
+
* every pull request goes red. That is PR #1002's outage with extra steps,
|
|
4445
|
+
* and it is why #1071 was filed rather than patched.
|
|
4446
|
+
*
|
|
4447
|
+
* The discriminator is read from the dependency's own source rather than
|
|
4448
|
+
* guessed. `restoreConfigFromBase()` in `src/github/operations/restore-config.ts`
|
|
4449
|
+
* at the pinned SHA is the only writer, and it writes exactly:
|
|
4450
|
+
*
|
|
4451
|
+
* ```ts
|
|
4452
|
+
* rmSync(".claude-pr", { recursive: true, force: true });
|
|
4453
|
+
* for (const p of SENSITIVE_PATHS) {
|
|
4454
|
+
* if (lstatSync(p, { throwIfNoEntry: false })) {
|
|
4455
|
+
* snapshotSensitivePath(p, `.claude-pr/${p}`, workTreeRealPath, tracked);
|
|
4456
|
+
* }
|
|
4457
|
+
* }
|
|
4458
|
+
* ```
|
|
4459
|
+
*
|
|
4460
|
+
* Every `p` is a single path component, so **the action creates nothing at the
|
|
4461
|
+
* TOP of its scratch except a name from that list** — including the
|
|
4462
|
+
* `recordPlaceholder` files, which land under the same `p`. A top-level entry
|
|
4463
|
+
* with any other name had no second author, and that is a property of the
|
|
4464
|
+
* writer, not a shape of the message.
|
|
4465
|
+
*
|
|
4466
|
+
* So the reader enumerates `.claude-pr/` at depth ONE, drops the mirrored
|
|
4467
|
+
* names, and classifies the rest exactly as it classifies any other path. On
|
|
4468
|
+
* a normal pull request that yields zero lines, by construction — which is
|
|
4469
|
+
* what makes this green rather than hopeful.
|
|
4470
|
+
*
|
|
4471
|
+
* ## The names come from `AI_REVIEW_UNTRUSTED_PATHS`, and that is a widening
|
|
4472
|
+
*
|
|
4473
|
+
* That constant is required to be a SUPERSET of the action's list, and it
|
|
4474
|
+
* currently holds two names the action does not snapshot — `.gitignore` and
|
|
4475
|
+
* `.gitattributes`, added by #856 because they are inputs to the measurement.
|
|
4476
|
+
* So `.claude-pr/.gitignore` stays unreported. Stated rather than hidden, and
|
|
4477
|
+
* asserted, but not repaired with a second list: a list that is a SUBSET of
|
|
4478
|
+
* the action's reds every pull request the first time the action's list
|
|
4479
|
+
* grows, and a superset costs two blind names. One declaring position, and
|
|
4480
|
+
* the error that remains is the survivable one.
|
|
4481
|
+
*
|
|
4482
|
+
* ## Volume, which is the bound the issue asked for
|
|
4483
|
+
*
|
|
4484
|
+
* `-maxdepth 1`, so the cost is the number of top-level entries — ten, not
|
|
4485
|
+
* the size of a copy of the pull request's `.claude/` tree. No `hash-object`
|
|
4486
|
+
* runs for a mirrored name. The limit below bounds what a REVIEWER can make
|
|
4487
|
+
* the reader print; truncating it cannot flip the verdict, because one line
|
|
4488
|
+
* is already a refusal.
|
|
4489
|
+
*
|
|
4490
|
+
* ## WHAT THIS DOES NOT FIX
|
|
4491
|
+
*
|
|
4492
|
+
* A write under a mirrored name — `.claude-pr/.claude/EVIL.md` — is still
|
|
4493
|
+
* invisible. That is `--ignored=matching`'s collapse, the same bound
|
|
4494
|
+
* `AI_REVIEW_PRESENT_UNHASHABLE` already states, and it is asserted in
|
|
4495
|
+
* `test/ai-review-ignored-reading.test.ts` so it cannot outlive its subject.
|
|
4496
|
+
*/
|
|
4497
|
+
export const AI_REVIEW_SCRATCH_SCAN_LIMIT = 50;
|
|
4498
|
+
|
|
4499
|
+
/**
|
|
4500
|
+
* What a path that is PRESENT but not a regular file hashes to (#1061,
|
|
4501
|
+
* #1070).
|
|
3819
4502
|
*
|
|
3820
4503
|
* ## `absent` was true of every input the reader could be handed, until #969
|
|
3821
4504
|
*
|
|
3822
|
-
* `--untracked-files=all` alone
|
|
3823
|
-
*
|
|
3824
|
-
*
|
|
3825
|
-
*
|
|
3826
|
-
*
|
|
4505
|
+
* `--untracked-files=all` alone yields nothing but file paths, so
|
|
4506
|
+
* `[ -f "${p}" ]` was a total question and its `else` branch was always
|
|
4507
|
+
* right: not a regular file meant gone. `AI_REVIEW_IGNORED_READING` broke
|
|
4508
|
+
* that, and the reader then had two states sharing one token —
|
|
4509
|
+
* *the path was removed* and *the path is here and is not a file*.
|
|
3827
4510
|
*
|
|
3828
|
-
* ## Why
|
|
4511
|
+
* ## Why conflating them is not a cosmetic lie
|
|
3829
4512
|
*
|
|
3830
4513
|
* `absent` is a VALUE the drift step branches on. #989's twice-restored
|
|
3831
4514
|
* classifier reads it as *the action deleted a restored path*, asks the base
|
|
3832
4515
|
* whether it carries the file, and on `no` files the line under `restored` —
|
|
3833
4516
|
* acquitted, and reported as the action's work rather than the reviewer's.
|
|
3834
|
-
*
|
|
3835
|
-
*
|
|
3836
|
-
*
|
|
3837
|
-
* Measured against `origin/main` at `d8f76417`, git 2.50.1, driving the real
|
|
3838
|
-
* `buildBaselineScript()` and `buildDriftScript()`. The reviewer does exactly
|
|
3839
|
-
* two things between the two readings — appends `/.claude/evil/` to
|
|
3840
|
-
* `.git/info/exclude`, and writes `.claude/evil/payload.md`:
|
|
4517
|
+
* So a path that exists reaches a branch that assumes it does not, and the
|
|
4518
|
+
* run says the opposite of what happened.
|
|
3841
4519
|
*
|
|
3842
|
-
*
|
|
3843
|
-
* |---|---|---|
|
|
3844
|
-
* | before this change | `!! .claude/evil/` | **exit 0**, warning: *"NOT counted as a reviewer write (#989). Paths: `absent .claude/evil/`"* |
|
|
3845
|
-
* | with this token | `!! .claude/evil/` | **exit 1**: *"The reviewer modified the tree it was reviewing: `ignored-dir .claude/evil/`"* |
|
|
4520
|
+
* ## Both shapes, measured end to end
|
|
3846
4521
|
*
|
|
3847
|
-
*
|
|
3848
|
-
*
|
|
3849
|
-
*
|
|
3850
|
-
* documents.
|
|
4522
|
+
* Real `buildBaselineScript()` and `buildDriftScript()`, git 2.50.1. In each
|
|
4523
|
+
* row the reviewer acts once between the two readings, under an untrusted
|
|
4524
|
+
* path so the line reaches #989's classifier:
|
|
3851
4525
|
*
|
|
3852
|
-
*
|
|
3853
|
-
*
|
|
3854
|
-
*
|
|
3855
|
-
*
|
|
4526
|
+
* | the reviewer writes | token | drift |
|
|
4527
|
+
* |---|---|---|
|
|
4528
|
+
* | `/.claude/evil/` into `.git/info/exclude`, then `.claude/evil/payload.md` | was `absent` | **exit 0**, credited to the action (`d8f76417`) |
|
|
4529
|
+
* | a dangling symlink `.claude/evil-link` | was `absent` | **exit 0**, credited to the action (`c514b585`) |
|
|
4530
|
+
* | either, with this token | `not-a-regular-file` | **exit 1**, named as a reviewer write |
|
|
4531
|
+
*
|
|
4532
|
+
* **Row two is why this constant is not called `ignored-dir`.** #1061 shipped
|
|
4533
|
+
* a trailing-slash case arm keyed on git's own slash, which is the shape of the first
|
|
4534
|
+
* row and not the property either row has. `[ -f ]` is false for a dangling
|
|
4535
|
+
* symlink, a fifo and a socket too, and none of those carries a slash. The
|
|
4536
|
+
* arm is gone: `[ -e ]` is true of a collapsed directory, so keeping both
|
|
4537
|
+
* would be two deciders for one question and a mutation of either would
|
|
4538
|
+
* leave the other holding the case up.
|
|
4539
|
+
*
|
|
4540
|
+
* `[ -e ]` FOLLOWS symlinks, so it is false for a dangling one. `[ -L ]` is
|
|
4541
|
+
* the half that catches it, and omitting it is exactly how #1061 came up
|
|
4542
|
+
* short.
|
|
4543
|
+
*
|
|
4544
|
+
* The refusal is not a new rule. The line stops entering the `absent` branch,
|
|
4545
|
+
* falls through to the blob comparison, resolves nothing on the base, and
|
|
4546
|
+
* stays in `added` — the tight direction that comparison already documents.
|
|
4547
|
+
*
|
|
4548
|
+
* `absent` keeps its meaning and its branch: a tracked file the reviewer
|
|
4549
|
+
* DELETES still reads `absent` and is still classified exactly as before.
|
|
4550
|
+
* `AC-11/deletion` is the control that says this is a repair and not a
|
|
4551
|
+
* widening that retires a working branch.
|
|
3856
4552
|
*
|
|
3857
4553
|
* ## Not folded into the UNMEASURED warning, deliberately
|
|
3858
4554
|
*
|
|
@@ -3862,13 +4558,14 @@ export const AI_REVIEW_ACTION_SCRATCH = ".claude-pr/";
|
|
|
3862
4558
|
*
|
|
3863
4559
|
* ## WHAT THIS DOES NOT FIX
|
|
3864
4560
|
*
|
|
3865
|
-
* The
|
|
3866
|
-
*
|
|
3867
|
-
*
|
|
3868
|
-
*
|
|
3869
|
-
*
|
|
4561
|
+
* The line carries no content, so a write INSIDE a directory already ignored
|
|
4562
|
+
* at baseline is still invisible and a modification inside one still produces
|
|
4563
|
+
* a byte-identical line. Unchanged, UNMEASURED, asserted by `AC-8/inside`.
|
|
4564
|
+
* `--ignored=traditional` is the only setting that sees it, at 1508 lines on
|
|
4565
|
+
* this checkout. The blindness under `AI_REVIEW_ACTION_SCRATCH` specifically
|
|
4566
|
+
* is #1071.
|
|
3870
4567
|
*/
|
|
3871
|
-
export const
|
|
4568
|
+
export const AI_REVIEW_PRESENT_UNHASHABLE = "not-a-regular-file";
|
|
3872
4569
|
|
|
3873
4570
|
/**
|
|
3874
4571
|
* The one reading of the tree, shared by the baseline step and the drift step
|
|
@@ -3938,8 +4635,162 @@ export const AI_REVIEW_IGNORED_DIR_HASH = "ignored-dir";
|
|
|
3938
4635
|
* content.
|
|
3939
4636
|
*/
|
|
3940
4637
|
|
|
3941
|
-
export const AI_REVIEW_TREE_READER = `
|
|
3942
|
-
local
|
|
4638
|
+
export const AI_REVIEW_TREE_READER = `classify_path() {
|
|
4639
|
+
local p h esc
|
|
4640
|
+
p="\${1}"
|
|
4641
|
+
# ONE quoting decision, for every source that reaches this function.
|
|
4642
|
+
#
|
|
4643
|
+
# The leading-quote test is git's shape: porcelain v1 C-quotes a path
|
|
4644
|
+
# carrying a newline, a quote or a backslash, so a git-derived path arrives
|
|
4645
|
+
# already wrapped and matches here. \`read_scratch\` (#1071) does NOT get its
|
|
4646
|
+
# paths from git — it globs the filesystem — so an attacker-chosen name
|
|
4647
|
+
# reaches this function raw, and the line below PRINTS it. A name carrying a
|
|
4648
|
+
# newline therefore printed as TWO lines, and the second was indistinguishable
|
|
4649
|
+
# from a record this function produced: a reviewer naming a file
|
|
4650
|
+
# \`p<newline>absent .ripgreprc\` wrote \`absent .ripgreprc\` into the reading,
|
|
4651
|
+
# which is the token #989's classifier acquits on and reports as the review
|
|
4652
|
+
# action's own restore. Measured on \`origin/main\` at \`77dd0f7f\`: exit 1 from
|
|
4653
|
+
# the reviewer's own genuine line, and the forged path named in the
|
|
4654
|
+
# twice-restored warning as the ACTION's work.
|
|
4655
|
+
#
|
|
4656
|
+
# Asked HERE and not in the walk, deliberately. "Is this path safe to print"
|
|
4657
|
+
# has one answer, and two guards answering it are one decider with a spare —
|
|
4658
|
+
# a mutation of either leaves the other holding the case up
|
|
4659
|
+
# (\`.claude/rules/checks-must-be-able-to-fail.md\`, fourth shape). The next
|
|
4660
|
+
# path source inherits this instead of needing a third.
|
|
4661
|
+
#
|
|
4662
|
+
# THE NEWLINE IS THE ONE THAT MATTERS, and a quote-anywhere test is the
|
|
4663
|
+
# cheapest wrong fix: a quote or a backslash in the MIDDLE of a name
|
|
4664
|
+
# corrupts a field, while only a newline forges a RECORD. A case built
|
|
4665
|
+
# around a quoted filename goes green on the newline and witnesses nothing.
|
|
4666
|
+
#
|
|
4667
|
+
# TWO ARMS, ONE TOKEN (#1104). Both are \`unquotable\` and both raise
|
|
4668
|
+
# UNMEASURED; they differ only in whether the name is already safe to print.
|
|
4669
|
+
#
|
|
4670
|
+
# git C-quotes a porcelain path carrying a space, a quote, a backslash or a
|
|
4671
|
+
# control character — measured, git 2.50.1: \`"ordinary name with spaces.md"\`
|
|
4672
|
+
# comes back WRAPPED. So a git-derived path is already single-line and
|
|
4673
|
+
# already injective, and re-escaping it would change the record for every
|
|
4674
|
+
# spaced filename in every consumer repository to buy nothing.
|
|
4675
|
+
#
|
|
4676
|
+
# A path from \`read_scratch\` was never seen by git and is wrapped by
|
|
4677
|
+
# nothing. That is the one that needs escaping below, and \`esc\` is how the
|
|
4678
|
+
# renderer knows which it is WITHOUT asking the question a second time.
|
|
4679
|
+
case "\${p}" in
|
|
4680
|
+
'"'*) h=unquotable; esc= ;;
|
|
4681
|
+
*$'\\n'*) h=unquotable; esc=1 ;;
|
|
4682
|
+
*)
|
|
4683
|
+
esc=
|
|
4684
|
+
if [ -f "\${p}" ]; then
|
|
4685
|
+
# --no-filters, or the repository's own text/eol conversion is
|
|
4686
|
+
# applied before hashing and two DIFFERENT working-tree blobs
|
|
4687
|
+
# collapse to one hash (#856 F3). Measured under \`* text eol=lf\`:
|
|
4688
|
+
# "x\\r\\n" and "x\\n" both hash 587be6b4…, and with --no-filters
|
|
4689
|
+
# they are db127bf6… and 587be6b4…. The reading is only a reading
|
|
4690
|
+
# of content if the hash is of the bytes on disk.
|
|
4691
|
+
# Isolated for the same reason as the status below (#960). It is
|
|
4692
|
+
# the \`-c\` half that matters here: \`--no-filters\` already
|
|
4693
|
+
# defeats a text/eol conversion, but a hash taken under the
|
|
4694
|
+
# reviewer's config is still a reading the reviewer chose.
|
|
4695
|
+
h=$(${AI_REVIEW_GIT_ISOLATED} hash-object --no-filters -- "\${p}" 2>/dev/null) || h=unreadable
|
|
4696
|
+
# PRESENT but not a regular file, which is not a deletion. \`-e\`
|
|
4697
|
+
# FOLLOWS symlinks, so it is false for a dangling one — \`-L\` is the
|
|
4698
|
+
# half that catches it, and leaving it out is how #1061 came up
|
|
4699
|
+
# short. See AI_REVIEW_PRESENT_UNHASHABLE.
|
|
4700
|
+
elif [ -e "\${p}" ] || [ -L "\${p}" ]; then
|
|
4701
|
+
h=${AI_REVIEW_PRESENT_UNHASHABLE}
|
|
4702
|
+
else
|
|
4703
|
+
h=absent
|
|
4704
|
+
fi
|
|
4705
|
+
;;
|
|
4706
|
+
esac
|
|
4707
|
+
# ESCAPED, not truncated (#1104). The record must be one line, and it must
|
|
4708
|
+
# name the entry it is about.
|
|
4709
|
+
#
|
|
4710
|
+
# The first repair truncated at the first newline. That made the record
|
|
4711
|
+
# single-line and made the printed path NOT the path on disk, so a reviewer
|
|
4712
|
+
# who writes both \`x\` and \`x<newline>y\` produced two records naming one
|
|
4713
|
+
# path with two different tokens — fail-safe, both refuse, and a reading a
|
|
4714
|
+
# human cannot act on. Full redaction is worse: two distinct plants collapse
|
|
4715
|
+
# to byte-identical lines and the refusal names neither.
|
|
4716
|
+
#
|
|
4717
|
+
# \`%q\` is injective and single-line, so the name survives in full and two
|
|
4718
|
+
# entries can never collide. It is also the convention this reader already
|
|
4719
|
+
# has for this condition — the docblock above describes a path git had to
|
|
4720
|
+
# quote, and this is the same answer for a path git never saw.
|
|
4721
|
+
#
|
|
4722
|
+
# KEYED OFF \`\${esc}\`, NOT OFF \`\${p}\`. The \`case\` has already decided
|
|
4723
|
+
# whether this path can be printed as itself; asking again here would be the
|
|
4724
|
+
# second decider #1071 spent its whole battery avoiding, and the two could
|
|
4725
|
+
# then be changed apart. This reads that answer.
|
|
4726
|
+
#
|
|
4727
|
+
# NOT UNCONDITIONAL, and this is the coupling to protect: \`%q\` escapes a
|
|
4728
|
+
# SPACE, and the drift step does \`p="\${line#* }"\` and hands the result to
|
|
4729
|
+
# \`git cat-file -e <base>:<path>\` (#989). An escaped ordinary path would
|
|
4730
|
+
# stop resolving on the base, so every path with a space in it would stop
|
|
4731
|
+
# being acquitted. \`%q\` is the identity for a path with no special
|
|
4732
|
+
# characters, which is exactly why an unconditional version looks green and
|
|
4733
|
+
# is not.
|
|
4734
|
+
if [ -n "\${esc}" ]; then
|
|
4735
|
+
printf '%s %q\\n' "\${h}" "\${p}"
|
|
4736
|
+
else
|
|
4737
|
+
printf '%s %s\\n' "\${h}" "\${p}"
|
|
4738
|
+
fi
|
|
4739
|
+
}
|
|
4740
|
+
|
|
4741
|
+
# The interior of the one exempted entry, one level deep (#1071). Split out of
|
|
4742
|
+
# the loop below so there is exactly ONE classifier: every path this finds goes
|
|
4743
|
+
# through \`classify_path\` rather than through a copy of it, so whoever next
|
|
4744
|
+
# changes how a path is turned into a token changes it here too without
|
|
4745
|
+
# knowing this function exists.
|
|
4746
|
+
#
|
|
4747
|
+
# \`\${1}\` is the scratch entry git just reported, carrying git's own trailing
|
|
4748
|
+
# slash, so the globs below expand against its contents. Three of them,
|
|
4749
|
+
# because a single \`*\` does not match a leading dot and the two dot forms
|
|
4750
|
+
# skip \`.\` and \`..\`. Globbing rather than \`find\`: a filename may contain a
|
|
4751
|
+
# newline, and \`find | while read\` would split one entry into two and report
|
|
4752
|
+
# neither.
|
|
4753
|
+
#
|
|
4754
|
+
# NOTHING here asks what kind of thing an entry is. #1070 made
|
|
4755
|
+
# \`classify_path\` ask the property — present-and-hashable against
|
|
4756
|
+
# present-and-not against gone — so a directory, a fifo and a dangling link
|
|
4757
|
+
# planted here are all answered by the one classifier. An earlier draft of
|
|
4758
|
+
# this walk tested \`[ -d \]\` to hand a directory on in git's collapsed shape;
|
|
4759
|
+
# that was a second decider for a question #1070 already answers, and it is
|
|
4760
|
+
# gone rather than left beside it.
|
|
4761
|
+
read_scratch() {
|
|
4762
|
+
local root e name u mirrored n
|
|
4763
|
+
root="\${1}"
|
|
4764
|
+
n=0
|
|
4765
|
+
for e in "\${root}"* "\${root}".[!.]* "\${root}"..?*; do
|
|
4766
|
+
# An unmatched glob comes back as the pattern itself. \`-L\` as well as
|
|
4767
|
+
# \`-e\`, because \`-e\` follows symlinks and is false for a dangling one —
|
|
4768
|
+
# which is a thing the reviewer can create and the reader must still
|
|
4769
|
+
# report (#1070).
|
|
4770
|
+
{ [ -e "\${e}" ] || [ -L "\${e}" ]; } || continue
|
|
4771
|
+
name="\${e##*/}"
|
|
4772
|
+
# The action snapshots each of these paths into the scratch under its own
|
|
4773
|
+
# name, and every one of them is a single component, so a top-level entry
|
|
4774
|
+
# with any other name is not the action's. See
|
|
4775
|
+
# AI_REVIEW_SCRATCH_SCAN_LIMIT.
|
|
4776
|
+
mirrored=
|
|
4777
|
+
for u in ${AI_REVIEW_UNTRUSTED_PATHS.map(p => "'" + p + "'").join(" ")}; do
|
|
4778
|
+
if [ "\${name}" = "\${u}" ]; then
|
|
4779
|
+
mirrored=1
|
|
4780
|
+
break
|
|
4781
|
+
fi
|
|
4782
|
+
done
|
|
4783
|
+
[ -z "\${mirrored}" ] || continue
|
|
4784
|
+
n=$((n + 1))
|
|
4785
|
+
if [ "\${n}" -gt ${AI_REVIEW_SCRATCH_SCAN_LIMIT} ]; then
|
|
4786
|
+
break
|
|
4787
|
+
fi
|
|
4788
|
+
classify_path "\${e}"
|
|
4789
|
+
done
|
|
4790
|
+
}
|
|
4791
|
+
|
|
4792
|
+
read_tree() {
|
|
4793
|
+
local raw line xy p
|
|
3943
4794
|
# Checked on its own line, never captured into an assignment: \`x=$(...)\`
|
|
3944
4795
|
# DISCARDS the exit code, so a git that failed produces the same empty
|
|
3945
4796
|
# string a clean tree produces, and "unreadable" would pass as "clean".
|
|
@@ -3969,35 +4820,16 @@ export const AI_REVIEW_TREE_READER = `read_tree() {
|
|
|
3969
4820
|
# a path merely starting with the name, or carrying anything after the
|
|
3970
4821
|
# slash, is still reported. See AI_REVIEW_ACTION_SCRATCH for why an
|
|
3971
4822
|
# exemption is unavoidable at all.
|
|
4823
|
+
#
|
|
4824
|
+
# DESCEND rather than \`continue\` (#1071). This entry is not one line of
|
|
4825
|
+
# the reading, it IS the reading — \`matching\` collapses the whole subtree
|
|
4826
|
+
# into it — so skipping it left the comparison empty and everything the
|
|
4827
|
+
# reviewer wrote under that path invisible at any depth.
|
|
3972
4828
|
if [ "\${p}" = "${AI_REVIEW_ACTION_SCRATCH}" ]; then
|
|
4829
|
+
read_scratch "\${p}"
|
|
3973
4830
|
continue
|
|
3974
4831
|
fi
|
|
3975
|
-
|
|
3976
|
-
'"'*) h=unquotable ;;
|
|
3977
|
-
# A wholly-ignored directory, reported COLLAPSED with git's own
|
|
3978
|
-
# trailing slash. It is PRESENT, so \`absent\` would be false — and
|
|
3979
|
-
# \`absent\` is a value the drift step branches on, so the lie does not
|
|
3980
|
-
# stay cosmetic. See AI_REVIEW_IGNORED_DIR_HASH.
|
|
3981
|
-
*/) h=${AI_REVIEW_IGNORED_DIR_HASH} ;;
|
|
3982
|
-
*)
|
|
3983
|
-
if [ -f "\${p}" ]; then
|
|
3984
|
-
# --no-filters, or the repository's own text/eol conversion is
|
|
3985
|
-
# applied before hashing and two DIFFERENT working-tree blobs
|
|
3986
|
-
# collapse to one hash (#856 F3). Measured under \`* text eol=lf\`:
|
|
3987
|
-
# "x\\r\\n" and "x\\n" both hash 587be6b4…, and with --no-filters
|
|
3988
|
-
# they are db127bf6… and 587be6b4…. The reading is only a reading
|
|
3989
|
-
# of content if the hash is of the bytes on disk.
|
|
3990
|
-
# Isolated for the same reason as the status above (#960). It is
|
|
3991
|
-
# the \`-c\` half that matters here: \`--no-filters\` already
|
|
3992
|
-
# defeats a text/eol conversion, but a hash taken under the
|
|
3993
|
-
# reviewer's config is still a reading the reviewer chose.
|
|
3994
|
-
h=$(${AI_REVIEW_GIT_ISOLATED} hash-object --no-filters -- "\${p}" 2>/dev/null) || h=unreadable
|
|
3995
|
-
else
|
|
3996
|
-
h=absent
|
|
3997
|
-
fi
|
|
3998
|
-
;;
|
|
3999
|
-
esac
|
|
4000
|
-
printf '%s %s\\n' "\${h}" "\${p}"
|
|
4832
|
+
classify_path "\${p}"
|
|
4001
4833
|
done
|
|
4002
4834
|
}`;
|
|
4003
4835
|
|
|
@@ -4373,7 +5205,7 @@ ${AI_REVIEW_RUNTIME_CONFIG_PATHS.map((p, i) => {
|
|
|
4373
5205
|
\\) \\
|
|
4374
5206
|
2>/dev/null | head -50 || true)
|
|
4375
5207
|
if [ -n "\${runtime_config}" ]; then
|
|
4376
|
-
echo "::warning title=${
|
|
5208
|
+
echo "::warning title=${AI_REVIEW_RUNTIME_CONFIG_TITLE}::${runtimeConfig}: $(escape_annotation "\${runtime_config}")"
|
|
4377
5209
|
fi
|
|
4378
5210
|
|
|
4379
5211
|
if [ -n "\${outside}" ]; then
|
|
@@ -4562,9 +5394,14 @@ function indented(lines: string[], indent: string): string {
|
|
|
4562
5394
|
/**
|
|
4563
5395
|
* The review steps, as YAML, ready to be indented under a job's `steps:`.
|
|
4564
5396
|
*
|
|
4565
|
-
*
|
|
4566
|
-
*
|
|
4567
|
-
*
|
|
5397
|
+
* In the order they have to run: check out the branch, choose a payload path
|
|
5398
|
+
* outside it, install bun for the adjudicator, authenticate to Vertex, run the
|
|
5399
|
+
* reviewer, adjudicate its payload, and refuse one that edited the tree it was
|
|
5400
|
+
* reviewing.
|
|
5401
|
+
*
|
|
5402
|
+
* `version` is the generating harness version, and it reaches the `bunx`
|
|
5403
|
+
* invocation in the verdict step. It is a parameter rather than a read because
|
|
5404
|
+
* this module has no relative imports — see `AiReviewActionRefs`.
|
|
4568
5405
|
*
|
|
4569
5406
|
* Every credential is gated on the mode the
|
|
4570
5407
|
* auth step resolved rather than on the secret itself — the auth step is the
|
|
@@ -4578,6 +5415,7 @@ function indented(lines: string[], indent: string): string {
|
|
|
4578
5415
|
export function buildReviewRunStep(
|
|
4579
5416
|
vertex: VertexCiDecision,
|
|
4580
5417
|
refs: AiReviewActionRefs,
|
|
5418
|
+
version: string,
|
|
4581
5419
|
indent = " ",
|
|
4582
5420
|
): string {
|
|
4583
5421
|
const modeIs = (mode: string) =>
|
|
@@ -4602,6 +5440,27 @@ export function buildReviewRunStep(
|
|
|
4602
5440
|
...buildPrepareScript().trimEnd().split("\n").map(l => (l ? ` ${l}` : "")),
|
|
4603
5441
|
];
|
|
4604
5442
|
|
|
5443
|
+
// #1013. BEFORE the baseline, for #836's reason rather than for
|
|
5444
|
+
// convenience: anything a step writes into GITHUB_WORKSPACE after the
|
|
5445
|
+
// baseline is taken lands in the REVIEWER's column in the drift reading.
|
|
5446
|
+
// This action writes to the runner's tool cache and to `~/.bun`, not to the
|
|
5447
|
+
// checkout — but "it does not write there today" is the kind of belief the
|
|
5448
|
+
// drift step exists to stop relying on, and taking it early makes whatever
|
|
5449
|
+
// it does write cancel.
|
|
5450
|
+
//
|
|
5451
|
+
// `continue-on-error: true`, like every other step here: nothing in this
|
|
5452
|
+
// job may have an `if:`, and a setup action that fails hard turns a runner
|
|
5453
|
+
// with no bun into a RED check rather than an UNMEASURED one. The verdict
|
|
5454
|
+
// step reads the adjudicator's own output and says which it was.
|
|
5455
|
+
const setupBun = [
|
|
5456
|
+
`- name: ${AI_REVIEW_SETUP_BUN_STEP_NAME}`,
|
|
5457
|
+
` id: ${AI_REVIEW_SETUP_BUN_STEP_ID}`,
|
|
5458
|
+
` continue-on-error: true`,
|
|
5459
|
+
` uses: ${refs.setupBun}`,
|
|
5460
|
+
` with:`,
|
|
5461
|
+
...refs.setupBunWith.trimEnd().split("\n"),
|
|
5462
|
+
];
|
|
5463
|
+
|
|
4605
5464
|
// Workload Identity Federation, and NO service-account key (#677 AC-15).
|
|
4606
5465
|
//
|
|
4607
5466
|
// Emitted only when `ci.vertex` resolved. A step that authenticates with
|
|
@@ -4759,8 +5618,12 @@ export function buildReviewRunStep(
|
|
|
4759
5618
|
// exits 0, so a reading a consumer could configure would be a switch for
|
|
4760
5619
|
// turning every unmeasured pull request green.
|
|
4761
5620
|
` ${AI_REVIEW_EVENT_VAR}: \${{ github.event_name }}`,
|
|
5621
|
+
// #1180. The per-pull-request waiver, resolved by the RUNNER into the
|
|
5622
|
+
// literal `true` or `false` so no label text reaches the step. See
|
|
5623
|
+
// `AI_REVIEW_OVERRIDE_LABEL` for why this is a label and not a variable.
|
|
5624
|
+
` ${AI_REVIEW_OVERRIDE_VAR}: \${{ contains(github.event.pull_request.labels.*.name, '${AI_REVIEW_OVERRIDE_LABEL}') }}`,
|
|
4762
5625
|
` run: |`,
|
|
4763
|
-
...buildReviewRunScript().trimEnd().split("\n").map(l => (l ? ` ${l}` : "")),
|
|
5626
|
+
...buildReviewRunScript(version).trimEnd().split("\n").map(l => (l ? ` ${l}` : "")),
|
|
4764
5627
|
];
|
|
4765
5628
|
|
|
4766
5629
|
return (
|
|
@@ -4769,6 +5632,17 @@ export function buildReviewRunStep(
|
|
|
4769
5632
|
(vertexAuth.length === 0 ? "" : indented(vertexAuth, indent)) +
|
|
4770
5633
|
(credsRelocate.length === 0 ? "" : indented(credsRelocate, indent)) +
|
|
4771
5634
|
indented(restore, indent) +
|
|
5635
|
+
// AFTER the restore and BEFORE the baseline, and both halves are load
|
|
5636
|
+
// bearing. The action reads the bun-version declaration out of the
|
|
5637
|
+
// CHECKOUT to decide which runtime to install, so running it before the
|
|
5638
|
+
// restore lets the branch choose the interpreter this job then executes
|
|
5639
|
+
// the adjudicator with. That declaration is in
|
|
5640
|
+
// `AI_REVIEW_UNTRUSTED_PATHS` for exactly that reason, and restoring it
|
|
5641
|
+
// buys nothing if the step that reads it has already run. Before the
|
|
5642
|
+
// baseline is #836's ordering: anything a step writes into the workspace
|
|
5643
|
+
// after the baseline is taken lands in the REVIEWER's column in the
|
|
5644
|
+
// drift reading.
|
|
5645
|
+
indented(setupBun, indent) +
|
|
4772
5646
|
indented(baseline, indent) +
|
|
4773
5647
|
indented(review, indent) +
|
|
4774
5648
|
indented(report, indent) +
|