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
package/src/ci/gates.ts CHANGED
@@ -163,6 +163,8 @@ export const SKIP_SIZE_COMMENT_MARKER = `${MARKER_OPEN}skip-size -->`;
163
163
  export const SKIP_BUDGET_COMMENT_MARKER = `${MARKER_OPEN}skip-budget -->`;
164
164
  export const SKIP_COVERAGE_COMMENT_MARKER = `${MARKER_OPEN}skip-coverage -->`;
165
165
  export const MANUAL_REQUIRED_COMMENT_MARKER = `${MARKER_OPEN}manual-required -->`;
166
+ // Never posted (planCiExcludedSkip has no comment); kept so the plan shape stays whole.
167
+ const SKIP_EXCLUDED_COMMENT_MARKER = `${MARKER_OPEN}skip-excluded -->`;
166
168
 
167
169
  // Same register as ci/reporter.ts's `skipSizeLines`/`skipBudgetLines` and
168
170
  // project rule 4 (assistant posture): a gate skip is a courteous notice
@@ -566,6 +568,9 @@ export interface CiGateSkipPlan {
566
568
  markerPrefix: string;
567
569
  summaryMarkdown: string;
568
570
  outputs: CiOutputs;
571
+ // False for a skip that never posts a PR comment, even under --post (#317:
572
+ // nothing to review). Absent posts `comment` as every other skip does.
573
+ postsComment?: false;
569
574
  }
570
575
 
571
576
  // Spec 1.1's $GITHUB_OUTPUT contract for a skip: no review ran, so every
@@ -579,6 +584,7 @@ export function ciGateSkipOutputs(
579
584
  | "skipped-size"
580
585
  | "skipped-budget"
581
586
  | "skipped-coverage"
587
+ | "skipped-excluded"
582
588
  | "manual-required",
583
589
  estimatedCostUsd: number,
584
590
  ): CiOutputs {
@@ -605,6 +611,31 @@ export function planCiSizeSkip(
605
611
  };
606
612
  }
607
613
 
