feat: auto-repair loop for failing auto-update PRs #48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/auto-repair-loop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problema
Le PR di aggiornamento settimanale del flake (
auto-update-*, create da.forgejo/workflows/auto-update-pr.yaml) vengono buildate da.forgejo/workflows/auto-update-build.yaml. Quando un aggiornamento rompe la build, il workflow attuale si limita a commentare i fallimenti sulla PR e si ferma: la PR resta aperta, non-mergeabile (es. PR #47 "WIP"), e richiede intervento manuale.Soluzione
Questa PR aggiunge un repair-loop automatico (
.forgejo/workflows/auto-repair.yaml) che usa un coding agent (pi, tramite OpenRouter) per tentare di sistemare la build fallita direttamente sul branch della PR:auto-update/*per gli eventiopenedesynchronizedi pull_request versomaster.mergeable; se la PR è già mergeable la build è ok ed esce senza fare nulla (niente lavoro inutile).auto-update-build.yaml, colmena). Se passa, non fa nulla./tmp/build-failures.txt, prepara un prompt e lanciapi(conNOT_SYS=trueeOPENROUTER_API_KEY) per correggereflake.nix/flake.lock. L'agente committafix: auto-repair attempt Ne pusha sul branch della PR (mai force-push, mai merge). Il push genera un nuovo eventosynchronize→ la build riparte.fix: auto-repair attemptnella storia del branch — max 3 tentativi. Oltre il terzo, il workflow commenta "🛑 Auto-repair gave up" sulla PR e si ferma senza pushare, lasciando l'intervento all'uomo.Secrets usati (stesso runner
nix):MINE_API_TOKEN(già presente) eOPENROUTER_API_KEY(da aggiungere ai secrets del repo).Il README viene aggiornato con una sezione "Auto-repair" che documenta il flusso.
File modificati
+ .forgejo/workflows/auto-repair.yaml(nuovo workflow di repair-loop)M README.md(documentazione del flusso)Azioni necessarie prima/col merge
OPENROUTER_API_KEYal repository (Settings → Actions → Secrets).CURSOR_API_KEYal repositorypisia installato sul runnernix(il workflow lo richiama comepi -p ...).e69904f3bctoac86de27d6Update: switched from pi to Cursor SDK
The repair step no longer runs pi with pi-cursor-sdk on the runner. It now uses @cursor/sdk via a small script at
scripts/auto-repair/auto-repair.mjs.
Why
What changed
pi)NOT_SYS=true pi --provider cursor ...on the runnernode scripts/auto-repair/auto-repair.mjsCURSOR_API_KEY/OPENROUTER_API_KEYin agenixpi-envonforgejo-runnerCURSOR_API_KEYas Forgejo Actions secretservices.forgejo-runner.pi.*NixOS modulenodejs(already inhostPackages)fix: auto-repair attempt Nand pushesThe repair step calls
Agent.prompt(..., { local: { cwd, settingSources: [] } })with build logs in the prompt. Model defaults to composer-2.5;override with repo variable CURSOR_MODEL.
Setup before merge
OPENROUTER_API_KEYif it was added for the old approach)CURSOR_MODELas a repository variable if you want something other than composer-2.5Unchanged