From 2794a05d7c9108cf8704b6b1c1390da4970adf88 Mon Sep 17 00:00:00 2001 From: YifanXu1999 Date: Wed, 18 Nov 2026 16:05:12 +0800 Subject: [PATCH] docs(policy): delete head branches on merge; define merged branches Adds to the code review policy's Merging section: the merger deletes the PR's head branch on GitHub (retargeting stacked PRs first), and a new "Removing branches" section that defines when a branch counts as merged (ancestor of a release branch, head of a merged PR at the merged tip, or fully patch-equivalent), allows anyone to delete such a branch with a SHA lease, and keeps unmerged branches and bases of open PRs for their owners. Production LOC: 188532 -> 188532 (delta 0); docs-only commit. Scope: core/engine/control/api production source, tools/production_loc.py at the parent; reference absent (retired R9c; last counted 65,417 at tree 498dd1917812). Co-Authored-By: Claude Opus 5.5 --- docs/policy/code-review.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/policy/code-review.md b/docs/policy/code-review.md index de53b2a7f..2c59663bd 100644 --- a/docs/policy/code-review.md +++ b/docs/policy/code-review.md @@ -210,6 +210,37 @@ PRs are squash-merged. The author writes the squash commit's message, including its `Production LOC:` line computed against the base branch's head at merge time. +Whoever merges a PR deletes its head branch on GitHub in the same step, +unless another open PR uses that branch as its base: retarget those PRs +first, then delete it. Push follow-up work to a new branch, not to a merged +one. Deleting a GitHub branch does not touch anyone's local branch or +worktree; each owner removes their own. + +### Removing branches + +The release branches `main` and `layerfs_v2_0_0` are never deleted. Any +other branch on GitHub counts as **merged** when one of these holds: + +- its tip is an ancestor of a release branch; +- it is the head of a merged PR and its tip is the commit that PR merged + (squash merges leave no ancestry); +- every one of its commits is patch-equivalent to a commit already in a + release branch (`git cherry ` prints no `+` line). + +Anyone may delete a merged branch without asking. Delete with the tip you +checked as a lease, so a branch pushed to since then is refused rather than +lost: + +```bash +git push origin --force-with-lease=refs/heads/: :refs/heads/ +``` + +A branch with any commit outside the release branches is not merged, even +if its PR was closed or it was pushed to after its PR merged. Keep it, and +keep any branch that is the base of an open PR; only its owner deletes it. +Record the name and tip of each branch deleted in a sweep (in the PR or +issue that did it), so one can be restored from its tip if needed. + ## Issue priority An issue's priority comes from **impact first** (severity), then exposure