ReviewOS

also looking at this

stacks/buddy

fix: report skipped gates as skipped, and honour ai.majorUpgrades.maxAttempts

#1433
Merged glennmichael123 wants to merge fix/gate-neutral into main
9 files +257 -8
src/gates/checks.tsmodified+38-2
Changes to src/gates/checks.ts
@@ -9,6 +9,14 @@ export interface GateResult {
99 /** `error` blocks the merge under branch protection; `warning` does not */
1010 mode: GateMode
1111 passed: boolean
12 /**
13 * The gate did not run — no AI configured, nothing to check against, the
14 * assessment failed. Distinct from `passed`, which it used to be folded
15 * into: a gate that could not run was rendered with the same green tick as
16 * one that ran and found nothing, and a check run made of nothing but
17 * skipped gates reported "All checks passed".
18 */
19 neutral?: boolean
1220 /** What failed, or what passed */
1321 summary: string
1422 /** Extra explanation shown under the summary */
@@ -199,17 +207,31 @@ export function summarizeGates(results: GateResult[]): {
199207
200208 const blocking = results.filter(result => !result.passed && result.mode === 'error')
201209 const warnings = results.filter(result => !result.passed && result.mode === 'warning')
210 const skipped = results.filter(result => result.neutral)
202211
203212 const lines = results.map((result) => {
204 const icon = result.passed ? '✅' : result.mode === 'error' ? '❌' : '⚠️'
213 const icon = gateIcon(result)
205214 return `${icon} **${result.name}** — ${result.summary}${result.detail ? `\n\n${result.detail}\n` : ''}`
206215 })
207216
217 // Every gate skipped is not a pass. It is the "no checks configured" case
218 // arrived at a different way, and gets the same conclusion.
219 if (skipped.length === results.length) {
220 return {
221 conclusion: 'neutral',
222 title: `${skipped.length} check(s) did not run`,
223 summary: lines.join('\n\n'),
224 }
225 }
226
227 const ran = results.length - skipped.length
208228 const title = blocking.length > 0
209229 ? `${blocking.length} check(s) failed`
210230 : warnings.length > 0
211231 ? `${warnings.length} warning(s)`
212 : 'All checks passed'
232 : skipped.length > 0
233 ? `${ran} check(s) passed, ${skipped.length} did not run`
234 : 'All checks passed'
213235
214236 return {
215237 conclusion: blocking.length > 0 ? 'failure' : 'success',
@@ -218,6 +240,20 @@ export function summarizeGates(results: GateResult[]): {
218240 }
219241}
220242
243/**
244 * The icon a gate result renders with.
245 *
246 * Shared with the CLI so a skipped gate looks the same in a terminal as in
247 * the check run.
248 *
249 * @param result - A gate result
250 */
251export function gateIcon(result: GateResult): string {
252 if (result.neutral)
253 return '⏭️'
254 return result.passed ? '✅' : result.mode === 'error' ? '❌' : '⚠️'
255}
256
221257function escapeRegExp(value: string): string {
222258 return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
223259}