@rmartz/pr-policy 0.11.0 → 0.13.0

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 CHANGED
@@ -34,13 +34,13 @@ is in its [consumer guide](https://github.com/rmartz/pr-policy-action/blob/main/
34
34
 
35
35
  ## Library and CLI
36
36
 
37
- Every check is importable. The `ai-pr-policy` CLI is a thin wrapper around them:
37
+ Every check is importable. The `pr-policy` CLI is a thin wrapper around them:
38
38
 
39
39
  ```bash
40
- ai-pr-policy evaluate --pr 12 --repo rmartz/pr-policy # post the check-run, status + labels
41
- ai-pr-policy evaluate --pr 12 --repo rmartz/pr-policy --json # evaluate only, change nothing
42
- ai-pr-policy evaluate --facts pr.json # offline, from a JSON facts file
43
- ai-pr-policy evaluate --pr 12 --repo rmartz/pr-policy --skip-uat # for a repo with no UAT
40
+ pr-policy evaluate --pr 12 --repo rmartz/pr-policy # post the check-run, status + labels
41
+ pr-policy evaluate --pr 12 --repo rmartz/pr-policy --json # evaluate only, change nothing
42
+ pr-policy evaluate --facts pr.json # offline, from a JSON facts file
43
+ pr-policy evaluate --pr 12 --repo rmartz/pr-policy --skip-uat # for a repo with no UAT
44
44
  ```
45
45
 
46
46
  ## Documentation
@@ -7,14 +7,14 @@ import {
7
7
  postVerdict,
8
8
  resolveRepoTarget,
9
9
  selectChecks
10
- } from "../chunk-LWLZD5YW.js";
10
+ } from "../chunk-VJXHTDY2.js";
11
11
 
12
12
  // src/bin/pr-policy.ts
13
13
  import { readFile } from "fs/promises";
14
14
  import { parseArgs } from "util";
15
15
  var USAGE = `Usage:
16
- ai-pr-policy evaluate --pr <n> [--repo <owner/repo>] [--json] [--skip-uat]
17
- ai-pr-policy evaluate --facts <path|-> [--skip-uat]
16
+ pr-policy evaluate --pr <n> [--repo <owner/repo>] [--json] [--skip-uat]
17
+ pr-policy evaluate --facts <path|-> [--skip-uat]
18
18
 
19
19
  --pr Evaluate a live PR, post the pr-policy check-run and commit status on
20
20
  its head, and apply the label edits the checks planned. --json
@@ -5,11 +5,13 @@ var CI_CHANGE_APPROVED_LABEL = "CI change approved";
5
5
  var UAT_PASSED_LABEL = "UAT passed";
6
6
  var LEGACY_UAT_PASSED_LABEL = "tested";
7
7
  var NO_UAT_NEEDED_LABEL = "no UAT needed";
8
+ var CONTAINED_BREAK_LABEL = "contained break";
8
9
  var SIGN_OFF_LABELS = [
9
10
  CI_CHANGE_APPROVED_LABEL,
10
11
  UAT_PASSED_LABEL,
11
12
  LEGACY_UAT_PASSED_LABEL,
12
- NO_UAT_NEEDED_LABEL
13
+ NO_UAT_NEEDED_LABEL,
14
+ CONTAINED_BREAK_LABEL
13
15
  ];
14
16
  var DO_NOT_MERGE_LABEL = "do not merge";
15
17
  var DNM_LABEL = "dnm";
@@ -1263,18 +1265,37 @@ function decideTitle(pr) {
1263
1265
  } else if (!breakingIntent && title.breaking) {
1264
1266
  findings.push(
1265
1267
  block2(
1266
- `The title marks a breaking change but the PR lacks the \`${BREAKING_CHANGE_LABEL}\` label, which is the source of truth. Add the label, or drop the \`!\`.`
1268
+ `The title marks a breaking change but the PR lacks the \`${BREAKING_CHANGE_LABEL}\` label; the two must agree. Add the label, or drop the \`!\`.`
1267
1269
  )
1268
1270
  );
1269
1271
  }
