Introducing a new way to review your PRs.

Read the announcement

tracer-cloud / opensre

The open-source agent for CI/CD reliability.

View on GitHub

25 documents · Updated Nov 23, 2026

docs / github-ci-repair-automation

GitHub CI repair automation

GitHub CI repair automation turns a detected CI failure into bounded repair work with human approval, isolated source changes, post-push checks, and a durable outcome. The flow separates a read-only health view from the mutating repair loop, so engineers can see the failure signal before a repair changes a repository. See Operational automation, Alert intake and scheduling, Delivery and deployment, Operational analytics, and Integration platform for the surrounding systems.

System boundary

The system has two connected responsibilities. A health scan finds failing pull request and branch heads across a GitHub scope. A repair loop then acts on one selected target and retains evidence about what happened.

The scan does not repair, retry, or rerun CI. The repair loop is a supervised operation that needs a connected OpenSRE GitHub app, GitHub write access, a ready coding agent, and approval before it edits, commits, or pushes. GitHub CI health scan describes the read-only view, while GitHub CI fix describes the direct repair capability.

The user-facing onboarding path keeps analysis and repair separate. A user can first review historical CI performance, then choose a disposable local demonstration, a repair on the managed service, or no repair. The local and hosted choices are separate supervision modes rather than two names for one continuous service. References: core/…/SKILL.md• L20-59, core/…/SKILL.md• L139-164, core/…/SKILL.md• L21-33

CI health scan

The health scan provides the fleet-level starting point for repair work. It resolves repositories under the requested owners, reads their relevant commit heads, and returns failing pull requests, default branches, and optionally other branches.

Scan scope

The scan uses the GitHub token to define the visible account and organization scope. By default it favors current signal: recently pushed repositories, the default branch head, and recently updated open pull requests. An explicit all-branches mode widens the search when a branch-level view is needed.

The result keeps coverage information beside the failures. It distinguishes repositories that were read from repositories that could not be read, and it reports caps or skipped data instead of presenting partial coverage as a complete view.

References: integrations/…/tool.py• L115-160 integrations/…/models.py• L116-205 integrations/…/scan.py• L353-399 core/…/SKILL.md• L72-97

Failure classification

The scan classifies each head from its GitHub check rollup. Failed check conclusions and failed commit-status states become repair candidates. Cancelled checks remain visible as context but do not count as failures because a cancelled run can be a superseded run rather than a broken build.

Each failing head carries the repository, ref, commit identity, failing check names, and links. For pull requests it also carries the pull request identity and fork or draft state, which helps the next stage decide whether the target is suitable for repair.

The onboarding target picker uses this signal to offer repositories that have at least one failing pull request. It does not offer a repository with no failing pull request as a live repair target, although a green target can still be observed by the repair loop when it is already selected.

References: integrations/…/classify.py• L10-73 integrations/…/models.py• L32-96 core/…/SKILL.md• L78-97

Failure analysis

Failure analysis turns one scan result or one explicit target into a repair context. It confirms that the target is still open and supported, identifies the exact head commit, collects failing checks, and adds compact log evidence for the coding agent.

Repair context

For a pull request, the context joins pull request metadata with its check rollup and merge state. For a branch, it uses workflow runs on that branch head. The resulting task tells the coding agent which checks failed and what evidence they produced, while asking for the smallest change that addresses the observed failure.

The analysis rejects unsupported or unsafe targets before a push. In particular, the repair path does not push to a fork-owned pull request head, a closed pull request, or a target that has no failure to address. A pull request that cannot build checks because it conflicts with its base is treated as a base-merge repair case.

The supervised workflow selects the pull request after the repository is known. This keeps the repair scope tied to one user-approved target and avoids creating a repair run before the target choice is complete.

References: integrations/…/context.py• L91-128 integrations/…/context.py• L145-251 integrations/…/context.py• L287-379 core/…/SKILL.md• L99-115 core/…/test_scheduling_workflow.py• L183-254

