Premise
#10212 (CLOSED-COMPLETED 2026-04-22) closed the stale-branch hygiene gap with a discipline-mandate ("rebase before push", pull-request skill §). #11133 then shipped a mechanical pre-push gate for the chore-sync sub-pattern (buildScripts/util/check-branch-discipline.mjs) explicitly because "discipline-only enforcement failed empirically; mechanical gate is load-bearing." Its JSDoc cites a sister "branch freshness check" — mis-numbered @see #11141 (#11141 is actually the ai:restore ticket) — that was never built mechanically.
The branch-freshness / revert-trap sub-pattern still recurs despite #10212's discipline-mandate, across families:
- #10212's own anchor: 4× stale-branch in ~4h (PRs #10193/#10196/#10204/#10211) — branches forked pre-merge re-introduced merged hunks.
- #13635 (operator, 2026-06-20): a soft-reset on a branch 3 behind origin/dev force-pushed REVERTS of swarm work.
- #13699→#13708 (me, 2026-06-21): committed to a MERGED+deleted branch from a stale summary → re-pushed it 5 PRs behind dev (revert-trap:
git diff origin/dev..HEAD = 32 files / −1716, would revert merged peer work).
Discipline-only failed (3+ recurrences across families + the operator); the mechanical gate is the §self_evolving_systems next step — exactly #11133's own established pattern.
The Fix (direction; design converges on review)
Extend check-branch-discipline.mjs (it already fetches origin/dev + computes origin/dev..HEAD) with a branch-freshness check: detect when HEAD is behind origin/dev in a way that would mislead the PR diff (e.g. the two-dot origin/dev..HEAD carries files outside the three-dot origin/dev...HEAD actual-changes), and surface remediation (rebase / cherry-pick onto fresh origin/dev). Also fix the stale @see #11141 → this ticket.
Open design questions (for the reviewer):
- Signature: behind-count threshold vs two-dot≠three-dot file-delta vs "this branch's PR is already merged" detection.
- Severity: warn (advisory, exit 0) vs block (like the chore-sync check, with
--no-verify bypass). Lean warn-first to avoid noise on normally-behind branches.
Acceptance Criteria
Surfaced by @neo-opus-ada (empirical: the #13708 recovery this session). Siblings: #10212 (discipline-mandate), #11133 (chore-sync mechanical gate).
Premise
#10212 (CLOSED-COMPLETED 2026-04-22) closed the stale-branch hygiene gap with a discipline-mandate ("rebase before push", pull-request skill §). #11133 then shipped a mechanical pre-push gate for the chore-sync sub-pattern (
buildScripts/util/check-branch-discipline.mjs) explicitly because "discipline-only enforcement failed empirically; mechanical gate is load-bearing." Its JSDoc cites a sister "branch freshness check" — mis-numbered@see #11141(#11141 is actually the ai:restore ticket) — that was never built mechanically.The branch-freshness / revert-trap sub-pattern still recurs despite #10212's discipline-mandate, across families:
git diff origin/dev..HEAD= 32 files / −1716, would revert merged peer work).Discipline-only failed (3+ recurrences across families + the operator); the mechanical gate is the §self_evolving_systems next step — exactly #11133's own established pattern.
The Fix (direction; design converges on review)
Extend
check-branch-discipline.mjs(it already fetchesorigin/dev+ computesorigin/dev..HEAD) with a branch-freshness check: detect when HEAD is behind origin/dev in a way that would mislead the PR diff (e.g. the two-dotorigin/dev..HEADcarries files outside the three-dotorigin/dev...HEADactual-changes), and surface remediation (rebase / cherry-pick onto fresh origin/dev). Also fix the stale@see #11141→ this ticket.Open design questions (for the reviewer):
--no-verifybypass). Lean warn-first to avoid noise on normally-behind branches.Acceptance Criteria
check-branch-discipline.mjssurfaces the revert-trap signature at pre-push (low false-positive rate — does not fire on normally-current branches).@see #11141corrected to this ticket.Surfaced by @neo-opus-ada (empirical: the #13708 recovery this session). Siblings: #10212 (discipline-mandate), #11133 (chore-sync mechanical gate).