crysk 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +11 -5
  2. package/dist/SKILL-6j27707y.md +140 -0
  3. package/dist/SKILL-816621e5.md +74 -0
  4. package/dist/SKILL-bnh7nrjz.md +74 -0
  5. package/dist/SKILL-fv8x6hhx.md +140 -0
  6. package/dist/SKILL-nv32jpc5.md +74 -0
  7. package/dist/SKILL-qnfc8yp3.md +539 -0
  8. package/dist/SKILL-xr56f0b6.md +140 -0
  9. package/dist/SKILL-y8rv8msh.md +134 -0
  10. package/dist/SKILL-ygka1bs0.md +515 -0
  11. package/dist/SKILL-yz6wk92g.md +542 -0
  12. package/dist/ci-admission-09k2ba89.md +126 -0
  13. package/dist/ci-admission-f19qh39t.md +128 -0
  14. package/dist/ci-admission-qk9r9taq.md +124 -0
  15. package/dist/ci-admission-tcqsj7b2.md +126 -0
  16. package/dist/cli.js +2463 -1573
  17. package/dist/index.js +1464 -911
  18. package/dist/materiality-f1qwnvg1.md +27 -0
  19. package/package.json +4 -3
  20. package/prompts/materiality.md +27 -0
  21. package/skills/crysk/SKILL.md +2 -2
  22. package/skills/crysk-ci-setup/SKILL.md +13 -7
  23. package/skills/crysk-ci-setup/references/ci-admission.md +8 -2
  24. package/skills/crysk-loop/SKILL.md +62 -16
  25. package/src/asset-manifest.ts +2 -0
  26. package/src/assets.ts +4 -1
  27. package/src/brand.ts +11 -9
  28. package/src/ci/cli-record.ts +1 -1
  29. package/src/ci/gates.ts +59 -6
  30. package/src/ci/outcome.ts +2 -1
  31. package/src/ci/override.ts +11 -10
  32. package/src/ci/publish.ts +44 -103
  33. package/src/ci/reporter.ts +36 -7
  34. package/src/ci/review-admission.ts +11 -2
  35. package/src/ci/review-levels.ts +21 -0
  36. package/src/ci/setup.ts +1 -2
  37. package/src/commands/post.ts +17 -0
  38. package/src/compare/loop.ts +356 -0
  39. package/src/compare/materiality.ts +266 -0
  40. package/src/compare/noise.ts +166 -0
  41. package/src/diversity/projection.ts +3 -0
  42. package/src/index.ts +1 -1
  43. package/src/model/routing.ts +62 -0
  44. package/src/pr/admission.ts +191 -42
  45. package/src/pr/answered-findings.ts +169 -0
  46. package/src/pr/ci-admission-gate.ts +80 -2
  47. package/src/pr/discovery.ts +17 -5
  48. package/src/pr/inline.ts +15 -1
  49. package/src/pr/plan.ts +5 -0
  50. package/src/pr/post-floor.ts +30 -0
  51. package/src/pr/posting.ts +4 -0
  52. package/src/pr/pr-status.ts +73 -1
  53. package/src/pr/pr.ts +50 -34
  54. package/src/pr/preflight.ts +2 -2
  55. package/src/pr/publish-outcome.ts +4 -0
  56. package/src/pr/review-pr.ts +65 -26
  57. package/src/pr/teardown.ts +1 -1
  58. package/src/rereview/prepare.ts +16 -0
  59. package/src/rereview/state.ts +206 -25
  60. package/src/review/boundary.ts +4 -1
  61. package/src/review/dedupe.ts +48 -4
  62. package/src/review/findings.ts +47 -1
  63. package/src/review/materiality-gate.ts +134 -0
  64. package/src/review/pipeline.ts +521 -41
  65. package/src/review/preflight.ts +69 -0
  66. package/src/review/report.ts +73 -10
  67. package/src/review/review.ts +16 -0
  68. package/src/review/route-preflight.ts +29 -1
  69. package/src/review/run.ts +2 -0
  70. package/src/ui/config.ts +8 -0
  71. package/src/updater.ts +1 -1
