[DEV-76] CI failure watcher acquirer: auto-fix failing checks on the agent's own PRs - #51
Open
danii1 wants to merge 3 commits into
Open
[DEV-76] CI failure watcher acquirer: auto-fix failing checks on the agent's own PRs#51danii1 wants to merge 3 commits into
danii1 wants to merge 3 commits into
Conversation
…g checks on the agent's own PRs
# Conflicts: # docs/code/worker.md # packages/code/src/index.ts # packages/code/src/lib/dashboard-api.ts # packages/code/src/lib/run-recorder.ts # packages/code/src/lib/workspace/fleet-events.ts # packages/code/src/lib/workspace/workspace-worker.ts # packages/dashboard-ui/src/lib/api.ts # packages/dashboard-ui/src/views/RunsView.tsx # packages/dashboard-ui/src/views/StatsView.tsx
# Conflicts: # packages/code/src/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements DEV-76: a new worker acquirer that watches CI on the agent's own PRs and automatically re-runs the agent to fix failing checks.
What was built
New acquirer —
packages/code/src/lib/ci-failure-watcher-acquirer.tsagent_prsregistry: ETag-cached conditional GETs on the PR (unwatch closed/merged), head-SHA check runs, and combined commit statusesfailureconclusions; fork PRs skipped quietly; dedupe perheadSha + checkRunIdunder sourcegithub:civiaqueue.hasProcessed/markProcessed(survives restarts)CI_FIX_MAX_ATTEMPTS, default 3) persisted in a newci_fix_statetable inWorkerState; exhaustion posts an escalation comment once and blocks until the head moves; fully-green CI resets the budget (mixed results don't refund it)truncateCiLogs(): strips ANSI, keeps error-marker windows across the whole log plus a tail window, caps at ~16k charsGitHub client —
github-reviews.ts:getCheckRuns,getCombinedStatus,getWorkflowRunJobs,getWorkflowRunsForSha,getJobLogs(null on 403/404),getCheckRunAnnotations(log fallback)Fix pipeline —
address-review.tsgained--ci-feedback <file>mode: reads watcher-written JSON (CiFailureFeedbackfromreview-formatter.ts), begins a run with originci_fix, then reuses the existing worktree prep, sandboxed agent spawn, commit/push-with-hook-retries flow verbatim. Also fixes a dangling in-progress run when the agent makes no changes. CLI spawn helper:runCiFixViaCli.Run recording/dashboard —
"ci_fix"added toRunOrigin, statsbyOrigin, dashboard-api filter validation, and dashboard-ui types/filters/stats hint.Wiring — registered in single-repo worker (
index.ts) and fleet mode (workspace-worker.ts→ newcreateFleetCiFixinfleet-events.ts), gated on GitHub creds like the review poller.Tests —
tests/ci-failure-watcher-acquirer.test.ts(15 tests) + truncation unit tests +formatCiFixPrompttests. All gates pass: 809 tests (0 fail), typecheck, lint, format. Docs updated indocs/code/worker.md.