Skip to content

Commit 48f8186

Browse files
authored
Merge pull request #3427 from lidge-jun/codex/promote-main-2420-badges
[WRONG BRANCH] release: promote dev onto main for the main-account badge fix
2 parents 4600f80 + 072df52 commit 48f8186

257 files changed

Lines changed: 13486 additions & 288 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CREDITS.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,34 @@ unnecessary.
9595

9696
If you find a landing that belongs on this page, open an issue. Being missed is
9797
the defect this file documents, not a claim you have to argue for.
98+
99+
### A gap the gate does not close
100+
101+
The gate checks that a trailer is **present**. It cannot check that the trailer
102+
resolves to the account it names.
103+
104+
A 2026-09-04 backlog review found carry PR
105+
[#3374](https://github.com/lidge-jun/opencodex/pull/3374), carrying
106+
[#3333](https://github.com/lidge-jun/opencodex/pull/3333) by
107+
[@blackjune67](https://github.com/blackjune67), with:
108+
109+
```
110+
Co-authored-by: hajune <[email protected]>
111+
```
112+
113+
(The address is masked here — `privacy:scan` blocks real contributor emails in the
114+
tree. What matters is its shape: a personal work address, not a GitHub-linked one.)
115+
116+
That is the git identity on the contributor's own commits, so it looks correct
117+
in every review. But GitHub attributes co-authors by **account-linked** email,
118+
and that address is linked to no account — so the trailer would have credited
119+
nobody, and the contributor would have been invisible on their own patch. The
120+
gate passed it, because a trailer was there.
121+
122+
It was corrected before the merge to the contributor's account-linked
123+
`users.noreply.github.com` address, which is why there is no table row for it above.
124+
125+
The lesson generalizes: when carrying work, take the trailer address from the
126+
author's GitHub account (the numeric-id `users.noreply.github.com` form is always
127+
safe), not from the commit metadata on their branch. A contributor who commits
128+
under a work email is the normal case, not an edge case.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# 260904 — Repository hygiene campaign
2+
3+
Unit for the branch/PR/issue drawdown requested on 2026-09-04: delete landed and
4+
abandoned refs locally and on `origin`, close superseded and partially-landed
5+
pull requests and issues, consolidate surviving scope into new issues, and credit
6+
every contributor whose work is carried.
7+
8+
## Inventory at entry (2026-09-04, origin/dev = b5777aa2d)
9+
10+
| Surface | Count |
11+
|---|---|
12+
| Local branches | 230 |
13+
| Remote branches on `origin` | 56 |
14+
| Open pull requests | 53 |
15+
| Open issues | 45 |
16+
| Worktrees | 67 |
17+
18+
## Classification of local branches
19+
20+
Every branch was scored on four independent axes rather than by name:
21+
22+
1. `git merge-base --is-ancestor <br> origin/dev` — plain ancestry.
23+
2. `git cherry origin/dev <br>` — patch-equivalence, which catches rebases.
24+
3. Content landing — the files the branch touches
25+
(`git diff --name-only origin/dev...<br>`) are compared two-dot against
26+
`origin/dev` restricted to exactly those paths. Zero remaining difference
27+
means the branch's content is already on `dev` even though a squash merge
28+
destroyed its commit identity.
29+
4. Exact reference matching against live GitHub state: open-PR head refs,
30+
worktree-backing refs, and the PR number a scratch branch was cut for.
31+
32+
Resulting buckets:
33+
34+
| Bucket | Count | Disposition |
35+
|---|---|---|
36+
| PROTECTED (`dev`, `main`, `preview`) | 3 | never touched |
37+
| OPEN_PR_HEAD | 7 | never touched |
38+
| WORKTREE-backed | 44 | never touched |
39+
| SAFE_DELETE (ancestor or zero unique commits) | 13 | delete |
40+
| Scratch branches for MERGED/CLOSED PRs | 85 | delete |
41+
| Content already landed on `dev` | 6 | delete |
42+
| UNIQUE_WORK still unlanded | 39 | keep |
43+
44+
## Prior-run failure this unit must not repeat
45+
46+
A cleanup run on 2026-09-02 guessed PR numbers from branch names, treated the
47+
guesses as merge evidence, and deleted the head refs of open pull requests: only
48+
4 of 33 open PR heads survived it. Two rules follow. Open-PR head refs are read
49+
from `gh` and matched by exact string immediately before each deletion batch,
50+
never inferred. And a branch is deleted only when at least one of the four tests
51+
above passes on the branch itself.
52+
53+
## A shell hazard that produced a false positive
54+
55+
The content-landing test was first written in shell. The login shell here is
56+
zsh, which does not word-split an unquoted variable, so a 57-path file list
57+
collapsed into a single nonexistent pathspec and `git diff` returned empty —
58+
reporting `feat/macos-app`, a branch with 57 genuinely unlanded files including
59+
an entire `app/` tree absent from `dev`, as fully landed. Acting on that would
60+
have destroyed the macOS app work.
61+
62+
The test was rebuilt in Python passing a real argument list, and validated
63+
against controls in both directions before any deletion: an open PR head must
64+
score UNLANDED, and a branch whose content is known to be on `dev` must score
65+
LANDED. The rewritten test moved `feat/macos-app` to UNLANDED and reduced the
66+
"landed" set from a bogus 41 to a verified 6.
67+
68+
Rule for this unit: any bulk classifier gets a negative control before its
69+
output authorizes a destructive action.
70+
71+
## Work phases
72+
73+
| Phase | Doc | Scope |
74+
|---|---|---|
75+
| wp0 | this file + 010 | roadmap and inventory |
76+
| wp1 | 020 | local branch deletion |
77+
| wp2 | 030 | `origin` remote branch deletion |
78+
| wp3 | 040 | maintainer-authored PR drawdown |
79+
| wp4 | 050 | contributor PR drawdown with credit |
80+
| wp5 | 060 | issue drawdown and consolidation |
81+
| wp6 | 070 | credit ledger and closeout |
82+
83+
## Out of scope
84+
85+
Merging any pull request, pushing to `dev`/`main`/`preview`, releases,
86+
force-push, history rewriting, worktree removal, and behavior changes under
87+
`src/`. The local test suite is forbidden for this unit by explicit instruction.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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).
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# 015 — Audit record for the deletion ledger
2+
3+
The branch-deletion ledger was reviewed by an independent auditor before any
4+
branch was touched. It failed three times. Each failure is recorded here because
5+
each one would have destroyed work.
6+
7+
## Round 1 — FAIL
8+
9+
> `cursor-call-prerebase-260818` was matched to unrelated PR #2608 by parsing a
10+
> date-like branch suffix and still contains unique unmerged patches
11+
12+
The scratch-branch rule extracted the first 3–4 digit run from a branch name and
13+
treated the matching PR's state as merge evidence. The branch is dated
14+
2026-08-18, so `260818` yielded `2608`, which is a real merged PR about a
15+
completely different subject. The branch carries two unique Cursor fixes — an
16+
unlabeled stream EOF failure and a cancel surface — and 31 commits reachable
17+
from nothing else.
18+
19+
This is the same class of error that deleted open-PR head refs on 2026-09-02,
20+
reproduced inside the unit written to prevent it. Writing the rule down did not
21+
prevent it; an auditor running the numbers did.
22+
23+
Fix: the PR number must be a whole numeric token of the branch name, and PR
24+
state alone no longer authorizes anything — the branch must be proven a
25+
duplicate of that PR's head (same SHA, ancestor, or content-identical).
26+
Candidate set 104 → approved 71.
27+
28+
## Round 2 — FAIL
29+
30+
> `final.py` can authorize deletion from a stale PR-head ref or failed `git
31+
> diff` because both command failures are ignored
32+
33+
The generator ignored return codes. A failed `fetch` left a stale
34+
`refs/prhead/<n>` that would be compared as if current, and a failed `git diff`
35+
produced empty stdout that read as "no difference" — the same shape as the zsh
36+
bug in `010_method.md`, where absence of output was mistaken for absence of
37+
change. Twice in one unit, so it is a pattern and not an accident: **empty
38+
output is not evidence unless the command is known to have succeeded.**
39+
40+
Fix: fail-closed. Git failures raise, PR heads are force-fetched with a checked
41+
return code, and any error rejects the branch. Regenerating produced exactly the
42+
same 71 branches, which is itself the evidence that the earlier approvals were
43+
sound rather than lucky.
44+
45+
## Round 3 — FAIL
46+
47+
> cached T1/T2 and T3 proofs are not recomputed or SHA-bound, so a branch that
48+
> moves after classification can lose new work
49+
50+
Proofs were inherited from JSON snapshots taken earlier in the session and the
51+
ledger stored no SHAs, so a branch that gained a commit between classification
52+
and deletion would still be deleted on the strength of a stale verdict.
53+
54+
Fix: snapshots now supply only the candidate list. Every proof is recomputed
55+
live, and each approval records the branch tip, the proof, and the `origin/dev`
56+
SHA it was proven against. Execution re-reads each tip immediately before
57+
deletion and refuses on any mismatch.
58+
59+
## Round 4 — PASS
60+
61+
- 71/71 recorded tips equal current branch tips
62+
- 71/71 proofs still hold at the recorded SHA
63+
- 33/33 rejected branches still present, including `cursor-call-prerebase-260818`
64+
- guards empty against live state: no open-PR head, no worktree ref, nothing protected
65+
- `origin/dev` moved during the audit (`b5777aa2d` → `664d80c76`) and invalidates
66+
no proof; no rejected branch became landed as a result
67+
68+
Non-safety note from the auditor: `rb-2122-ELZMyj` and `rb-2734` are
69+
tree-identical to their PR heads but stay preserved because the comparison uses
70+
three-dot form. Over-preservation, so it stands.
71+
72+
## What this cost and why it was worth it
73+
74+
Four rounds against one auditor, no branch deleted until the fourth passed. The
75+
first round alone justifies the whole exercise: the plan document explicitly
76+
warned against branch-name guessing on line 46, and the implementation did it
77+
anyway on line 12 of the very next file. A rule you wrote does not audit the
78+
code you wrote.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# 020 — wp1: local branch deletion
2+
3+
Delete the 71 branches in the verified deletion set, in batches, re-reading the
4+
guard sets before each batch. Each entry carries a named proof; a branch with no
5+
proof is preserved rather than deleted.
6+
7+
## Procedure
8+
9+
1. Snapshot every local ref to scratch: `git for-each-ref refs/heads` with SHAs,
10+
so any deletion is recoverable by SHA for as long as the objects survive gc.
11+
2. Re-read open-PR head refs from `gh` and worktree refs from
12+
`git worktree list --porcelain`. Intersect with the deletion set; a non-empty
13+
intersection aborts the phase.
14+
3. Delete with `git branch -D` in batches of ~20, capturing the reported SHA for
15+
each deletion.
16+
4. Verify: the local branch count drops by exactly 71, and every
17+
protected / open-PR / worktree ref still resolves. Counts are measured live
18+
at execution rather than asserted here — the branch total moves as other
19+
sessions work in this repository, and a stale expected number is a false
20+
alarm, not a safety property.
21+
22+
`-D` rather than `-d` is required because squash-landed branches are not
23+
ancestors of `dev` and `-d` refuses them; that is exactly the case T3 exists to
24+
decide, and the decision has already been made with evidence.
25+
26+
## Outcome (executed 2026-09-04)
27+
28+
71 branches deleted, each after re-reading its tip and comparing it to the SHA
29+
recorded at classification. Zero failures, zero tip mismatches.
30+
31+
| Measure | Before | After |
32+
|---|---|---|
33+
| Local branches | 241 | 170 |
34+
35+
Post-deletion verification, run against live state rather than the plan:
36+
37+
| Check | Result |
38+
|---|---|
39+
| Open-PR head refs present locally that were lost | 0 of 13 |
40+
| Worktree-backing refs lost | 0 of 47 |
41+
| Preserved (rejected) branches wrongly deleted | 0 of 33 |
42+
| `dev` / `main` / `preview` intact | yes |
43+
44+
That first row is the whole point of this unit. The 2026-09-02 run left only 4
45+
of 33 open-PR heads alive; this one lost none.
46+
47+
## Exit criteria
48+
49+
- Exactly the 71 approved refs are gone; nothing else was removed.
50+
- Every open-PR head ref present locally still resolves.
51+
- Every worktree-backing ref still resolves.
52+
- `dev`, `main`, `preview` resolve to their pre-phase SHAs.
53+
- `cursor-call-prerebase-260818` and the other 32 preserved branches still
54+
resolve.

0 commit comments

Comments
 (0)