@@ -0,0 +1,169 @@
1
+ import { liveBlockingFindings } from "#pr/pr-status";
2
+ import { parseFindingMarker } from "#pr/preflight";
3
+ import { TIER_UNRECOVERABLE } from "#rereview/classify";
4
+ import { CI_ADJUDICATOR_LOGIN } from "#triage/adjudication";
5
+ import { parseTriageMarker } from "#triage/triage";
6
+ import { parsePrCommentMarker } from "#watch/preflight";
7
+
8
+ // budget-exhausted-carry S3-S5: whether every blocking finding of the reviewed head is answered, read when a
9
+ // skip carries a blocking red and no review is left to verify the fixes. Pure: the impure half (who may write
10
+ // to the repository) is the gate's, which passes its lookups in as `writers`.
11
+
12
+ // The blocking findings the read could see, and how many of them are still open. A finding is answered when
13
+ // its newest triage reply sits at the head it was posted on (the rule crysk status uses) and is `applied`, or
14
+ // is a `dismissed` the CI adjudicator upheld. `deferred` and `misclassified` stay open: they name a real
15
+ // finding, and only a fix or a human override may close one.
16
+ export interface AnsweredFindings {
17
+ blocking: number;
18
+ open: number;
19
+ }
20
+
21
+ export interface AnswerIssueComment {
22
+ id: number;
23
+ user: string;
24
+ body: string;
25
+ created_at?: string;
26
+ }
27
+
28
+ export interface AnswerReviewComment extends AnswerIssueComment {
29
+ in_reply_to_id: number | null;
30
+ path?: string;
31
+ line?: number | null;
32
+ }
33
+
34
+ function isTriageReply(body: string): boolean {
35
+ return parseTriageMarker(body) !== null;
36
+ }
37
+
38
+ // The logins whose permission the gate must look up: every author of a triage reply.
39
+ export function triageReplyAuthors(
40
+ comments: readonly AnswerIssueComment[],
41
+ ): string[] {
42
+ const authors = new Set<string>();
43
+ for (const comment of comments) {
44
+ if (isTriageReply(comment.body)) authors.add(comment.user);
45
+ }
46
+ return [...authors];
47
+ }
48
+
49
+ // WHY the CI bot is trusted for a finding or a summary: Crysk posts both as github-actions[bot], which only a
50
+ // workflow of this repository can write as. `trustedActors` (resolveCiTrustedActors) adds the configured
51
+ // writers; when it is undefined no author is known, and every author passes, as scanPostedFindingTiers does.
52
+ function trustedPoster(
53
+ user: string,
54
+ trustedActors: ReadonlySet<string> | undefined,
55
+ ): boolean {
56
+ if (trustedActors === undefined) return true;
57
+ return user === CI_ADJUDICATOR_LOGIN || trustedActors.has(user);
58
+ }
59
+
60
+ function isGateInput(body: string): boolean {
61
+ return (
62
+ parseFindingMarker(body) !== null || parsePrCommentMarker(body) !== null
63
+ );
64
+ }
65
+
66
+ // WHY a reply to a finding from an older head must be newer than the carried verdict: such a finding is live
67
+ // on the reviewed head through the summary's rows, so the review that wrote the verdict saw its reply and kept
68
+ // it. A reply from before that verdict is the claim the review already contradicted. A reply carries the
69
+ // head its finding was posted on (triage/reply.ts), so its time is the only thing that says it came after.
70
+ // A reply at the reviewed head itself always answers the review of that head.
71
+ function isStaleReply(
72
+ comment: AnswerIssueComment,
73
+ reviewedHead: string,
74
+ verdictAt: number | null,
75
+ ): boolean {
76
+ const marker = parseTriageMarker(comment.body);
77
+ if (marker === null || marker.headSha === reviewedHead) return false;
78
+ const createdAt =
79
+ comment.created_at === undefined
80
+ ? Number.NaN
81
+ : Date.parse(comment.created_at);
82
+ return (
83
+ verdictAt === null || Number.isNaN(createdAt) || createdAt <= verdictAt
84
+ );
85
+ }
86
+
87
+ // The comments the read may trust, or null when one cannot be judged (S5: fail closed).
88
+ // WHY a triage reply needs write access (S4): it is the only thing that turns a red green here, and anyone
89
+ // can comment on a pull request. A reply from a login with no write access is dropped; a login whose
90
+ // permission did not read (null, or never looked up) fails the whole read closed.
91
+ function trustedComments<T extends AnswerIssueComment>(
92
+ comments: readonly T[],
93
+ writers: ReadonlyMap<string, boolean | null>,
94
+ trustedActors: ReadonlySet<string> | undefined,
95
+ reviewedHead: string,
96
+ verdictAt: number | null,
97
+ ): T[] | null {
98
+ const kept: T[] = [];
99
+ for (const comment of comments) {
100
+ if (isTriageReply(comment.body)) {
101
+ if (isStaleReply(comment, reviewedHead, verdictAt)) continue;
102
+ const writer = writers.get(comment.user);
103
+ if (writer === undefined || writer === null) return null;
104
+ if (writer) kept.push(comment);
105
+ continue;
106
+ }
107
+ if (
108
+ isGateInput(comment.body) &&
109
+ !trustedPoster(comment.user, trustedActors)
110
+ )
111
+ continue;
112
+ kept.push(comment);
113
+ }
114
+ return kept;
115
+ }
116
+
117
+ export function answeredBlockingFindings(input: {
118
+ pr: number;
119
+ reviewedHead: string;
120
+ issueComments: readonly AnswerIssueComment[];
121
+ reviewComments: readonly AnswerReviewComment[];
122
+ trustedActors: ReadonlySet<string> | undefined;
123
+ writers: ReadonlyMap<string, boolean | null>;
124
+ // When the carried verdict was written (its commit status's created_at), or null when unknown.
125
+ verdictAt: string | null;
126
+ }): AnsweredFindings | null {
127
+ const parsedAt =
128
+ input.verdictAt === null ? Number.NaN : Date.parse(input.verdictAt);
129
+ const verdictAt = Number.isNaN(parsedAt) ? null : parsedAt;
130
+ const issueComments = trustedComments(
131
+ input.issueComments,
132
+ input.writers,
133
+ input.trustedActors,
134
+ input.reviewedHead,
135
+ verdictAt,
136
+ );
137
+ const reviewComments = trustedComments(
138
+ input.reviewComments,
139
+ input.writers,
140
+ input.trustedActors,
141
+ input.reviewedHead,
142
+ verdictAt,
143
+ );
144
+ if (issueComments === null || reviewComments === null) return null;
145
+ const findings = liveBlockingFindings({
146
+ pr: input.pr,
147
+ head: input.reviewedHead,
148
+ nowMs: 0,
149
+ statuses: [],
150
+ issueComments,
151
+ reviewComments,
152
+ });
153
+ // S5: a finding whose tier could not be read is blocking only by fail-closed default; it cannot be
154
+ // the evidence that unlocks the gate.
155
+ if (findings.some((finding) => finding.tier === TIER_UNRECOVERABLE))
156
+ return null;
157
+ let open = 0;
158
+ for (const finding of findings) {
159
+ const triage = finding.triage;
160
+ const answered =
161
+ triage !== null &&
162
+ finding.head !== null &&
163
+ triage.head === finding.head &&
164
+ (triage.tag === "applied" ||
165
+ (triage.tag === "dismissed" && finding.ci_verdict === "upheld"));
166
+ if (!answered) open++;
167
+ }
168
+ return { blocking: findings.length, open };
169
+ }
@@ -56,6 +56,11 @@ import {
56
56
  settleCiAdmissionLedger,
57
57
  settleCiGateSkip,
58
58
  } from "#pr/admission";
