@rmartz/pr-policy 1.7.1 → 1.8.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
@@ -12,17 +12,17 @@ new required-status name.
12
12
 
13
13
  ## Checks
14
14
 
15
- | Check | Blocks when |
16
- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
- | **Blocking labels** ([docs](docs/checks/merge-block.md)) | The PR carries `do not merge`, `dnm`, `blocked`, or `escalation needed` (shows as pending). |
18
- | **CI-change classification** ([docs](docs/checks/ci-change.md)) | pr-lifecycle's `pr-lifecycle/sign-off` status asks for a CI sign-off (or, before a repo cuts over, a `.github/workflows/**` change loosens CI), and no human has applied `CI change approved` (shows as pending). |
19
- | **Base branch** ([docs](docs/checks/base-branch.md)) | The PR targets a branch other than the default and it isn't a non-epic PR on an open epic's branch. A stacked PR waits for its base PR (shows as pending); a base no open PR heads blocks. |
20
- | **Title-type rules** ([docs](docs/checks/title.md)) | The squash title isn't a valid Conventional Commit, puts `!` on a non-functional type, disagrees with the `breaking change` label, types a linter/formatter bump as a non-release, non-`ci` type, or changes paths its type rules out (`docs`, `test`, `refactor`, `ci`). |
21
- | **UAT sign-off** ([docs](docs/checks/uat.md)) | pr-lifecycle's sign-off status says the head needs UAT (or, before a repo cuts over, the PR isn't docs, tests, CI, repo tooling, dependency-only, or repo metadata), or the status can't be trusted, and no trusted user has applied `no UAT needed`, or `UAT passed` (or `tested`) since the last push (shows as pending). |
22
- | **UAT label presence** ([docs](docs/checks/uat-label.md)), opt-in | `require-uat-label` is on and the PR carries none of `no UAT needed`, `UAT pending`, `UAT ready`, `UAT passed` (shows as pending). |
23
- | **Dependabot claim verification** ([docs](docs/checks/dependabot.md)) | A Dependabot PR touches a non-dependency path, changes a dependency its description doesn't claim, pins a version other than the claimed one, or edits anything Dependabot never edits (a `package.json` script, a workflow step). |
24
- | Domain labels (backlog) | Never blocks. Additive path-glob → domain-label map. |
25
- | Milestone inheritance (backlog) | Never blocks. Issue → PR milestone. |
15
+ | Check | Blocks when |
16
+ | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | **Blocking labels** ([docs](docs/checks/merge-block.md)) | The PR carries `do not merge`, `dnm`, `blocked`, or `escalation needed` (shows as pending). |
18
+ | **CI-change classification** ([docs](docs/checks/ci-change.md)) | pr-lifecycle's `pr-lifecycle/sign-off` status asks for a CI sign-off (or, before a repo cuts over, a `.github/workflows/**` change loosens CI), and no human has applied `CI change approved` (shows as pending). |
19
+ | **Base branch** ([docs](docs/checks/base-branch.md)) | The PR targets a branch other than the default and it isn't a non-epic PR on an open epic's branch. A stacked PR waits for its base PR (shows as pending); a base no open PR heads blocks. |
20
+ | **Title-type rules** ([docs](docs/checks/title.md)) | The squash title isn't a valid Conventional Commit, puts `!` on a non-functional type, disagrees with the `breaking change` label, types a linter/formatter bump as a non-release, non-`ci` type, or changes paths its type rules out (`docs`, `test`, `refactor`, `ci`). |
21
+ | **UAT sign-off** ([docs](docs/checks/uat.md)) | pr-lifecycle's sign-off status says the head needs UAT (or, before a repo cuts over, the PR isn't docs, tests, CI, repo tooling, dependency-only, or repo metadata), or the status can't be trusted, and the head isn't signed off: a `v2` status reports `signoff=absent`, or, under `v1` or no status, no trusted user has applied `no UAT needed`, or `UAT passed` (or `tested`) since the last push (shows as pending). |
22
+ | **UAT label presence** ([docs](docs/checks/uat-label.md)), opt-in | `require-uat-label` is on and the PR carries none of `no UAT needed`, `UAT pending`, `UAT ready`, `UAT passed` (shows as pending). |
23
+ | **Dependabot claim verification** ([docs](docs/checks/dependabot.md)) | A Dependabot PR touches a non-dependency path, changes a dependency its description doesn't claim, pins a version other than the claimed one, or edits anything Dependabot never edits (a `package.json` script, a workflow step). |
24
+ | Domain labels (backlog) | Never blocks. Additive path-glob → domain-label map. |
25
+ | Milestone inheritance (backlog) | Never blocks. Issue → PR milestone. |
26
26
 