Repair loop

The repair loop gives one selected target a durable identity, a fixed time budget, and a supervised worker. A request can schedule a repair or read its report later without starting a second repair.

The flow below shows how a detected failure moves through analysis, isolated work, verification, and outcome recording.

flowchart TD
    A[CI health result or selected target] --> B[Resolve failure context]
    B --> C[Reserve one repair scope and deadline]
    C --> D[Start supervised worker]
    D --> E[Prepare isolated checkout or worktree]
    E --> F[Apply and push repair]
    F --> G[Verify the exact pushed commit]
    G --> H[Persist outcome and evidence]
    H --> I[Read report or inspect retained artifacts]

Repair scheduling

Scheduling first checks that a pull request is open and that its head branch belongs to the selected repository. It then reserves one active run for the authenticated GitHub account and target, which prevents duplicate active repairs while preserving the original deadline when a request is repeated.

The repair tools require an authenticated OpenSRE GitHub app connection at discovery and execution time. This keeps the connection identity and token together as the schedule moves between the interactive tool, the scheduler, and later status reads.

The scheduler gives each run a durable identity and a fixed ten-minute budget. On a hosted gateway, the gateway scheduler owns the task; on a local host, the system ensures a background scheduler can run it. Both paths use a real thirty-second trigger and one bounded worker. The supervisor stops the worker before the finish reserve and converts unfinished work into a terminal report instead of leaving an untracked repair in progress.

Remote runs record the start of monitoring when the gateway accepts the scheduled task. Local runs do not claim that remote monitoring milestone, which keeps hosted operations separate from repairs started from a user's shell.

The local onboarding flow lets the scheduler own the first tick and the repair deadline. It waits on the repair record instead of forcing an immediate scheduler run, because a forced run can couple the repair lifetime to the shell request. Repeated requests reuse the active run and its original deadline.

References: integrations/…/schedule.py• L93-107 integrations/…/schedule.py• L124-195 integrations/…/models.py• L18-60 integrations/…/telemetry.py• L1-33 config/…/ci_repair.py• L1-20 integrations/…/supervisor.py• L46-94 integrations/…/tool.py• L98-181 integrations/…/agent_tools.py• L15-80 core/…/SKILL.md• L128-167 core/…/test_scheduling_workflow.py• L119-152

Repair execution

The worker checks that the coding agent and the GitHub account that authorized the run are still valid before it changes anything. It creates or reuses the run's checkout and observes the selected pull request until it sees a settled failing signal. If a non-demo pull request is already green, the worker verifies that green result without making a repair.

Each repair attempt records its result and any pushed head. A successful repair must produce a pushed commit whose checks pass and whose head is still the commit verified by the worker. Retryable failures may use another attempt within the same fixed run budget. A later commit from another actor is not credited as the repair.

The repair runner keeps unrelated pre-existing edits out of the repair scope and can enforce an authorized file set when one is supplied. For a pull request, it updates the existing same-repository head branch. If the head is behind its base, the base is brought into the repair first so the fix is tested against current repository state. If GitHub reports that a pushed head conflicts with the base, the loop allows one bounded base-merge recovery, pushes the resulting head, and verifies it again. A second conflict or an unresolved merge stops the repair rather than guessing.

The worker records attempt diagnostics and treats a small set of outcomes as retryable, including failed checks, execution errors, timeouts, and no-change attempts. It stops on unsupported targets or other non-retryable outcomes, and it stops after the configured maximum number of attempts. The local supervised workflow limits a scheduled run to three attempts and does not ask the user to schedule a second run inside the same repair plan.

References: integrations/…/worker.py• L63-170 integrations/…/worker.py• L230-304 integrations/…/tool.py• L63-82 integrations/…/runner.py• L424-486 integrations/…/runner.py• L489-517 integrations/…/runner.py• L565-616 integrations/…/base_merge.py• L67-179 integrations/…/ship.py• L71-142 core/…/SKILL.md• L146-181

