@thegpvc/gp-foundry 0.2.14 → 0.2.16

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.
@@ -37,11 +37,15 @@ disqualifying first:
37
37
  block does *not* constrain — can publish its own approval. `gp-foundry build`
38
38
  emits the human-gate's check pinned to `@github-actions`, the app GITHUB_TOKEN
39
39
  writes as. Leave third-party CI checks unpinned.
40
- 7. **Hand-written additions** — additions of non-`excludeGlobs` files must be
40
+ 7. **Review requests** (opt-in, `requireNoReviewRequests: true`) — no pending
41
+ requested reviewer or team, else `review-requested`.
42
+ 8. **Open review threads** (opt-in, `requireNoOpenThreads: true`) — no open
43
+ thread, else `open-threads`. See [Open threads](#open-threads).
44
+ 9. **Hand-written additions** — additions of non-`excludeGlobs` files must be
41
45
  `<= maxAdditions`, else apply `labels.needsHuman`.
42
- 8. **Protected paths** — no changed file may match `protectedPaths`, else apply
46
+ 10. **Protected paths** — no changed file may match `protectedPaths`, else apply
43
47
  `labels.needsHuman`.
44
- 9. **Clean rebase** — the branch must rebase cleanly onto the base branch
48
+ 11. **Clean rebase** — the branch must rebase cleanly onto the base branch
45
49
  (unless `requireCleanRebase: false`), else apply `labels.rebaseNeeded`.
46
50
 
47
51
  If all pass, the action is `merge` — of the **exact head SHA that was scored**,
@@ -74,6 +78,87 @@ counts verdicts it can attribute:
74
78
 
75
79
  The latest verdict wins: a newer rejection invalidates an earlier approval.
76
80
 
81
+ ## Open threads
82
+
83
+ With `requireNoOpenThreads: true` the wrapper reads the PR's review threads
84
+ (GraphQL `reviewThreads`: resolution, every comment's author, reactions on the
85
+ first comment). A thread is **open** when all of these hold:
86
+
87
+ - it is unresolved;
88
+ - its first comment is not by the PR author (a note to self never blocks);
89
+ - no later comment is by the PR author, and the author has not reacted to the
90
+ first comment — a reply or a reaction is the author's answer, and the next
91
+ review judges it;
92
+ - if a login in `botLogins` (e.g. `greptile-apps[bot]`, `cursor[bot]`) opened
93
+ it, its first comment matches `botThreadBlockingRegex` (default
94
+ `P1|High Severity`). A review bot's lower-severity thread never blocks.
95
+
96
+ Logins compare case-insensitively and with or without the `[bot]` suffix
97
+ (GraphQL drops it). A failed thread read fails closed: the PR is not evaluated
98
+ that run.
99
+
100
+ ## Evaluate mode
101
+
102
+ `mode: evaluate` never merges, labels or comments. It evaluates the policy for
103
+ every open, non-draft PR on a `branchPrefix` branch (narrowed by `authors`,
104
+ `opt-in-label`, `skip-labels` and `skip-bot-authors` when given; or just
105
+ `pr-number`) and publishes the result as one check run per head, named
106
+ `check-name`:
107
+
108
+ | conclusion | when |
109
+ | --- | --- |
110
+ | `success` | the gate's decision is `merge` |
111
+ | `action_required` | the trusted reviewer's latest verdict on the head is an escalation (`**Verdict:** ESCALATE`, or `escalationBodyRegex`) |
112
+ | `neutral` | `noVerdictConclusion: neutral` and the head has no verdict yet, with the missing approval as its only failing clause ("awaiting the approver") |
113
+ | `failure` | anything else; `output.summary` carries the gate's `code` and `reason` |
114
+
115
+ `output.text` lists the open threads, the checks not passing and the pending
116
+ review requests. The run is written with `checks-token` (GITHUB_TOKEN) and is
117
+ idempotent per head: an existing run of that name from `github-actions` is
118
+ updated in place, and when its conclusion, summary and text already match,
119
+ nothing is written. Gate state that changes without a push (a thread answered,
120
+ CI finished, a review request dropped) therefore flips the check on the next
121
+ run, at no model cost, and the check can be made required.
122
+
123
+ In this mode the gate leaves its own check out of the CI rollup (a failing
124
+ verdict would otherwise hold itself failing), and `requireCleanRebase` defaults
125
+ to `false` — mergeability is only settled by a merge attempt, which this mode
126
+ never makes. The token needs only `checks: write`, `pull-requests: read` and
127
+ `contents: read`.
128
+
129
+ ## Verdict markers
130
+
131
+ Review bodies are matched as a reader sees them: HTML comments removed (the
132
+ harness appends its own after the verdict line — the unchanged-diff stamp, the
133
+ also-head marker) and trailing whitespace trimmed.
134
+
135
+ A review is a verdict when that visible body's last non-empty line, trimmed, is
136
+ exactly `**Verdict:** <word>`, with the words given by the `verdicts` input
137
+ (default `APPROVE,REQUEST_CHANGES,ESCALATE`: approve, request changes, escalate).
138
+ The approval and escalation markers default to those exact lines, which is the
139
+ grammar the sweep's select and mark jobs use (`src/shared/verdicts.ts`), so a head
140
+ the sweep counts as decided is one the gate can read.
141
+ `**Verdict:** APPROVE (once gates pass)` is not a verdict.
142
+
143
+ The rejection marker defaults to the loose `Verdict.*<request-changes word>`, on
144
+ purpose: a rejection the gate fails to recognize leaves an earlier approval
145
+ standing and the PR merges, while one it recognizes too eagerly only holds a merge
146
+ back. The approval marker is tested first, so an approval that mentions the
147
+ earlier request in prose is still an approval. `approvalBodyRegex`,
148
+ `rejectionBodyRegex` and `escalationBodyRegex` override a marker, but an override
149
+ can drift from the sweep; leave them unset.
150
+
151
+ ## Whose approval counts
152
+
153
+ An approval counts when it comes from `botLogin` or from an author whose
154
+ association is in `trustedAuthorAssociations` — and **never from the pull
155
+ request's own author**, unless that author is `botLogin`. GitHub refuses a formal
156
+ `APPROVED` review from a PR's author but allows a `COMMENTED` one, and a comment
157
+ review ending in the approval line is how the gate reads an approval; without
158
+ this rule a trusted collaborator could open a PR and approve it themselves. The
159
+ harness bot is the deliberate exception: it writes and reviews agent PRs under
160
+ one identity. A rejection counts from anyone, including the author.
161
+
77
162
  ## Inputs
78
163
 
79
164
  | input | required | description |
@@ -84,12 +169,17 @@ The latest verdict wins: a newer rejection invalidates an earlier approval.
84
169
  | `bot-login` | no | Login of the reviewer bot whose verdicts are trusted; overrides the policy's `bot_login`. |
85
170
  | `required-checks` | no | Comma/newline-separated check-run names that must be present and green on the head SHA; overrides the policy's `required_checks`. |
86
171
  | `clean-rebase`| no | Override the rebase check with `"true"`/`"false"`; inferred from mergeable state otherwise. |
172
+ | `checks-token` | no | Token for reading (and, in evaluate mode, writing) check runs; pass GITHUB_TOKEN. |
173
+ | `verdicts` | no | The verdict words, approve / request changes / escalate (default `APPROVE,REQUEST_CHANGES,ESCALATE`). |
174
+ | `mode` | no | `merge` (default) or `evaluate` (publish a check run per head, never merge). |
175
+ | `check-name` | evaluate | The check run evaluate mode publishes. |
176
+ | `authors`, `opt-in-label`, `skip-labels`, `skip-bot-authors` | no | Evaluate-mode PR selection (comma-separated logins / labels; `"true"`). |
87
177
  | `dry-run` | no | `"true"` to evaluate + emit outputs without mutating. |
88
178
 
89
179
  ## Outputs
90
180
 
91
181
  `action`, `code`, `reason`, `label` (when labeling), and `merged` (`"true"` if
92
- this run merged the PR).
182
+ this run merged the PR). Evaluate mode sets `evaluated` and `checks-written`.
93
183
 
