Skip to content

fix(branch_sweep): protect legacy trunks by name, not by containment - #281

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

fix(branch_sweep): protect legacy trunks by name, not by containment#281
Jammy2211 merged 1 commit into
mainfrom
claude/repo-cleanup-82k6kh

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Found by the first org-wide audit

Auditing all 25 repos before deleting anything in any of them turned up a repo carrying a master branch alongside main.

It landed in KEEP — but only because it happens to hold unique content. The sweep protected the default branch and nothing else, so a master fully folded into main after a rename is indistinguishable from spent work and would have been deleted.

Why that is not an ordinary branch

Deleting a legacy trunk breaks every stale clone, bookmark, CI reference and doc link still pointing at it — and nothing about the branch's content says so. Containment is the wrong test; the name is the whole signal.

The skill's own recipe has always excluded both names:

git branch --merged origin/main | grep -vE '^(main|master)$'

Protecting only the default silently implemented half of a rule that was written whole.

The fix

main and master are protected by name, whether or not either is this repo's default, alongside whatever the default actually is.

Checks

pytest tests/508 passed · check_skill_line_counts.sh → OK · repos_sync.py --checkall 12 green, tenant firewall included.

The new test was verified the usual way: it fails without the guard and passes with it.

The wider point

This is the case for audit-first. The gap was real, it was in the delete path, and it surfaced while it was still hypothetical rather than after 484 deletions. Nothing has been swept in any of these repos yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq


Generated by Claude Code

The first org-wide audit found a repo carrying a `master` branch alongside
`main`. It landed in KEEP, but only because it happened to hold unique
content — the sweep protected the *default* branch and nothing else, so a
`master` fully folded into `main` after a rename is indistinguishable from
spent work and would have been deleted.

That is not an ordinary branch. Deleting it breaks every stale clone,
bookmark, CI reference and doc link still pointing at the old trunk, and
nothing about the branch's content says so — which is exactly why the
skill's own recipe has always excluded both names (`grep -vE
'^(main|master)$'`). Protecting only the default silently implemented half of
a rule that was written whole.

So `main` and `master` are now protected on NAME, whether or not either is
this repo's default, alongside whatever the default actually is.

Found by running the audit across 25 repos before deleting anything in any of
them — the value of audit-first is that it surfaces this class of thing while
it is still hypothetical. The test fails without the guard and passes with it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq
@Jammy2211
Jammy2211 merged commit 2d7b767 into main Aug 25, 2026
2 checks passed
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