ReviewOS

also looking at this

stacks/buddy

fix(ci): give the repair loop the guard it already had

#1407
Merged glennmichael123 wants to merge fix/wire-ci-repair-attempt-guard into main
10 files +229 -34
src/commands/handlers.tsmodified+11-12
Changes to src/commands/handlers.ts
@@ -1,9 +1,7 @@
11import type { GitProvider } from '../git/provider'
22import type { BuddyConfig } from '../types'
33import type { CommandContext, CommandHandler, CommandOutcome } from './dispatcher'
4import process from 'node:process'
54import { createAiClient } from '../ai'
6import { attemptFix } from '../ci/fix'
75
86/** Everything the built-in handlers need to act. */
97export interface HandlerDeps {
@@ -90,16 +88,17 @@ export function createHandlers(deps: HandlerDeps): Record<string, CommandHandler
9088 },
9189
9290 async 'fix-ci'(context): Promise<CommandOutcome> {
93 const ai = createAiClient(deps.config, context.logger)
94 const outcome = await attemptFix({
95 log: '',
96 workspace: process.cwd(),
97 baseBranch: deps.config.repository?.baseBranch ?? 'main',
98 ai,
99 logger: context.logger,
100 })
101
102 return { handled: true, reply: outcome.report }
91 // This handler has no run to read. Diagnosis is entirely a function of
92 // the failing job's log, so calling attemptFix with an empty one only
93 // ever produced a confident-looking `unknown` classification with no
94 // evidence behind it. Saying so is more useful than that.
95 return {
96 handled: false,
97 reply: 'I diagnose a failure from its job log, and a comment does not tell me which run failed. '
98 + 'Buddy repairs failing checks automatically when the `fix-ci` job is enabled in your workflow — '
99 + 'it runs on the failed run itself and reports back here. '
100 + 'See https://buddy.sh/features/ci-repair',
101 }
103102 },
104103
105104 async remember(context): Promise<CommandOutcome> {