59
+ import {
60
+ type AnsweredFindings,
61
+ answeredBlockingFindings,
62
+ triageReplyAuthors,
63
+ } from "#pr/answered-findings";
59
64
  import {
60
65
  CommentsTruncatedError,
61
66
  fetchCommitStatuses,
@@ -174,6 +179,16 @@ export async function evaluateCiAdmissionGate(input: {
174
179
  extra: config.ci_trusted_actors,
175
180
  });
176
181
  const allComments = [...reviewComments, ...issueComments];
182
+ const readAnswered = answeredReader({
183
+ operatorRoot,
184
+ prNumber,
185
+ reviewedHead: authorityFailOpen ? null : summaryHead,
186
+ issueComments,
187
+ reviewComments,
188
+ trustedActors,
189
+ spawnFn,
190
+ sleepFn: input.sleepFn ?? Bun.sleep,
191
+ });
177
192
  const postedFindings =
178
193
  summaryHead === null
179
194
  ? null
@@ -352,6 +367,7 @@ export async function evaluateCiAdmissionGate(input: {
352
367
  reason: admissionVerdict.reason,
353
368
  reviewedHead: summaryHead,
354
369
  priorBlocking: admissionVerdict.prior.blocking,
370
+ readAnswered,
355
371
  },
356
372
  });
