Skip to content

feature(ci): add the dispatchable branch sweep - #321

Merged
Jammy2211 merged 2 commits into
mainfrom
claude/repo-cleanup-82k6kh
Aug 25, 2026
Merged

feature(ci): add the dispatchable branch sweep#321
Jammy2211 merged 2 commits into
mainfrom
claude/repo-cleanup-82k6kh

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Why

A cloud Claude session can audit branches but cannot delete a remote ref — 403 for the session credential, and no delete-ref call in its GitHub tool surface. So cleanup was laptop-only. A /repo_cleanup sweep on 2026-08-25 found 176 branches here, 135 of them provably contained in main, and could not act on any of it.

A workflow's GITHUB_TOKEN has the contents: write this repo already grants dashboard_refresh.yml, so the sweep runs here instead.

What's here

One workflow. This repo hosts the trigger; PyAutoBrain hosts the logic — the workflow checks Brain out and runs bin/branch_sweep.sh, so there is one implementation and no copy to drift.

Dispatch with mode=audit (the default) to see the contained / unmerged / protected split in the run summary; mode=delete to act, with an optional limit for a first cautious batch. The weekly cron is audit-only and forces that mode regardless of input, so nothing is ever removed unattended.

The safety gates live in the script, not the workflow: never main, never archive/condemned/* (PyAutoGut transit refs — voiding one early destroys the recovery path the Gut exists to provide), never an open PR's head, never a branch git cannot prove is contained.

This is the backstop, not the fix

This repo has Settings → General → "Automatically delete head branches" off, which is why every merged PR head since #22 is still present. Turning that on prevents the pile-up. The sweep clears what predates it, branches pushed without a PR, and heads whose PR closed unmerged — none of which auto-delete covers.

Merge order

Merges after PyAutoLabs/PyAutoBrain#278, which puts branch_sweep.sh on Brain's main. Dispatching this before that lands would fail at the checkout step.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq


Generated by Claude Code

Companion to PyAutoBrain's `bin/branch_sweep.sh` — this repo hosts the trigger,
the Brain hosts the logic (the workflow checks Brain out, so there is one
implementation and no copy to drift).

Why it exists: a cloud Claude session can audit branches but cannot delete a
remote ref (403 for the session credential; no delete-ref call in its GitHub
tool surface), so cleanup was laptop-only. A sweep on 2026-08-25 found 176
branches here, 135 of them provably contained in main, and could not act on
any of it. A workflow's GITHUB_TOKEN has the `contents: write` this repo
already grants dashboard_refresh.yml, so the sweep runs here instead.

Dispatch with mode=audit (the default) to see the contained / unmerged /
protected split in the run summary; mode=delete to act, with an optional limit
for a first cautious batch. The weekly cron is audit-only and forces that mode
regardless of input, so nothing is ever removed unattended.

Note this is the backstop, not the fix: this repo has "Automatically delete
head branches" off, which is why every merged PR head since #22 is still
present. Turning that on prevents the pile-up; the sweep clears what predates
it, branches pushed without a PR, and heads whose PR closed unmerged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq
The PR-time spawn contract test failed on the new workflow: every tracked file
must match a MIND_RULES entry, so spawn can decide whether it travels into the
fresh-slate template. `branch_sweep.yml` matched nothing.

DROP, on both of rule 9c's existing grounds. It checks out
PyAutoLabs/PyAutoBrain for the sweep logic — dashboard_refresh.yml's failure
mode, where owner substitution yields the literal YOURORG/PyAutoBrain and the
run dies on checkout — and it carries a weekly cron, which rule 9's
no-unattended-trigger condition rejects independently. A fresh org would
inherit a scheduled job that fails every Sunday and cannot be made to work
until it has a Brain.

The sweep is worth having in a mature organism; it is worth re-adding
deliberately rather than by inheritance.

Spec table extended first, then mirrored into MIND_RULES, in the order the
assertion message asks for.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq
@Jammy2211
Jammy2211 merged commit 5f99419 into main Aug 25, 2026
2 checks passed
@github-actions
github-actions Bot deleted the claude/repo-cleanup-82k6kh branch August 25, 2026 14:03
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.

2 participants