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
test/ai-gates.test.tsmodified+48-0
Changes to test/ai-gates.test.ts
@@ -9,6 +9,7 @@ import {
99 isMergeEvent,
1010 runAiGates,
1111 runPostMerge,
12 summarizeGates,
1213} from '../src/gates'
1314import {
1415 clearQuickSelection,
@@ -486,3 +487,50 @@ describe('EOL feeds the dependency gate', () => {
486487 expect(checkDependencies([{ name: 'node', version: '22' }], { mode: 'error' }).passed).toBe(true)
487488 })
488489})
490
491/**
492 * `neutral()` in the assertion gates returned `passed: true`, and `GateResult`
493 * had no other state — so a gate that could not run was rendered with the same
494 * green tick as one that ran and found nothing, and a check run made of
495 * nothing but skipped gates was titled "All checks passed".
496 */
497describe('neutral gate results', () => {
498 const passed = { name: 'deps', mode: 'error' as const, passed: true, summary: 'fine' }
499 const skipped = { name: 'linked-issue', mode: 'warning' as const, passed: true, neutral: true, summary: 'No AI provider configured' }
500 const failed = { name: 'size', mode: 'error' as const, passed: false, summary: 'too big' }
501
502 it('failure case - all gates skipped is not "all checks passed"', () => {
503 const summary = summarizeGates([skipped])
504
505 expect(summary.conclusion).toBe('neutral')
506 expect(summary.title).toContain('did not run')
507 expect(summary.title).not.toContain('passed')
508 })
509
510 it('success case - a skipped gate beside a real pass is counted apart', () => {
511 const summary = summarizeGates([passed, skipped])
512
513 expect(summary.conclusion).toBe('success')
514 expect(summary.title).toBe('1 check(s) passed, 1 did not run')
515 })
516
517 it('success case - a skipped gate renders as skipped, not as a tick', () => {
518 const { summary } = summarizeGates([passed, skipped])
519
520 expect(summary).toContain('⏭️ **linked-issue**')
521 expect(summary).toContain('✅ **deps**')
522 })
523
524 it('failure case - a skipped gate never blocks', () => {
525 expect(summarizeGates([skipped, failed]).conclusion).toBe('failure')
526 expect(summarizeGates([skipped, passed]).conclusion).toBe('success')
527 })
528
529 it('success case - a gate that could not run is flagged neutral', async () => {
530 // No AI is the commonest reason. It says so rather than passing.
531 const result = await checkLinkedIssue(null, { diff: 'x', linkedIssues: [{ number: 1, title: 't', body: 'b' }] } as never, 'error')
532
533 expect(result.neutral).toBe(true)
534 expect(result.passed).toBe(true)
535 })
536})