94
184
  ## Policy file
95
185
 
@@ -137,7 +227,14 @@ trustedAuthorAssociations: ["OWNER", "MEMBER", "COLLABORATOR"]
137
227
  allowCommentApprovals: false # plain issue comments are NOT approvals
138
228
 
139
229
  # wrapper-only (I/O) knobs:
140
- approvalBodyRegex: "Verdict.*APPROVE" # count a COMMENTED review as approval
230
+ # approvalBodyRegex / rejectionBodyRegex / escalationBodyRegex: overrides only;
231
+ # by default each is the exact verdict line (see "Verdict markers").
232
+
233
+ # evaluate-mode clauses (off by default; also apply in merge mode when set):
234
+ requireNoOpenThreads: true
235
+ botLogins: ["greptile-apps[bot]", "cursor[bot]"]
236
+ botThreadBlockingRegex: "P1|High Severity"
237
+ requireNoReviewRequests: true
141
238
  ciIgnoreCheckNames: ["review", "fix", "sweep", "merge"]
142
239
  mergeMethod: "rebase" # merge | squash | rebase
143
240
  deleteBranchOnMerge: true
@@ -63,6 +63,44 @@ inputs:
63
63
  unset, the action infers it from the PR's mergeable state.
64
64
  required: false
65
65
  default: ""
