Files
msd-core/docs/adr/230-introduce-next-integration-branch.md
Tom Boucher 67a9243cf1 chore(#2356): make the ADR index a generated artifact and enforce ADR lifecycle invariants (#2367)
* chore: rebuild ADR index as a generated artifact and enforce lifecycle invariants

The ADR index in docs/adr/README.md was hand-maintained with nothing checking
it, and had drifted to 40 of 65 ADRs. The absent rows included the entire
capability family (857/894/959/1016/1143/1213/1244) and ADR-1239 (EoS) itself,
so the decisions a reader most needed were the ones they could not find.

Make the index a derived artifact, matching the repo's existing generated-file
idiom (lint:generated-sync), and enforce the corpus' lifecycle invariants:

- scripts/gen-adr-index.cjs generates the index between markers and validates
  the status vocabulary (Accepted/Proposed/Superseded/Legacy/Retired),
  successor links, id/filename agreement, and supersession symmetry.
- Wire --check into lint:generated-sync so drift fails CI.

Correct the lifecycle metadata the gate surfaced, without flipping any status:

- ADR-1239 (EoS) declared it subsumed ADR-1016/58/3660/894; none recorded it.
  Add reciprocal "Subsumed by" pointers + dated amendments. Subsumption keeps
  the target Accepted -- these are live adapters, not dead decisions.
- ADR-857/894 carry dated status caveats: they read Proposed while the
  capability system shipped and epic #857 is closed. Ratification is a
  maintainer act and is deliberately left open.
- Link ADR-0005/0007/0012/3524 -> ADR-0174 and ADR-0010 -> ADR-0009; record
  the reciprocal Supersedes on ADR-0009.
- ADR-218 declared itself "ADR-0175" -- an unfinished rename.
- The 0011 PRD moves from the non-canonical "Draft" to "Legacy".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* test: capture stderr via spawnSync; record ADR-0010 draft supersession

Two fixes surfaced by the first gsd-test run and by regenerating the index:

- tests/adr-index-gate.test.cjs used execFileSync, which only surfaces stderr
  through the thrown error on non-zero exit. The `--write` path exits 0 while
  reporting outstanding violations on stderr, so the helper always saw ''.
  spawnSync captures both streams on both outcomes.
- The hand-maintained index recorded 0010-skill-surface-budget-module.md as
  "earlier draft superseded by ADR-0011" while the file itself still said
  Proposed. Deriving the index from the files would have dropped that
  assertion and resurrected a superseded draft as a live decision, so it is
  recorded at its source, with the reciprocal Supersedes on ADR-0011.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix: drop the dead sdk/ model-catalog candidate retired by ADR-0174

src/model-catalog.cts resolved model-catalog.json through three candidates, the
second being sdk/shared/model-catalog.json three levels up. That was the legacy
source-repo fallback kept by the #3288 fix ("check the co-located path FIRST,
before the legacy source-repo path").

ADR-0174 then retired the @opengsd/gsd-sdk package boundary and deleted the sdk/
tree (11918dcc3), so the candidate can no longer resolve in any layout: a source
repo has no sdk/, and an install layout points it at ~/.claude/sdk/shared/, which
the installer never writes -- the original #3288 bug. It was dead weight implying
a package boundary this repo no longer has.

No test depends on it: the #3288 regression tests in tests/install.test.cjs write
their own synthetic old-path fixture and assert it throws.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs: ratify nine shipped ADRs; record why ten others stay Proposed

The corpus carried 19 Proposed ADRs, most describing architecture that had
already shipped. A Proposed label on live architecture tells contributors and
agents the decision is an unbuilt idea -- the capability system and EoS were
both being misread that way.

Audited all 19 against the shipped tree and GitHub. Each candidate flip then had
to survive two independent reviewers instructed to refute it.

Ratified Proposed -> Accepted, each with a dated Ratification section carrying
the verified evidence (file:line, symbols, tests, issue state):

  857  capability system      894  declaration format   1244 capability ecosystem
  1577 injection boundary     1610 size-budget ratchet  1990 existing-code onboarding
  15   cross-AI convergence   22   plan-drift guard     0011 default reviewers

Held ten, each now carrying a "Why this is still Proposed" section naming the
blocker and its unblock condition, so the audit is not repeated:

  2264 its own headline acceptance criterion is unmet in the tree
  230  live branch protection contradicts the decided spec (1 approval, not 2)
  660  the namesake release/<version> re-cut is manual, not automated
  959  issue #2346 is approved and plans its graduation as its own ADR
  1213 the shipped writer's return shape differs from the decided interface
  443  the orchestrator override path has no live caller
  1143 / 1606 each states its own bar for acceptance; neither is met
  612 / 1671 legitimately open

Shipped code proved necessary but not sufficient: eight ADRs had every named
module, symbol, and test present with their epics closed, and still failed the
bar. That lesson is written into README.md's ratification procedure.

Also corrected ADR-857's "Supersedes (generalizes)" to "Subsumes": taken
literally it would have marked two live seams dead -- ADR-0011 (surface.cts:348)
and ADR-58 (runtime-artifact-install-plan.cts:82). Both keep Accepted status and
gain Subsumed-by pointers.

Index: Active 39->48, Proposed 19->10, Superseded/Legacy 7. 65 total.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix: harden gen-adr-index against hostile titles and non-ADR filenames (#2356)

Three findings from the pre-PR orthogonal security review, all confirmed:

- An ADR title containing the literal ADR-INDEX:END marker was emitted verbatim
  into its table cell, relocating the splice boundary so the NEXT --write
  spliced against the wrong marker and truncated README.md. Titles now render
  through cellText(), which escapes pipes and angle brackets -- making an HTML
  comment (and any other HTML) unformable from ADR-authored text.
- A docs/adr/*.md without a numeric prefix crashed on match(...)[1] of null.
  Such a file is also invisible to the index -- the very failure this gate
  exists to prevent -- so it is now reported as a naming-convention violation
  naming the file and the fix.
- Tests leaked their mkdtemp dirs. They now use helpers.createTempDir/cleanup
  via t.after(); helpers.cleanup carries the Windows-EBUSY retry budget that a
  raw fs.rmSync lacks (caught by local/no-raw-rmsync-in-tests).

Adds five regression tests: marker hijack, HTML injection, pipe cell-break,
non-conforming filename, and splice stability across repeated writes.

Refs #2356

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix: close two gate false-passes; read ## Supersedes sections (#2356)

Second round of confirmed findings from the pre-PR orthogonal code review. Both
false-passes matter more than a false-fail: a gate that silently misses a
violation is worse than no gate, because it is trusted.

- A relation field mixing a link with a bare id silently dropped the bare claim:
  the check tested `rel.links.length` (does this field have ANY link?) instead
  of whether THAT id was linked. `Supersedes: [ADR-0001](...), ADR-0011` passed
  clean -- accepting exactly the ambiguous bare reference the rule forbids. Now
  each bare id is checked against the ids actually linked in the same field, so
  a repeat in trailing prose stays quiet while an unlinked claim is flagged.
- The ratification guard (`statusToken !== 'Accepted'`) skipped BOTH relation
  directions, which killed the IN check entirely: `supersedes.in` is only ever
  populated on an ADR whose status IS `Superseded`, so a dangling `Superseded by
  X` where X never claims it always passed. The guard now applies to OUT only --
  a prospective claim must not obligate its target, but an ADR's statement about
  ITSELF is always owed a reciprocal.
- Fixing that surfaced a parser gap: ADR-0174 declares its supersessions in a
  `## Supersedes` table SECTION, not a header field, and headerBlock() stops at
  the first `##`. The repo's best-documented supersession was invisible. Section
  form is now parsed for both relations.
- Replaced a vacuous test: the em-dash negation case passed whether or not
  NEGATED_RELATION_RE matched (a mutation to /$^/ survived). It now carries a
  link that would create a failing asymmetric relation if negation did not fire.

Also removes docs/adr/9401-test-target.md -- a synthetic fixture a reviewer
created in the worktree while reproducing a finding, swept in by `git add -A`.

Adds regression tests for each: mixed link+bare, linked-and-repeated-in-prose,
dangling superseded-by from a non-Accepted ADR, and the ADR-0174 section shape.

Refs #2356

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix: escape backslashes before pipes in the ADR index cell renderer (#2356)

CodeQL js/incomplete-sanitization (high) on scripts/gen-adr-index.cjs: cellText()
escaped `|` -> `\|` without first escaping the backslash. Markdown's escape
character is the backslash, so the input `\|` became `\\|`, which renders as a
literal backslash followed by an UNESCAPED pipe -- re-opening the cell break the
pipe escape exists to prevent. Order is load-bearing: escape the escape
character first, then everything that emits one.

Same class as the index-marker hijack fixed earlier: ADR-authored text breaking
out of the cell it is rendered into.

Adds a regression test asserting a `\|`-bearing title leaves exactly the row's
own 5 unescaped delimiters and cannot forge a Status cell. Uses split(/\r?\n/)
per local/no-crlf-fragile-split -- a literal "\n" split is CRLF-fragile on the
Windows CI leg.

Refs #2356

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 10:51:58 -04:00

20 KiB

Introduce next as a long-lived integration branch

  • Status: Proposed
  • Date: 2026-05-23

Filename note. This ADR uses the placeholder (now resolved to 230) per CONTRIBUTING.md §Proposing an ADR. Before merging, open a chore: issue, replace XXXX with the assigned issue number, and rename the file accordingly.

Why this is still Proposed (audited 2026-07-17)

The architectural shift is real and operating: the live default branch is next (gh api repos/open-gsd/gsd-core --jq .default_branch), .github/workflows/auto-backmerge.yml runs unconditionally (if: true, not the Phase-1 if: false stub) and has produced real, merged main → next back-merge PRs across multiple releases (#671, #1337, #1673, and others), release.yml cherry-picks from origin/next with an origin/main fallback per the Phase-3 patch, pr-target-validator.yml enforces (WARN_ONLY: 'false'), and auto-branch.yml branches from next with a main fallback.

The blocker. The Decision section requires differentiated branch protection: main — "strict: 2 reviewer approvals, all CI green, ... restrict push to maintainers via PR only"; next — "loose: ... 'require branches up to date' OFF." Live settings invert this. main's classic branch protection (verified via gh api repos/open-gsd/gsd-core/branches/main/protection and its required_pull_request_reviews / required_status_checks sub-resources) shows required_approving_review_count: 1 (spec: 2), required_status_checks returns 404 "not enabled" (spec: all CI green required — there is no CI gate on main at all), and allow_force_pushes.enabled: true (spec: restrict push to maintainers via PR only). next's protection, by contrast, has required_status_checks.strict: true across 7 contexts and allow_force_pushes.enabled: false — stricter than main, not looser. The two GitHub Rulesets that might have compensated (main-protection id 16752567, release-branches id 16752568) are both enforcement: "evaluate" (dry-run, non-blocking) and were never promoted to active; main-protection's condition further targets ~DEFAULT_BRANCH, a dynamic alias that now resolves to next (the current default branch), so even if activated it would apply to the wrong branch. Migration Phase 2 step 3 ("Apply branch protection: bash scripts/setup-branch-protection.sh") was evidently run for next but never durably applied to main.

Issue #230's own closure (state_reason: completed) certifies only Phase 1 (additive infrastructure) — its body scopes itself explicitly to Phase 1 and defers branch-protection application, the default-branch flip, and workflow-enforcement flags to a "Phase 2 follow-up (separate PR)"; that follow-up evidently landed for next but not for main's protection. Separately, next's "require branches up to date OFF (this is the whole point)" was reversed five days later by ADR-415 (Accepted, 2026-05-28), which set required_status_checks.strict = true on next after a real stale-base regression (#406/#411/#412) — so the specific rebase-treadmill relief this ADR promises for next no longer holds exactly as written, though the broader architectural decision (integration branch, isolated main, automated back-merge) is unaffected. Migration Phase 4 cleanup (drop develop from branch-naming.yml's alwaysValid; drop the || main fallbacks in release.yml/auto-branch.yml) is also still open, gated on "2-3 successful releases" per the ADR's own text — cosmetic, not blocking.

Unblock condition. Ratify once main's live branch protection matches this ADR's Decision section — required_approving_review_count: 2, required_status_checks enabled and required, allow_force_pushes: false — applied via scripts/setup-branch-protection.sh (or an equivalent gh api call), and the two evaluate-mode Rulesets are either activated with corrected ref_name conditions or removed as redundant with classic protection. Verify with:

gh api repos/open-gsd/gsd-core/branches/main/protection/required_pull_request_reviews --jq .required_approving_review_count   # expect 2
gh api repos/open-gsd/gsd-core/branches/main/protection/required_status_checks                                                # expect 200, not 404
gh api repos/open-gsd/gsd-core/branches/main/protection --jq .allow_force_pushes.enabled                                      # expect false

Until then, either bring main's protection into line with the Decision section, or amend this ADR (as ADR-415 did for one next parameter) to record the protection posture actually in force.

Context

Today every contributor branch — feat/, fix/, chore/, docs/, refactor/, test/, perf/, ci/, revert/ — is cut from main and PR'd back to main. Release branches (release/X.Y.0) and hotfix branches (hotfix/X.Y.Z) are also cut from main. As a result:

  1. main moves on every merge. With ~315 unreleased changesets queued and multiple PRs in flight at any time, main advances multiple times a day.
  2. GitHub branch protection on main requires "branches up to date before merging" (the dominant pattern across mature OSS projects with linear history). Every time another PR lands, every in-flight PR must rebase before its own merge button enables.
  3. release/X.Y.0 accumulates RC-cycle fixes that drift from main. When finalize opens the merge-back PR, the diff is large and contributors who PR'd to release/* can't be sure their fix is also queued for the next minor.
  4. hotfix.yml cherry-picks fix:/chore: commits from main since the prior tag. This works today only because every fix lands on main. The pattern is fragile — any deviation (e.g. fix landing on release/*) is invisible to the picker. v1.42.3 (#3621) shipped a half-state for exactly this class of reason.

The maintainer's stated pain: "every update doesn't mean the next pr needs a rebase" — i.e. the rebase treadmill from (2), driven by (1).

Decision

Introduce next as a long-lived integration branch.

  • All work that today targets main instead targets next, with the sole exceptions of release/X.Y.0 and hotfix/X.Y.Z branches, which still merge to main.
  • next is always at-or-ahead of main. Any push to main (release or hotfix merge) triggers an automated back-merge PR main → next to keep next aligned.
  • Branch protection rules differ:
    • main — strict: 2 reviewer approvals, all CI green, "require branches up to date" ON, signed commits, restrict push to maintainers via PR only.
    • next — loose: 1 reviewer approval, all CI green, "require branches up to date" OFF, auto-delete source branches.
  • Default branch (in repo Settings) becomes next. gh pr create and the GitHub web UI then default new PRs to the correct target without a flag.

Where each branch type goes

Branch prefix Today's target New target Rationale
feat/ main next Features ship in minor releases
fix/ main next Regular fixes ship in minor (or get cherry-picked by hotfix.yml)
chore/, docs/, refactor/, test/, perf/, ci/, revert/ main next All same-flow as fixes
fix/critical-* main main Production-down only, auto-back-merges to next
release/X.Y.0 main main (cut from next) Promoted to production on finalize
hotfix/X.Y.Z main main (cut from prior tag, cherry-picks from next) Patch releases

Mechanical changes summary

Component Change
release.yml (create) Branch from next, not main
release.yml (finalize) Open merge-back PR to both main and next (was just main)
hotfix.yml (cherry-pick step) Cherry-pick from origin/next, not origin/main
hotfix.yml (finalize) Open merge-back PRs to both main and next (was just main)
branch-naming.yml Add next to alwaysValid list
auto-branch.yml Branch from next HEAD instead of main HEAD for issue-labeled branches
New pr-target-validator.yml Block PRs targeting main from branches that aren't release/*, hotfix/*, or fix/critical-*
New auto-backmerge.yml On push to main, open main → next PR
Repo settings Default branch = next; squash-merge only on next; merge-commit on main (preserve tag context)
scripts/setup-branch-protection.sh New: idempotent script to apply both branch protection rule sets via gh api

Consequences

Positive

  • Rebase treadmill ends. PRs targeting next are not gated on "up-to-date before merge". Concurrent PRs to next merge in any order as long as they don't conflict on the same lines.
  • main becomes a stable reference. It changes only on release/hotfix merges — a handful of times per week, not multiple times per day. CI on main runs less; downstream consumers (linked CI, npm tag watchers) see fewer transient states.
  • Hotfix cherry-pick base is unambiguous. All fix:/chore: commits candidate for a hotfix live on next. The cherry-pick filter (today hardcoded against origin/main) becomes correct-by-construction once retargeted to origin/next.
  • RC-only fixes flow back to next automatically. Today a fix that lands on release/1.28.0 to unblock RC2 only makes it to next-equivalent (i.e. main) when finalize back-merges. Under the new model finalize back-merges to both main and next, so an RC fix is never accidentally dropped from the next minor.
  • Default branch switch is one click. Cost is low; setting takes effect for every new PR and clone immediately.

Negative

  • One more concept to teach contributors. Mitigated by docs/branching.md
    • CONTRIBUTING update + PR-target validator that says "retarget to next" with a one-line fix instruction.
  • Hotfix and release workflows need updates. Patches are inlined below. Both are reversible — if a patch causes pain, revert and re-target the workflows back to main. No on-disk state migration required.
  • The auto-backmerge PR is a new background-noise source. It opens silently after each release/hotfix push to main. Mitigated by labeling the PR automation and auto-merging if CI passes (configurable in auto-backmerge.yml).
  • Existing 315-changeset queue. Doesn't strictly block this change but the next release will be a large one. Recommend cutting 1.28.0 from main (current behavior, last time) before flipping the default branch to next — see "Migration" below.

Risks not worth the trade-off

We considered and rejected:

  • develop instead of next. The git-flow nomenclature is established but the gitflow model itself is heavier than this project needs (no long-lived release/* branches per-major, no support/* for old majors). next matches the existing npm dist-tag (@next) and is the convention for Angular, Next.js, React Native, and others. Use the name that already appears in VERSIONING.md.
  • Merge queue. GitHub's merge queue (GA in 2023) addresses the same pain by serializing merges and rebasing+testing automatically. Rejected because (a) it doesn't address the parallel work-stream separation that a next branch gives, (b) it still requires "branches up to date" which we want to relax, and (c) the maintainer is a git beginner and merge queue's failure modes (split commits, requeued PRs) are harder to debug than a conventional model.
  • Pure trunk-based with feature flags. Rejected because the project publishes to npm and doesn't have a runtime feature-flag system. Feature flags would be a larger separate investment.

Migration

This is a phase-gated rollout. Each phase is reversible.

Phase 0 — Decide

  1. Open a chore: issue: "Introduce next integration branch". Get the issue number. Rename this ADR file from XXXX- to <issue#>-.
  2. Review this ADR. Decide on the merge-commit-vs-squash policy for next (recommended: squash) and for main (recommended: merge commit on release back-merges, to preserve the tag-commit relationship).

Phase 1 — Additive infrastructure (no behavior change)

The following land on main (current model, one last time) before flipping:

  • docs/branching.md (new)
  • docs/adr/<issue#>-introduce-next-integration-branch.md (this file)
  • scripts/setup-branch-protection.sh (new)
  • .github/workflows/auto-backmerge.yml (new, disabled with if: false until phase 2)
  • .github/workflows/pr-target-validator.yml (new, in "warning only" mode)
  • .github/workflows/branch-naming.yml (update: add next to alwaysValid)
  • CONTRIBUTING.md update: "Where do I open my PR?" section

Phase 2 — Flip

When the next release is ready to start its RC cycle:

  1. Cut the current planned release (e.g. 1.28.0) using release.yml as today — this drains the 315-changeset queue from main cleanly.
  2. After v1.28.0 finalizes and back-merges to main, run:
    git checkout main && git pull --ff-only
    git checkout -b next && git push -u origin next
    
  3. Apply branch protection: bash scripts/setup-branch-protection.sh.
  4. Settings → Branches → change default branch to next.
  5. Re-enable auto-backmerge.yml (remove the if: false).
  6. Flip pr-target-validator.yml from warning-only to enforcing.

Phase 3 — Retarget release/hotfix workflows

Apply these patches once next is established and the team has run at least one feature PR through it.

release.yml — branch from next (create step):

@@ create:
       - name: Create release branch
         env:
           BRANCH: ${{ needs.validate-version.outputs.branch }}
           VERSION: ${{ inputs.version }}
           IS_MAJOR: ${{ needs.validate-version.outputs.is_major }}
         run: |
+          git fetch origin next:next || git fetch origin main:main
-          git checkout -b "$BRANCH"
+          git checkout -b "$BRANCH" next 2>/dev/null || git checkout -b "$BRANCH" main

The || main fallback is for the transition window where next may not yet exist. After Phase 2 the fallback can be removed.

release.yml — back-merge to both branches (finalize step):

@@ Create PR to merge release back to main
       - name: Create PR to merge release back to main
         ...
+      - name: Create PR to merge release back to next
+        if: ${{ !inputs.dry_run }}
+        continue-on-error: true
+        env:
+          GH_TOKEN: ${{ github.token }}
+          BRANCH: ${{ needs.validate-version.outputs.branch }}
+          VERSION: ${{ inputs.version }}
+        run: |
+          EXISTING_PR=$(gh pr list --base next --head "$BRANCH" --state open --json number --jq '.[0].number' 2>/dev/null || echo "")
+          if [ -n "$EXISTING_PR" ]; then
+            gh pr edit "$EXISTING_PR" \
+              --title "chore: merge release v${VERSION} to next" \
+              --body "Merge release branch back to next after v${VERSION} stable release (picks up RC-only fixes)." \
+              || echo "::warning::Could not update next merge-back PR. Open it manually."
+          else
+            gh pr create \
+              --base next \
+              --head "$BRANCH" \
+              --title "chore: merge release v${VERSION} to next" \
+              --body "Merge release branch back to next after v${VERSION} stable release (picks up RC-only fixes)." \
+              || echo "::warning::Could not create next merge-back PR. Open it manually."
+          fi

hotfix.yml — cherry-pick from next (with main fallback):

@@ Cherry-pick fix/chore commits from origin/main since base tag
-      - name: Cherry-pick fix/chore commits from origin/main since base tag
+      - name: Cherry-pick fix/chore commits from origin/next since base tag
         ...
         run: |
           set -euo pipefail
-          git fetch origin main:refs/remotes/origin/main
+          # Prefer next; fall back to main during the transition window or
+          # for production-down emergencies that landed directly on main.
+          if git ls-remote --exit-code origin next >/dev/null 2>&1; then
+            git fetch origin next:refs/remotes/origin/next
+            SOURCE="origin/next"
+          else
+            git fetch origin main:refs/remotes/origin/main
+            SOURCE="origin/main"
+          fi

-          CANDIDATES=$(git cherry "$BASE_TAG" origin/main | awk '/^\+ / {print $2}')
+          CANDIDATES=$(git cherry "$BASE_TAG" "$SOURCE" | awk '/^\+ / {print $2}')
...
-          ORDERED=$(git log --reverse --format='%H' "$BASE_TAG..origin/main" \
+          ORDERED=$(git log --reverse --format='%H' "$BASE_TAG..$SOURCE" \
             | grep -F -f <(echo "$CANDIDATES") || true)

hotfix.yml — back-merge to both branches (finalize step):

@@ Create PR to merge hotfix back to main
       - name: Create PR to merge hotfix back to main
         ...
+      - name: Create PR to merge hotfix back to next
+        if: ${{ !inputs.dry_run }}
+        env:
+          GH_TOKEN: ${{ github.token }}
+          BRANCH: ${{ needs.validate-version.outputs.branch }}
+          VERSION: ${{ inputs.version }}
+        run: |
+          EXISTING_PR=$(gh pr list --base next --head "$BRANCH" --state open --json number --jq '.[0].number')
+          if [ -n "$EXISTING_PR" ]; then
+            gh pr edit "$EXISTING_PR" \
+              --title "chore: merge hotfix v${VERSION} back to next" \
+              --body "Merge hotfix changes back to next after v${VERSION} release."
+          else
+            gh pr create \
+              --base next \
+              --head "$BRANCH" \
+              --title "chore: merge hotfix v${VERSION} back to next" \
+              --body "Merge hotfix changes back to next after v${VERSION} release."
+          fi

auto-branch.yml — branch from next:

-            // Create branch from main HEAD
-            const mainRef = await github.rest.git.getRef({
+            // Create branch from next HEAD (fall back to main if next missing)
+            let baseRef;
+            try {
+              baseRef = await github.rest.git.getRef({
                 owner: context.repo.owner,
                 repo: context.repo.repo,
-              ref: 'heads/main',
-            });
+                ref: 'heads/next',
+              });
+            } catch (e) {
+              if (e.status !== 404) throw e;
+              baseRef = await github.rest.git.getRef({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                ref: 'heads/main',
+              });
+            }

             await github.rest.git.createRef({
               owner: context.repo.owner,
               repo: context.repo.repo,
               ref: `refs/heads/${branch}`,
-              sha: mainRef.data.object.sha,
+              sha: baseRef.data.object.sha,
             });

Phase 4 — Cleanup

After 2-3 successful releases under the new model:

  • Remove the || main fallbacks from release.yml and hotfix.yml.
  • Remove develop from branch-naming.yml alwaysValid (it was vestigial; the project never used it).
  • Drop warning-only mode from pr-target-validator.yml.

References

  • docs/branching.md — contributor-facing how-to-use-it guide
  • VERSIONING.md — semver tiers and npm dist-tag mapping
  • .github/workflows/release.yml, .github/workflows/hotfix.yml — release/hotfix automation that this ADR adjusts
  • scripts/setup-branch-protection.sh — bootstrap script for branch protection rules
  • Angular branching model — closest analogue (main + <version>-next)
  • Next.js release flow — uses canary as the integration branch with the same shape