27
27
  The design, and why this is separate from `merge-safety` and `pr-lifecycle`, is
28
28
  in [docs/decisions.md](docs/decisions.md).
@@ -8,7 +8,7 @@ import {
8
8
  postVerdict,
9
9
  resolveRepoTarget,
10
10
  selectChecks
11
- } from "../chunk-SWWJ3U3V.js";
11
+ } from "../chunk-ISEUZ3TA.js";
12
12
 
13
13
  // src/bin/pr-policy.ts
14
14
  import { readFile } from "fs/promises";
@@ -68,21 +68,25 @@ function signOffState(pr, names) {
68
68
  }
69
69
 
70
70
  // src/sign-off-status.ts
71
- var SIGN_OFF_STATUS_VERSIONS = ["v1"];
71
+ var SIGN_OFF_STATUS_VERSIONS = ["v1", "v2"];
72
72
  var SIGN_OFF_REQUIREMENTS = ["none", "ci", "uat"];
73
73
  var WAIVER_STATES = ["current", "stale", "absent"];
74
- var KNOWN_KEYS = /* @__PURE__ */ new Set(["requirement", "waiver", "loosening"]);
74
+ var UAT_SIGN_OFF_OUTCOMES = ["waived", "passed", "absent"];
75
+ var UAT_KEY = { v1: "waiver", v2: "signoff" };
75
76
  var member = (values, value) => values.find((candidate) => candidate === value);