Hosted repair delegation

Hosted repair delegation moves one bounded repair from the interactive shell to a managed gateway. The shell checks gateway readiness, confirms the target, and retains the remote prompt identity; the gateway performs the repair and returns its outcome. This path does not create continuous repository monitoring.

The shell verifies the same delegated record after execution. The report must keep the task identity and the repair evidence together, including the fix commit and passing run when they exist. A gateway blocker remains a blocker instead of being replaced with the local success path, and a gateway question is returned to the user for a decision.

References: core/…/SKILL.md• L21-59 core/…/SKILL.md• L72-126 core/…/test_delegating_github_ci_workflow.py• L34-41 core/…/test_delegating_github_ci_workflow.py• L78-189

Demo fixture

Demo mode creates or reuses one private repository with a known healthy baseline, then creates a unique failing branch and pull request for the run. The baseline is checked before reuse, so an unrecognized or modified repository is rejected rather than overwritten.

The demo limits the repair to the intended source file. After verified success, it closes only its own pull request and removes only its own branch while retaining the reusable repository. A demo therefore exercises the real failure, repair, and verification path without changing an unrelated repository.

The supervised demo path groups setup, scheduling, waiting, evidence capture, and loop removal into one bounded operation. It keeps the demo repository for later use and reports the retained resources instead of deleting the repository. If the named repository is not a recognized demo fixture, the flow leaves it unchanged and uses a new run-owned repository. When a retained pull request already contains the earlier repair, the next run first adds one new failing commit so the run has a fresh failure head to compare with its repair.

References: integrations/…/fixture.py• L20-43 integrations/…/fixture.py• L57-82 integrations/…/fixture.py• L121-236 integrations/…/worker.py• L230-255 integrations/…/tool.py• L201-230 integrations/…/tool.py• L418-479 core/…/SKILL.md• L109-126 core/…/SKILL.md• L183-193

Workspace isolation

Workspace isolation keeps repair edits separate from unrelated local work and from protected source branches. The chosen workspace is also the boundary for the coding agent and for the files that the repair may push.

Pull request workspace

Pull request repairs use a repair workspace that matches the target repository and then operate on the pull request head branch. The system records the pre-existing workspace state so unrelated user changes are not included in the repair commit. It checks that the remote source head still matches the analyzed head before editing and pushing.

References: integrations/…/runner.py• L383-446 integrations/…/runner.py• L450-470 integrations/…/runner.py• L489-517 integrations/…/ship.py• L54-69

Branch repair worktree

A branch target such as a default branch is never edited or pushed directly. The system creates a linked Git worktree from that branch and gives the repair a fresh namespaced branch. The repair branch can be pushed for review while the original branch remains protected. The temporary worktree and local repair ref are removed after the run when cleanup is possible.

References: integrations/…/worktree.py• L21-41 integrations/…/worktree.py• L37-81 integrations/…/worktree.py• L84-105 integrations/…/runner.py• L437-443

Verification

Verification proves that the checks for the repair commit reached a settled result. It does not accept an old green run or a later commit as proof for the commit that the repair pushed.

Pull request checks

Pull request verification watches the expected head commit while checks register and settle. It includes workflow runs, external checks, and commit statuses. It returns a passed or failed result only after the observed checks are terminal and stable for the settle window.

If the pull request head changes during verification, the result is superseded. If GitHub reports that the pushed commit conflicts with the base and therefore has no checks, the result is conflicted so the repair loop can make its limited base-merge recovery rather than wait for a false timeout.

References: integrations/…/verification.py• L40-77 integrations/…/verification.py• L91-167 integrations/…/runner.py• L619-654

Branch checks

Branch verification follows workflow runs for the exact pushed commit and then checks external statuses on that commit. It waits for late runs to register and for the completed result to remain stable. A later branch commit does not replace the commit under verification, so the result remains tied to the repair branch head.

References: integrations/…/verification.py• L170-245 integrations/…/verification.py• L278-336

Outcome recording

Outcome recording makes the repair observable after the worker exits. The run state stores the target, deadline, attempts, commit identities, check evidence, and terminal reason. A rendered report links the failing and passing runs, the repair commit, the worker log, and the latest attempt data when those items exist.

Durable repair state

Repair state is written atomically and guarded against concurrent schedule or worker updates. A completed run cannot become active again. Each run is bound to the GitHub account that authorized it, so a later status request can retrieve the same run only with that account's credentials.

The stored identity also distinguishes a demo run from a pull request target and records whether the run belongs to a hosted scheduler. This lets repeated requests reuse the correct active scope without extending its deadline, while legacy records that lack account identity cannot authorize a new account.

References: integrations/…/models.py• L18-81 integrations/…/storage.py• L23-129 integrations/…/tool.py• L192-229

Evidence report

The terminal report states whether the run succeeded, failed, timed out, or was cancelled. It avoids claiming a repair commit or passing CI when the worker did not verify them. The scheduler keeps the report and diagnostics after termination so a failed or interrupted repair can be inspected before another attempt.

For the one-call demo, the runner waits for a terminal loop, reads the pull request head and check rollup, and then records the outcome. It reports success only when the loop succeeded, the head differs from the seeded failing head, at least one check passed, and every reported check is non-blocking. A failed loop remains failed; any other incomplete evidence is blocked rather than presented as a verified repair.

The loop records milestone telemetry for hosted runs when monitoring starts, when the selected failure is detected, and when a repair succeeds. Demo setup also records the test failure it creates. These events identify the run, repository, pull request, and demo mode, while success telemetry adds attempt count and duration for operational analysis.

The direct repair path records each verification against the target and the exact pushed head. A selected pull request that is already green can finish successfully without a repair commit, but the result still records the verification. Verified repairs update the local repair ledger once per source head, and a best-effort persistence failure does not change the tool result.

Hosted reports add the remote task identity and the evidence links returned by the gateway. They include a root-cause section only when the delegated record provides one, and they state when the gateway did not report a root cause. The shell shows the report once, then uses a separate follow-up choice for a next repair or a blocker. A successful hosted repair can also hand off to Slack setup, which verifies or configures the connection and explains the handoff without posting a message.

Demo reports add an evidence-bound root-cause view. They name the seeded fault only when the run observed the seeded failing commit, and they attribute a fix only when the pull request head is still the commit that the run verified. If the head moved or the repair did not succeed, the report keeps the fix unverified instead of assigning credit to an unrelated commit.

References: integrations/…/supervisor.py• L30-43 integrations/…/report.py• L11-45 integrations/…/worker.py• L63-100 integrations/…/worker.py• L103-227 integrations/…/worker.py• L257-304 integrations/…/telemetry.py• L21-50 integrations/…/tool.py• L184-274 integrations/…/tool.py• L309-415 integrations/…/root_cause.py• L60-190 integrations/…/runner.py• L619-654 integrations/…/ledger.py• L125-161 integrations/…/agent_tools.py• L15-80 core/…/SKILL.md• L107-144 core/…/SKILL.md• L195-219 core/…/SKILL.md• L24-36

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the health scan's failure classification aligned with the repair context's accepted failure states. A new GitHub state must not appear as a scan candidate that the fixer ignores.
  • Preserve the target-head contract across context gathering, push checks, and post-push verification. A repair must not verify or push a commit different from the one it analyzed.
  • Keep pull request and branch verification separate. Pull requests can become superseded or conflicted; branch verification uses the pushed commit's workflow runs.
  • Keep the repair deadline shared by scheduling, supervision, worker execution, and the rendered report. A new retry or wait path must leave time to record the terminal result.
  • Keep durable run identity, account ownership, scheduler ownership, and GitHub app connection identity consistent between reservation, status lookup, telemetry, and stored reports. Otherwise duplicate, cross-account, or misattributed repair records can occur.
  • Keep the OpenSRE GitHub connection requirement aligned at tool discovery and execution boundaries. Nested schedule, status, demo, and cleanup calls must receive the same authorized connection rather than fall back to ambient credentials.
  • Keep target validation before reservation. A closed or fork-owned pull request must not create a new durable run, while a repeated request must still be able to read its existing active run.
  • Keep verified-repair ledger identity tied to the original source head. Changes to the outcome schema can silently alter deduplication and repair counts.
  • Keep authorized-path checks aligned with the files included in a repair commit. Base-merge edits and pre-existing workspace changes must not bypass or broaden the repair's allowed scope.
  • Keep the single post-push conflict recovery bounded. A second base merge must remain a terminal conflict instead of creating an unbounded push and verification loop.
  • Keep verification recording tied to the pushed head and target identity. Downstream repair epochs must not be published for an unverified or superseded commit.
  • Keep demo baseline validation and cleanup scoped to the run's owned repository, branch, and pull request. A reusable fixture must not overwrite an existing repository or remove another run's artifacts.
  • Keep hosted and local telemetry paths distinct. A shell-started run must not be counted as gateway monitoring, while a hosted run must retain the milestones needed for operational analysis.
  • Keep the local onboarding handoff aligned with the actual repair mode. The recurring local option must not be described as a one-off hosted repair, and the hosted option must not be described as continuous monitoring.
  • Keep the demo operation's single-call boundary intact. Seed, schedule, wait, evidence capture, and cleanup must not become a sequence that can silently leave a loop running after the report.
  • Keep hosted delegation tied to one remote prompt identity and one target. A follow-up read must verify the delegated record rather than start a second repair or load a local repair workflow on the gateway.
  • Keep the report and follow-up separate. A blocked remote run must reach a blocker question, not the success-path handoff menu.
  • Keep demo root-cause claims tied to the commits and checks recorded by the same run. A seeded fault or fix must not be attributed when the observed head or verified head does not match.
  • Keep the demo runner's success contract aligned with the final pull request read. A terminal loop alone is not enough; the report needs a changed head, a passing check, and no blocking check.

Important failure modes

TriggerConsequenceGuard
GitHub app connection is missing or its token cannot read the requested repositoriesRepair tools refuse to run or the scan returns no usable fleet signalConnect GitHub in the OpenSRE app and refresh the connection before retrying
GitHub token cannot read the requested repositories or the GraphQL rate budget is exhaustedThe scan returns no usable fleet signalReport access or rate-limit failure and narrow the owner scope or retry after the budget resets
Scan coverage reaches a repository, pull request, branch, or check capSome failures are not classifiedKeep the coverage notice with the result instead of treating the scan as complete
The selected pull request is closed or its head changes during repairThe repair is cancelled or its verification is supersededRe-read pull request state and require the expected head SHA
The target is a fork-owned pull request or a protected branch targetNo direct push is made to the unsupported targetRefuse fork-owned PRs before reservation and use a fresh branch worktree for branch targets
A different GitHub account requests an active target or reads its reportThe request cannot reuse or inspect the runBind run identity to the authorizing account and check that account on lookup and worker start
The coding agent is unavailable or its authorized account changesThe repair stops before remote editsCheck agent readiness and account identity inside the supervised worker
The coding agent changes a file outside its authorized scopeThe repair is rejected without a pushCompare workspace and repair-commit changes with the allowed path set
The selected demo repository is not private, owned by the run, writable, or an unchanged known baselineThe demo stops before it can overwrite existing filesValidate repository ownership, permissions, marker, file set, and file contents before initialization or reuse
Background scheduler registration failsThe run becomes failed without an untracked repairPersist a terminal failure report and inspect the scheduler log
The coding agent cannot resolve a base merge conflictThe merge is aborted and the repair stops without a pushRequire all conflicts to be resolved before committing the merge
A pushed repair head still conflicts with the base after one recoveryThe repair remains conflicted instead of retrying without a boundAllow one base merge and re-verification only
Checks do not settle before the run deadlineThe run becomes timed out and unfinished artifacts remainReserve finish time for supervision and report writing
A verified repair outcome cannot be written to the local ledgerThe repair result still returns, but the local repair count may not include itTreat ledger persistence as best effort and keep the durable run report as the primary evidence
The scheduler is forced to run from the shell instead of waiting for its taskA hosted request can stop the worker before the repair reaches a terminal stateLet the scheduler trigger the first tick and wait on the repair record
The hosted gateway lacks the required repair skill or stops after reportingThe remote outcome cannot be independently verifiedRecord the blocker and re-read the same delegated prompt rather than starting another task
A blocked or failed run is sent to the successful-repair follow-upThe user may start the wrong next action or assume the repair passedShow the outcome first and ask a blocker-specific question
A demo pull request head changes after the run verifies a repairThe report could attribute the fix to a commit that is no longer the pull request headReport the fix and passing run only when the current head matches the verified commit
The demo loop reaches a terminal state but the final pull request read has no changed head or passing checkThe demo is blocked instead of reported as a successful repairRequire the changed head, one successful check, and only non-blocking check conclusions
The final pull request read fails after schedulingThe report cannot safely claim an outcomeRemove the demo schedule and return the task identity with the read failure

