Skip to content

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
mainfrom
cursor/sre-automation-agent-protocol-c644
Closed

cursor[bot] wants to merge 2 commits into
mainfrom
cursor/sre-automation-agent-protocol-c644

Conversation

@cursor

@cursor cursor Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

SRE Automation Agent response to Slack #data-boar-ops message ts 1777370978.136399 (~10:09 UTC, 2026-04-28). Operator ask: git branch -r does not fit one screen; delete cursor/sre-* integradas ou abandonadas; rule "se não tem PR aberto, não tem por que ter branch no origin" + 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 lister scripts/git-list-remote-orphan-branches.{sh,ps1} that answers exactly the operator's rule; never deletes anything itself.
  • docs(ops) — dated audit docs/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 -r actually contains today

After git fetch --prune origin at 2026-04-28T10:19Z (base main @ 624f4e7):

total remote refs                          : 41
remote refs backed by an OPEN PR (gh)      : 40 of 41
remote refs in keep-list (main, …)         :  1
remote refs that are TRULY orphan (no PR)  :  1
   - fix-rust-ci-coverage-9061  (last 2026-04-27 17:24 -03, ahead=6)

A second orphan, cursor/sre-agent-protocol-370e, was harvested by a parallel --prune mid-audit — the prune lever already works; the residue is the open-PR fleet, not orphans.

Slack qualifier Verifiable today Outcome
Delete cursor/sre-* integradas All 40 are 1+ commits ahead of main (none merged) 0 of 40 match
Delete cursor/sre-* abandonadas All 40 back live OPEN PRs (#235–#289) per gh pr list --state open 0 of 40 match
"Se não tem PR aberto, não tem por que ter branch no origin" (remote) ∖ (open-PR head refs) ∖ (keep-list) = {fix-rust-ci-coverage-9061} Encoded as the new lister
"Não for sidequest investigativa óbvia progredindo" fix-rust-ci-coverage-9061 is 6 commits ahead, related to live Rust-CI PRs (#255/#256/#260/#263) — human read Surfaced for review, not auto-deleted
"git branch -r caber em uma tela só" Dominant term is the 40-PR backlog, not orphans (PR #273 covers that lever) Documented, not actioned

What lands

Path Class Rationale
scripts/git-list-remote-orphan-branches.sh workflow Pipeline: git fetch --prune → gh pr list --json headRefName → git for-each-ref refs/remotes/origin → set difference minus keep-list. Prints git push origin --delete <branch> lines as suggestions, never executes them. Optional --pattern and --include-stale-days filters.
scripts/git-list-remote-orphan-branches.ps1 workflow Cross-platform twin per docs/ops/SCRIPTS_CROSS_PLATFORM_PAIRING.md. ASCII-only per pre-commit-ruff.mdc PowerShell rule (PS 5.1 safety) — verified by tests/test_scripts.py::test_powershell_scripts_ascii_safe.
docs/ops/BRANCH_AND_DOCKER_CLEANUP.md §3.1 docs "Find branches with no open PR" — open-PR-as-truth rule + helper invocation + screen-fit RCA pointer.
docs/ops/BRANCH_AND_DOCKER_CLEANUP.pt_BR.md §2.1 docs pt-BR sync per docs-locale-pt-br-contract.mdc.
docs/ops/sre_audits/BRANCH_HYGIENE_RCA_2026-04-28.md docs Dated SRE audit (Julia-Evans-style RCA + LMDE-issue form): per-qualifier table, commands, doctrine refs, what does not land and why.
docs/ops/sre_audits/README.md docs Index sync.

Defensive Architecture posture

Per DEFENSIVE_SCANNING_MANIFESTO.md §1.3 (no surprise side effects) the lister is read-only by design: no git push --delete, no git branch -D, no gh 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.md Risk 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.

Pre-existing: tests/test_scripts.py PowerShell-parse tests (35 of them) fail in this Cloud-Agent VM because pwsh/powershell is not installed. Confirmed identical failure shape on main before this PR. Not introduced by this change.

Type of change

  • Workflow (new helper script under scripts/)
  • Documentation (RCA + cleanup-doc §3.1 / §2.1 + audits index)
  • Behavior change — no product file modified.

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

  • Slack handoff: #data-boar-ops, automation def95df7-a634-431a-93e5-659e4d831725 (2026-04-28 ~10:09 UTC, message ts 1777370978.136399).
  • Open-PR fleet RCA: PR #273 — audit-PR swarm vs. one mergeable fix (the lever for the screen-fit goal).
  • Prior rejection of the destructive sibling shape (mass-close PRs): PR #289 — for cross-reference; this trigger is not of that family because it scopes its rule to branches, not PRs, and respects the integradas ou abandonadas qualifier.
  • Existing complementary helper: scripts/git-cleanup-merged-gone-branches.ps1 — local-branch hygiene (merged + [gone]); the new lister is its remote-branch counterpart.
  • Doctrine: DEFENSIVE_SCANNING_MANIFESTO.md §1.3, THE_ART_OF_THE_FALLBACK.md §2–§3, AGENTS.md Risk posture.
Open in Web View Automation 

cursoragent and others added 2 commits April 28, 2026 10:25
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]>
@FabioLeitao
FabioLeitao force-pushed the main branch 2 times, most recently from ae0da8d to b5c995c Compare May 3, 2026 17:52
@FabioLeitao
FabioLeitao force-pushed the cursor/sre-automation-agent-protocol-c644 branch from 831a067 to 66912cb Compare May 3, 2026 17:52
@FabioLeitao FabioLeitao closed this May 3, 2026
@FabioLeitao
FabioLeitao deleted the cursor/sre-automation-agent-protocol-c644 branch May 3, 2026 18:39
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