feat(prompts): fix all CI/CD even when inherited under --auto-restart-until-mergeable (#1887)#1888
feat(prompts): fix all CI/CD even when inherited under --auto-restart-until-mergeable (#1887)#1888konard wants to merge 5 commits into
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: #1887
…ited (#1887) When --auto-restart-until-mergeable is enabled, a PR whose CI/CD stays red restarts forever. The AI must actually attempt to fix failing checks — even when the breakage looks pre-existing or inherited from another branch — instead of only reporting it and asking for a human decision. - Add explicit fix-all-CI guidance + infinite-loop warning to buildAutoRestartInstructions() (shared by all auto-restart/watch iterations) - Add two 'When x, do y.' statements to buildSystemPrompt() for all 6 AI tools (claude, codex, gemini, qwen, agent, opencode): fix failing CI/CD even if pre-existing, and keep the default branch clean by assuming repository-wide fix scope unless the user explicitly restricts it - Add tests/test-issue-1887-ci-fix-prompt.mjs (16 assertions)
Compile the deep case study under docs/case-studies/issue-1887/ (README, requirements, analysis, solutions, existing-components) with saved kefine issue/PR data, the verbatim before-fix auto-restart prompt, and the AI's decision comments. Add a minor changeset for the prompt change (#1887).
--auto-restart-until-mergeable is enabled
Working session summaryВсё готово — это была фоновая задача ожидания CI, которая подтвердила, что все проверки прошли успешно. Работа над issue #1887 полностью завершена. Итог: Что сделано в PR #1888 (#1888):
This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $6.227771📊 Context and tokens usage:Claude Opus 4.8: (2 sub-sessions)
Total: (20.2K new + 268.1K cache writes + 6.2M cache reads) input tokens, 53.3K output tokens, $6.227771 cost 🤖 Models used:
📎 Log file uploaded as Gist (2842KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit 737320c.
Summary
Under
--auto-restart-until-mergeable(also implied by--auto-merge), the solver restarts the AI session until the pull request is mergeable. If the AI decides a failing CI/CD check is pre-existing or inherited from another branch and merely asks a human for a decision instead of fixing it, the loop cannot converge without a human and keeps restarting — burning iterations and money (observed inlefinepro/kefine#170, $16+ by iteration 2).This PR raises the probability the AI fixes the checks itself — without forcing it — by adding soft
When x, do y.guidance in the auto-restart prompt and the system prompt (the issue explicitly allowed "or both").Changes
src/solve.restart-shared.lib.mjs—buildAutoRestartInstructions()(the single shared auto-restart/watch feedback prompt used by every tool) now:src/{claude,codex,gemini,qwen,agent,opencode}.prompts.lib.mjs—buildSystemPrompt()for all six tools gains twoWhen x, do y.statements (fix failing CI/CD even when pre-existing/inherited; keep the default branch clean by assuming repository-wide scope unless the user restricts it). Applied to all tools per the "fix in all places" requirement.Why no hard gate
The issue asked to increase probability … but no forcing. A hard rule ("never end while CI is red") was deliberately rejected: genuine human-only blockers exist (infra, secrets, policy), and forcing would turn "loop asking" into "loop unable to stop". The change shifts the agent's default toward fixing while preserving the human-escalation escape hatch. The existing 5-iteration cap remains the runaway backstop.
How to reproduce the original problem
solveon an issue with--auto-merge/--auto-restart-until-mergeableagainst a base branch whose CI is already red.Tests
tests/test-issue-1887-ci-fix-prompt.mjs— 16 assertions verifying the new guidance is present in the auto-restart prompt and in all six tools' system prompts.src/, Prettier clean.Case study (Requirements R4–R5)
Compiled under
docs/case-studies/issue-1887/:README.md— executive summary, reconstructed timeline, root cause, the fix.requirements.md— R1–R9 mapped to how this PR addresses each.analysis.md— restart-loop walkthrough, why the AI escalated, root-cause statement, why-not-hard-gate, verbose-sufficiency (R6 n/a), third-party reporting (R7 n/a).solutions.md— options A–D considered and why A was chosen, plus follow-ups.existing-components.md— in-repo and ecosystem prior art reused.data/— saved kefine issue/PR JSON, comment timeline, the verbatim before-fix prompt, and the AI's decision comments.Closes #1887