Skip to content

Add Aspire Bot: self-maintaining repo loop with layered kill switches - #2208

Merged
Adam Ratzman (adamint) merged 7 commits into
mainfrom
aspire-bot/autopilot
Dec 6, 2026
Merged

Adam Ratzman (adamint) merged 7 commits into
mainfrom
aspire-bot/autopilot

Conversation

@IEvangelist

@IEvangelist David Pine (IEvangelist) commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: c8961c69bc7c61d30a57b177201c12abdba7cab7

Dimension Assessment Rationale
Change confidence 8/10 ↑ 35 control-plane unit tests pass, including new medium-tier, provenance, and failing-CI cases.
↑ gh aw compile --strict succeeds; the only warning (cache-poisoning on CI doctor) predates this change.
↑ Full reconcile dry run against this repo classifies all 11 Dependabot PRs as before.
↓ The activity log actor for App pushes is assumed to be the App's bot login; unverified until the first bot PR.
↓ The fixer gate's positive path wasn't exercised live (no aspire-bot PRs exist yet).
↑ No ruleset bypass: a live dry run labels an eligible Dependabot PR merge-ready and dismisses a stale policy approval left on an older commit.
↓ The policy service's isActivitySender match on aspire-repo-bot and the ruleset's require_extra_approval_for_unattributed_changes are unverified until the first live merge.
↓ CI on this revision is pending.

Aspire Bot: a self-maintaining loop with layered kill switches

This makes aspire-samples maintain itself. Agents find work, open PRs, review them, fix them, merge the low- and medium-risk ones, and run a weekly retro to improve themselves. Humans stay in control through layered kill switches, and each one stops the bot on its own:

Switch Who can use it What it stops
aspire-bot:stop label on any open issue or PR Anyone with triage access Everything, until someone removes the label
ASPIRE_BOT_MODE variable Write access Everything when stopped or unset. paused previews writes and merges nothing.
ASPIRE_BOT_MERGE variable Write access Merges, unless it's enabled
Circuit breaker Automatic Everything. It adds aspire-bot:stop when CI fails on main after an Aspire Bot merge, or when 50 automated PRs merge in 24 hours (Dependabot peaked at 36 in the last six months).
Disable workflow Write access One agent
aspire-bot:hold or needs-human-review Triage access One issue or PR
Suspend the App, or delete its key App owner or repo admin Everything that acts as Aspire Bot
flowchart LR
    Signals[Issues, alerts, Dependabot PRs, CI failures] --> Agents[gh-aw agents<br/>safe outputs only]
    Agents -->|PR| Reviewer[PR reviewer<br/>SHA-bound verdict]
    Reviewer -->|request-changes| Fixer[PR fixer] --> Reviewer
    Reviewer --> Gate[Deterministic control plane<br/>policy.json risk tiers]
    Gate -->|low or medium risk, approved, CI Gate green,<br/>every switch allows it| Merge[Merge job: re-validate, then<br/>squash merge pinned to head SHA]
    Gate -->|high risk, 3 failed fixes,<br/>or CI failing on main| Human[needs-human-review]
    Gate -->|main broke after a bot merge,<br/>or too many merges| Stop[aspire-bot:stop]
Loading