1270
- const majors = majorBumps(pr.manifestChanges);
1271
- if (functional && !breakingIntent && !title.breaking && majors.length > 0) {
1272
+ const containedBreakLabel = labels.has(CONTAINED_BREAK_LABEL);
1273
+ if (containedBreakLabel && (breakingIntent || title.breaking)) {
1272
1274
  findings.push(
1273
1275
  block2(
1274
- `This PR bumps a dependency's major version (${majors.map((bump) => `\`${bump}\``).join(", ")}), so it is a breaking change. Retitle to \`${breakingTitle}\` and add the \`${BREAKING_CHANGE_LABEL}\` label.`
1276
+ `\`${CONTAINED_BREAK_LABEL}\` says the break doesn't reach consumers, but the PR is also marked breaking. Remove \`${CONTAINED_BREAK_LABEL}\`, or drop the \`!\` and the breaking label.`
1275
1277
  )
1276
1278
  );
1277
1279
  }
1280
+ const majors = majorBumps(pr.manifestChanges);
1281
+ if (functional && !breakingIntent && !title.breaking && majors.length > 0) {
1282
+ const bumped = majors.map((bump) => `\`${bump}\``).join(", ");
1283
+ const waiver = signOffState(pr, [CONTAINED_BREAK_LABEL]);
1284
+ if (waiver.status === "trusted") {
1285
+ findings.push({
1286
+ check: TITLE_CHECK,
1287
+ effect: "info",
1288
+ message: `\`${waiver.appliedBy.login}\` waived the dependency major bump (${bumped}) with \`${CONTAINED_BREAK_LABEL}\`, so it releases without \`!\`.`
1289
+ });
1290
+ } else {
1291
+ const untrusted = waiver.status === "untrusted" ? ` The \`${CONTAINED_BREAK_LABEL}\` label doesn't count: ${waiver.reason}.` : "";
1292
+ findings.push(
1293
+ block2(
1294
+ `This PR bumps a dependency's major version (${bumped}), so it is a breaking change. Retitle to \`${breakingTitle}\` and add the \`${BREAKING_CHANGE_LABEL}\` label. If the bump is invisible to this package's consumers, someone who can merge may add \`${CONTAINED_BREAK_LABEL}\` instead.${untrusted}`
1295
+ )
1296
+ );
1297
+ }
1298
+ }
1278
1299
  const pathViolation = typePathViolation(title.type, pr.changedFiles);
1279
1300
  if (pathViolation !== void 0) findings.push(block2(pathViolation));
1280
1301
  const mayRetitle = !functional && title.type !== "ci";
package/dist/index.d.ts CHANGED
@@ -56,8 +56,8 @@ interface PullRequestBase {
56
56
  /**
57
57
  * The facts about a pull request that policy checks judge. Every field is a
58
58
  * property of the PR's current state — its content and the labels on it, never
59
- * its review history, which belongs to the separate lifecycle reconciler
60
- * (rmartz/ai-tools#306).
59
+ * its review history, which belongs to the separate lifecycle reconciler in
60
+ * `rmartz/pr-lifecycle`.
61
61
  */
62
62
  interface PullRequestFacts {
63
63
  title: string;
@@ -337,9 +337,9 @@ declare const ESCALATION_NEEDED_LABEL = "escalation needed";
337
337
  declare const BLOCKING_LABELS: readonly ["do not merge", "dnm", "blocked", "escalation needed"];
338
338
  /**
339
339
  * Labels the title check reads and never writes. They belong to the review and
340
- * release flow: `breaking change` is the source of truth for a breaking PR,
341
- * `hotfix` implies one, and release-please marks its release PRs with
342
- * `autorelease: pending`.
340
+ * release flow: `breaking change` must agree with the title's `!`, which is what
341
+ * the release and merge-safety read; `hotfix` implies one; and release-please
342
+ * marks its release PRs with `autorelease: pending`.
343
343
  */
344
344
  declare const BREAKING_CHANGE_LABEL = "breaking change";
345
345
  declare const HOTFIX_LABEL = "hotfix";
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ import {
48
48
  sensitiveBumps,
49
49
  statusBody,
50
50
  titleCheck
51
- } from "./chunk-LWLZD5YW.js";
51
+ } from "./chunk-VJXHTDY2.js";
52
52
  export {
53
53
  AMBIGUOUS_INDICATORS,
54
54
  BLOCKED_LABEL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmartz/pr-policy",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Read-only PR content classifiers — CI-change classification, title-type rules, and more — reported as one blocking pr-policy check-run. Distributed as a pinned Action kept current by Dependabot.",
5
5
  "keywords": [
6
6
  "pr-policy",
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "bin": {
29
- "ai-pr-policy": "./dist/bin/pr-policy.js"
29
+ "pr-policy": "./dist/bin/pr-policy.js"
30
30
  },
31
31
  "files": [
32
32
  "dist"