614
+ // #317: every changed file is excluded by the ignore rules, so there is nothing
615
+ // to review. Unlike a size or budget skip this is not a review held back, so it
616
+ // posts no PR comment: a lockfile-only PR would otherwise collect one per push.
617
+ // The step summary and the commit status (admission.ts) say what happened.
618
+ export function planCiExcludedSkip(input: {
619
+ prNumber: number;
620
+ excludedPaths: readonly string[];
621
+ ciMode: CiMode;
622
+ }): CiGateSkipPlan {
623
+ return {
624
+ comment: "",
625
+ postsComment: false,
626
+ markerPrefix: SKIP_EXCLUDED_COMMENT_MARKER,
627
+ summaryMarkdown: renderStepSummary(
628
+ {
629
+ kind: "skipped-excluded",
630
+ prNumber: input.prNumber,
631
+ excludedPaths: [...input.excludedPaths],
632
+ },
633
+ input.ciMode,
634
+ ),
635
+ outputs: ciGateSkipOutputs("skipped-excluded", 0),
636
+ };
637
+ }
638
+
608
639
  export function planCiBudgetSkip(
609
640
  input: CiBudgetGateSkipInput & { force: boolean; ciMode: CiMode },
610
641
  ): CiGateSkipPlan | null {
@@ -664,21 +695,43 @@ function buildCoverageSkipComment(
664
695
  return `${lines.join("\n")}\n`;
665
696
  }
666
697
 
698
+ // budget-exhausted-carry S10: the comment a PR gets once no automatic review is left. It says so, explains
699
+ // it by the repository's own rules, says what the gate does with the next pushes, and how to ask for more.
700
+ // WHY no "override" here: an exhausted budget carries the last verdict (S2), and answered findings unlock a
701
+ // carried red (S3), so nothing in this situation needs a human to unlock the gate.
667
702
  function buildManualRequiredComment(data: ManualRequiredSummary): string {
703
+ const manualOnly = data.admissionReason === "manual-only-policy";
704
+ const rules = [
705
+ ...(data.policyMode === undefined
706
+ ? []
707
+ : [`- Review policy: \`${data.policyMode}\` (\`ci_review_policy\`).`]),
708
+ manualOnly
709
+ ? "- This repository reviews automatically once per pull request; every later review is on request."
710
+ : `- Automatic reviews used: ${data.reviewCount}/${data.maxAttempts} (\`ci_max_attempts\`).`,
711
+ ...(data.reviewedHead === undefined || data.reviewedHead === null
712
+ ? []
713
+ : [`- Last reviewed head: \`${data.reviewedHead.slice(0, 7)}\`.`]),
714
+ ];
668
715
  const lines = [
669
716
  MANUAL_REQUIRED_COMMENT_MARKER,
670
- "## Crysk review requires manual override",
717
+ "## Crysk: automatic reviews are done for this pull request",
671
718
  "",
672
- "🛑 Automatic review did not run on this push.",
719
+ "⏹️ No more automatic reviews will run on this pull request.",
673
720
  "",
674
721
  `**${data.detail}**`,
675
722
  "",
676
- `Attempts on this PR: ${data.reviewCount}/${data.maxAttempts}.`,
723
+ "How it got here, by this repository's rules:",
677
724
  "",
678
- "The existing review comment still describes the last head Crysk " +
679
- "reviewed.",
725
+ ...rules,
680
726
  "",
681
- ciForceReviewHintLine(data.prNumber),
727
+ "What the gate does with the next pushes: it keeps the last review's verdict. A red verdict turns " +
728
+ "green, marked unverified, once every blocking finding has a reply from someone with write access: " +
729
+ "`applied`, or a `dismissed` the CI adjudicator upheld. Reply before you push: the gate reads the " +
730
+ "replies when the push arrives.",
731
+ "",
732
+ "The existing review comment still describes the last head Crysk reviewed.",
733
+ "",
734
+ `Want more review rounds? ${ciForceReviewHintLine(data.prNumber)}`,
682
735
  ];
683
736
  return `${lines.join("\n")}\n`;
684
737
  }
package/src/ci/outcome.ts CHANGED
@@ -274,7 +274,7 @@ export interface CliRecord {
274
274
  | "yielded"
275
275
  | "error";
276
276
  // Only for outcome "skipped".
277
- skip?: "size" | "budget" | "coverage" | "manual-required";
277
+ skip?: "size" | "budget" | "coverage" | "manual-required" | "excluded";
278
278
  // The head the CLI reviewed or resolved, when it knows one. 40 lowercase hex.
279
279
  // Required for "reviewing": the head the CLI is about to post its pending
280
280
  // status on (the head it holds the review lock for).
@@ -597,6 +597,7 @@ const CLI_SKIPS: readonly NonNullable<CliRecord["skip"]>[] = [
597
597
  "budget",
598
598
  "coverage",
599
599
  "manual-required",
600
+ "excluded",
600
601
  ];
601
602
  const CLI_HEAD_PATTERN = /^[0-9a-f]{40}$/;
602
603
 
@@ -126,16 +126,17 @@ export function overrideActorOf(description: string): string | null {
126
126
  // as preflight.ts's latestStatusInContext except on a tie, where that one takes the later row
127
127
  // (`>=`). This module cannot import it. The publisher's reads use this one too.
128
128
  //
129
- // WHY one context means two names: for one version the gate is written on `crysk` and on the
130
- // legacy `pr-hero`, and an older action still writes only `pr-hero`. The newest row across both
131
- // names is the gate, so an override posted by an older action still beats a newer-version
132
- // verdict that is older than it. Two rows with the same time are a pair one run wrote, with
133
- // identical content, so either would do; the crysk row is taken so the answer never depends
134
- // on the order of the list.
135
- // A half-landed pair. Every write posts both names, so a name whose newest row is still
136
- // pending while the other name holds a later settled row missed that write. The settled
137
- // row is the verdict (a finished review, or a human's override), and the stuck name is
138
- // what a repair copies it onto. Undefined when the two names agree.
129
+ // WHY one context means two names: since #457 the gate is written on `crysk` alone, but a head
130
+ // reviewed before that change carries rows on the legacy `pr-hero` too, and an older action
131
+ // still writes only `pr-hero`. The newest row across both names is the gate, so an override
132
+ // posted by an older action still beats a newer-version verdict that is older than it. Two
133
+ // rows with the same time are a pair a run before #457 wrote, with identical content, so
134
+ // either would do; the crysk row is taken so the answer never depends on the order of the list.
135
+ // A stranded pair: a name whose newest row is still pending while the other name holds a later
136
+ // settled row. It comes from a pair a run before #457 half-landed, or from an older action's
137
+ // `pr-hero` verdict over this version's `crysk` pending. The settled row is the verdict (a
138
+ // finished review, or a human's override). A repair copies it onto a stuck `crysk` only: the
139
+ // legacy name is never written. Undefined when the two names agree.
139
140
  export function strandedStatusPair<T extends OverrideStatusFact>(
140
141
  statuses: readonly T[],
141
142
  context: string,
package/src/ci/publish.ts CHANGED
@@ -56,7 +56,6 @@ import {
56
56
  MARKER_OPEN,
57
57
  matchMarkerPrefix,
58
58
  STATUS_CONTEXT,
59
- statusContextForms,
60
59
  } from "../brand";
61
60
  import type {
62
61
  CliRecord,
@@ -616,43 +615,17 @@ function workflowCommand(
616
615
  return `::${command} title=crysk::${escaped}\n`;
617
616
  }
618
617
 
619
- // The status write, on BOTH names of its context: the new one, then the legacy `pr-hero` one
620
- // (statusContextForms). Users have `pr-hero` as a required check in branch protection, and a
621
- // head that stops getting it blocks every PR, so the publisher keeps writing it for one version.
622
- // A failed write never skips the other: the required check may be either name. The first
623
- // failure is the one reported, so the renderer sees the same answer a single write gave.
618
+ // The status write: one POST on `status.context`, the crysk name, retried once unless
619
+ // `attempts` is 1. Since #457 the legacy `pr-hero` context is never written, only read
620
+ // (isStatusContext), so a branch protection that still requires `pr-hero` must switch to
621
+ // `crysk`. Returns the failure's HTTP status when gh printed one, so the renderer can pick
622
+ // the permission or the server wording.
624
623
  function postStatus(
625
624
  deps: PublishDeps,
626
625
  repository: string,
627
626
  headSha: string,
628
627
  status: StatusPost,
629
628
  attempts = 2,
630
- ): { ok: true } | { ok: false; httpStatus: number | undefined } {
631
- let failure: { ok: false; httpStatus: number | undefined } | undefined;
632
- for (const context of statusContextForms(status.context)) {
633
- const posted = postStatusOn(
634
- deps,
635
- repository,
636
- headSha,
637
- status,
638
- context,
639
- attempts,
640
- );
641
- if (!posted.ok) failure ??= posted;
642
- }
643
- return failure ?? { ok: true };
644
- }
645
-
646
- // One write on one context, retried once unless `attempts` is 1. Returns the failure's HTTP
647
- // status when gh printed one, so the renderer can pick the permission or the server
648
- // wording.
649
- function postStatusOn(
650
- deps: PublishDeps,
651
- repository: string,
652
- headSha: string,
653
- status: StatusPost,
654
- context: string,
655
- attempts: number,
656
629
  ): { ok: true } | { ok: false; httpStatus: number | undefined } {
657
630
  const args = [
658
631
  "api",
@@ -660,7 +633,7 @@ function postStatusOn(
660
633
  "-f",
661
634
  `state=${status.state}`,
662
635
  "-f",
663
- `context=${context}`,
636
+ `context=${status.context}`,
664
637
  "-f",
665
638
  `description=${status.description}`,
666
639
  "-f",
@@ -1112,13 +1085,15 @@ function parseStatusRow(line: string): HeadStatusRow | undefined {
1112
1085
  // The head's newest pr-hero status, as the three states the table needs. The newest row is
1113
1086
  // picked by its time, not by its place in the answer. A failed read, no pr-hero row, or a
1114
1087
  // state the table does not name is unknown, which the table answers with the status.
1115
- // Copies the verdict of a half-landed pair onto the name that missed it (strandedStatusPair).
1116
- // The stuck name may be the repository's required check, and the readers below take the
1117
- // newest row across both names, so nothing else would ever settle it. Only the stuck name
1118
- // is written: the verdict, which may be a human's override, is never replaced. A failed
1119
- // copy is a warning, and the run goes on as it would have. Returns the verdict whenever
1120
- // the pair is stranded, copied or not: it, not the stuck pending row, is the gate's state,
1121
- // and the readers' newest-row pick could still choose the stuck row on a same-second tie.
1088
+ // Copies the verdict of a stranded pair onto crysk when crysk is the name that missed it
1089
+ // (strandedStatusPair): a crysk pending behind a later pr-hero verdict an older action or a
1090
+ // run before #457 wrote. crysk is the required check, and the readers below take the newest
1091
+ // row across both names, so nothing else would ever settle it. Only crysk is written: the
1092
+ // verdict, which may be a human's override, is never replaced, and a stuck legacy `pr-hero`
1093
+ // row is left as it is, because the legacy name is never written since #457. A failed copy is
1094
+ // a warning, and the run goes on as it would have. Returns the verdict whenever the pair is
1095
+ // stranded, copied or not: it, not the stuck pending row, is the gate's state, and the
1096
+ // readers' newest-row pick could still choose the stuck row on a same-second tie.
1122
1097
  function repairStrandedPair(
1123
1098
  deps: PublishDeps,
1124
1099
  repo: string,
@@ -1127,6 +1102,7 @@ function repairStrandedPair(
1127
1102
  ): HeadStatusRow | undefined {
1128
1103
  const pair = strandedStatusPair(statuses, STATUS_CONTEXT);
1129
1104
  if (pair === undefined) return undefined;
1105
+ if (pair.stranded.context !== STATUS_CONTEXT) return pair.verdict;
1130
1106
  const state = pair.verdict.state;
1131
1107
  const description = pair.verdict.description;
1132
1108
  // A verdict this step cannot reproduce faithfully is not copied: a blank description
@@ -1138,19 +1114,12 @@ function repairStrandedPair(
1138
1114
  ) {
1139
1115
  return pair.verdict;
1140
1116
  }
1141
- const posted = postStatusOn(
1142
- deps,
1143
- repo,
1144
- sha,
1145
- {
1146
- state,
1147
- context: STATUS_CONTEXT,
1148
- description,
1149
- targetUrl: pair.verdict.targetUrl ?? actionsRunUrl(deps.env) ?? "",
1150
- },
1151
- pair.stranded.context,
1152
- 2,
1153
- );
1117
+ const posted = postStatus(deps, repo, sha, {
1118
+ state,
1119
+ context: STATUS_CONTEXT,
1120
+ description,
1121
+ targetUrl: pair.verdict.targetUrl ?? actionsRunUrl(deps.env) ?? "",
1122
+ });
1154
1123
  deps.stdout(
1155
1124
  posted.ok
1156
1125
  ? workflowCommand(
@@ -1237,30 +1206,19 @@ function overrideDescription(actor: string): string {
1237
1206
  // an override the status never received would be a false record.
1238
1207
  function overrideCommentBody(
1239
1208
  plan: Extract<Publication, { kind: "override" }>,
1240
- landed: readonly string[],
1209
+ landed: boolean,
1241
1210
  at: Date,
1242
1211
  ): string {
1243
1212
  const when = `${at.toISOString().slice(0, 16).replace("T", " ")} UTC`;
1244
1213
  const marker = `${MARKER_OPEN}override head=${plan.headSha ?? "unknown"} run=${plan.runId} attempt=${plan.runAttempt} -->`;
1245
- if (landed.length > 0 && plan.headSha !== undefined) {
1246
- // Name exactly the contexts that were written: a branch protection that requires the
1247
- // other one is still blocked, and this comment is never cleaned up (#435 F001).
1248
- const names = landed.map((context) => `\`${context}\``).join(" and ");
1249
- const missed = statusContextForms(STATUS_CONTEXT).filter(
1250
- (context) => !landed.includes(context),
1251
- );
1252
- const missedNote =
1253
- missed.length === 0
1254
- ? ""
1255
- : ` The ${missed.map((context) => `\`${context}\``).join(" and ")} status could not be written, so a rule that requires it is still blocked: comment ${commandHint(OVERRIDE_COMMAND)} again to retry.`;
1214
+ if (landed && plan.headSha !== undefined) {
1215
+ // Names the one context written: since #457 an override posts `crysk` alone, and this
1216
+ // comment is never cleaned up, so it must not claim a legacy `pr-hero` status.
1256
1217
  return [
1257
1218
  marker,
1258
1219
  "",
1259
- (landed.includes(STATUS_CONTEXT)
1260
- ? `Crysk's gate was overridden by @${plan.actor} on head \`${plan.headSha}\` at ${when}. `
1261
- : `@${plan.actor}'s override of Crysk's gate on head \`${plan.headSha}\` at ${when} landed only in part. `) +
1262
- `The ${names} status${landed.length > 1 ? "es" : ""} on that head ${landed.length > 1 ? "are" : "is"} now success, with no review of this head.` +
1263
- missedNote +
1220
+ `Crysk's gate was overridden by @${plan.actor} on head \`${plan.headSha}\` at ${when}. ` +
1221
+ `The \`${STATUS_CONTEXT}\` status on that head is now success, with no review of this head.` +
1264
1222
  ` A new push or a later ${commandHint(REVIEW_COMMAND)} on this head replaces it.`,
1265
1223
  ].join("\n");
1266
1224
  }
@@ -1283,41 +1241,26 @@ function publishOverride(
1283
1241
  deps: PublishDeps,
1284
1242
  plan: Extract<Publication, { kind: "override" }>,
1285
1243
  ): number {
1286
- const landed: string[] = [];
1244
+ let landed = false;
1287
1245
  let exitCode = 0;
1288
1246
  if (plan.headSha !== undefined) {
1289
- // Each context is written on its own (postStatus would fold the pair into one answer):
1290
- // when one lands and the other fails, the head IS overridden on the one that landed, and
1291
- // the permanent audit comment must say so (#434 F001). The failed half is still reported.
1292
- let failure: { ok: false; httpStatus: number | undefined } | undefined;
1293
- for (const context of statusContextForms(STATUS_CONTEXT)) {
1294
- const posted = postStatusOn(
1295
- deps,
1296
- plan.repository,
1297
- plan.headSha,
1298
- {
1299
- state: "success",
1300
- context: STATUS_CONTEXT,
1301
- description: overrideDescription(plan.actor),
1302
- targetUrl: plan.runUrl,
1303
- },
1304
- context,
1305
- 2,
1306
- );
1307
- if (posted.ok) landed.push(context);
1308
- else failure ??= posted;
1309
- }
1310
- if (landed.includes(STATUS_CONTEXT)) {
1247
+ // One write, on crysk alone (#457): the legacy `pr-hero` context is no longer posted.
1248
+ const posted = postStatus(deps, plan.repository, plan.headSha, {
1249
+ state: "success",
1250
+ context: STATUS_CONTEXT,
1251
+ description: overrideDescription(plan.actor),
1252
+ targetUrl: plan.runUrl,
1253
+ });
1254
+ landed = posted.ok;
1255
+ if (posted.ok) {
1311
1256
  // WHY here, right after the success and before the audit comment: the crysk gate is
1312
- // green now, so an earlier run's outcome comment contradicts it. When only the legacy
1313
- // pr-hero status landed, crysk is still red and that comment still explains why. The audit comment does not
1314
- // gate this cleanup, and its warnings never change the exit code (as for a review).
1257
+ // green now, so an earlier run's outcome comment contradicts it. The audit comment does
1258
+ // not gate this cleanup, and its warnings never change the exit code (as for a review).
1315
1259
  cleanupOlderOutcomes(deps, plan);
1316
- }
1317
- if (failure !== undefined) {
1260
+ } else {
1318
1261
  reportStatusWriteFailure(
1319
1262
  deps,
1320
- failure.httpStatus,
1263
+ posted.httpStatus,
1321
1264
  plan.runId,
1322
1265
  plan.runUrl,
1323
1266
  );
@@ -1327,11 +1270,9 @@ function publishOverride(
1327
1270
  deps.stdout(
1328
1271
  workflowCommand(
1329
1272
  "notice",
1330
- landed.includes(STATUS_CONTEXT)
1273
+ landed
1331
1274
  ? `crysk gate overridden by @${plan.actor} on head ${plan.headSha}.`
1332
- : landed.length > 0
1333
- ? `crysk override by @${plan.actor} set only the ${landed.join(", ")} status on head ${plan.headSha}.`
1334
- : `crysk override by @${plan.actor} set no commit status.`,
1275
+ : `crysk override by @${plan.actor} set no commit status.`,
1335
1276
  ),
1336
1277
  );
1337
1278
  const at = (deps.now ?? (() => new Date()))();
@@ -31,10 +31,12 @@
31
31
  // multiple output keys written across several tool calls). An overwrite here
32
32
  // would silently destroy an earlier step's contribution to the same file.
33
33
  import { appendFile } from "node:fs/promises";
34
+ import { listPaths } from "#git/refs";
34
35
  import type { CiMode } from "#pr/preflight";
35
36
  import type { Finding, Severity } from "#review/findings";
36
37
  import {
37
38
  blobUrl,
39
+ code,
38
40
  formatElapsed,
39
41
  type PrCommentDelta,
40
42
  severityEmoji,
@@ -155,6 +157,12 @@ interface CiSkipBudgetSummary {
155
157
  budgetUsd: number;
156
158
  }
157
159
 
160
+ interface CiSkipExcludedSummary {
161
+ kind: "skipped-excluded";
162
+ prNumber: number;
163
+ excludedPaths: string[];
164
+ }
165
+
158
166
  interface CiSkipCoverageSummary {
159
167
  kind: "skipped-coverage";
160
168
  prNumber: number;
@@ -198,6 +206,7 @@ export type CiSummaryData =
198
206
  | CiReviewSummary
199
207
  | CiSkipSizeSummary
200
208
  | CiSkipBudgetSummary
209
+ | CiSkipExcludedSummary
201
210
  | CiSkipCoverageSummary
202
211
  | CiManualRequiredSummary;
203
212
 
@@ -336,6 +345,24 @@ function skipBudgetLines(data: CiSkipBudgetSummary): string[] {
336
345
  ];
337
346
  }
338
347
 
348
+ // #317: not a review held back but a diff with nothing in scope, so the heading
349
+ // is a plain fact, not a warning, and the wording never says "found nothing":
350
+ // nothing was looked at.
351
+ function skipExcludedLines(data: CiSkipExcludedSummary): string[] {
352
+ return [
353
+ `### Crysk: nothing to review — PR #${data.prNumber}`,
354
+ "",
355
+ "**Reason:** every changed file is excluded from review by the ignore " +
356
+ "rules (`.cryskignore` and the shipped defaults).",
357
+ "",
358
+ // Capped like every other path list (listPaths), and each path through
359
+ // code(): the paths are the author's, and a backtick would break the span.
360
+ listPaths(data.excludedPaths.map(code)),
361
+ "",
362
+ "Nothing was spawned and nothing was spent.",
363
+ ];
364
+ }
365
+
339
366
  function admissionMetricRows(
340
367
  data: CiSkipCoverageSummary | CiManualRequiredSummary,
341
368
  ): string[] {
@@ -402,9 +429,9 @@ function skipCoverageLines(data: CiSkipCoverageSummary): string[] {
402
429
 
403
430
  function manualRequiredLines(data: CiManualRequiredSummary): string[] {
404
431
  return [
405
- `### 🛑 Crysk Review — Manual Override Required — PR #${data.prNumber}`,
432
+ `### ⏹️ Crysk Review — Automatic Reviews Done — PR #${data.prNumber}`,
406
433
  "",
407
- "**Reason:** automatic review did not run on this push.",
434
+ "**Reason:** no automatic review is left for this pull request; the gate keeps the last verdict.",
408
435
  "",
409
436
  "| Metric | Value |",
410
437
  "| --- | --- |",
@@ -466,11 +493,13 @@ export function renderStepSummary(
466
493
  ? skipSizeLines(data)
467
494
  : data.kind === "skipped-budget"
468
495
  ? skipBudgetLines(data)
469
- : data.kind === "skipped-coverage"
470
- ? skipCoverageLines(data)
471
- : data.kind === "manual-required"
472
- ? manualRequiredLines(data)
473
- : reviewedLines(data);
496
+ : data.kind === "skipped-excluded"
497
+ ? skipExcludedLines(data)
498
+ : data.kind === "skipped-coverage"
499
+ ? skipCoverageLines(data)
500
+ : data.kind === "manual-required"
501
+ ? manualRequiredLines(data)
502
+ : reviewedLines(data);
474
503
  const out = [...body, "---", "", footerFor(ciMode)];
475
504
  return `${out.join("\n").trimEnd()}\n`;
476
505
  }
@@ -801,13 +801,22 @@ export function ciReviewSkipDetail(
801
801
  }
802
802
  }
803
803
 
804
- // The short label a status description names for a coverage skip (the carry-forward in
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: "once-per-pr" | "below-threshold" | "low-risk-delta" | "stopped",
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":
@@ -8,6 +8,7 @@
8
8
  // keys it sets are always written to .crysk/config.json, so what a repo does
9
9
  // is visible in the file it versions, never inherited silently.
10
10
 
11
+ import type { PostMinSeverity } from "#pr/post-floor";
11
12
  import { DEFAULT_SIZE_GATE } from "#review/size-gate";
12
13
  import { CI_DEFAULT_METERED_BUDGET_USD } from "./gates";
13
14
  import {
@@ -236,6 +237,12 @@ export interface ConfigPlan {
236
237
  remove: string[];
237
238
  }
238
239
 
240
+ // What setup writes for `post_min_severity`. The engine's own default stays
241
+ // "post everything", so a repo changes only when setup runs on it: a new repo,
242
+ // or a re-run (`--force` included) on one whose config has no floor yet. Filled
243
+ // only when absent, so a floor someone chose is never reset.
244
+ export const RECOMMENDED_POST_MIN_SEVERITY: PostMinSeverity = "warning";
245
+
239
246
  export function configPlan(choices: CiSetupChoices): ConfigPlan {
240
247
  const { ignorePatterns: _ignored, ...advanced } = choices.advanced;
241
248
  const set: Record<string, unknown> = {};
@@ -251,6 +258,7 @@ export function configPlan(choices: CiSetupChoices): ConfigPlan {
251
258
  } else fillIfAbsent.push(levelKeys);
252
259
  if (choices.chosen.maxChangedLines) Object.assign(set, lineKeys);
253
260
  else fillIfAbsent.push(lineKeys);
261
+ fillIfAbsent.push({ post_min_severity: RECOMMENDED_POST_MIN_SEVERITY });
254
262
  // An advanced key is present only because someone gave it.
255
263
  for (const [key, value] of Object.entries(advanced)) {
256
264
  if (value !== undefined) set[key] = value;
@@ -303,8 +311,21 @@ export function renderChoicesSummary(
303
311
  ` observe only ${a.ci_admission_observe_only === true ? "yes: skip decisions are logged, every push is reviewed" : "no"}`,
304
312
  ` trusted actors ${a.ci_trusted_actors && a.ci_trusted_actors.length > 0 ? a.ci_trusted_actors.join(", ") : "none beyond the workflow actor"}`,
305
313
  ` size limit ${"max_changed_lines" in kept ? `${JSON.stringify(kept.max_changed_lines)} changed lines (kept)` : choices.maxChangedLines === 0 ? "no changed-lines limit (0)" : `${choices.maxChangedLines} changed lines`}, ${a.max_changed_files === undefined ? "files resolved from how the review is paid" : `${a.max_changed_files} files`}`,
314
+ ` posting ${postingLine(effective.post_min_severity)}`,
306
315
  ` exclusions ${a.ignorePatterns && a.ignorePatterns.length > 0 ? `${a.ignorePatterns.join(", ")} (.cryskignore)` : "none added (.cryskignore)"}`,
307
316
  "Change them later in the repo config (.crysk/config.json, or .prhero/config.json in a repo set up before the rename) and the review workflow (.github/workflows/crysk.yml, or pr-hero.yml in a repo set up before the rename) (`npx -y crysk config` shows the effective values).",
308
317
  ];
309
318
  return lines;
310
319
  }
320
+
321
+ // Read off the file as written, so a floor set by hand is reported as it stands.
322
+ function postingLine(value: unknown): string {
323
+ if (value === "blocking") {
324
+ return "blocking findings only; advisory ones are counted in the summary (post_min_severity)";
325
+ }
326
+ if (value === "warning") {
327
+ return "every finding except advisory suggestions, which are counted in the summary (post_min_severity)";
328
+ }
329
+ if (value === "suggestion") return "every finding (post_min_severity)";
330
+ return "every finding (post_min_severity unset)";
331
+ }
package/src/ci/setup.ts CHANGED
@@ -12,8 +12,7 @@
12
12
  // caller points it at (via `crysk setup --ci` / `crysk ci init`); a repo that
13
13
  // already has the pre-rename `pr-hero.yml` keeps that file, updated in place.
14
14
  // Pillar 3 Phase 5 (tasks.md 5.2) reuses this SAME function to produce this
15
- // repo's own canonical example workflow (which stays at `pr-hero.yml`: this
16
- // repo is the existing-repo case), rather than
15
+ // repo's own canonical example workflow (at `crysk.yml`), rather than
17
16
  // hand-authoring a second copy that could silently drift from what every
18
17
  // caller of `setup --ci` actually gets — test/packaging.test.ts asserts the
19
18
  // committed file's bytes equal generateCiWorkflowTemplate()'s output exactly.
@@ -1,8 +1,11 @@
1
1
  import { existsSync } from "node:fs";
2
+ import os from "node:os";
2
3
  import path from "node:path";
3
4
  import { assertRunMatchesPr } from "#ci/gates";
5
+ import { loadEffectiveConfig } from "#config/config";
4
6
  import { resolveRepoRoot } from "#git/git";
5
7
  import { postingExitCode } from "#pr/inline";
8
+ import type { PostMinSeverity } from "#pr/post-floor";
6
9
  import {
7
10
  ghCurrentBranchPr,
8
11
  ghRepoWebUrl,
@@ -54,11 +57,19 @@ export async function postCommand(options: CliOptions): Promise<number> {
54
57
  options.pr === "current"
55
58
  ? resolveCurrentPrNumber(await ghCurrentBranchPr(operatorRoot))
56
59
  : options.pr;
60
+ // The same floor `review --pr --post` applies, read from the same layers,
61
+ // so a replayed run posts what the live run would have.
62
+ const { effective } = await loadEffectiveConfig({
63
+ root: operatorRoot,
64
+ home: os.homedir(),
65
+ configFlag: options.config,
66
+ });
57
67
  return runPostCommand({
58
68
  operatorRoot,
59
69
  pr: prNumber,
60
70
  from: options.from,
61
71
  dryRun: options.dryRun,
72
+ postMinSeverity: effective.post_min_severity,
62
73
  });
63
74
  }
64
75
 
@@ -68,6 +79,7 @@ export async function runPostCommand(input: {
68
79
  from: string;
69
80
  dryRun: boolean;
70
81
  spawnFn?: typeof Bun.spawn;
82
+ postMinSeverity?: PostMinSeverity;
71
83
  }): Promise<number> {
72
84
  const { operatorRoot, pr: prNumber, dryRun, spawnFn } = input;
73
85
  const runDir = path.resolve(input.from);
@@ -193,6 +205,7 @@ export async function runPostCommand(input: {
193
205
  doc,
194
206
  diffPatch,
195
207
  spawnFn,
208
+ postMinSeverity: input.postMinSeverity,
196
209
  });
197
210
  // The preview refuses whatever the post would refuse. A dry run that
198
211
  // prints a plan for a run dir the live path then rejects is a $0 gate
@@ -234,6 +247,9 @@ export async function runPostCommand(input: {
234
247
  for (const finding of plan.issueComments) {
235
248
  log(` outside ${finding.path}:${finding.line} ${finding.id}`);
236
249
  }
250
+ for (const finding of plan.notPosted) {
251
+ log(` hidden ${finding.path}:${finding.line} ${finding.id}`);
252
+ }
237
253
  log("dry run: nothing was fetched-for-mutation or posted.");
238
254
  return 0;
239
255
  }
@@ -253,6 +269,7 @@ export async function runPostCommand(input: {
253
269
  ...(rereview === undefined ? {} : { rereview, rereviewPriors: [] }),
254
270
  requireRereviewOnPriorSummary: true,
255
271
  refuseOnVanishedPriorSummary: true,
272
+ postMinSeverity: input.postMinSeverity,
256
273
  });
257
274
  await writePostReceipt(runDir, prNumber, doc.head_sha, outcome);
258
275
  log(