What's included

  • Control plane (.github/aspire-bot/, aspire-bot-control.yml): deterministic Python with unit tests. It runs only from the default branch. It classifies risk from policy.json, verifies the reviewer's verdict against the head SHA, disarms GitHub auto-merge on bot and Dependabot PRs, and maintains the Aspire Bot status issue. Merges run in a separate job. GitHub reads repository variables when each job starts, so that job sees mode and merge switch changes made mid-run. It checks the stop label, re-reads each PR, and merges with PUT /pulls/N/merge and sha=<validated head>, so a later push makes GitHub refuse the merge.
  • Agents (gh-aw, Copilot engine, strict: true). Each one checks the stop label before it activates:
    • triage
    • dependency steward (Dependabot and code scanning alerts, and failing Dependabot PRs)
    • CI doctor
    • PR reviewer (skips before starting unless an open PR's head commit is unreviewed)
    • PR fixer (at most 3 attempts per PR; every run counts; skips before starting unless a bot PR failed CI Gate or got a request-changes verdict, and manual runs are checked the same way)
    • improver (works only on issues labeled aspire-bot:approved, enforced by gh-aw integrity filtering)
    • weekly retro
  • Risk tiers:
    • Low: docs, version-only manifest bumps (compared line by line, in order), and lockfiles that resolve from trusted registries. npm lockfiles are parsed at the merge base and the head commit, and every added or changed package must resolve from registry.npmjs.org.
    • Medium: small sample code fixes (at most 5 files and 100 lines) on Aspire Bot PRs, merged after an approving review and a green CI Gate. The repository activity log must show that Aspire Bot made every push to the branch, so nobody can push code onto a bot PR and have it merge on the bot's review. Package source configs, Dockerfiles, scripts, build wrappers, and MSBuild imports inside samples stay high.
    • High (needs a human): tests, larger sample changes, workflows, policies, and Aspire Bot itself.
  • Policy changes:
    • label-prs.yml no longer adds auto-merge to Dependabot PRs; the control plane merges them instead.
    • auto-merge.yml skips PRs labeled aspire-bot or dependencies.
    • dependabot.yml skips the generated *.lock.yml files.

Security review notes

  • Secret references: ASPIRE_BOT_APP_ID and ASPIRE_BOT_PRIVATE_KEY, as secrets of the new aspire-bot environment. They're used only by actions/create-github-app-token (SHA-pinned v3.3.0) in the control plane and the gh-aw-generated jobs, and gh-aw redacts both from logs.
  • App credentials stay on main: every job that uses them declares the aspire-bot environment (deployment: false), and the environment only allows main. A run started from any other branch, including a manually dispatched modified agent, can't reach them.
  • What agents can write: agents can't merge, approve, or add auto-merge or aspire-bot:stop. PR and push outputs are restricted by allowed-files (samples, tests, and version pins in ci.yml). Only the retro can touch aspire-bot-* workflows, and its PRs are always high risk.
  • Verdict parsing: a verdict counts only from the newest bot review on the head SHA, as an unambiguous two-line footer. Quoted or duplicated markers are rejected.
  • Failing CI on main: nothing merges until it passes. The control plane adds needs-human-review to open aspire-bot:ci-failure issues and PRs (the CI doctor labels both), and comments on the status issue once per failing commit.
  • Actions: github/gh-aw-actions/setup@v1.2.2 (pinned in .github/aw/actions-lock.json). The stop-label check uses actions/github-script v9.0.0 at the SHA gh-aw already pins.
  • No ruleset bypass: the main ruleset requires one approval, and Aspire Bot can't approve its own PRs. When a PR passes every check, the control plane adds aspire-bot:merge-ready, and a new GitOps rule (.github/policies/aspire-bot.yml) approves it. The rule fires only when the aspire-repo-bot App adds the label, and it never enables auto-merge. The control plane merges only if that approval is on the validated head SHA. When the PR changes or stops being eligible, it dismisses the approval and removes the label, because the ruleset doesn't dismiss stale approvals. Classic branch protection still requires CI Gate.

Behavior change

After this merges, Dependabot PRs are no longer merged automatically until ASPIRE_BOT_MODE is active and ASPIRE_BOT_MERGE is enabled. Even with the mode unset, the control plane removes the old auto-merge label and disables GitHub auto-merge on open Dependabot PRs.

Rollout

Before merging, a repository admin:

  1. Confirms the Aspire Bot App has these permissions:
    • Read and write: contents, pull requests, issues, workflows.
    • Read: actions, checks, security events, Dependabot alerts.
  2. Creates the aspire-bot environment with deployment branches limited to main, adds ASPIRE_BOT_APP_ID and ASPIRE_BOT_PRIVATE_KEY as environment secrets, and deletes the repository secrets with those names.

Then:

  1. Merge with ASPIRE_BOT_MODE unset. Agents skip, and nothing merges.
  2. Set ASPIRE_BOT_MODE=paused, then review the staged previews and the status issue.
  3. Set ASPIRE_BOT_MODE=active. Agents open, review, and fix PRs, and maintainers merge them.
  4. Set ASPIRE_BOT_MERGE=enabled.

See .github/aspire-bot/README.md for the full design and runbook.

Validation

  • gh aw compile --strict: all 7 workflows compile, and recompiling changes nothing.
  • actionlint 1.7.12 is clean on the hand-written workflows.
  • Control-plane unit tests: 37 pass.
  • Reviewer and fixer work gates, run against this repository: the reviewer proceeds (build(deps-dev): Bump cross-spawn from 7.0.6 to 7.1.2 in /samples/aspire-with-javascript/AspireJavaScript.Vite #2279 has an unreviewed head), the scheduled fixer skips, and a manual fixer run on a non-bot PR is rejected.
  • Push provenance against this PR's real activity log: trusted only when every push came from the expected account.
  • Every agent's pre-activation job declares issues: read and pull-requests: read for the stop-label check.
  • Dry runs against this repository:
    • All 12 open Dependabot PRs classify as low, including 5 npm lockfile bumps whose lockfiles also contain 1ES mirror entries.
    • The merge command skipped a PR whose CI Gate had failed and one whose head SHA had changed.
    • The merge command merged nothing with ASPIRE_BOT_MERGE unset.

Adds gh-aw agentic workflows (triage, dependency steward, CI doctor, PR
reviewer, PR fixer, improver, weekly retro) that write only through safe
outputs under the Aspire Bot GitHub App, plus a deterministic control plane
that merges low-risk bot and Dependabot PRs with a SHA-pinned squash merge
after a SHA-bound review verdict and a green CI Gate.

The ASPIRE_BOT_MODE repository variable (active | paused | stopped; unset
means stopped) controls the whole loop.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 03:01
The repository already stores ASPIRE_BOT_APP_ID as a secret, next to
ASPIRE_BOT_PRIVATE_KEY, but the workflows read vars.ASPIRE_BOT_APP_ID. That
variable doesn't exist, so minting the App token would fail once
ASPIRE_BOT_MODE is paused or active. Read secrets.ASPIRE_BOT_APP_ID instead
and recompile the gh-aw lock files with gh-aw v1.2.2.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical findings allow automatic merges to bypass control-plane safeguards, classify unsafe changes as low risk, and expose repository-scoped App credentials to unmerged workflow code.

10 open issues
What changed in this PR

Introduces Aspire Bot, a repository-maintenance loop combining seven agent workflows with a deterministic merge controller. ASPIRE_BOT_MODE controls rollout, and Dependabot PRs stop receiving automatic merge enrollment.

Changes:

  • Adds agents for triage, dependency maintenance, CI diagnosis, PR review and repair, improvements, and weekly retrospectives.
  • Adds risk classification, SHA-bound review validation, pinned merge requests, a status dashboard, and control-plane tests.
  • Adds setup guidance and generated-workflow handling for Dependabot and GitHub’s diff display.
File Description
.github/​workflows/​shared/​aspire-bot.md Shared credentials, rules, PR format, and review verdict format.
.github/​workflows/​aspire-bot-triage.md Classifies issues and requests missing information.
.github/​workflows/​aspire-bot-selftest.yml Runs policy validation and control-plane tests.
.github/​workflows/​aspire-bot-retro.md Produces weekly reports and workflow-improvement PRs.
.github/​workflows/​aspire-bot-pr-reviewer.md Defines PR reviews with SHA-bound verdicts.
.github/​workflows/​aspire-bot-pr-reviewer.lock.yml Compiled reviewer workflow and output handling.
.github/​workflows/​aspire-bot-pr-fixer.md Defines follow-up fixes for failing bot PRs.
.github/​workflows/​aspire-bot-improver.md Defines approved-issue, documentation, and test improvements.
.github/​workflows/​aspire-bot-dependency-steward.md Proposes fixes for dependency and scanning alerts.
.github/​workflows/​aspire-bot-control.yml Schedules and authenticates deterministic reconciliation.
.github/​workflows/​aspire-bot-ci-doctor.md Diagnoses main-branch CI failures.
.github/​skills/​agentic-workflows/​SKILL.md Adds routing guidance for gh-aw development tasks.
.github/​policies/​label-prs.yml Stops adding auto-merge to Dependabot PRs.
.github/​policies/​auto-merge.yml Updates descriptive text; executable rules remain unchanged.
.github/​dependabot.yml Excludes generated workflow locks from action updates.
.github/​aw/​actions-lock.json Pins gh-aw setup actions.
.github/​aspire-bot/​scripts/​test_aspire_bot.py Tests classification, modes, verdicts, and merge decisions.
.github/​aspire-bot/​scripts/​aspire_bot.py Implements reconciliation, merge decisions, and status reporting.
.github/​aspire-bot/​README.md Documents architecture, rollout, and operations.
.github/​aspire-bot/​policy.json Defines risk rules, labels, limits, and verdict syntax.
.github/​agents/​agentic-workflows.md Adds a gh-aw development assistant definition.
.gitattributes Marks workflow lockfiles as generated.

Review effort: Balanced

Comment thread .github/policies/auto-merge.yml Resolved
Comment thread .github/workflows/shared/aspire-bot.md Resolved
Comment thread .github/workflows/shared/aspire-bot.md Resolved
Kill switches:
- An aspire-bot:stop label on any open issue or PR stops every agent before
  activation and blocks all merges. Anyone with triage access can add it.
- ASPIRE_BOT_MERGE must be `enabled` for any merge, on top of ASPIRE_BOT_MODE.
- Circuit breaker: the control plane adds aspire-bot:stop to the status issue
  when CI fails on main after an Aspire Bot merge, or when 10 automated PRs
  merge in 24 hours.
- The App credentials move to the aspire-bot environment, restricted to main,
  so runs started from other branches can't reach them.

Review feedback:
- Compare version-only lines in order within each change block.
- Parse npm lockfiles at the merge base and head; added or changed packages
  must resolve from registry.npmjs.org.
- needs-human-review blocks merges.
- Merge in a separate job that re-reads the mode and merge switch, checks the
  stop label, and re-validates each PR right before merging.
- The auto-merge policy skips aspire-bot and dependencies PRs, and the control
  plane disables GitHub auto-merge on them.
- Count every fixer run as an attempt, and check manual fixer runs before
  activation.
- Run the PR-producing workflows in one queue and recount open PRs right
  before publishing.

Also fix the yarn.lock source pattern, which flagged registry URLs, and decode
gh output as UTF-8.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@IEvangelist David Pine (IEvangelist) changed the title Add Aspire Bot: self-maintaining repo loop with a single kill switch Add Aspire Bot: self-maintaining repo loop with layered kill switches Nov 23, 2026
Declare on.permissions (issues and pull-requests read, plus contents read for
the fixer's eligibility check) so the pre-activation job can read labels
explicitly. Before, its token had no permissions, and the check relied on
public-repo reads; if that read failed, agents would silently never run.

Raise maxAutoMergesPerDay from 10 to 50. Over the last six months, Dependabot
PRs merged up to 36 times in 24 hours, and at least 8 calendar days had 10 or
more, so a limit of 10 would have stopped the whole bot most weeks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- policy.json: small sample-code fixes (5 files, 100 lines) are medium risk on
  Aspire Bot PRs whose every push came from Aspire Bot (repository activity log).
  Tests, scripts, Dockerfiles, package-source configs, build wrappers, and
  MSBuild imports stay high.
- Control plane: classify medium, label tier-medium, verify push provenance,
  and while CI fails on main, flag aspire-bot:ci-failure items with
  needs-human-review and comment once per failing commit on the status issue.
- Reviewer and fixer skip before the agent starts when there is no work.
- CI doctor PRs carry aspire-bot:ci-failure.
- Reviewer prompt: reject fixes that weaken checks, since its approval now
  gates sample code.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The main ruleset requires one approval. Instead of making the App a bypass
actor, the control plane adds aspire-bot:merge-ready to an eligible PR, and a
new GitOps rule (.github/policies/aspire-bot.yml) approves it, but only when the
Aspire Bot App (aspire-repo-bot) adds the label. The control plane merges only
when that approval is on the validated head SHA, and dismisses policy approvals
and removes the label when the PR changes or stops being eligible, since the
ruleset doesn't dismiss stale approvals.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 37 control-plane fixture tests passed locally in an offline container at this commit. No live App, repository actions, or merge workflows were exercised.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@adamint Adam Ratzman (adamint) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 4cc5f5e: merge-boundary CI/verdict rechecks added, all CI green, all threads resolved.

@adamint
Adam Ratzman (adamint) merged commit 06829f6 into main Dec 6, 2026
7 checks passed
@adamint
Adam Ratzman (adamint) deleted the aspire-bot/autopilot branch December 6, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants