crysk 0.3.0 → 0.3.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/README.md +2 -0
- package/dist/SKILL-y8rv8msh.md +134 -0
- package/dist/SKILL-ygka1bs0.md +515 -0
- package/dist/ci-admission-qk9r9taq.md +124 -0
- package/dist/cli.js +659 -450
- package/dist/index.js +5 -5
- package/package.json +2 -2
- package/skills/crysk-ci-setup/SKILL.md +1 -1
- package/skills/crysk-ci-setup/references/ci-admission.md +4 -2
- package/skills/crysk-loop/SKILL.md +30 -11
- package/src/assets.ts +1 -1
- package/src/ci/gates.ts +28 -6
- package/src/ci/reporter.ts +2 -2
- package/src/ci/review-admission.ts +11 -2
- package/src/index.ts +1 -1
- package/src/pr/admission.ts +178 -41
- package/src/pr/answered-findings.ts +169 -0
- package/src/pr/ci-admission-gate.ts +80 -2
- package/src/pr/pr-status.ts +59 -1
- package/src/updater.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -2189,7 +2189,7 @@ var workflow_default = "./workflow-w1g9szna.yml";
|
|
|
2189
2189
|
var init_workflow = () => {};
|
|
2190
2190
|
|
|
2191
2191
|
// skills/crysk-ci-setup/references/ci-admission.md
|
|
2192
|
-
var ci_admission_default = "./ci-admission-
|
|
2192
|
+
var ci_admission_default = "./ci-admission-qk9r9taq.md";
|
|
2193
2193
|
var init_ci_admission = () => {};
|
|
2194
2194
|
|
|
2195
2195
|
// skills/crysk-ci-setup/references/opencode-ci.md
|
|
@@ -2197,7 +2197,7 @@ var opencode_ci_default = "./opencode-ci-7b0be64p.md";
|
|
|
2197
2197
|
var init_opencode_ci = () => {};
|
|
2198
2198
|
|
|
2199
2199
|
// skills/crysk-ci-setup/SKILL.md
|
|
2200
|
-
var SKILL_default2 = "./SKILL-
|
|
2200
|
+
var SKILL_default2 = "./SKILL-y8rv8msh.md";
|
|
2201
2201
|
var init_SKILL2 = () => {};
|
|
2202
2202
|
|
|
2203
2203
|
// skills/crysk-loop/adjudicator.md
|
|
@@ -2205,7 +2205,7 @@ var adjudicator_default = "./adjudicator-dtg2axnh.md";
|
|
|
2205
2205
|
var init_adjudicator = () => {};
|
|
2206
2206
|
|
|
2207
2207
|
// skills/crysk-loop/SKILL.md
|
|
2208
|
-
var SKILL_default3 = "./SKILL-
|
|
2208
|
+
var SKILL_default3 = "./SKILL-ygka1bs0.md";
|
|
2209
2209
|
var init_SKILL3 = () => {};
|
|
2210
2210
|
|
|
2211
2211
|
// skills/crysk-pr/SKILL.md
|
|
@@ -2289,7 +2289,7 @@ function resolveVersion() {
|
|
|
2289
2289
|
}
|
|
2290
2290
|
}
|
|
2291
2291
|
} catch {}
|
|
2292
|
-
return "0.3.
|
|
2292
|
+
return "0.3.1";
|
|
2293
2293
|
}
|
|
2294
2294
|
function resolveEngineAssets() {
|
|
2295
2295
|
const mode = detectAssetMode();
|
|
@@ -20000,7 +20000,7 @@ function envelopeModel(options, agentFiles) {
|
|
|
20000
20000
|
// src/index.ts
|
|
20001
20001
|
init_spec();
|
|
20002
20002
|
var ENGINE_NAME = "pr-hero";
|
|
20003
|
-
var ENGINE_VERSION = "0.3.
|
|
20003
|
+
var ENGINE_VERSION = "0.3.1";
|
|
20004
20004
|
export {
|
|
20005
20005
|
zeroUsage,
|
|
20006
20006
|
writeFindings,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crysk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/cryskai/crysk.git"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://
|
|
10
|
+
"homepage": "https://crysk.dev",
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/cryskai/crysk/issues"
|
|
13
13
|
},
|
|
@@ -22,7 +22,7 @@ Load when the user asks to:
|
|
|
22
22
|
- **No install needed:** run every Crysk command as `npx -y crysk <command>` (Node is enough; the package brings its own Bun). A global `crysk` on PATH is the same command. CI itself needs no local CLI at all: the workflow runs the action. `npx -y crysk skills install` installs the Crysk, triage, and CI-setup skills into every detected coding agent, with no TTY and no MCP or launchd registration (neither is needed for the CI loop, and npx's temporary cache refuses them).
|
|
23
23
|
- **Deterministic scaffolding:** Run `npx -y crysk setup --ci` (or `npx -y crysk ci init`) with the interview's flags. It writes the one workflow file, `.github/workflows/crysk.yml` (a repo that already has `pr-hero.yml` keeps it: `--force` rewrites it in place, and setup refuses to add a second file beside it). Do not fabricate it from memory. Fallback: copy `assets/workflow.yml`. Never scaffold a `pr-hero-force.yml`; it is retired.
|
|
24
24
|
- **`fetch-depth: 0` is mandatory** on `actions/checkout@v4`.
|
|
25
|
-
- **Gate mode:** the `crysk` commit status is the required check (the legacy `pr-hero` status is still posted for one version). The scaffold writes `mode: gate` explicitly: blocking findings, a size or
|
|
25
|
+
- **Gate mode:** the `crysk` commit status is the required check (the legacy `pr-hero` status is still posted for one version). The scaffold writes `mode: gate` explicitly: blocking findings, a size or spend-ceiling skip, and a crash set it red. Every review rule that skips a push (low-risk delta, once per PR, `/crysk stop`, the attempt budget used up, `manual_only`) carries the last verdict; answered blocking findings turn a carried red green, marked unverified. `mode: advisory` keeps it green for a finished review. The job's exit code stays `0` on findings either way, so do not gate on the job.
|
|
26
26
|
- **Required permissions:** `contents: read`, `pull-requests: write`, `issues: write`, `statuses: write`, **`checks: write`**, **`actions: read`** (the admission gate lists past runs; a private repo 403s without it). Template in `assets/workflow.yml` includes all six.
|
|
27
27
|
- **Retrigger is a PR comment: `gh pr comment <n> --body "/crysk review"`.** GitHub Actions runs the review on the runner with `--force`. The comment must be exactly `/crysk review` (or `/crysk review --full`; `/pr-hero review` on a workflow scaffolded before the rename, see the `/crysk` vs `/pr-hero` bullet), and its author needs write access; the action refuses anyone else. Do not run `crysk review --force` locally when the review should happen in CI. `gh run rerun` on a skipped run re-evaluates the gates and does not force. In this repo a comment run checks out the PR head commit before `uses: ./`, so it runs the PR's own engine, not the default branch's.
|
|
28
28
|
- **`/crysk recheck` re-reviews the head and asks the CI adjudicator to rule on pending dismissals.** It is `/crysk review` plus `--adjudicate`, with the same permission check and reaction; refused on fork pull requests. See `docs/github-actions.md` ("Rechecking a dismissal").
|
|
@@ -63,9 +63,11 @@ Size threshold: `max_changed_lines` is always written (default 4000, `--max-chan
|
|
|
63
63
|
|---|---|
|
|
64
64
|
| Review runs | Normal pipeline |
|
|
65
65
|
| **Skipped** | Push did not justify spend (same head, low score, docs-only delta, etc.) — **not** “clean” |
|
|
66
|
-
| **
|
|
66
|
+
| **Automatic reviews done** | Budget exhausted or `manual_only` — the gate keeps the last verdict, answered findings turn a red green (marked unverified), and `/crysk review` runs another round |
|
|
67
67
|
|
|
68
|
-
Skipped and
|
|
68
|
+
Skipped and automatic-reviews-done posts include admission metadata in the step summary. The automatic-reviews-done
|
|
69
|
+
comment explains the end of the budget by the repository's rules (policy, attempts used, last reviewed head) and how to
|
|
70
|
+
ask for more rounds.
|
|
69
71
|
|
|
70
72
|
## Durable ledger
|
|
71
73
|
|
|
@@ -60,7 +60,8 @@ tag, not applying the review as a todo list.
|
|
|
60
60
|
|
|
61
61
|
Every Crysk comment is a **claim to verify**, not an order. An advisory report never blocks anything. A CI
|
|
62
62
|
report in gate mode can turn the `crysk` status red on blocking findings. Your reply is argument and evidence,
|
|
63
|
-
and it never clears that status on its own. A blocking finding stops counting in
|
|
63
|
+
and it never clears that status on its own while a review can still run. A blocking finding stops counting in
|
|
64
|
+
exactly two ways:
|
|
64
65
|
|
|
65
66
|
- **A fix**, pushed to the head and verified gone by the next review.
|
|
66
67
|
- **A dismissal the CI adjudicator upholds.** You reply `dismissed`, comment `/crysk recheck`, an
|
|
@@ -68,6 +69,22 @@ and it never clears that status on its own. A blocking finding stops counting in
|
|
|
68
69
|
`github-actions[bot]` on that head) lets the next review stop counting the finding. See
|
|
69
70
|
"Closing a dismissal" below.
|
|
70
71
|
|
|
72
|
+
**When no review is left, answers unlock the gate.** Every review rule that skips a push (the
|
|
73
|
+
attempt budget used up, `/crysk stop`, `once_per_pr`, a low-risk or below-threshold delta,
|
|
74
|
+
`manual_only`) carries the last verdict. A carried red turns green, marked
|
|
75
|
+
`fixes unverified`, on the next push when every blocking finding's newest reply, from your
|
|
76
|
+
write-access account, is `applied` at the head it was posted on or a `dismissed` the adjudicator
|
|
77
|
+
upheld. Nobody verifies those fixes, so `applied` must mean you fixed it and ran the tests. The
|
|
78
|
+
gate reads the replies when the push arrives: **reply first, then push.**
|
|
79
|
+
|
|
80
|
+
**`/crysk override` is a maintainer's, and only for what answers cannot unlock.** Never post it,
|
|
81
|
+
and never ask for it because the review budget ran out. Ask a maintainer for it only when:
|
|
82
|
+
- the CI review itself is broken (every hunter failing, credit or credentials, `PRH-HUNTERS-FAILED`):
|
|
83
|
+
stop the loop and report what is failing, never route around it;
|
|
84
|
+
- a `deferred` or `misclassified` finding should merge unfixed: it names a real defect, so
|
|
85
|
+
accepting it is the maintainer's call;
|
|
86
|
+
- a partial review keeps failing on the same hunters and their route cannot be fixed.
|
|
87
|
+
|
|
71
88
|
`deferred` and `misclassified` never leave the gate count, whatever any adjudicator says: they are
|
|
72
89
|
for findings that are real (or real at another severity), so the gate stays red until a fix or a
|
|
73
90
|
human `/crysk override`. You — the
|
|
@@ -96,15 +113,15 @@ Later review passes hunt only the push delta. Once the real defects from pass 1
|
|
|
96
113
|
1. **Never patch code to appease a contrived or over-severitied finding.**
|
|
97
114
|
- If the claimed bug requires an impossible precondition, contradicts an intentional invariant, or is already guarded: tag it `dismissed` with cited code and use `/crysk recheck` so the CI adjudicator clears it **without** a code change or a new push.
|
|
98
115
|
- If the observation is technically true but trivial, stylistic, pre-existing, or inflated to blocking: tag it `misclassified` or `deferred`. Never rewrite working code just to avoid asking for `/crysk override`.
|
|
99
|
-
2. **Do not auto-force past `ci_max_attempts` on routine fix-ups.** The repository's `ci_max_attempts` (default `2`) exists specifically to stop diminishing-returns re-reviews
|
|
116
|
+
2. **Do not auto-force past `ci_max_attempts` on routine fix-ups.** The repository's `ci_max_attempts` (default `2`) exists specifically to stop diminishing-returns re-reviews, and the PR gets an "automatic reviews are done" comment when it runs out. The gate then carries the last verdict: answer every blocking finding (`applied` with the fix in the tree, or `dismissed` + `/crysk recheck`) **before** you push, and that push turns a carried red green, marked `fixes unverified`. If the commits since `report.head` only applied straightforward fixes for already-triaged findings, do not post `/crysk review`: stop the loop and tell the user the PR finished its review passes and is ready to merge, with the fixes unverified by a review. No override is needed.
|
|
100
117
|
3. **Stop and recommend merge when only diminishing-returns items remain.** On `override-or-fix` (or pass 2+ when every real bug is fixed and the only remaining red-gate items are `deferred`, `misclassified`, or a contrived finding whose dismissal the adjudicator did not uphold), **do not cave in and edit the code**. Exit the loop, list the remaining finding(s) with a one-line explanation of why they are contrived/out-of-scope, and tell the user the PR is ready to `/crysk override` and merge.
|
|
101
|
-
4. **Stop automatic reviews BEFORE the push that should not be reviewed.** When you decide no further review pass is needed but you still have fixes to push, post `gh pr comment <n> --body "/crysk stop"` **first**, then `git push`. CI admission reads the stop on that push and skips the review, carrying the last verdict (a red
|
|
118
|
+
4. **Stop automatic reviews BEFORE the push that should not be reviewed.** When you decide no further review pass is needed but you still have fixes to push, post `gh pr comment <n> --body "/crysk stop"` **first**, then `git push`. CI admission reads the stop on that push and skips the review, carrying the last verdict (a carried red turns green, marked `fixes unverified`, when every blocking finding was answered before that push; otherwise it stays red). The stop stays in force for every later push until someone comments `/crysk review` or `/crysk recheck`. It counts only from a user with write access, starts no workflow run, and costs $0. Never push first and try to stop the review afterwards: nothing cancels a review that already started.
|
|
102
119
|
|
|
103
120
|
### B. Requesting or suggesting another review when workflow rules skipped it
|
|
104
121
|
|
|
105
122
|
The opposite happens when a repository's workflow policy (`once_per_pr`, `thresholded`, `risk_aware` below the score floor, `ci_max_attempts` exhausted, or the size gate) suppresses an automatic review on a push that **genuinely changed load-bearing code**:
|
|
106
123
|
- Under `once_per_pr`, `thresholded`, or `risk_aware`, a skipped push can inherit a carried `success` status from `report.head`, so `next_action` reads `"done"` even though `report.head !== head` (the commits `report.head..head` were never reviewed).
|
|
107
|
-
- Under `ci_max_attempts` or the size
|
|
124
|
+
- Under `ci_max_attempts` or `manual_only`, the push carries the last verdict the same way, or a `fixes unverified` green once every blocking finding is answered. Under the size or spend-ceiling gate, the automatic run is blocked and the head is red. Either way `report.head !== head`.
|
|
108
125
|
|
|
109
126
|
Whenever `report.head !== head`, inspect `git diff <report.head>..<head>`:
|
|
110
127
|
- If that unreviewed delta introduced **new business logic, state-machine or concurrency changes, auth/security/isolation edits, or a non-trivial refactor** (for example, fixing a finding required redesigning a function rather than adding a guard), an extra review **is** justified:
|
|
@@ -158,10 +175,11 @@ read that file instead.
|
|
|
158
175
|
|
|
159
176
|
Act on its `next_action` and immediately loop back to step 0 until `done`:
|
|
160
177
|
- `wait`: if `--wait` was omitted, re-run with `--wait` and let it block until the review finishes.
|
|
161
|
-
- `review`: no review has run on this head, the last one did not finish, the CI adjudicator
|
|
162
|
-
upheld every dismissal and the next review will stop counting them
|
|
163
|
-
|
|
164
|
-
|
|
178
|
+
- `review`: no review has run on this head, the last one did not finish, or the CI adjudicator
|
|
179
|
+
upheld every dismissal and the next review will stop counting them. (A head statused before
|
|
180
|
+
2026-10-30 may also read "the automatic review budget for this PR is used up"; push the answered
|
|
181
|
+
fixes instead, and the gate carries the verdict.) Check the forced-run bound below, comment
|
|
182
|
+
`gh pr comment <n> --body "/crysk review"`, and immediately run step 0 with `--wait`.
|
|
165
183
|
- `triage`: a live blocking finding on this head has no triage reply at the head it was posted
|
|
166
184
|
on, or the gate is green and a finding posted on this head has no reply yet (advisory findings
|
|
167
185
|
need one too). Run the triage batch below (steps 1–6), which judges every finding, applies real fixes in the tree, posts all replies, and either pushes the fixes or triggers `recheck` before looping back to step 0 with `--wait`.
|
|
@@ -177,12 +195,13 @@ read that file instead.
|
|
|
177
195
|
(model or credential), or ask a maintainer to override;
|
|
178
196
|
- every blocking finding is already answered but none can clear without a fix (a dismissal the
|
|
179
197
|
CI adjudicator rejected, a `deferred` / `misclassified` tag, or a `dismissed` finding with no
|
|
180
|
-
review thread, which no adjudicator can rule on): if the adjudicator's rejection exposed a real defect you missed, fix, commit, and `git push` (then step 0 `--wait`); if the finding is `deferred`, `misclassified`, or still contrived/absurd ("Stopping diminishing returns" above), **do not edit code to appease it** — exit the loop and tell the maintainer the PR is ready for `/crysk override` and merge;
|
|
198
|
+
review thread, which no adjudicator can rule on): if the adjudicator's rejection exposed a real defect you missed, fix, commit, and `git push` (then step 0 `--wait`); if the finding is `deferred`, `misclassified`, or still contrived/absurd ("Stopping diminishing returns" above), **do not edit code to appease it** — exit the loop and tell the maintainer the PR is ready for `/crysk override` and merge (a `deferred` or `misclassified` finding names a real defect, so accepting it unfixed is the maintainer's call);
|
|
181
199
|
- the red gate names no live blocking finding on this head (the `reason` quotes the gate
|
|
182
200
|
description): read that description and act on what it says; when it names nothing you can
|
|
183
201
|
fix, ask a maintainer.
|
|
184
202
|
- `done`: nothing is owed on this head. The gate passed (or an override unlocked it) and every
|
|
185
|
-
finding posted on this head has a reply.
|
|
203
|
+
finding posted on this head has a reply. A `fixes unverified` green (the `reason` says no review
|
|
204
|
+
verified it) is done too: report the PR ready to merge and say the fixes were not verified by a review. Before exiting, check whether `report.head && report.head !== head` (a green status carried over an unreviewed push under `once_per_pr`, `thresholded`, or `risk_aware`): if `git diff <report.head>..<head>` contains non-trivial logic or risky changes ("Requesting or suggesting another review" above), recommend `/crysk review` naming those changes; otherwise exit the loop and report that the PR is ready to merge.
|
|
186
205
|
|
|
187
206
|
**Bound the forced runs.** `/crysk review` and `/crysk recheck` each run a full paid review
|
|
188
207
|
that bypasses the size, budget and admission gates (`ci_max_attempts` included), and a gate
|
|
@@ -244,7 +263,7 @@ current head:
|
|
|
244
263
|
`--verdict` from the adjudicator. `--issue` is optional and only valid
|
|
245
264
|
with `--tag deferred`.
|
|
246
265
|
6. **Advance the loop in one batch once all findings on this head are answered:**
|
|
247
|
-
- **If you made clean code fixes (`applied` or unthreaded blocking fixes):** if you decided this push needs no further review ("Stopping diminishing returns", rule 4), post `/crysk stop` before pushing, and after the push do **not** wait for a re-review: none will run. Report that the fixes are pushed and the PR is ready
|
|
266
|
+
- **If you made clean code fixes (`applied` or unthreaded blocking fixes):** if you decided this push needs no further review ("Stopping diminishing returns", rule 4), post `/crysk stop` before pushing, and after the push do **not** wait for a re-review: none will run. Report that the fixes are pushed and the PR is ready to merge: the gate carries the last verdict, and every blocking finding you answered before the push turns a carried red green, marked `fixes unverified`. Only a finding left `deferred` or `misclassified` still needs a maintainer's `/crysk override`. Otherwise, commit and `git push` all fixes in a single push, then immediately run `npx -y crysk status --pr <n> --wait --json` to subscribe to the re-review on the new head. Do **not** run `/crysk recheck` before pushing: a new push invalidates prior-head recheck rulings and wastes a CI run.
|
|
248
267
|
- **If no code changes were needed:** run `npx -y crysk status --pr <n> --wait --json` and execute its `next_action` (`recheck` when blocking findings were `dismissed`, or `done` when the gate is already green).
|
|
249
268
|
|
|
250
269
|
*(Note: The MCP server is strictly read-only for querying runs, findings, and
|
package/src/assets.ts
CHANGED
package/src/ci/gates.ts
CHANGED
|
@@ -664,21 +664,43 @@ function buildCoverageSkipComment(
|
|
|
664
664
|
return `${lines.join("\n")}\n`;
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
+
// budget-exhausted-carry S10: the comment a PR gets once no automatic review is left. It says so, explains
|
|
668
|
+
// it by the repository's own rules, says what the gate does with the next pushes, and how to ask for more.
|
|
669
|
+
// WHY no "override" here: an exhausted budget carries the last verdict (S2), and answered findings unlock a
|
|
670
|
+
// carried red (S3), so nothing in this situation needs a human to unlock the gate.
|
|
667
671
|
function buildManualRequiredComment(data: ManualRequiredSummary): string {
|
|
672
|
+
const manualOnly = data.admissionReason === "manual-only-policy";
|
|
673
|
+
const rules = [
|
|
674
|
+
...(data.policyMode === undefined
|
|
675
|
+
? []
|
|
676
|
+
: [`- Review policy: \`${data.policyMode}\` (\`ci_review_policy\`).`]),
|
|
677
|
+
manualOnly
|
|
678
|
+
? "- This repository reviews automatically once per pull request; every later review is on request."
|
|
679
|
+
: `- Automatic reviews used: ${data.reviewCount}/${data.maxAttempts} (\`ci_max_attempts\`).`,
|
|
680
|
+
...(data.reviewedHead === undefined || data.reviewedHead === null
|
|
681
|
+
? []
|
|
682
|
+
: [`- Last reviewed head: \`${data.reviewedHead.slice(0, 7)}\`.`]),
|
|
683
|
+
];
|
|
668
684
|
const lines = [
|
|
669
685
|
MANUAL_REQUIRED_COMMENT_MARKER,
|
|
670
|
-
"## Crysk
|
|
686
|
+
"## Crysk: automatic reviews are done for this pull request",
|
|
671
687
|
"",
|
|
672
|
-
"
|
|
688
|
+
"⏹️ No more automatic reviews will run on this pull request.",
|
|
673
689
|
"",
|
|
674
690
|
`**${data.detail}**`,
|
|
675
691
|
"",
|
|
676
|
-
|
|
692
|
+
"How it got here, by this repository's rules:",
|
|
677
693
|
"",
|
|
678
|
-
|
|
679
|
-
"reviewed.",
|
|
694
|
+
...rules,
|
|
680
695
|
"",
|
|
681
|
-
|
|
696
|
+
"What the gate does with the next pushes: it keeps the last review's verdict. A red verdict turns " +
|
|
697
|
+
"green, marked unverified, once every blocking finding has a reply from someone with write access: " +
|
|
698
|
+
"`applied`, or a `dismissed` the CI adjudicator upheld. Reply before you push: the gate reads the " +
|
|
699
|
+
"replies when the push arrives.",
|
|
700
|
+
"",
|
|
701
|
+
"The existing review comment still describes the last head Crysk reviewed.",
|
|
702
|
+
"",
|
|
703
|
+
`Want more review rounds? ${ciForceReviewHintLine(data.prNumber)}`,
|
|
682
704
|
];
|
|
683
705
|
return `${lines.join("\n")}\n`;
|
|
684
706
|
}
|
package/src/ci/reporter.ts
CHANGED
|
@@ -402,9 +402,9 @@ function skipCoverageLines(data: CiSkipCoverageSummary): string[] {
|
|
|
402
402
|
|
|
403
403
|
function manualRequiredLines(data: CiManualRequiredSummary): string[] {
|
|
404
404
|
return [
|
|
405
|
-
`###
|
|
405
|
+
`### ⏹️ Crysk Review — Automatic Reviews Done — PR #${data.prNumber}`,
|
|
406
406
|
"",
|
|
407
|
-
"**Reason:** automatic review
|
|
407
|
+
"**Reason:** no automatic review is left for this pull request; the gate keeps the last verdict.",
|
|
408
408
|
"",
|
|
409
409
|
"| Metric | Value |",
|
|
410
410
|
"| --- | --- |",
|
|
@@ -801,13 +801,22 @@ export function ciReviewSkipDetail(
|
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
803
|
|
|
804
|
-
// The short label a status description names for a
|
|
804
|
+
// The short label a status description names for a skip (the carry-forward in
|
|
805
805
|
// src/pr/admission.ts). The same wording as the coverage comment (ci/gates.ts COVERAGE_REASON_LABEL,
|
|
806
806
|
// which is not exported), kept here so a description reads the same as the comment beside it.
|
|
807
807
|
export function ciReviewSkipLabel(
|
|
808
|
-
reason:
|
|
808
|
+
reason:
|
|
809
|
+
| "once-per-pr"
|
|
810
|
+
| "below-threshold"
|
|
811
|
+
| "low-risk-delta"
|
|
812
|
+
| "stopped"
|
|
813
|
+
| CiReviewManualRequiredReason,
|
|
809
814
|
): string {
|
|
810
815
|
switch (reason) {
|
|
816
|
+
case "max-attempts-exhausted":
|
|
817
|
+
return "review budget for this PR is used up";
|
|
818
|
+
case "manual-only-policy":
|
|
819
|
+
return "ci_review_policy is manual_only";
|
|
811
820
|
case "once-per-pr":
|
|
812
821
|
return "once_per_pr policy allows one automatic review";
|
|
813
822
|
case "below-threshold":
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Public API surface; the deep-review lab consumes exactly these exports.
|
|
3
3
|
|
|
4
4
|
export const ENGINE_NAME = "pr-hero";
|
|
5
|
-
export const ENGINE_VERSION = "0.3.
|
|
5
|
+
export const ENGINE_VERSION = "0.3.1";
|
|
6
6
|
|
|
7
7
|
// errors and git/refs used to reach this surface only through re-exports in
|
|
8
8
|
// review/preflight.ts; they are exported directly now that those re-exports
|
package/src/pr/admission.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
formatWorkflowCommand,
|
|
23
23
|
} from "#ci/reporter";
|
|
24
24
|
import { type CiReviewPolicy, ciReviewSkipLabel } from "#ci/review-admission";
|
|
25
|
+
import type { AnsweredFindings } from "#pr/answered-findings";
|
|
25
26
|
import {
|
|
26
27
|
fetchCommitStatuses,
|
|
27
28
|
fetchCommitStatusList,
|
|
@@ -282,8 +283,15 @@ export async function recordCiAdmissionGateSkip(input: {
|
|
|
282
283
|
// WHY fail closed: no verdict within the cap, a failed read, a head missing from the PR's commits (a
|
|
283
284
|
// force-push, or a list cut short by GitHub's cap), or no reviewed head writes failure, so a trivial push
|
|
284
285
|
// cannot pass the gate without a verdict behind it.
|
|
285
|
-
// WHY
|
|
286
|
-
//
|
|
286
|
+
// WHY an exhausted budget and a manual-only policy carry too (budget-exhausted-carry S2, the owner's
|
|
287
|
+
// decision of 2026-10-30, replacing the fixed failure S4 first wrote): every review rule is respected the
|
|
288
|
+
// same way. The once-per-pr, threshold and stop skips already carried a green over an unreviewed push, so a
|
|
289
|
+
// fixed failure here only turned the agent's last fix-up push red and made a human override routine.
|
|
290
|
+
// Same-head writes nothing, because that head's own status already exists.
|
|
291
|
+
// WHY answered findings may turn a carried blocking red green (S3): with no review left, the fixes cannot
|
|
292
|
+
// be verified. A write-access `applied` reply, or a dismissal the CI adjudicator upheld, on every blocking
|
|
293
|
+
// finding of the reviewed head is the most the gate can know, and the green it writes says so
|
|
294
|
+
// (unverifiedFixesDescription), so it never reads as a green a review earned.
|
|
287
295
|
export type AdmissionStatusReason =
|
|
288
296
|
| "same-head"
|
|
289
297
|
| "once-per-pr"
|
|
@@ -303,6 +311,10 @@ export interface AdmissionStatusInput {
|
|
|
303
311
|
// failure's description does not name a count. Every text isReviewVerdictStatus admits names one, so this
|
|
304
312
|
// is unreachable through the walk today; it stays because ci-admission-gate.ts still supplies it.
|
|
305
313
|
priorBlocking: number;
|
|
314
|
+
// Reads the reviewed head's answered blocking findings (pr/answered-findings.ts). Called only when the
|
|
315
|
+
// carried verdict is a blocking red, so every other skip makes no extra API call. Absent means never read.
|
|
316
|
+
// `verdictAt` is when the carried verdict was written (its status's created_at), or null when unknown.
|
|
317
|
+
readAnswered?: (verdictAt: string | null) => Promise<AnsweredFindings | null>;
|
|
306
318
|
}
|
|
307
319
|
|
|
308
320
|
export interface AdmissionStatusDecision {
|
|
@@ -314,23 +326,20 @@ export interface AdmissionStatusDecision {
|
|
|
314
326
|
export interface CarriedVerdict {
|
|
315
327
|
sha: string;
|
|
316
328
|
statuses: readonly CommitStatusFact[];
|
|
329
|
+
// The PR's commits older than `sha`, newest first, within the walk's cap: where a chained carry's review
|
|
330
|
+
// verdict is looked up (reviewVerdictTime). Absent means none to look at.
|
|
331
|
+
older?: readonly string[];
|
|
317
332
|
}
|
|
318
333
|
|
|
319
|
-
type CarriedReason =
|
|
320
|
-
| "once-per-pr"
|
|
321
|
-
| "below-threshold"
|
|
322
|
-
| "low-risk-delta"
|
|
323
|
-
| "stopped";
|
|
334
|
+
type CarriedReason = Exclude<AdmissionStatusReason, "same-head">;
|
|
324
335
|
|
|
336
|
+
// Every rule that skips a review carries the last verdict the same way (budget-exhausted-carry S2): the
|
|
337
|
+
// rule is respected, so no review runs, and the head reads what the last review decided. Same-head is the
|
|
338
|
+
// one exception: that head's own status already exists.
|
|
325
339
|
function isCarriedReason(
|
|
326
340
|
reason: AdmissionStatusReason,
|
|
327
341
|
): reason is CarriedReason {
|
|
328
|
-
return
|
|
329
|
-
reason === "once-per-pr" ||
|
|
330
|
-
reason === "below-threshold" ||
|
|
331
|
-
reason === "low-risk-delta" ||
|
|
332
|
-
reason === "stopped"
|
|
333
|
-
);
|
|
342
|
+
return reason !== "same-head";
|
|
334
343
|
}
|
|
335
344
|
|
|
336
345
|
// The readers below rewrite a legacy `pr-hero` lead into `crysk` first (canonicalStatusText), so the
|
|
@@ -366,6 +375,28 @@ export function carriedBlockingDescription(count: number, sha: string): string {
|
|
|
366
375
|
);
|
|
367
376
|
}
|
|
368
377
|
|
|
378
|
+
// The text a skip writes when a carried blocking red has every blocking finding answered and no review is
|
|
379
|
+
// left to verify the fixes (S3, S6). It names the rule that skipped, so a reader sees why nothing verified it.
|
|
380
|
+
// WHY "answered finding(s)" and not "blocking finding(s)": BLOCKING_COUNT reads that prefix as a red count.
|
|
381
|
+
export function unverifiedFixesDescription(
|
|
382
|
+
count: number,
|
|
383
|
+
label: string,
|
|
384
|
+
sha: string,
|
|
385
|
+
): string {
|
|
386
|
+
return clipStatusDescription(
|
|
387
|
+
`${STATUS_CONTEXT}: ${count} answered finding(s), fixes unverified (${label}); ${CARRIED_FROM}${sha.slice(0, 7)}`,
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const ANSWERED_COUNT = /^crysk: (\d+) answered finding\(s\), fixes unverified/;
|
|
392
|
+
|
|
393
|
+
function answeredCountIn(description: string): number | null {
|
|
394
|
+
const match = ANSWERED_COUNT.exec(canonicalStatusText(description));
|
|
395
|
+
if (match === null) return null;
|
|
396
|
+
const count = Number(match[1]);
|
|
397
|
+
return count > 0 ? count : null;
|
|
398
|
+
}
|
|
399
|
+
|
|
369
400
|
// The text a skip writes when it inherits a finished review's partial verdict (some hunters failed).
|
|
370
401
|
export function carriedPartialDescription(
|
|
371
402
|
failed: number,
|
|
@@ -384,6 +415,8 @@ const CARRY_REASONS: readonly CarriedReason[] = [
|
|
|
384
415
|
"below-threshold",
|
|
385
416
|
"low-risk-delta",
|
|
386
417
|
"stopped",
|
|
418
|
+
"max-attempts-exhausted",
|
|
419
|
+
"manual-only-policy",
|
|
387
420
|
];
|
|
388
421
|
|
|
389
422
|
function finishedSuccessMatches(rawDescription: string): boolean {
|
|
@@ -429,6 +462,21 @@ function carriedSuccessMatches(rawDescription: string): boolean {
|
|
|
429
462
|
);
|
|
430
463
|
}
|
|
431
464
|
|
|
465
|
+
function unverifiedFixesMatches(rawDescription: string): boolean {
|
|
466
|
+
const description = canonicalStatusText(rawDescription);
|
|
467
|
+
const sha = carriedSha(description);
|
|
468
|
+
const count = answeredCountIn(description);
|
|
469
|
+
return (
|
|
470
|
+
sha !== null &&
|
|
471
|
+
count !== null &&
|
|
472
|
+
CARRY_REASONS.some(
|
|
473
|
+
(reason) =>
|
|
474
|
+
unverifiedFixesDescription(count, ciReviewSkipLabel(reason), sha) ===
|
|
475
|
+
description,
|
|
476
|
+
)
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
|
|
432
480
|
function carriedBlockingMatches(rawDescription: string): boolean {
|
|
433
481
|
const description = canonicalStatusText(rawDescription);
|
|
434
482
|
const sha = carriedSha(description);
|
|
@@ -499,7 +547,9 @@ export function isReviewVerdictStatus(
|
|
|
499
547
|
if (typeof description !== "string") return false;
|
|
500
548
|
if (status.state === "success") {
|
|
501
549
|
return (
|
|
502
|
-
finishedSuccessMatches(description) ||
|
|
550
|
+
finishedSuccessMatches(description) ||
|
|
551
|
+
carriedSuccessMatches(description) ||
|
|
552
|
+
unverifiedFixesMatches(description)
|
|
503
553
|
);
|
|
504
554
|
}
|
|
505
555
|
if (status.state === "failure") {
|
|
@@ -534,39 +584,27 @@ function failClosed(label: string): AdmissionStatusDecision {
|
|
|
534
584
|
// What the gate's skip writes on the new head, or null for no write. `carried` is the verdict the skip
|
|
535
585
|
// inherits (findCarriedVerdict), or null when none was read or found. A reason that never carries reads none.
|
|
536
586
|
export function admissionSkipDecision(
|
|
537
|
-
input: AdmissionStatusInput & {
|
|
587
|
+
input: AdmissionStatusInput & {
|
|
588
|
+
carried: CarriedVerdict | null;
|
|
589
|
+
// The blocking findings of the reviewed head and how many are still open (answeredBlockingFindings),
|
|
590
|
+
// read only when the carried verdict is a blocking red. Null when unread or failed closed.
|
|
591
|
+
answered?: AnsweredFindings | null;
|
|
592
|
+
},
|
|
538
593
|
): AdmissionStatusDecision | null {
|
|
539
|
-
|
|
540
|
-
case "same-head":
|
|
541
|
-
return null;
|
|
542
|
-
case "max-attempts-exhausted":
|
|
543
|
-
return {
|
|
544
|
-
state: "failure",
|
|
545
|
-
description: clipStatusDescription(
|
|
546
|
-
`${STATUS_CONTEXT}: review budget for this PR is used up — /pr-hero review reviews this head`,
|
|
547
|
-
),
|
|
548
|
-
};
|
|
549
|
-
case "manual-only-policy":
|
|
550
|
-
return {
|
|
551
|
-
state: "failure",
|
|
552
|
-
description: clipStatusDescription(
|
|
553
|
-
`${STATUS_CONTEXT}: review needs a manual trigger (ci_review_policy is manual_only) — /pr-hero review reviews this head`,
|
|
554
|
-
),
|
|
555
|
-
};
|
|
556
|
-
case "once-per-pr":
|
|
557
|
-
case "below-threshold":
|
|
558
|
-
case "low-risk-delta":
|
|
559
|
-
case "stopped":
|
|
560
|
-
break;
|
|
561
|
-
}
|
|
594
|
+
if (input.reason === "same-head") return null;
|
|
562
595
|
const label = ciReviewSkipLabel(input.reason);
|
|
563
596
|
if (input.carried === null) return failClosed(label);
|
|
564
597
|
const verdict = newestCarriedVerdict(input.carried.statuses);
|
|
565
598
|
if (verdict === undefined) return failClosed(label);
|
|
566
599
|
if (verdict.state === "success") {
|
|
600
|
+
// A carried unverified green stays unverified: chaining it never turns it into a green a review earned.
|
|
601
|
+
const answeredCount = answeredCountIn(verdict.description ?? "");
|
|
567
602
|
return {
|
|
568
603
|
state: "success",
|
|
569
|
-
description:
|
|
604
|
+
description:
|
|
605
|
+
answeredCount === null
|
|
606
|
+
? carriedSuccessDescription(label, input.carried.sha)
|
|
607
|
+
: unverifiedFixesDescription(answeredCount, label, input.carried.sha),
|
|
570
608
|
};
|
|
571
609
|
}
|
|
572
610
|
// S5: a partial verdict is red, and it is never read as a blocking count (it has none). Taking the
|
|
@@ -587,12 +625,42 @@ export function admissionSkipDecision(
|
|
|
587
625
|
blockingCountIn(verdict.description) ??
|
|
588
626
|
(input.priorBlocking > 0 ? input.priorBlocking : null);
|
|
589
627
|
if (blocking === null) return failClosed(label);
|
|
628
|
+
// S3, S5: every blocking finding answered unlocks the red, and the read must see at least as many
|
|
629
|
+
// blocking findings as the red counts; fewer means some live where this read cannot see them.
|
|
630
|
+
const answered = input.answered ?? null;
|
|
631
|
+
if (
|
|
632
|
+
answered !== null &&
|
|
633
|
+
answered.open === 0 &&
|
|
634
|
+
answered.blocking > 0 &&
|
|
635
|
+
answered.blocking >= blocking
|
|
636
|
+
) {
|
|
637
|
+
return {
|
|
638
|
+
state: "success",
|
|
639
|
+
description: unverifiedFixesDescription(
|
|
640
|
+
answered.blocking,
|
|
641
|
+
label,
|
|
642
|
+
input.carried.sha,
|
|
643
|
+
),
|
|
644
|
+
};
|
|
645
|
+
}
|
|
590
646
|
return {
|
|
591
647
|
state: "failure",
|
|
592
648
|
description: carriedBlockingDescription(blocking, input.carried.sha),
|
|
593
649
|
};
|
|
594
650
|
}
|
|
595
651
|
|
|
652
|
+
// The carried verdict's blocking count when it is a blocking red (not a partial), else null. The gate reads
|
|
653
|
+
// the answered findings only then, so a carried green or a partial red makes no extra API call.
|
|
654
|
+
export function carriedBlockingCount(
|
|
655
|
+
carried: CarriedVerdict | null,
|
|
656
|
+
): number | null {
|
|
657
|
+
if (carried === null) return null;
|
|
658
|
+
const verdict = newestCarriedVerdict(carried.statuses);
|
|
659
|
+
if (verdict === undefined || verdict.state !== "failure") return null;
|
|
660
|
+
if (partialCountsIn(verdict.description) !== null) return null;
|
|
661
|
+
return blockingCountIn(verdict.description);
|
|
662
|
+
}
|
|
663
|
+
|
|
596
664
|
// The most earlier commits the carry reads for a verdict. A push on top of a longer run of commits with
|
|
597
665
|
// no verdict fails closed rather than walking the whole PR.
|
|
598
666
|
const CARRY_WALK_CAP = 20;
|
|
@@ -624,7 +692,9 @@ async function findCarriedVerdict(input: {
|
|
|
624
692
|
spawnFn: input.spawnFn,
|
|
625
693
|
});
|
|
626
694
|
if (statuses === null) return null;
|
|
627
|
-
if (newestCarriedVerdict(statuses) !== undefined)
|
|
695
|
+
if (newestCarriedVerdict(statuses) !== undefined) {
|
|
696
|
+
return { sha, statuses, older: earlier.slice(earlier.indexOf(sha) + 1) };
|
|
697
|
+
}
|
|
628
698
|
}
|
|
629
699
|
return null;
|
|
630
700
|
}
|
|
@@ -664,6 +734,53 @@ async function overrideStandsOnHead(input: {
|
|
|
664
734
|
return newest !== undefined && isOverrideStatus(newest);
|
|
665
735
|
}
|
|
666
736
|
|
|
737
|
+
// When the review behind the carried verdict wrote its own verdict, or null when none reads: the stale-reply
|
|
738
|
+
// cutoff (answered-findings.ts isStaleReply). WHY the review's own verdict, not the carried one: a chained
|
|
739
|
+
// skip carries a status a skip wrote later, and a reply made between the review and that skip answers the
|
|
740
|
+
// review; cutting at the skip's time would drop it. The walk goes on down the PR's own commits from the
|
|
741
|
+
// carried one, the carry's source (never the summary's head, which a comment can name), and stops at the
|
|
742
|
+
// first commit with a review's own verdict. A failed read, or none within the cap, is null: fail closed.
|
|
743
|
+
async function reviewVerdictTime(input: {
|
|
744
|
+
operatorRoot: string;
|
|
745
|
+
carried: CarriedVerdict | null;
|
|
746
|
+
spawnFn?: typeof Bun.spawn;
|
|
747
|
+
readStatuses: typeof fetchCommitStatusList;
|
|
748
|
+
}): Promise<string | null> {
|
|
749
|
+
if (input.carried === null) return null;
|
|
750
|
+
const ownIn = (statuses: readonly CommitStatusFact[]) =>
|
|
751
|
+
newestStatusInContext(
|
|
752
|
+
statuses.filter((status) => finishedVerdict(status)),
|
|
753
|
+
COMMIT_STATUS_CONTEXT,
|
|
754
|
+
);
|
|
755
|
+
const first = ownIn(input.carried.statuses);
|
|
756
|
+
if (first !== undefined) return first.created_at ?? null;
|
|
757
|
+
for (const sha of input.carried.older ?? []) {
|
|
758
|
+
const statuses = await input.readStatuses(input.operatorRoot, sha, {
|
|
759
|
+
spawnFn: input.spawnFn,
|
|
760
|
+
});
|
|
761
|
+
if (statuses === null) return null;
|
|
762
|
+
const own = ownIn(statuses);
|
|
763
|
+
if (own !== undefined) return own.created_at ?? null;
|
|
764
|
+
}
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// A verdict a review wrote itself: never a carried, skipped, or override text.
|
|
769
|
+
function finishedVerdict(
|
|
770
|
+
status: Pick<CommitStatusFact, "state" | "description">,
|
|
771
|
+
): boolean {
|
|
772
|
+
const description = status.description;
|
|
773
|
+
if (typeof description !== "string") return false;
|
|
774
|
+
if (status.state === "success") return finishedSuccessMatches(description);
|
|
775
|
+
if (status.state === "failure") {
|
|
776
|
+
return (
|
|
777
|
+
finishedBlockingMatches(description) ||
|
|
778
|
+
finishedPartialMatches(description)
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
return false;
|
|
782
|
+
}
|
|
783
|
+
|
|
667
784
|
// The status a gate-mode skip writes, or null for none. A size or budget skip is a fixed failure.
|
|
668
785
|
// An admission skip or manual-required is decided by admissionSkipDecision; the carry's walk runs only
|
|
669
786
|
// when the verdict carries forward, so same-head and manual-required make no read.
|
|
@@ -703,7 +820,27 @@ async function gateSkipDecision(
|
|
|
703
820
|
readStatuses: input.readStatuses ?? fetchCommitStatusList,
|
|
704
821
|
})
|
|
705
822
|
: null;
|
|
706
|
-
|
|
823
|
+
// S3: a carried blocking red asks whether every blocking finding was answered. A read that throws fails
|
|
824
|
+
// closed: the red stays.
|
|
825
|
+
let answered: AnsweredFindings | null = null;
|
|
826
|
+
if (
|
|
827
|
+
carriedBlockingCount(carried) !== null &&
|
|
828
|
+
input.admission.readAnswered !== undefined
|
|
829
|
+
) {
|
|
830
|
+
try {
|
|
831
|
+
answered = await input.admission.readAnswered(
|
|
832
|
+
await reviewVerdictTime({
|
|
833
|
+
operatorRoot: input.operatorRoot,
|
|
834
|
+
carried,
|
|
835
|
+
spawnFn: input.spawnFn,
|
|
836
|
+
readStatuses: input.readStatuses ?? fetchCommitStatusList,
|
|
837
|
+
}),
|
|
838
|
+
);
|
|
839
|
+
} catch {
|
|
840
|
+
answered = null;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return admissionSkipDecision({ ...input.admission, carried, answered });
|
|
707
844
|
}
|
|
708
845
|
|
|
709
846
|
// The skip kind a plan stands for, read from the status its outputs carry. The
|