Key files

FileWhy to read it
integrations/…/tool.pyDefines the read-only fleet scan boundary and its returned signal.
integrations/…/scan.pyShows how repository heads are covered and how partial coverage is reported.
integrations/…/classify.pyDefines which GitHub check and status results count as failures.
integrations/…/context.pyConnects a selected target to failing checks, logs, merge state, and the repair task.
integrations/…/agent_tools.pyDefines the OpenSRE GitHub app connection gate and credential propagation for nested GitHub work.
integrations/…/tool.pyExposes scheduling and report lookup while enforcing approval, app connection, and account-scoped access.
integrations/…/models.pyDefines the durable run identity, scheduler ownership, lifecycle states, deadline, and evidence fields.
integrations/…/schedule.pyDefines target preflight checks, one-target reservation, account ownership, deadline, and local or hosted scheduler registration.
integrations/…/fixture.pyShows how the private demo repository and its run-owned failure fixture are created, checked, and cleaned up.
integrations/…/telemetry.pyDefines the hosted monitoring, failure, success, and demo activation milestones.
integrations/…/storage.pyDefines atomic run persistence, active-run identity, and retained cleanup state.
integrations/…/supervisor.pyShows how the bounded worker is supervised and how terminal history is retained.
integrations/…/worker.pyCoordinates account checks, demo setup, observation, repair attempts, verification, cleanup, telemetry, and terminal state.
integrations/…/tool.pyCoordinates one bounded demo call from seeding through terminal observation, final check read, outcome classification, and evidence cleanup.
integrations/…/runner.pyConnects workspace preparation, scoped edits, pushing, conflict recovery, verification, and repair outcome signals.
integrations/…/worktree.pyDefines isolation for branch-target repairs and protection of the original branch.
integrations/…/verification.pyDefines exact-commit verification for pull request and branch repairs.
integrations/…/report.pyDefines the evidence-backed terminal report presented to the engineer.
integrations/…/root_cause.pyDefines evidence-bound demo links and root-cause attribution for the failure and verified fix.
integrations/…/ledger.pyDefines deduplicated recording of verified repair outcomes.
core/…/SKILL.mdDefines the onboarding boundary and the handoff from the entry choice to a repair workflow.
core/…/SKILL.mdDefines the local recurring repair flow, disposable demo, scheduler wait, and cleanup report.
core/…/SKILL.mdDefines the hosted one-repair delegation, remote verification, and blocker handling.
core/…/SKILL.mdDefines the read-only analysis that can hand a user into local or hosted repair.