66
+ verdicts:
67
+ description: >
68
+ The verdict words, comma-separated, in order: approve, request changes,
69
+ escalate (default "APPROVE,REQUEST_CHANGES,ESCALATE"). A review is a verdict
70
+ when its last non-empty line, trimmed, is exactly "**Verdict:** <word>"; the
71
+ approval, rejection and escalation markers default to those lines. The
72
+ compiler passes foundry.config.yaml's `verdicts:` here.
73
+ required: false
74
+ default: ""
75
+ mode:
76
+ description: >
77
+ "merge" (default): merge the first qualifying PR, or label/skip. "evaluate":
78
+ never merge or label — evaluate every open PR in scope and publish the
79
+ result as one check run per head (named by check-name), updated in place
80
+ each run and left alone when nothing changed. Evaluate mode needs only
81
+ `checks: write`, `pull-requests: read` and `contents: read` on the token.
82
+ required: false
83
+ default: "merge"
84
+ check-name:
85
+ description: "Evaluate mode: the check run to publish on each head (required in that mode)."
86
+ required: false
87
+ default: ""
88
+ authors:
89
+ description: "Evaluate mode: only PRs by these comma-separated logins (or carrying opt-in-label)."
90
+ required: false
91
+ default: ""
92
+ opt-in-label:
93
+ description: "Evaluate mode: with authors, a PR carrying this label is in scope whoever opened it."
94
+ required: false
95
+ default: ""
96
+ skip-labels:
97
+ description: "Evaluate mode: comma-separated labels; a PR carrying any is not evaluated."
98
+ required: false
99
+ default: ""
100
+ skip-bot-authors:
101
+ description: "Evaluate mode: 'true' leaves out PRs opened by a bot other than bot-login."
102
+ required: false
103
+ default: "false"
66
104
  dry-run:
67
105
  description: "When 'true', evaluate and emit outputs but perform no mutation."
68
106
  required: false
@@ -81,6 +119,10 @@ outputs:
81
119
  description: "'true' if a PR was merged by this run, else 'false'."
82
120
  merged-pr:
83
121
  description: "The PR number that was merged, if any."
122
+ evaluated:
123
+ description: "Evaluate mode: how many PRs were evaluated."
124
+ checks-written:
125
+ description: "Evaluate mode: how many check runs were created or updated (unchanged ones are not written)."
84
126
 
85
127
  runs:
86
128
  using: "node24"