76
77
  function parseSignOffDescription(description) {
77
- const [version, ...pairs] = description.trim().split(/\s+/);
78
- if (member(SIGN_OFF_STATUS_VERSIONS, version) === void 0) {
79
- return `its format version \`${version ?? ""}\` is not one this pr-policy understands (${SIGN_OFF_STATUS_VERSIONS.join(", ")})`;
78
+ const [versionText, ...pairs] = description.trim().split(/\s+/);
79
+ const version = member(SIGN_OFF_STATUS_VERSIONS, versionText);
80
+ if (version === void 0) {
81
+ return `its format version \`${versionText ?? ""}\` is not one this pr-policy understands (${SIGN_OFF_STATUS_VERSIONS.join(", ")})`;
80
82
  }
83
+ const uatKey = UAT_KEY[version];
84
+ const knownKeys = /* @__PURE__ */ new Set(["requirement", "loosening", uatKey]);
81
85
  const fields = /* @__PURE__ */ new Map();
82
86
  for (const pair of pairs) {
83
87
  const [key = "", value, ...rest] = pair.split("=");
84
88
  if (value === void 0 || rest.length > 0) return `\`${pair}\` is not a \`key=value\` pair`;
85
- if (!KNOWN_KEYS.has(key)) return `\`${key}\` is not a known key`;
89
+ if (!knownKeys.has(key)) return `\`${key}\` is not a known key in \`${version}\``;
86
90
  if (fields.has(key)) return `\`${key}\` appears twice`;
87
91
  fields.set(key, value);
88
92
  }
@@ -92,9 +96,16 @@ function parseSignOffDescription(description) {
92
96
  if (looseningText !== "yes" && looseningText !== "no") return "`loosening` must be `yes` or `no`";
93
97
  const loosening = looseningText === "yes";
94
98
  if (requirement !== "uat") {
95
- if (fields.has("waiver")) return "`waiver` is only meaningful with `requirement=uat`";
99
+ if (fields.has(uatKey)) return `\`${uatKey}\` is only meaningful with \`requirement=uat\``;
96
100
  return { requirement, loosening };
97
101
  }
102
+ if (version === "v2") {
103
+ const signoff = member(UAT_SIGN_OFF_OUTCOMES, fields.get("signoff"));
104
+ if (signoff === void 0) {
105
+ return "`requirement=uat` needs `signoff=waived`, `passed`, or `absent`";
106
+ }
107
+ return { requirement, loosening, signoff };
108
+ }
98
109
  const waiver = member(WAIVER_STATES, fields.get("waiver"));
99
110
  if (waiver === void 0) return "`requirement=uat` needs `waiver=current`, `stale`, or `absent`";
100
111
  return { requirement, loosening, waiver };
@@ -1711,6 +1722,7 @@ function decideFromStatus2(pr, status) {
1711
1722
  case "ci":
1712
1723
  return [info2("No UAT needed: this head needs a CI sign-off instead (`ci-change`).")];
1713
1724
  case "uat": {
1725
+ if ("signoff" in status) return fromReportedSignOff(status.signoff);
1714
1726
  const waiver = status.waiver === "current" ? [] : [
1715
1727
  {
1716
1728
  label: NO_UAT_NEEDED_LABEL,
@@ -1721,6 +1733,17 @@ function decideFromStatus2(pr, status) {
1721
1733
  }
1722
1734
  }
1723
1735
  }
1736
+ function fromReportedSignOff(signoff) {
1737
+ const reported = `pr-lifecycle reports the UAT sign-off as \`${signoff}\` for this head`;
1738
+ if (signoff === "absent") {
1739
+ return [
1740
+ hold(
1741
+ `Waiting for UAT: ${reported}. A person applies \`${UAT_PASSED_LABEL}\` after testing, or the review agent or a person waives it with \`${NO_UAT_NEEDED_LABEL}\`.`
1742
+ )
1743
+ ];
1744
+ }
1745
+ return [{ ...info2(`UAT signed off: ${reported}.`), headline: true }];
1746
+ }
1724
1747
  function decideWithoutStatus2(pr) {
1725
1748
  const categories = trivialCategories(pr);
1726
1749
  if (categories !== void 0) {
@@ -2396,6 +2419,7 @@ export {
2396
2419
  SIGN_OFF_STATUS_VERSIONS,
2397
2420
  SIGN_OFF_REQUIREMENTS,
2398
2421
  WAIVER_STATES,
2422
+ UAT_SIGN_OFF_OUTCOMES,
2399
2423
  parseSignOffDescription,
2400
2424
  GITHUB_ACTIONS_BOT,
2401
2425
  parseSignOffStatusCreators,
package/dist/index.d.ts CHANGED
@@ -242,7 +242,7 @@ declare const RELEASE_PLEASE_PENDING_LABEL = "autorelease: pending";
242
242
  * pr-lifecycle's sign-off status: the one signal pr-lifecycle sends this gate.
243
243
  * pr-lifecycle classifies each head and posts a `pr-lifecycle/sign-off` commit
244
244
  * status on it whose description says which human sign-off the head needs, for
245
- * example `v1 requirement=uat waiver=current`. The format is pr-lifecycle's
245
+ * example `v2 requirement=uat signoff=passed`. The format is pr-lifecycle's
246
246
  * contract (its docs/sign-off-status.md, rmartz/pr-lifecycle#119); the two
247
247
  * must stay compatible.
248
248
  *
@@ -258,12 +258,22 @@ declare const RELEASE_PLEASE_PENDING_LABEL = "autorelease: pending";
258
258
  */
259
259
 
260
260
  /** The description format versions this gate understands. */
261
- declare const SIGN_OFF_STATUS_VERSIONS: readonly ["v1"];
261
+ declare const SIGN_OFF_STATUS_VERSIONS: readonly ["v1", "v2"];
262
262
  declare const SIGN_OFF_REQUIREMENTS: readonly ["none", "ci", "uat"];
263
263
  type SignOffRequirement = (typeof SIGN_OFF_REQUIREMENTS)[number];
264
+ /** `v1`'s `waiver`: whether a `no UAT needed` label counts for this head. */
264
265
  declare const WAIVER_STATES: readonly ["current", "stale", "absent"];
265
266
  type WaiverState = (typeof WAIVER_STATES)[number];
266
- /** A parsed, valid sign-off status. */
267
+ /**
268
+ * `v2`'s `signoff`: the UAT sign-off pr-lifecycle resolved for this head, from
269
+ * people's labels and the review agent's verdict records (rmartz/pr-policy#109).
270
+ */
271
+ declare const UAT_SIGN_OFF_OUTCOMES: readonly ["waived", "passed", "absent"];
272
+ type UatSignOffOutcome = (typeof UAT_SIGN_OFF_OUTCOMES)[number];
273
+ /**
274
+ * A parsed, valid sign-off status. A `uat` head carries `waiver` from a `v1`
275
+ * status, or `signoff` from a `v2` one.
276
+ */
267
277
  type SignOffClassification = {
268
278
  requirement: 'none';
269
279
  loosening: boolean;
@@ -274,6 +284,10 @@ type SignOffClassification = {
274
284
  requirement: 'uat';
275
285
  loosening: boolean;
276
286
  waiver: WaiverState;
287
+ } | {
288
+ requirement: 'uat';
289
+ loosening: boolean;
290
+ signoff: UatSignOffOutcome;
277
291
  };
278
292
  /**
279
293
  * - `absent`: no status on the head.
@@ -696,4 +710,5 @@ interface FetchClientOptions {
696
710
  }
697
711
  declare function createFetchClient(options: FetchClientOptions): GitHubClient;
698
712
 
699
- export { AMBIGUOUS_INDICATORS, type AmbiguousIndicator, BLOCKED_LABEL, BLOCKING_LABELS, BREAKING_CHANGE_LABEL, CHECKS, CI_APPROVAL_NEEDED_LABEL, CI_CHANGE_APPROVED_LABEL, CI_CHANGE_CHECK, CI_CHANGE_VERDICTS, CI_SENSITIVE_PACKAGES, COMMIT_TYPES, type CheckResult, type CheckRunReport, type CheckStatus, type CheckStatusOptions, type CiChangeVerdict, type Claim, type Classification, type ClientTarget, type CommitStatus, type CommitType, DEPENDABOT_CHECK, DEPENDABOT_LOGIN, DNM_LABEL, DO_NOT_MERGE_LABEL, ESCALATION_NEEDED_LABEL, FUNCTIONAL_TYPES, type FetchClientOptions, type FileChange, type Finding, GITHUB_ACTIONS_BOT, type GitHubClient, HOTFIX_LABEL, type Indicator, type IndicatorClass, type IndicatorKind, LOOSENING_INDICATORS, type LooseningIndicator, MERGE_BLOCK_CHECK, POLICY_OUTCOMES, PR_POLICY_CHECK_NAME, type ParsedTitle, type PolicyCheck, type PolicyEvaluation, type PolicyOptions, type PolicyOutcome, type PullRequestAuthor, type PullRequestFacts, type PullRequestTarget, RELEASE_PLEASE_PENDING_LABEL, SIGN_OFF_REQUIREMENTS, SIGN_OFF_STATUS_CONTEXT, SIGN_OFF_STATUS_VERSIONS, type SignOffClassification, type SignOffRequirement, type SignOffStatusReading, TITLE_CHECK, UAT_LABELS, UAT_LABEL_CHECK, type VerdictOptions, WAIVER_STATES, type WaiverState, type WorkflowFileChange, applyLabelEdits, buildReport, checkRunBody, checkStatuses, ciChangeCheck, ciRetitle, classifyWorkflowChanges, classifyWorkflowFile, clientOf, createFetchClient, createGhClient, decideCiChange, decideDependabot, decideMergeBlock, decideTitle, decideUatLabel, dependabotCheck, evaluatePolicy, gatherFacts, isManifestPath, isWorkflowPath, mergeBlockCheck, openPullRequestsAtHead, parseClaims, parseFacts, parseSignOffDescription, parseSignOffStatusCreators, parseTitle, postCheckRun, postCheckStatuses, postVerdict, readSignOffStatus, selectChecks, sensitiveBumps, statusBody, titleCheck, uatLabelCheck };
713
+ export { AMBIGUOUS_INDICATORS, BLOCKED_LABEL, BLOCKING_LABELS, BREAKING_CHANGE_LABEL, CHECKS, CI_APPROVAL_NEEDED_LABEL, CI_CHANGE_APPROVED_LABEL, CI_CHANGE_CHECK, CI_CHANGE_VERDICTS, CI_SENSITIVE_PACKAGES, COMMIT_TYPES, DEPENDABOT_CHECK, DEPENDABOT_LOGIN, DNM_LABEL, DO_NOT_MERGE_LABEL, ESCALATION_NEEDED_LABEL, FUNCTIONAL_TYPES, GITHUB_ACTIONS_BOT, HOTFIX_LABEL, LOOSENING_INDICATORS, MERGE_BLOCK_CHECK, POLICY_OUTCOMES, PR_POLICY_CHECK_NAME, RELEASE_PLEASE_PENDING_LABEL, SIGN_OFF_REQUIREMENTS, SIGN_OFF_STATUS_CONTEXT, SIGN_OFF_STATUS_VERSIONS, TITLE_CHECK, UAT_LABELS, UAT_LABEL_CHECK, UAT_SIGN_OFF_OUTCOMES, WAIVER_STATES, applyLabelEdits, buildReport, checkRunBody, checkStatuses, ciChangeCheck, ciRetitle, classifyWorkflowChanges, classifyWorkflowFile, clientOf, createFetchClient, createGhClient, decideCiChange, decideDependabot, decideMergeBlock, decideTitle, decideUatLabel, dependabotCheck, evaluatePolicy, gatherFacts, isManifestPath, isWorkflowPath, mergeBlockCheck, openPullRequestsAtHead, parseClaims, parseFacts, parseSignOffDescription, parseSignOffStatusCreators, parseTitle, postCheckRun, postCheckStatuses, postVerdict, readSignOffStatus, selectChecks, sensitiveBumps, statusBody, titleCheck, uatLabelCheck };
714
+ export type { AmbiguousIndicator, CheckResult, CheckRunReport, CheckStatus, CheckStatusOptions, CiChangeVerdict, Claim, Classification, ClientTarget, CommitStatus, CommitType, FetchClientOptions, FileChange, Finding, GitHubClient, Indicator, IndicatorClass, IndicatorKind, LooseningIndicator, ParsedTitle, PolicyCheck, PolicyEvaluation, PolicyOptions, PolicyOutcome, PullRequestAuthor, PullRequestFacts, PullRequestTarget, SignOffClassification, SignOffRequirement, SignOffStatusReading, UatSignOffOutcome, VerdictOptions, WaiverState, WorkflowFileChange };
package/dist/index.js CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  TITLE_CHECK,
30
30
  UAT_LABELS,
31
31
  UAT_LABEL_CHECK,
32
+ UAT_SIGN_OFF_OUTCOMES,
32
33
  WAIVER_STATES,
33
34
  applyLabelEdits,
34
35
  buildReport,
@@ -64,7 +65,7 @@ import {
64
65
  statusBody,
65
66
  titleCheck,
66
67
  uatLabelCheck
67
- } from "./chunk-SWWJ3U3V.js";
68
+ } from "./chunk-ISEUZ3TA.js";
68
69
 
69
70
  // src/github/check-statuses.ts
70
71
  var MAX_DESCRIPTION = 140;
@@ -218,6 +219,7 @@ export {
218
219
  TITLE_CHECK,
219
220
  UAT_LABELS,
220
221
  UAT_LABEL_CHECK,
222
+ UAT_SIGN_OFF_OUTCOMES,
221
223
  WAIVER_STATES,
222
224
  applyLabelEdits,
223
225
  buildReport,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmartz/pr-policy",
3
- "version": "1.7.1",
3
+ "version": "1.8.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",
@@ -61,7 +61,7 @@
61
61
  "eslint-import-resolver-typescript": "^4.4.5",
62
62
  "eslint-plugin-import": "^2.32.0",
63
63
  "prettier": "^3.9.8",
64
- "tsup": "^8.5.1",
64
+ "tsup": "^9.0.0",
65
65
  "typescript": "^6.0.3",
66
66
  "vite": "^8.3.0",
67
67
  "vitest": "^5.0.1"