|
| 1 | +# 010 — Classification method and its controls |
| 2 | + |
| 3 | +## The four tests |
| 4 | + |
| 5 | +A local branch is deletable when at least one holds, and no guard fires. |
| 6 | + |
| 7 | +``` |
| 8 | +T1 ancestry git merge-base --is-ancestor <br> origin/dev |
| 9 | +T2 patch-equiv git cherry origin/dev <br> -> no '+' lines |
| 10 | +T3 content paths = git diff --name-only origin/dev...<br> |
| 11 | + git diff --name-only origin/dev <br> -- <paths> -> empty |
| 12 | +T4 scratch branch name encodes a PR number whose state is MERGED or CLOSED |
| 13 | + AND the name matches the scratch prefix set |
| 14 | + AND the number is a WHOLE numeric token of the branch name |
| 15 | + AND the branch is provably a duplicate of that PR's head: |
| 16 | + identical SHA, an ancestor of it, or content-identical to it |
| 17 | +``` |
| 18 | + |
| 19 | +T3 is the one that matters for this repository, because `dev` takes squash |
| 20 | +merges: after a squash the branch shares no commit with `dev`, so T1 and T2 both |
| 21 | +report "unmerged" for work that is fully shipped. T3 asks the only question that |
| 22 | +is actually load-bearing — is there any difference left in the files this branch |
| 23 | +claims to change. |
| 24 | + |
| 25 | +T4 is deliberately narrow. It fires only for throwaway prefixes |
| 26 | +(`pr*`, `rb-`, `jrb-`, `mtp/`, `big-`, `cf-`, `ocx-`, `wip/`, `backup/`, |
| 27 | +`candidate`, `cursor-`, `midstream`) created by earlier review and rebase runs, |
| 28 | +and only when the referenced PR is already MERGED or CLOSED. A `codex/*` branch |
| 29 | +is never deleted on T4 alone. |
| 30 | + |
| 31 | +**T4 alone is not sufficient, and the first version of it was wrong.** PR state |
| 32 | +says nothing about whether *this branch* still holds unique work, so T4 now |
| 33 | +requires a positive duplication proof against the PR head itself: the branch is |
| 34 | +the same commit, an ancestor of it, or content-identical to it. If the PR head |
| 35 | +cannot be fetched or the branch matches none of those, the branch falls through |
| 36 | +to the content test against `dev`, and if that also fails it is preserved. |
| 37 | + |
| 38 | +The number must also be a whole numeric token of the branch name. The naive |
| 39 | +regex extracted `2608` from the date suffix in |
| 40 | +`cursor-call-prerebase-260818` and matched it to an unrelated merged PR — the |
| 41 | +exact name-guessing that destroyed open-PR heads on 2026-09-02, reproduced |
| 42 | +inside the very unit written to prevent it. That branch holds two unique Cursor |
| 43 | +stream-EOF and cancel fixes and 31 otherwise-unreachable commits. |
| 44 | + |
| 45 | +This was caught by an independent auditor, not by the author of the rule. |
| 46 | + |
| 47 | +## The guards |
| 48 | + |
| 49 | +Deletion is refused, regardless of test result, for: |
| 50 | + |
| 51 | +- `dev`, `main`, `preview` |
| 52 | +- any ref appearing as `headRefName` of an open pull request, read from `gh` |
| 53 | + immediately before the batch and matched as an exact string |
| 54 | +- any ref backing a live worktree, from `git worktree list --porcelain` |
| 55 | +- the currently checked-out branch |
| 56 | + |
| 57 | +## Controls run before deletion was authorized |
| 58 | + |
| 59 | +The content test is a destructive-action authority, so it was falsified first. |
| 60 | + |
| 61 | +**Negative control.** `origin/codex/responses-usage-passthrough`, head of open |
| 62 | +PR #3364, must not score LANDED. It differs from `dev` in 38 files and scored |
| 63 | +UNLANDED. Passed. |
| 64 | + |
| 65 | +**Positive control.** `codex/remote-hub-restack-roadmap-archive` carries 39 |
| 66 | +unique commits but every file it touches is already identical on `dev`; a |
| 67 | +commit-based test calls it unmerged, the content test calls it LANDED. Passed. |
| 68 | + |
| 69 | +**Failure the controls caught.** The first shell implementation reported 41 |
| 70 | +branches LANDED including `feat/macos-app`, which adds an entire `app/` tree |
| 71 | +that does not exist on `dev`. Cause: zsh does not word-split unquoted |
| 72 | +variables, so `git diff ... -- $paths` passed one 57-line pathspec that matched |
| 73 | +nothing and produced empty output, which the test read as "no difference." Any |
| 74 | +branch would have scored LANDED. Rebuilt in Python with a real argv list; the |
| 75 | +landed set fell from 41 to 6 and `feat/macos-app` correctly moved to UNLANDED. |
| 76 | + |
| 77 | +## Result |
| 78 | + |
| 79 | +Candidate set 104, of which 33 failed the hardened tests and are preserved. |
| 80 | + |
| 81 | +| Verdict | Count | Proof | |
| 82 | +|---|---|---| |
| 83 | +| Delete | 50 | identical SHA to its PR head | |
| 84 | +| Delete | 2 | ancestor of its PR head | |
| 85 | +| Delete | 13 | ancestor of `dev` or zero unique commits | |
| 86 | +| Delete | 6 | content already on `dev` (squash-hidden) | |
| 87 | +| **Total deletion set** | **71** | every entry carries a named proof | |
| 88 | +| Preserved: failed the duplication proof | 32 | | |
| 89 | +| Preserved: number not a whole token | 1 | `cursor-call-prerebase-260818` | |
| 90 | +| Keep: unlanded unique work | 39 | | |
| 91 | +| Keep: open-PR head, worktree-backed, protected | 54 | | |
| 92 | + |
| 93 | +Every entry in the final set names its own proof, so no deletion rests on the |
| 94 | +absence of evidence. Ledgers: `.tmp/hygiene/DELETE_FINAL.json` and |
| 95 | +`.tmp/hygiene/REJECTED_FINAL.json`. |
| 96 | + |
| 97 | +Ledger of the deletion set with per-branch reason: |
| 98 | +`.tmp/hygiene/delete-local.json` (scratch space, not tracked). |
0 commit comments