Repository navigation
feat(workflow)+docs(ops): read-only orphan-remote-branch lister + branch-hygiene RCA (Slack 2026-04-28) - #290
Closed
cursor[bot] wants to merge 2 commits into
Closed
cursor[bot] wants to merge 2 commits into
cursor[bot] wants to merge 2 commits into
Conversation
Adds scripts/git-list-remote-orphan-branches.{sh,ps1} -- a read-only
helper that answers exactly 'which remote branches have no open PR
right now?' Per the operator rule (Slack 2026-04-28, message
ts 1777370978.136399): 'se nao tem PR aberto, nao tem por que ter
branch no origin'.
Pipeline (no regex guessing of what looks 'old'):
1. git fetch --prune origin
2. gh pr list --state open --json headRefName (single source of truth
for 'is this branch backed by an open PR?')
3. git for-each-ref refs/remotes/origin
4. set difference, minus keep-list (main, auditoria-ia, release/beta)
The script prints suggested 'git push origin --delete <branch>' lines
the operator can copy after a final review. It NEVER deletes anything
itself -- per docs/ops/inspirations/DEFENSIVE_SCANNING_MANIFESTO.md
S1.3 'no surprise side effects' contract.
Cross-platform pair (.sh + .ps1) per
docs/ops/SCRIPTS_CROSS_PLATFORM_PAIRING.md; .ps1 is ASCII-only per
.cursor/rules/pre-commit-ruff.mdc PowerShell rule.
Co-authored-by: Fabio Tavares Leitão <[email protected]>
Dated audit + workflow doc updates for the Slack ts 1777370978.136399 ask: 'git branch -r' does not fit one screen, delete cursor/sre-* that are 'integradas ou abandonadas', rule 'se nao tem PR aberto, nao tem por que ter branch no origin'. RCA (audit doc): * After 'git fetch --prune origin' at 2026-04-28T10:19Z (main 4bc0861): - total remote refs: 41 - backed by an OPEN PR (gh): 40 of 41 - in keep-list (main): 1 - TRULY orphan (no PR, not in keep): 1 fix-rust-ci-coverage-9061 * The 40 cursor/sre-* branches are NEITHER 'integradas' NOR 'abandonadas' -- they back live OPEN PRs (#235-#289). Deleting them would auto-close the PRs and lose the audit paper trail (FABRICATED_CLAIMS_INDEX.md cross-references). * Real screen-bloat lever is the open-PR backlog, not orphans (PR #273 covers the 'audit-PR swarm' RCA). Doc updates: * BRANCH_AND_DOCKER_CLEANUP.md S3.1 (EN) / S2.1 (pt-BR): point at new lister, reaffirm open-PR rule + qualifier 'sidequest investigativa obvia progredindo'. * sre_audits/README.md: index sync. Doctrine: DEFENSIVE_SCANNING_MANIFESTO S1.3 (no surprise side effects), THE_ART_OF_THE_FALLBACK S2-S3 (monotonic ladder, diagnostic on fall), AGENTS.md Risk posture. No behavior change. Zero impact on database locks. Co-authored-by: Fabio Tavares Leitão <[email protected]>
1 of 2 tasks
FabioLeitao
force-pushed
the
main
branch
2 times, most recently
from
May 3, 2026 17:52
ae0da8d to
b5c995c
Compare
FabioLeitao
force-pushed
the
cursor/sre-automation-agent-protocol-c644
branch
from
May 3, 2026 17:52
831a067 to
66912cb
Compare
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
SRE Automation Agent response to Slack
#data-boar-opsmessagets 1777370978.136399(~10:09 UTC, 2026-04-28). Operator ask:git branch -rdoes not fit one screen; deletecursor/sre-*integradas ou abandonadas; rule "se não tem PR aberto, não tem por que ter branch noorigin" + qualifier "se não for sidequest investigativa óbvia progredindo, não tem por que ter dangling branch".Two commits, two tracks (per
execution-priority-and-pr-batching.mdc):feat(workflow)— read-only listerscripts/git-list-remote-orphan-branches.{sh,ps1}that answers exactly the operator's rule; never deletes anything itself.docs(ops)— dated auditdocs/ops/sre_audits/BRANCH_HYGIENE_RCA_2026-04-28.md+ cleanup-doc §3.1 / §2.1 (EN + pt-BR) + audits-folder index sync.RCA — what
git branch -ractually contains todayAfter
git fetch --prune originat2026-04-28T10:19Z(basemain@624f4e7):A second orphan,
cursor/sre-agent-protocol-370e, was harvested by a parallel--prunemid-audit — the prune lever already works; the residue is the open-PR fleet, not orphans.cursor/sre-*integradasmain(none merged)cursor/sre-*abandonadasgh pr list --state open(remote) ∖ (open-PR head refs) ∖ (keep-list) = {fix-rust-ci-coverage-9061}fix-rust-ci-coverage-9061is 6 commits ahead, related to live Rust-CI PRs (#255/#256/#260/#263) — human readgit branch -rcaber em uma tela só"What lands
scripts/git-list-remote-orphan-branches.shgit fetch --prune→gh pr list --json headRefName→git for-each-ref refs/remotes/origin→ set difference minus keep-list. Printsgit push origin --delete <branch>lines as suggestions, never executes them. Optional--patternand--include-stale-daysfilters.scripts/git-list-remote-orphan-branches.ps1docs/ops/SCRIPTS_CROSS_PLATFORM_PAIRING.md. ASCII-only perpre-commit-ruff.mdcPowerShell rule (PS 5.1 safety) — verified bytests/test_scripts.py::test_powershell_scripts_ascii_safe.docs/ops/BRANCH_AND_DOCKER_CLEANUP.md§3.1docs/ops/BRANCH_AND_DOCKER_CLEANUP.pt_BR.md§2.1docs-locale-pt-br-contract.mdc.docs/ops/sre_audits/BRANCH_HYGIENE_RCA_2026-04-28.mddocs/ops/sre_audits/README.mdDefensive Architecture posture
Per
DEFENSIVE_SCANNING_MANIFESTO.md§1.3 (no surprise side effects) the lister is read-only by design: nogit push --delete, nogit branch -D, nogh pr close. Same rule that keeps Data Boar from issuing schema mutations against a customer database keeps this helper from mutating the GitHub state surface on a Cloud-Agent VM.Per
THE_ART_OF_THE_FALLBACK.md§2 (monotonic ladder) the lister composes only trusted parser-grade signals —git for-each-ref,gh pr list --json headRefName, set difference. No regex guessing of what looks "old" or "abandoned".Zero impact on database locks. Zero behavior change to the report pipeline. Zero PRs closed and zero remote branches deleted by this PR — the lister surfaces the candidate list and waits for human review per
AGENTS.mdRisk posture (destructive ops require operator review).Verification
$ uv run pre-commit run --files \ scripts/git-list-remote-orphan-branches.sh \ scripts/git-list-remote-orphan-branches.ps1 \ docs/ops/BRANCH_AND_DOCKER_CLEANUP.md \ docs/ops/BRANCH_AND_DOCKER_CLEANUP.pt_BR.md \ docs/ops/sre_audits/BRANCH_HYGIENE_RCA_2026-04-28.md \ docs/ops/sre_audits/README.md # all hooks Passed (Ruff skipped no-files, plans-stats, markdown, # pt-BR locale, commercial guard, external-plan-link guard, uv-lock, # PII guard, PII history guard). $ uv run pytest tests/test_scripts.py::test_powershell_scripts_ascii_safe -v # PASSED $ ./scripts/git-list-remote-orphan-branches.sh | tail -8 Orphan branches (no open PR, not in keep-list): - fix-rust-ci-coverage-9061 last=2026-04-27 17:24:44 -0300 ahead=6 behind=2 Suggested commands (copy + paste only after reviewing each branch): git push origin --delete fix-rust-ci-coverage-9061 This script is read-only. It does NOT delete anything.Type of change
scripts/)Form (LMDE-issue-style)
Same precedent as PRs #259 / #261 / #268 / #281 / #284 / #289 (
linuxmint/live-installer#177/#178): exact reproduction (verbatim trigger commands + exit codes), smallest claim that matches the evidence, the constraint that stopped the agent from running 40×git push origin --delete cursor/sre-…("deleting the head ref of an open PR auto-closes the PR; PRs #268 / #279 / #281 / #284 / #289 are the audit paper trail this folder exists to preserve"), and explicit non-action so the next maintainer reading the audit knows the boundary was tested and held — without inventing a fabrication-rejection where the operator gave a sound rule with a sound qualifier.Related
#data-boar-ops, automationdef95df7-a634-431a-93e5-659e4d831725(2026-04-28 ~10:09 UTC, messagets 1777370978.136399).scripts/git-cleanup-merged-gone-branches.ps1— local-branch hygiene (merged +[gone]); the new lister is its remote-branch counterpart.DEFENSIVE_SCANNING_MANIFESTO.md§1.3,THE_ART_OF_THE_FALLBACK.md§2–§3,AGENTS.mdRisk posture.