357
373
  return { ciPolicy, ciPolicyHash, ledgerRecords, exitCode };
@@ -370,7 +386,8 @@ export async function evaluateCiAdmissionGate(input: {
370
386
  blockingCount: admissionVerdict.prior.blocking,
371
387
  advisoryCount: admissionVerdict.prior.advisory,
372
388
  });
373
- // S4: manual-required is a failure in gate mode: its code was never reviewed.
389
+ // S2: manual-required carries the last verdict like every other skip (publishCiSkip,
390
+ // admissionSkipDecision); a carried red with every blocking finding answered turns green, unverified.
374
391
  const plan = planCiReviewManualRequired({
375
392
  prNumber,
376
393
  verdict: admissionVerdict,
@@ -384,7 +401,7 @@ export async function evaluateCiAdmissionGate(input: {
384
401
  isCi,
385
402
  stepSummaryFlag: options.stepSummary,
386
403
  plan,
387
- noticeMessage: `crysk review requires manual override — ${manualReason}`,
404
+ noticeMessage: `crysk automatic reviews are done for this PR — ${manualReason}`,
388
405
  ciMode: input.ciMode,
389
406
  headSha,
390
407
  spawnFn,
@@ -392,6 +409,7 @@ export async function evaluateCiAdmissionGate(input: {
392
409
  reason: admissionVerdict.reason,
393
410
  reviewedHead: summaryHead,
394
411
  priorBlocking: admissionVerdict.prior.blocking,
412
+ readAnswered,
395
413
  },
396
414
  });
397
415
  return { ciPolicy, ciPolicyHash, ledgerRecords, exitCode };
@@ -641,6 +659,66 @@ async function stoppedByMaintainer(
641
659
  return false;
642
660
  }
643
661
 
662
+ // budget-exhausted-carry S3, S4: the reader publishCiSkip calls when a skip carries a blocking red. Each
663
+ // triage reply's author is looked up once, with the stop lookup's bounds; a lookup that did not read is null,
664
+ // which answeredBlockingFindings fails closed on. A truncated comment read (authorityFailOpen) or no reviewed
665
+ // head reads nothing: the red stays.
666
+ function answeredReader(input: {
667
+ operatorRoot: string;
668
+ prNumber: number;
669
+ reviewedHead: string | null;
670
+ issueComments: readonly {
671
+ id: number;
672
+ user: string;
673
+ body: string;
674
+ created_at?: string;
675
+ }[];
676
+ reviewComments: readonly {
677
+ id: number;
678
+ user: string;
679
+ body: string;
680
+ created_at?: string;
681
+ in_reply_to_id: number | null;
682
+ path?: string;
683
+ line?: number | null;
684
+ }[];
685
+ trustedActors: ReadonlySet<string> | undefined;
686
+ spawnFn: typeof Bun.spawn | undefined;
687
+ sleepFn: (ms: number) => Promise<void>;
688
+ }): (verdictAt: string | null) => Promise<AnsweredFindings | null> {
689
+ return async (verdictAt) => {
690
+ const reviewedHead = input.reviewedHead;
691
+ if (reviewedHead === null) return null;
692
+ const writers = new Map<string, boolean | null>();
693
+ for (const login of triageReplyAuthors([
694
+ ...input.reviewComments,
695
+ ...input.issueComments,
696
+ ])) {
697
+ const permission = await stopAuthorPermission(
698
+ input.operatorRoot,
699
+ login,
700
+ input.spawnFn,
701
+ input.sleepFn,
702
+ );
703
+ writers.set(
704
+ login,
705
+ permission === null
706
+ ? null
707
+ : permission === "admin" || permission === "write",
708
+ );
709
+ }
710
+ return answeredBlockingFindings({
711
+ pr: input.prNumber,
712
+ reviewedHead,
713
+ issueComments: input.issueComments,
714
+ reviewComments: input.reviewComments,
715
+ trustedActors: input.trustedActors,
716
+ writers,
717
+ verdictAt,
718
+ });
719
+ };
720
+ }
721
+
644
722
  // Same bounds as the trigger's commenter lookup (lookupCommenterPermission):
645
723
  // one retry after a short wait, so a single API blip does not override a
646
724
  // maintainer's stop, and a timeout, so a hung gh call cannot stall admission.
@@ -95,6 +95,19 @@ export interface PrDiscoveryGit {
95
95
  ): Promise<{ ok: boolean; stdout: string; stderr: string }>;
96
96
  }
97
97
 
98
+ // A first review whose every changed file is excluded by the ignore rules
99
+ // (#317). A CliError with the same message as before, so a caller that does not
100
+ // look for it still exits 1 with the same line. The CI path catches it and ends
101
+ // the run as a skip: nothing reviewable changed, so nothing is owed.
102
+ export class AllExcludedError extends CliError {
103
+ readonly droppedPaths: readonly string[];
104
+
105
+ constructor(droppedPaths: readonly string[]) {
106
+ super(allExcludedMessage([...droppedPaths]));
107
+ this.droppedPaths = droppedPaths;
108
+ }
109
+ }
110
+
98
111
  export interface PrDiscoveryResult {
99
112
  prepared: PreparedDiscovery;
100
113
  skipDiscovery: boolean;
@@ -224,11 +237,10 @@ export async function resolvePrDiscovery(params: {
224
237
  prepared.plan.emptyDeltaIsError &&
225
238
  effectiveDiff.patch.trim().length === 0
226
239
  ) {
227
- throw new CliError(
228
- effectiveDiff.droppedPaths.length > 0
229
- ? allExcludedMessage(effectiveDiff.droppedPaths)
230
- : emptyDiffMessage(baseRef, headLabel, false),
231
- );
240
+ if (effectiveDiff.droppedPaths.length > 0) {
241
+ throw new AllExcludedError(effectiveDiff.droppedPaths);
242
+ }
243
+ throw new CliError(emptyDiffMessage(baseRef, headLabel, false));
232
244
  }
233
245
  const skipDiscovery =
234
246
  skipPlannedDiscovery || effectiveDiff.patch.trim().length === 0;
package/src/pr/inline.ts CHANGED
@@ -374,6 +374,12 @@ export interface PostPlan {
374
374
  issueComments: PostableFinding[];
375
375
  persisting: FindingMatch[];
376
376
  resolved: PostedFindingComment[];
377
+ // Unmatched findings below `post_min_severity` (pr/post-floor.ts): never
378
+ // posted, counted in the summary instead. Taken out AFTER matching on
379
+ // purpose: dropped before it, a still-live advisory comment from an earlier
380
+ // head would land in `resolved` and read as fixed. A hidden finding that
381
+ // matches an earlier comment stays in `persisting`.
382
+ notPosted: PostableFinding[];
377
383
  // From the matcher, not a stored count (design D5): persist = matched,
378
384
  // new = reviewComments.length + issueComments.length, resolved = prior
379
385
  // comments with nothing matched to them.
@@ -386,6 +392,8 @@ export function buildPostPlan(input: {
386
392
  posted: PostedFindingComment[];
387
393
  headSha: string;
388
394
  window?: number;
395
+ // Ids of the findings below `post_min_severity`. Absent posts everything.
396
+ hiddenIds?: ReadonlySet<string>;
389
397
  }): PostPlan {
390
398
  // Resolve post lines BEFORE matching: a re-anchored finding (544 → 938)
391
399
  // has to compare against a prior comment stored at 938, or a re-run on
@@ -405,7 +413,12 @@ export function buildPostPlan(input: {
405
413
  });
406
414
  const reviewComments: PostableFinding[] = [];
407
415
  const issueComments: PostableFinding[] = [];
416
+ const notPosted: PostableFinding[] = [];
408
417
  for (const finding of match.fresh) {
418
+ if (input.hiddenIds?.has(finding.id) === true) {
419
+ notPosted.push(finding);
420
+ continue;
421
+ }
409
422
  const anchorability = classifyAnchorability(finding, input.anchors);
410
423
  if (anchorability === "anchorable") reviewComments.push(finding);
411
424
  else issueComments.push(finding);
@@ -415,9 +428,10 @@ export function buildPostPlan(input: {
415
428
  issueComments,
416
429
  persisting: match.persist,
417
430
  resolved: match.resolved,
431
+ notPosted,
418
432
  delta: {
419
433
  resolved: match.resolved.length,
420
- new: match.fresh.length,
434
+ new: reviewComments.length + issueComments.length,
421
435
  persist: match.persist.length,
422
436
  },
423
437
  };
package/src/pr/plan.ts CHANGED
@@ -46,6 +46,7 @@ import type { buildPhaseBQueue, PreparedDiscovery } from "#rereview/prepare";
46
46
  import {
47
47
  type AgentsDirSource,
48
48
  type CliOptions,
49
+ resolveMaterialityGate,
49
50
  resolveMaxVerificationSteps,
50
51
  } from "#review/preflight";
51
52
  import type { ParsedAgent } from "#review/prompt-set";
@@ -213,6 +214,10 @@ export async function resolvePrPlanAndConfirm(params: {
213
214
  summarizerEnabled: params.summary.enabled && !params.skipDiscovery,
214
215
  scoutEnabled: params.options.scout && !params.skipDiscovery,
215
216
  consolidateEnabled: !params.skipDiscovery,
217
+ // Mirrors pipelineMaterialityInput in review-pr.ts: no judge step on a
218
+ // re-review that hunts nothing new.
219
+ materialityEnabled:
220
+ resolveMaterialityGate(params.config) && !params.skipDiscovery,
216
221
  });
217
222
  const routePlan = productionRoute?.routePlan;
218
223
  const productionAdmission = productionRoute?.productionAdmission;
@@ -0,0 +1,30 @@
1
+ // `post_min_severity`: the lowest finding a PR review posts. A posting filter
2
+ // only: the pipeline still finds, refutes and tiers every finding, and local
3
+ // reports still show all of them. The PR comments change, and with them the
4
+ // re-review admission, which scores only what was posted: a finding nobody
5
+ // sees should not spend a re-review. The gate is unaffected, since a blocking
6
+ // finding is never hidden.
7
+ //
8
+ // The floor never hides a blocking finding: `blocking` hides every advisory one,
9
+ // `warning` hides advisory SUGGESTIONs only, so a BLOCKER/CRITICAL the refuter
10
+ // demoted to advisory still posts there. Absent means `suggestion`: post
11
+ // everything, the behaviour before this key existed.
12
+
13
+ import type { Severity, Tier } from "#review/findings";
14
+
15
+ export const POST_MIN_SEVERITIES = [
16
+ "suggestion",
17
+ "warning",
18
+ "blocking",
19
+ ] as const;
20
+ export type PostMinSeverity = (typeof POST_MIN_SEVERITIES)[number];
21
+
22
+ export function isBelowPostFloor(
23
+ finding: { tier: Tier; severity: Severity },
24
+ floor: PostMinSeverity | undefined,
25
+ ): boolean {
26
+ if (finding.tier === "blocking") return false;
27
+ if (floor === "blocking") return true;
28
+ if (floor === "warning") return finding.severity === "SUGGESTION";
29
+ return false;
30
+ }
package/src/pr/posting.ts CHANGED
@@ -15,6 +15,7 @@
15
15
  // comparison guard in comparison.ts.
16
16
 
17
17
  import type { InlinePostOutcome } from "#pr/inline";
18
+ import type { PostMinSeverity } from "#pr/post-floor";
18
19
  import { ghRepoWebUrl, postInlineIfEligible, writePostReceipt } from "#pr/pr";
19
20
  import type { CiMode } from "#pr/preflight";
20
21
  import type { RereviewProvenance } from "#rereview/prepare";
@@ -57,6 +58,8 @@ export async function postFindingsIfEnabled(input: {
57
58
  // A comment-triggered run. Forwarded so the summary counter stays put (see
58
59
  // nextStateReviewCount in ci/review-admission.ts).
59
60
  force?: boolean;
61
+ // The `post_min_severity` config key (pr/post-floor.ts). Absent posts all.
62
+ postMinSeverity?: PostMinSeverity;
60
63
  }): Promise<PostingStageResult> {
61
64
  if (!input.postEnabled) {
62
65
  return { posted: null, postedWebUrl: undefined };
@@ -83,6 +86,7 @@ export async function postFindingsIfEnabled(input: {
83
86
  rereviewPriors: input.rereviewPriors,
84
87
  ciMode: input.ciMode,
85
88
  force: input.force,
89
+ postMinSeverity: input.postMinSeverity,
86
90
  });
87
91
  if (posted) {
88
92
  input.onDelivered?.();
@@ -249,6 +249,15 @@ function gateStateOf(state: string): PrGateState {
249
249
  return "error";
250
250
  }
251
251
 
252
+ // The live blocking findings at input.head, each with its newest triage reply and CI ruling, read exactly as
253
+ // buildPrStatus reads them. The admission gate reads them for the reviewed head (pr/answered-findings.ts).
254
+ export function liveBlockingFindings(input: PrStatusInput): PrStatusFinding[] {
255
+ const summary = readSummary(input.issueComments);
256
+ return readFindings(input, summary.rows)
257
+ .filter((a) => a.finding.blocking && a.finding.live_on_head)
258
+ .map((a) => a.finding);
259
+ }
260
+
252
261
  // The summary is the newest comment carrying the report marker (findMarkedCommentId picks
253
262
  // the newest). Its head and completeness come from the marker; its reviews count and its
254
263
  // live rows come from the state block that the summary carries.
@@ -527,10 +536,23 @@ function gateBlockingCount(gate: PrStatusGate): number | null {
527
536
  }
528
537
 
529
538
  // The gate descriptions that name no review of this head: the automatic budget is used up, or the
530
- // policy is manual (src/pr/admission.ts). Their text is the gate's own, so no count is read.
539
+ // policy is manual. A gate stopped writing them on 2026-10-30 (budget-exhausted-carry S2: both carry the
540
+ // last verdict now), so only a head statused before that still carries one. Their text is the gate's own,
541
+ // so no count is read.
531
542
  const REVIEW_TRIGGER_GATE =
532
543
  /^crysk: review (budget for this PR is used up|needs a manual trigger)/;
533
544
 
545
+ // A blocking red a skip carried from an earlier commit (admission.ts carriedBlockingDescription).
546
+ const CARRIED_BLOCKING_GATE = /^crysk: \d+ blocking finding\(s\) carried from /;
547
+
548
+ // The green a skip writes over answered findings no review verified (admission.ts unverifiedFixesDescription).
549
+ const UNVERIFIED_FIXES_GATE =
550
+ /^crysk: \d+ answered finding\(s\), fixes unverified \(/;
551
+
552
+ // The green a skip writes when every changed file is excluded (admission.ts NOTHING_TO_REVIEW_DESCRIPTION, #317).
553
+ const NOTHING_TO_REVIEW_GATE =
554
+ /^crysk: nothing to review — every changed file is excluded$/;
555
+
534
556
  // A blocking finding whose newest reply is a dismissal the CI adjudicator upheld on this head.
535
557
  function upheldDismissal(a: AnalyzedFinding): boolean {
536
558
  return (
@@ -606,6 +628,26 @@ function decideNext(
606
628
  reason: `The gate is green, but ${owed.length} finding(s) on this head have no reply yet; triage them.`,
607
629
  };
608
630
  }
631
+ // budget-exhausted-carry S6: a green no review verified. Nothing is owed, and the reason says why
632
+ // it is green, so the skill reports the fixes as unverified rather than reviewed.
633
+ if (
634
+ UNVERIFIED_FIXES_GATE.test(canonicalStatusText(gate.description ?? ""))
635
+ ) {
636
+ return {
637
+ next_action: "done",
638
+ reason: `The gate is green on answered findings no review verified (${gate.description}); the PR is ready to merge, or comment ${commandHint(REVIEW_COMMAND, "")} for another review.`,
639
+ };
640
+ }
641
+ // #317: no review ran, so the reason must not read as a review that passed.
642
+ if (
643
+ NOTHING_TO_REVIEW_GATE.test(canonicalStatusText(gate.description ?? ""))
644
+ ) {
645
+ return {
646
+ next_action: "done",
647
+ reason:
648
+ "Every changed file on this head is excluded from review, so there was nothing to review; nothing is owed.",
649
+ };
650
+ }
609
651
  return {
610
652
  next_action: "done",
611
653
  reason:
@@ -651,6 +693,36 @@ function decideNext(
651
693
  (a) => a.finding.triage?.tag === "applied",
652
694
  );
653
695
  if (applied.length > 0) {
696
+ // budget-exhausted-carry S3: a carried blocking red means a review rule skipped this head. The next push
697
+ // may be skipped too, and then the gate reads the replies instead of a review, but only every blocking
698
+ // finding answered unlocks it (answered-findings.ts), so the reason promises that only when it holds.
699
+ // A carried partial red is never unlocked by replies, so it keeps the plain reason.
700
+ if (
701
+ CARRIED_BLOCKING_GATE.test(canonicalStatusText(gate.description ?? ""))
702
+ ) {
703
+ // The gate's own rules (admission.ts admissionSkipDecision, answered-findings.ts): a finding is
704
+ // answered only by its newest reply at the head it was posted on, and the gate must see at least as
705
+ // many blocking findings as the red counts. The stale-reply cutoff needs the carried verdict's time,
706
+ // which this read does not have, so the reason says the push can turn green, never that it will.
707
+ const open = liveBlocking.filter(
708
+ (a) =>
709
+ !(
710
+ (a.finding.triage?.tag === "applied" &&
711
+ a.finding.triage.head === a.finding.head) ||
712
+ upheldDismissal(a)
713
+ ),
714
+ ).length;
715
+ const counted = gateBlockingCount(gate);
716
+ const unseen =
717
+ counted === null ? 0 : Math.max(0, counted - liveBlocking.length);
718
+ return {
719
+ next_action: "fix",
720
+ reason:
721
+ open === 0 && unseen === 0
722
+ ? "Every live blocking finding is answered and a review rule skipped this head; push the fix. If a rule skips that push too, the gate reads the replies on it and can turn green, marked unverified; otherwise the review verifies it."
723
+ : `A live blocking finding is tagged applied, but ${open + unseen} blocking finding(s) are still open (deferred, misclassified, a dismissal not upheld, a reply at another head, or one this read cannot see), so replies alone will not unlock the carried red; push the fix, and answer or fix the rest.`,
724
+ };
725
+ }
654
726
  return {
655
727
  next_action: "fix",
656
728
  reason: