From 3e506b9ee4d07049a2484c66807417bb5137cf6d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:06:37 +0000 Subject: [PATCH 1/5] Merge each push to a release line forward (forward.yml) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit forward.yml merges every push to release/vX.Y into release/vX.(Y+1), when that line exists, on forward/vXY-to-vX(Y+1)-, and opens the pull request. Conflicts in generated projections and locks take the next line's side and regenerate.yml, called with the branch named, writes them again and dispatches the gate. While the line has no spec/, its SPEC.md and register changes are carried into the next line's modules by `cargo xtask spec port --merged --register`. Any other conflict is committed as the next line's side and the pull request is a draft naming the paths. A newer push cancels the run and closes the older forward pull request. SPEC.md §9.4, RP-14, AGENTS.md, CHANGELOG.md. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3M8ULnzEQwLLngyBBX --- .github/scripts/forward-merge.sh | 159 +++++++++++++++++++++ .github/workflows/forward.yml | 63 ++++++++ AGENTS.md | 2 + CHANGELOG.md | 6 + SPEC.md | 4 +- crates/conformance/src/cases/repository.rs | 24 ++++ 6 files changed, 257 insertions(+), 1 deletion(-) create mode 100755 .github/scripts/forward-merge.sh create mode 100644 .github/workflows/forward.yml diff --git a/.github/scripts/forward-merge.sh b/.github/scripts/forward-merge.sh new file mode 100755 index 0000000000..9be2304674 --- /dev/null +++ b/.github/scripts/forward-merge.sh @@ -0,0 +1,159 @@ +#!/usr/bin/env bash +# The forward merge of a release line (SPEC.md §9.4): the pushed head of +# `release/vX.Y` merged, by merge commit, into the head of `release/vX.(Y+1)` +# on the branch `forward/vXY-to-vX(Y+1)-`, pushed, with its pull request. +# +# A conflict in a generated projection or a lock takes the next line's side: +# `regenerate.yml` writes those files again from the merged tree. While the +# pushed line has no `spec/` (its SPEC.md and register are hand-written), what +# it changed in SPEC.md and `model/ids.toml` is carried into the next line's +# modules by `cargo xtask spec port --merged … --register …`, since the +# projections are written from the modules and would drop it. Any other +# conflict, and a port that refuses, is committed as the next line's side and +# the pull request is opened as a draft naming the paths, for an agent to +# finish. A newer forward branch of the same lines closes the older ones. +# +# Inputs, from the environment: REPO, GITHUB_REF_NAME (the pushed line), the +# checkout (the pushed commit, full history, the workflow token), GITHUB_OUTPUT, +# GITHUB_STEP_SUMMARY, GITHUB_SERVER_URL. Outputs: branch, commit, clean. +set -euo pipefail + +repo=${REPO:?REPO names owner/name} +summary=${GITHUB_STEP_SUMMARY:-/dev/null} +output=${GITHUB_OUTPUT:-/dev/null} +say() { printf '%s\n' "$1" | tee -a "$summary"; } + +line=${GITHUB_REF_NAME:?GITHUB_REF_NAME names the pushed line} +if ! [[ "$line" =~ ^release/v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then + say "\`$line\` is not a release line: nothing to carry forward." + exit 0 +fi +major=${BASH_REMATCH[1]} +minor=${BASH_REMATCH[2]} +next="release/v$major.$((minor + 1))" +if ! git ls-remote --exit-code --heads origin "$next" >/dev/null; then + say "There is no \`$next\`: nothing to carry forward." + exit 0 +fi +git fetch --quiet origin "refs/heads/$next:refs/remotes/origin/$next" +source=$(git rev-parse HEAD) +if git merge-base --is-ancestor "$source" "origin/$next"; then + say "\`$next\` already contains \`$source\`." + exit 0 +fi +prefix="forward/v$major$minor-to-v$major$((minor + 1))-" +branch="$prefix${source:0:8}" +if git ls-remote --exit-code --heads origin "$branch" >/dev/null; then + say "\`$branch\` already exists: this head was carried forward before." + exit 0 +fi + +base=$(git merge-base "origin/$next" "$source") +git checkout --quiet -B "$branch" "origin/$next" +git config user.name 'github-actions[bot]' +git config user.email '41898282+github-actions[bot]@users.noreply.github.com' +git merge --quiet --no-ff --no-commit "$source" || true +git rev-parse --verify --quiet MERGE_HEAD >/dev/null || { + echo "::error::merging $source into $next did not start" + exit 1 +} + +generated() { + case "$1" in + SPEC.md | model/*.toml | CONFORMANCE.md | ERRORS.md | Cargo.lock | lexlean.lock | */lexlean.lock \ + | */expected/* | tests/golden/* | tests/production-export/* | tests/stack-bounds.json) return 0 ;; + *) return 1 ;; + esac +} +unresolved=() +while IFS= read -r path; do + [ -n "$path" ] || continue + generated "$path" || unresolved+=("$path") + if git cat-file -e "HEAD:$path" 2>/dev/null; then + git checkout --quiet HEAD -- "$path" + else + git rm --quiet --cached --ignore-unmatch -- "$path" + rm -f -- "$path" + fi +done < <(git diff --name-only --diff-filter=U) + +projections=(SPEC.md model/ids.toml model/errors.toml model/ledger.toml model/authorities.toml) +if ! git cat-file -e "$source:spec/src" 2>/dev/null; then + # The projections the next line writes from its modules keep nothing of the + # pushed line's own text but what the port carries into the modules. + git checkout --quiet HEAD -- "${projections[@]}" + scratch=$(mktemp -d) + portable=true + for path in SPEC.md model/ids.toml; do + name=${path##*/} + git show "$base:$path" >"$scratch/base-$name" + git show "HEAD:$path" >"$scratch/next-$name" + git show "$source:$path" >"$scratch/line-$name" + if ! git merge-file -p "$scratch/next-$name" "$scratch/base-$name" "$scratch/line-$name" >"$scratch/$name"; then + unresolved+=("$path (both lines changed one hunk)") + portable=false + fi + done + for path in model/errors.toml model/ledger.toml model/authorities.toml; do + if ! git diff --quiet "$base" "$source" -- "$path"; then + unresolved+=("$path (changed on $line; its module is edited by hand)") + fi + done + if [ "$portable" = true ] && ! git diff --quiet "$base" "$source" -- SPEC.md model/ids.toml; then + args=(--merged "$scratch/SPEC.md") + git diff --quiet "$base" "$source" -- model/ids.toml || args+=(--register "$scratch/ids.toml") + if ! cargo xtask spec port "${args[@]}" 2>&1 | tee "$scratch/port.txt"; then + unresolved+=("spec/src (the port refused: $(tail -1 "$scratch/port.txt"))") + git checkout --quiet HEAD -- spec/ "${projections[@]}" + fi + fi + rm -rf "$scratch" +fi +# A lock that took the next line's side gains what the merged manifests add. +cargo metadata --format-version 1 >/dev/null +git add --all + +clean=true +[ "${#unresolved[@]}" -eq 0 ] || clean=false +{ + printf 'Merge %s into %s\n\n' "$line" "$next" + printf 'Forward merge of %s at %s (forward.yml).\n' "$line" "$source" + if [ "$clean" = false ]; then + printf '\nCommitted as the side of %s, to finish by hand:\n' "$next" + printf -- '- %s\n' "${unresolved[@]}" + fi +} >"${RUNNER_TEMP:-/tmp}/forward-message" +git commit --quiet --no-verify -F "${RUNNER_TEMP:-/tmp}/forward-message" +git push --quiet origin "HEAD:refs/heads/$branch" +commit=$(git rev-parse HEAD) +{ + echo "branch=$branch" + echo "commit=$commit" + echo "clean=$clean" +} >>"$output" + +title="Forward-merge $line (${source:0:8}) into $next" +if [ "$clean" = true ]; then + body="Merges \`$line\` at \`$source\` into \`$next\` (SPEC.md §9.4; opened by \`forward.yml\`). \`regenerate.yml\` writes the generated projections and locks from the merged tree, delivers them here, and dispatches the gate. Land it with a merge commit." + draft=() +else + body="Merges \`$line\` at \`$source\` into \`$next\` (SPEC.md §9.4; opened by \`forward.yml\`). These paths are committed as \`$next\`'s side and are finished by hand before this is ready; then push the head to \`regenerate/\`:"$'\n\n'"$(printf -- '- `%s`\n' "${unresolved[@]}")" + draft=(--draft) +fi +if url=$(gh pr create --repo "$repo" --base "$next" --head "$branch" "${draft[@]}" \ + --title "$title" --body "$body" 2>&1); then + say "Opened $url" +else + # The repository may not let the workflow token open pull requests. + echo "::warning::no pull request opened ($url)" + say "Open the pull request: $GITHUB_SERVER_URL/$repo/compare/$next...$branch" + url="$branch" +fi +[ "$clean" = true ] || say "Finish by hand: $(printf '`%s` ' "${unresolved[@]}")" + +gh pr list --repo "$repo" --base "$next" --state open --json number,headRefName \ + --jq ".[] | select(.headRefName | startswith(\"$prefix\")) | select(.headRefName != \"$branch\") | .number" | + while read -r older; do + gh pr close "$older" --repo "$repo" --delete-branch --comment "Superseded by $url." || + echo "::warning::#$older not closed" + done diff --git a/.github/workflows/forward.yml b/.github/workflows/forward.yml new file mode 100644 index 0000000000..67b4096962 --- /dev/null +++ b/.github/workflows/forward.yml @@ -0,0 +1,63 @@ +# The forward merge of a release line (SPEC.md §9.4): every push to +# `release/vX.Y` is merged, by merge commit, into `release/vX.(Y+1)` when that +# line exists, on the branch `forward/vXY-to-vX(Y+1)-`, with its pull +# request (`.github/scripts/forward-merge.sh`). A merge whose conflicts lie in +# generated projections and locks is opened ready, and `regenerate.yml` writes +# those files from the merged tree, delivers them to the branch, and +# dispatches the gate there. Any other conflict is committed as the next +# line's side and opened as a draft naming its paths, for an agent to finish +# and push to `regenerate/`. A newer push to the line cancels a run still +# working and closes the older forward pull request. +name: forward + +on: + push: + branches: ["release/**"] + +permissions: + contents: read + +concurrency: + group: forward-${{ github.ref }} + cancel-in-progress: true + +jobs: + merge: + name: forward merge + if: github.repository == 'UOR-Foundation/LexLean' + runs-on: ubuntu-24.04 + timeout-minutes: 30 + permissions: + contents: write + pull-requests: write + outputs: + branch: ${{ steps.merge.outputs.branch }} + commit: ${{ steps.merge.outputs.commit }} + clean: ${{ steps.merge.outputs.clean }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + - name: Install the pinned Rust toolchain + run: rustup toolchain install + - name: Merge the line into the next and open the pull request + id: merge + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + run: .github/scripts/forward-merge.sh + + regenerate: + name: regenerate + needs: merge + if: needs.merge.outputs.clean == 'true' + uses: ./.github/workflows/regenerate.yml + # A reusable workflow is validated against what its caller grants before + # any of its jobs starts: `deliver` pushes and dispatches. + permissions: + contents: write + actions: write + pull-requests: read + with: + ref: ${{ needs.merge.outputs.commit }} + branch: ${{ needs.merge.outputs.branch }} diff --git a/AGENTS.md b/AGENTS.md index 39de274e8c..4b5d13213b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -120,6 +120,8 @@ head is an open pull request's, `regenerate.yml` commits the result to the pull request and restarts the gate there. A release `X.Y.Z` is cut by `git push origin release/vX.Y:refs/heads/cut/vX.Y.Z`; merging the pull request `cut.yml` opens tags and publishes it (`tag.yml`, `release.yml`). +Each push to a release line opens its forward merge into the next line +(`forward.yml`); a draft one names the conflicts left to finish by hand. A pull request that is final is marked ready with auto-merge on (`gh pr merge --auto --merge`), so it lands when its gate passes and its branch is deleted on merge. diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b88dae65c..5a704a247f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,12 @@ workspace carried at those versions without a tag. ## Unreleased +- Each push to a release line is merged forward by `forward.yml` (SPEC.md §9.4, `RP-14`): + the push is merged into the next line on `forward/vXY-to-vX(Y+1)-`, a conflict in a + generated projection or a lock takes the next line's side for `regenerate.yml` to rewrite, + SPEC.md and register changes of a line without `spec/` are carried into the next line's + modules by `cargo xtask spec port --register`, and any other conflict opens the pull + request as a draft naming its paths. A newer push supersedes the older forward branch. - Canonical JSON refuses duplicate keys that differ only in their escapes (SPEC.md §21.7, `AR-11`, #475). The duplicate check compared each key as written, so `{"a":1,"\u0061":2}` passed it and `Json::parse` returned `{"a":2}`, dropping the first member; keys are now diff --git a/SPEC.md b/SPEC.md index c2d7da9cc7..0c46fd3708 100644 --- a/SPEC.md +++ b/SPEC.md @@ -689,10 +689,12 @@ Its image MUST install the pinned Rust and Lean toolchains at build, so that not `ci.yml` MUST run every recipe of `just vv` from a clean checkout on Linux x86-64. It MUST install the exact Rust toolchain, Lean 4.32.1 through `elan`, `just`, and `cargo-deny`. -**What a run is.** `ci.yml` starts with the job `plan`, which decides from the event and the repository alone, through `.github/ci-plan.sh`, what the run is before any job that costs a runner starts. A pull request that is a draft runs the initial honesty part then the `rest` leg: a head pushed again before it is final costs these two jobs and not the full gate, the run is a development signal, and a draft is not mergeable on it; marking the pull request ready, and every push to it after, run the whole gate. So is a ready pull request whose base branch is neither `main` nor a `release/*` line (a stacked pull request, whose base is another feature branch): only a pull request into `main` or a release line can land on a line, that pull request runs the whole gate on the tree it lands, and the stacked run says in its step summary that the base is why it runs honesty then the `rest` leg. A ready pull request into `main` or a release line, a `workflow_dispatch`, and a push to `main` or to a release line are the whole gate, every job below. A `workflow_dispatch` on the head branch of exactly one open pull request of this repository is planned as that pull request, by its draft flag and base, because `regenerate.yml` commits to that branch with the workflow token, whose push starts no `pull_request` run, and dispatches the gate there instead; a dispatch on any other branch, or one whose pull request the plan cannot read, is the whole gate. A dispatch planned as a ready pull request whose head's tree such a run already verified, by the same walk down equal-tree merges from the head itself, runs no job but the plan, which records the run. One push to `main` or to a release line is not: when it is a merge commit whose tree is the tree of its second parent (a pull request head that already contained `main`) and a run of this workflow passed every job for that parent as a pull request of this repository or dispatched on its branch (or, while the parent is itself a merge whose tree is its second parent's, for that second parent, at most four merges down, as when a release merge that landed a regenerated head is carried to `main`), with none skipped, the join of Atlas, every host of §8.3, and every leg of `.github/vv-rows.json` among them, the push runs no job but the plan, which records the run: the tree it lands is byte for byte the tree that run verified, on the same runners and with the same pins. Any other push to `main` or to a release line, including one the plan cannot decide (a failed query, no run, a run of a draft, a merge that changed the tree, a push that is no merge), is the whole gate. `release.yml` consumes the complete same-tree gate evidence described below. `RP-14` runs the script against planted events, among them a ready pull request into a feature branch, into a release line, and into `main`, and a dispatch on a draft's head, on a ready head, and on a branch with no pull request, and a plant in it fails the case, and reads the CI and reproducibility workflows' push triggers, which name `main` and `release/**`. +**What a run is.** `ci.yml` starts with the job `plan`, which decides from the event and the repository alone, through `.github/ci-plan.sh`, what the run is before any job that costs a runner starts. A pull request that is a draft runs the initial honesty part then the `rest` leg: a head pushed again before it is final costs these two jobs and not the full gate, the run is a development signal, and a draft is not mergeable on it; marking the pull request ready, and every push to it after, run the whole gate. So is a ready pull request whose base branch is neither `main` nor a `release/*` line (a stacked pull request, whose base is another feature branch): only a pull request into `main` or a release line can land on a line, that pull request runs the whole gate on the tree it lands, and the stacked run says in its step summary that the base is why it runs honesty then the `rest` leg. A ready pull request into `main` or a release line, a `workflow_dispatch`, and a push to `main` or to a release line are the whole gate, every job below. A `workflow_dispatch` on the head branch of exactly one open pull request of this repository is planned as that pull request, by its draft flag and base, because `regenerate.yml` commits to that branch with the workflow token, whose push starts no `pull_request` run, and dispatches the gate there instead; a dispatch on any other branch, or one whose pull request the plan cannot read, is the whole gate. A dispatch planned as a ready pull request whose head's tree such a run already verified, by the same walk down equal-tree merges from the head itself, runs no job but the plan, which records the run. One push to `main` or to a release line is not: when it is a merge commit whose tree is the tree of its second parent (a pull request head that already contained `main`) and a run of this workflow passed every job for that parent as a pull request of this repository or dispatched on its branch (or, while the parent is itself a merge whose tree is its second parent's, for that second parent, at most four merges down, as when a release merge that landed a regenerated head is carried to `main`), with none skipped, the join of Atlas, every host of §8.3, and every leg of `.github/vv-rows.json` among them, the push runs no job but the plan, which records the run: the tree it lands is byte for byte the tree that run verified, on the same runners and with the same pins. Any other push to `main` or to a release line, including one the plan cannot decide (a failed query, no run, a run of a draft, a merge that changed the tree, a push that is no merge), is the whole gate. `release.yml` consumes the complete same-tree gate evidence described below. `RP-14` runs the script against planted events, among them a ready pull request into a feature branch, into a release line, and into `main`, and a dispatch on a draft's head, on a ready head, and on a branch with no pull request, and a plant in it fails the case, and reads the CI and reproducibility workflows' push triggers, which name `main` and `release/**`, and the forward merge's, which names `release/**`, with the regeneration it calls on the forward branch. **Release lines.** A release line is the branch `release/vX.Y` of the release X.Y: it is cut from `main` when work on X.Y begins, every pull request for the milestone X.Y targets it, each `vX.Y.Z` tag is made from it, and it is merged forward, by merge commit, into the next release line after each landing so that the next line carries every fix of the one before it. `main` is the newest released line: a release line is merged into `main` when its release is tagged, and nothing else lands on `main`. A release line is held to the same gate as `main`: a push to it is the whole gate under the rule above, and a pull request against it is a pull request of this repository. +**Forward merges.** `forward.yml` makes the forward merge of a line on every push to it: when `release/vX.(Y+1)` exists and does not contain the pushed commit, `.github/scripts/forward-merge.sh` merges the commit, by merge commit, into the head of `release/vX.(Y+1)` on the branch `forward/vXY-to-vX(Y+1)-`, pushes it, and opens its pull request into `release/vX.(Y+1)`. A conflict in a generated projection or a lock (`SPEC.md`, the files of `model/`, CONFORMANCE.md, ERRORS.md, `Cargo.lock`, a `lexlean.lock`, an `expected/` oracle, the golden files, the production-export packages, `tests/stack-bounds.json`) takes the next line's side, because `regenerate.yml` writes those files again. While the pushed line has no `spec/`, the next line's projections are written from its modules, so what the line changed in SPEC.md and `model/ids.toml` is merged against their merge base and carried into the modules by `cargo xtask spec port --merged --register `; the port refuses an added or removed register row, which is written in its module by hand. Every other conflict, a hunk both lines changed, a change of another model file, and a refused port are committed as the next line's side, and the pull request is opened as a draft naming each, for the change to be finished by hand and regenerated through `regenerate/`. Otherwise the pull request is opened ready and `regenerate.yml` is called on the merge with the branch named, so `deliver` commits the regenerated tree there and dispatches the gate, which verifies the merge as it does any pull request into the line. When the workflow token may not open pull requests, the step summary names the compare link instead, as `cut.yml`'s does. A newer push to the line cancels a forward run still working and closes the open forward pull request of an older commit, deleting its branch. + **Cutting a release.** A release `X.Y.Z` is cut by one push of the line's head to the branch `cut/vX.Y.Z`. `cut.yml` refuses a name that is not a version, a commit not on `release/vX.Y`, and a version already tagged; it runs `cargo xtask bump-version X.Y.Z`, which moves every site of the workspace version together (the `[workspace.package]` version and the workspace's path dependencies in `Cargo.toml`, the §2.3 block above, the identity literals of `RP-01` and `RP-12`, the changelog's `## Unreleased` heading, which becomes `## X.Y.Z`, and the workspace rows of `Cargo.lock`), refuses to write anything when a site does not read as it expects or the version does not follow the workspace's, and puts every file back when the lock cannot be updated, commits that on the pushed commit, opens the pull request into the line, and calls `regenerate.yml` on the commit, which writes what the version moves and delivers it to the branch. Merging that pull request is the decision to release. `tag.yml` runs on every push to a release line and stops at once unless the push changed the workspace version from its first parent's to one with no tag and a `## X.Y.Z` changelog entry; then it waits for this push's run of `ci.yml`, and only when that run passed it tags the commit `vX.Y.Z`, dispatches `release.yml` on the tag (a tag pushed with the workflow token starts no run), opens the pull request that merges the line into `main`, dispatches `ci.yml` on the line (a pull request opened with the workflow token starts no run), whose plan finds the run that verified the tagged tree and runs nothing again, and enables auto-merge, since the line contains `main` and the merge lands that tree. A tag pushed by hand starts `release.yml` itself; nothing here changes what a release publishes or what evidence it requires. **The release's evidence.** `release.yml` runs no recipe of the gate. The CI evidence a release attaches (§30.3) is a run of `ci.yml` that was the whole gate and passed every job, on the tagged commit or, while the commit is a merge whose tree is the tree of its second parent, on that parent, at most four merges down (the walk the plan makes); `.github/release-gate.sh` finds it under the rule `plan` applies to a push, and refuses, naming the commits it looked at, when no such run exists. The evidence names the run, every job of it with its conclusion, and the transcript of every leg the run still retains. The gate run whole on one hosted runner exceeds the six-hour job limit (the `bdd` recipe alone takes over four hours there, and Atlas follows it), so a release gate that re-ran it would never conclude, and the run of the line has already verified the tree. diff --git a/crates/conformance/src/cases/repository.rs b/crates/conformance/src/cases/repository.rs index d7c2dd69d3..622c47b940 100644 --- a/crates/conformance/src/cases/repository.rs +++ b/crates/conformance/src/cases/repository.rs @@ -2251,6 +2251,30 @@ pub(crate) fn run(id: &str) { "§9.4: {workflow} runs on a push to `main` and to a release line" ); } + // §9.4: the forward merge runs on every push to a release line, + // superseded by a newer one, and hands its merge to the + // regeneration on the forward branch, whose `deliver` commits there. + let forward = root_file(".github/workflows/forward.yml"); + for needed in [ + " push:\n branches: [\"release/**\"]\n", + " group: forward-${{ github.ref }}\n cancel-in-progress: true\n", + "run: .github/scripts/forward-merge.sh", + "uses: ./.github/workflows/regenerate.yml", + "ref: ${{ needs.merge.outputs.commit }}", + "branch: ${{ needs.merge.outputs.branch }}", + ] { + assert!(forward.contains(needed), "§9.4: forward.yml has `{needed}`"); + } + let merge = root_file(".github/scripts/forward-merge.sh"); + for needed in [ + "git merge --quiet --no-ff --no-commit", + "cargo xtask spec port", + "--register", + "--draft", + "compare/$next...$branch", + ] { + assert!(merge.contains(needed), "§9.4: forward-merge.sh has `{needed}`"); + } for forbidden in [ "actions/cache", "paths:", From 47cf763d1df1d3fd3301537473df0f016b48b4d7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:07:19 +0000 Subject: [PATCH 2/5] Format the RP-14 forward-merge assertion Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3M8ULnzEQwLLngyBBX --- crates/conformance/src/cases/repository.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/conformance/src/cases/repository.rs b/crates/conformance/src/cases/repository.rs index 622c47b940..0c1da11d4e 100644 --- a/crates/conformance/src/cases/repository.rs +++ b/crates/conformance/src/cases/repository.rs @@ -2273,7 +2273,10 @@ pub(crate) fn run(id: &str) { "--draft", "compare/$next...$branch", ] { - assert!(merge.contains(needed), "§9.4: forward-merge.sh has `{needed}`"); + assert!( + merge.contains(needed), + "§9.4: forward-merge.sh has `{needed}`" + ); } for forbidden in [ "actions/cache", From c3cb736e651506f256b1cbf36053b504242357a7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:00:50 +0000 Subject: [PATCH 3/5] Take a side only of generated outputs; supersede only bot-only branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review of #543 (two P1s): - A conflict takes the next line's side only in what a writer or `cargo metadata` writes: the projections, CONFORMANCE.md, ERRORS.md, the locks, `expected/` oracles, the golden files and the packages under `tests/production-export/*/packages/`. An export's `roots.json` and a measured row of `tests/stack-bounds.json` are authored writer inputs, so their conflict is listed and opens a draft. - An older forward pull request is closed, with its branch, only when the branch holds no commit beyond the next line and the pushed head but the bot's merge and the regeneration delivered on it, and only once the new pull request is open. Any other is left open and linked from the new one. `forward.yml` also takes a `workflow_call` with the line, since a merge made with the workflow token (#519's `land`) starts no push run, and its concurrency moves to the merge job so a newer push never cancels a caller's run. SPEC.md §9.4, CHANGELOG.md and the RP-14 case follow. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3M8ULnzEQwLLngyBBX --- .github/scripts/forward-merge.sh | 55 +++++++++++++++++----- .github/workflows/forward.yml | 19 ++++++-- CHANGELOG.md | 5 +- SPEC.md | 2 +- crates/conformance/src/cases/repository.rs | 17 ++++++- 5 files changed, 78 insertions(+), 20 deletions(-) diff --git a/.github/scripts/forward-merge.sh b/.github/scripts/forward-merge.sh index 9be2304674..c0ff6fb624 100755 --- a/.github/scripts/forward-merge.sh +++ b/.github/scripts/forward-merge.sh @@ -13,7 +13,7 @@ # the pull request is opened as a draft naming the paths, for an agent to # finish. A newer forward branch of the same lines closes the older ones. # -# Inputs, from the environment: REPO, GITHUB_REF_NAME (the pushed line), the +# Inputs, from the environment: REPO, LINE or GITHUB_REF_NAME (the line), the # checkout (the pushed commit, full history, the workflow token), GITHUB_OUTPUT, # GITHUB_STEP_SUMMARY, GITHUB_SERVER_URL. Outputs: branch, commit, clean. set -euo pipefail @@ -23,7 +23,7 @@ summary=${GITHUB_STEP_SUMMARY:-/dev/null} output=${GITHUB_OUTPUT:-/dev/null} say() { printf '%s\n' "$1" | tee -a "$summary"; } -line=${GITHUB_REF_NAME:?GITHUB_REF_NAME names the pushed line} +line=${LINE:-${GITHUB_REF_NAME:?LINE or GITHUB_REF_NAME names the pushed line}} if ! [[ "$line" =~ ^release/v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then say "\`$line\` is not a release line: nothing to carry forward." exit 0 @@ -58,10 +58,14 @@ git rev-parse --verify --quiet MERGE_HEAD >/dev/null || { exit 1 } +# Only what a writer of §9.2 or `cargo metadata` writes from the merged tree. +# What a writer reads (an export's `roots.json`, a measured row of +# `tests/stack-bounds.json`) is authored, and a conflict in it is listed. generated() { case "$1" in - SPEC.md | model/*.toml | CONFORMANCE.md | ERRORS.md | Cargo.lock | lexlean.lock | */lexlean.lock \ - | */expected/* | tests/golden/* | tests/production-export/* | tests/stack-bounds.json) return 0 ;; + SPEC.md | model/ids.toml | model/errors.toml | model/ledger.toml | model/authorities.toml \ + | CONFORMANCE.md | ERRORS.md | Cargo.lock | lexlean.lock | */lexlean.lock | */expected/* \ + | tests/golden/*.txt | tests/production-export/*/packages/*) return 0 ;; *) return 1 ;; esac } @@ -132,6 +136,29 @@ commit=$(git rev-parse HEAD) echo "clean=$clean" } >>"$output" +# An older forward pull request of these lines is superseded only when its +# branch holds nothing but what this run makes again: the bot's merge and the +# bot's regeneration on it. One carrying any other commit (a conflict finished +# by hand) stays open, linked from the new one, until its work is carried. +bot_pattern='41898282\+github-actions\[bot\]@users\.noreply\.github\.com' +superseded=() +kept=() +while read -r number ref; do + [ -n "$number" ] || continue + if ! git fetch --quiet origin "refs/heads/$ref:refs/remotes/origin/$ref"; then + kept+=("$number") + continue + fi + extra=$(git log --format='%ae %s' "origin/$ref" --not "origin/$next" "$source" | + grep -v -x -E "$bot_pattern (Merge release/v[0-9.]+ into release/v[0-9.]+|Regenerate the written outputs of [0-9a-f]+)" || true) + if [ -z "$extra" ]; then + superseded+=("$number") + else + kept+=("$number") + fi +done < <(gh pr list --repo "$repo" --base "$next" --state open --json number,headRefName \ + --jq ".[] | select(.headRefName | startswith(\"$prefix\")) | select(.headRefName != \"$branch\") | \"\\(.number) \\(.headRefName)\"") + title="Forward-merge $line (${source:0:8}) into $next" if [ "$clean" = true ]; then body="Merges \`$line\` at \`$source\` into \`$next\` (SPEC.md §9.4; opened by \`forward.yml\`). \`regenerate.yml\` writes the generated projections and locks from the merged tree, delivers them here, and dispatches the gate. Land it with a merge commit." @@ -140,20 +167,22 @@ else body="Merges \`$line\` at \`$source\` into \`$next\` (SPEC.md §9.4; opened by \`forward.yml\`). These paths are committed as \`$next\`'s side and are finished by hand before this is ready; then push the head to \`regenerate/\`:"$'\n\n'"$(printf -- '- `%s`\n' "${unresolved[@]}")" draft=(--draft) fi +if [ "${#kept[@]}" -gt 0 ]; then + body+=$'\n\n'"Older forward pull requests with work not yet in \`$next\`, left open: $(printf '#%s ' "${kept[@]}")" +fi if url=$(gh pr create --repo "$repo" --base "$next" --head "$branch" "${draft[@]}" \ --title "$title" --body "$body" 2>&1); then say "Opened $url" else - # The repository may not let the workflow token open pull requests. + # The repository may not let the workflow token open pull requests. With + # no replacement open, nothing older is closed. echo "::warning::no pull request opened ($url)" say "Open the pull request: $GITHUB_SERVER_URL/$repo/compare/$next...$branch" - url="$branch" + superseded=() fi [ "$clean" = true ] || say "Finish by hand: $(printf '`%s` ' "${unresolved[@]}")" - -gh pr list --repo "$repo" --base "$next" --state open --json number,headRefName \ - --jq ".[] | select(.headRefName | startswith(\"$prefix\")) | select(.headRefName != \"$branch\") | .number" | - while read -r older; do - gh pr close "$older" --repo "$repo" --delete-branch --comment "Superseded by $url." || - echo "::warning::#$older not closed" - done +[ "${#kept[@]}" -eq 0 ] || say "Left open, with work not yet in \`$next\`: $(printf '#%s ' "${kept[@]}")" +for older in "${superseded[@]}"; do + gh pr close "$older" --repo "$repo" --delete-branch --comment "Superseded by $url." || + echo "::warning::#$older not closed" +done diff --git a/.github/workflows/forward.yml b/.github/workflows/forward.yml index 67b4096962..fd9a2c4298 100644 --- a/.github/workflows/forward.yml +++ b/.github/workflows/forward.yml @@ -13,20 +13,29 @@ name: forward on: push: branches: ["release/**"] + # A merge made with the workflow token starts no push run, so a workflow + # that lands on a line itself (`cut.yml`) calls this one with the line. + workflow_call: + inputs: + line: + description: The release line whose head is carried forward + type: string + required: true permissions: contents: read -concurrency: - group: forward-${{ github.ref }} - cancel-in-progress: true - jobs: merge: name: forward merge if: github.repository == 'UOR-Foundation/LexLean' runs-on: ubuntu-24.04 timeout-minutes: 30 + # On the job, not the workflow: a call from `cut.yml` is part of the + # caller's run, which a newer push to the line must not cancel. + concurrency: + group: forward-${{ inputs.line || github.ref_name }} + cancel-in-progress: true permissions: contents: write pull-requests: write @@ -37,6 +46,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + ref: ${{ inputs.line || github.sha }} fetch-depth: 0 - name: Install the pinned Rust toolchain run: rustup toolchain install @@ -45,6 +55,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} REPO: ${{ github.repository }} + LINE: ${{ inputs.line || github.ref_name }} run: .github/scripts/forward-merge.sh regenerate: diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a704a247f..b460394206 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,10 @@ workspace carried at those versions without a tag. generated projection or a lock takes the next line's side for `regenerate.yml` to rewrite, SPEC.md and register changes of a line without `spec/` are carried into the next line's modules by `cargo xtask spec port --register`, and any other conflict opens the pull - request as a draft naming its paths. A newer push supersedes the older forward branch. + request as a draft naming its paths, an authored writer input such as an export's + `roots.json` among them. A newer push closes an older forward pull request only when its + branch holds nothing but the workflow's merge and regeneration, and only once the new one + is open; one with work finished by hand stays open and is linked. - Canonical JSON refuses duplicate keys that differ only in their escapes (SPEC.md §21.7, `AR-11`, #475). The duplicate check compared each key as written, so `{"a":1,"\u0061":2}` passed it and `Json::parse` returned `{"a":2}`, dropping the first member; keys are now diff --git a/SPEC.md b/SPEC.md index 0c46fd3708..735f0c945b 100644 --- a/SPEC.md +++ b/SPEC.md @@ -693,7 +693,7 @@ Its image MUST install the pinned Rust and Lean toolchains at build, so that not **Release lines.** A release line is the branch `release/vX.Y` of the release X.Y: it is cut from `main` when work on X.Y begins, every pull request for the milestone X.Y targets it, each `vX.Y.Z` tag is made from it, and it is merged forward, by merge commit, into the next release line after each landing so that the next line carries every fix of the one before it. `main` is the newest released line: a release line is merged into `main` when its release is tagged, and nothing else lands on `main`. A release line is held to the same gate as `main`: a push to it is the whole gate under the rule above, and a pull request against it is a pull request of this repository. -**Forward merges.** `forward.yml` makes the forward merge of a line on every push to it: when `release/vX.(Y+1)` exists and does not contain the pushed commit, `.github/scripts/forward-merge.sh` merges the commit, by merge commit, into the head of `release/vX.(Y+1)` on the branch `forward/vXY-to-vX(Y+1)-`, pushes it, and opens its pull request into `release/vX.(Y+1)`. A conflict in a generated projection or a lock (`SPEC.md`, the files of `model/`, CONFORMANCE.md, ERRORS.md, `Cargo.lock`, a `lexlean.lock`, an `expected/` oracle, the golden files, the production-export packages, `tests/stack-bounds.json`) takes the next line's side, because `regenerate.yml` writes those files again. While the pushed line has no `spec/`, the next line's projections are written from its modules, so what the line changed in SPEC.md and `model/ids.toml` is merged against their merge base and carried into the modules by `cargo xtask spec port --merged --register `; the port refuses an added or removed register row, which is written in its module by hand. Every other conflict, a hunk both lines changed, a change of another model file, and a refused port are committed as the next line's side, and the pull request is opened as a draft naming each, for the change to be finished by hand and regenerated through `regenerate/`. Otherwise the pull request is opened ready and `regenerate.yml` is called on the merge with the branch named, so `deliver` commits the regenerated tree there and dispatches the gate, which verifies the merge as it does any pull request into the line. When the workflow token may not open pull requests, the step summary names the compare link instead, as `cut.yml`'s does. A newer push to the line cancels a forward run still working and closes the open forward pull request of an older commit, deleting its branch. +**Forward merges.** `forward.yml` makes the forward merge of a line on every push to it, and when a workflow that merges onto the line with the workflow token, whose merge starts no push run, calls it with the line: when `release/vX.(Y+1)` exists and does not contain the pushed commit, `.github/scripts/forward-merge.sh` merges the commit, by merge commit, into the head of `release/vX.(Y+1)` on the branch `forward/vXY-to-vX(Y+1)-`, pushes it, and opens its pull request into `release/vX.(Y+1)`. A conflict in a generated projection or a lock (`SPEC.md`, the five projected files of `model/`, CONFORMANCE.md, ERRORS.md, `Cargo.lock`, a `lexlean.lock`, an `expected/` oracle, the golden files, the packages under `tests/production-export/*/packages/`) takes the next line's side, because `regenerate.yml` writes those files again; a file a writer reads rather than writes, such as an export's `roots.json` or a measured row of `tests/stack-bounds.json`, is authored, and its conflict is listed like any other. While the pushed line has no `spec/`, the next line's projections are written from its modules, so what the line changed in SPEC.md and `model/ids.toml` is merged against their merge base and carried into the modules by `cargo xtask spec port --merged --register `; the port refuses an added or removed register row, which is written in its module by hand. Every other conflict, a hunk both lines changed, a change of another model file, and a refused port are committed as the next line's side, and the pull request is opened as a draft naming each, for the change to be finished by hand and regenerated through `regenerate/`. Otherwise the pull request is opened ready and `regenerate.yml` is called on the merge with the branch named, so `deliver` commits the regenerated tree there and dispatches the gate, which verifies the merge as it does any pull request into the line. When the workflow token may not open pull requests, the step summary names the compare link instead, as `cut.yml`'s does. A newer push to the line cancels a forward merge job still working. Once the new pull request is open, it closes an open forward pull request of an older commit and deletes its branch only when that branch holds no commit but the workflow's merge and the regeneration delivered on it; one that carries any other commit, such as a conflict finished by hand, stays open and is named in the new pull request, and when no new pull request could be opened nothing older is closed. **Cutting a release.** A release `X.Y.Z` is cut by one push of the line's head to the branch `cut/vX.Y.Z`. `cut.yml` refuses a name that is not a version, a commit not on `release/vX.Y`, and a version already tagged; it runs `cargo xtask bump-version X.Y.Z`, which moves every site of the workspace version together (the `[workspace.package]` version and the workspace's path dependencies in `Cargo.toml`, the §2.3 block above, the identity literals of `RP-01` and `RP-12`, the changelog's `## Unreleased` heading, which becomes `## X.Y.Z`, and the workspace rows of `Cargo.lock`), refuses to write anything when a site does not read as it expects or the version does not follow the workspace's, and puts every file back when the lock cannot be updated, commits that on the pushed commit, opens the pull request into the line, and calls `regenerate.yml` on the commit, which writes what the version moves and delivers it to the branch. Merging that pull request is the decision to release. `tag.yml` runs on every push to a release line and stops at once unless the push changed the workspace version from its first parent's to one with no tag and a `## X.Y.Z` changelog entry; then it waits for this push's run of `ci.yml`, and only when that run passed it tags the commit `vX.Y.Z`, dispatches `release.yml` on the tag (a tag pushed with the workflow token starts no run), opens the pull request that merges the line into `main`, dispatches `ci.yml` on the line (a pull request opened with the workflow token starts no run), whose plan finds the run that verified the tagged tree and runs nothing again, and enables auto-merge, since the line contains `main` and the merge lands that tree. A tag pushed by hand starts `release.yml` itself; nothing here changes what a release publishes or what evidence it requires. diff --git a/crates/conformance/src/cases/repository.rs b/crates/conformance/src/cases/repository.rs index 0c1da11d4e..17503bdab8 100644 --- a/crates/conformance/src/cases/repository.rs +++ b/crates/conformance/src/cases/repository.rs @@ -2257,7 +2257,8 @@ pub(crate) fn run(id: &str) { let forward = root_file(".github/workflows/forward.yml"); for needed in [ " push:\n branches: [\"release/**\"]\n", - " group: forward-${{ github.ref }}\n cancel-in-progress: true\n", + " group: forward-${{ inputs.line || github.ref_name }}\n cancel-in-progress: true\n", + " workflow_call:\n", "run: .github/scripts/forward-merge.sh", "uses: ./.github/workflows/regenerate.yml", "ref: ${{ needs.merge.outputs.commit }}", @@ -2266,12 +2267,26 @@ pub(crate) fn run(id: &str) { assert!(forward.contains(needed), "§9.4: forward.yml has `{needed}`"); } let merge = root_file(".github/scripts/forward-merge.sh"); + // An authored writer input is never taken from one side unread. + for forbidden in [ + "tests/production-export/* ", + "tests/production-export/*)", + "tests/stack-bounds.json)", + ] { + assert!( + !merge.contains(forbidden), + "§9.4: forward-merge.sh takes no side of an authored input: `{forbidden}`" + ); + } for needed in [ "git merge --quiet --no-ff --no-commit", "cargo xtask spec port", "--register", "--draft", "compare/$next...$branch", + "tests/production-export/*/packages/*)", + "Regenerate the written outputs of", + "superseded=()", ] { assert!( merge.contains(needed), From 3dadb24473c4a34758afa8a676bf20876da2a010 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:59:30 +0000 Subject: [PATCH 4/5] Lease the delete of a superseded forward branch to its inspected head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The head each candidate had when the run read it is recorded, and its branch is deleted with --force-with-lease to that head, so a push since then refuses the delete. The older pull request is closed only after the delete succeeded; one whose branch moved or whose delete failed stays open with its branch and is named on the new pull request. SPEC.md §9.4 says so and RP-14 asserts the lease. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3M8ULnzEQwLLngyBBX --- .github/scripts/forward-merge.sh | 22 +++++++++++++++++++--- SPEC.md | 2 +- crates/conformance/src/cases/repository.rs | 3 +++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.github/scripts/forward-merge.sh b/.github/scripts/forward-merge.sh index c0ff6fb624..bfdd796f8e 100755 --- a/.github/scripts/forward-merge.sh +++ b/.github/scripts/forward-merge.sh @@ -152,7 +152,8 @@ while read -r number ref; do extra=$(git log --format='%ae %s' "origin/$ref" --not "origin/$next" "$source" | grep -v -x -E "$bot_pattern (Merge release/v[0-9.]+ into release/v[0-9.]+|Regenerate the written outputs of [0-9a-f]+)" || true) if [ -z "$extra" ]; then - superseded+=("$number") + # The head inspected here is the lease of its deletion below. + superseded+=("$number $ref $(git rev-parse "origin/$ref")") else kept+=("$number") fi @@ -182,7 +183,22 @@ else fi [ "$clean" = true ] || say "Finish by hand: $(printf '`%s` ' "${unresolved[@]}")" [ "${#kept[@]}" -eq 0 ] || say "Left open, with work not yet in \`$next\`: $(printf '#%s ' "${kept[@]}")" +# A branch is deleted only while its head is still the one inspected (a lease: +# a push to it since then refuses the delete), and its pull request is closed +# only once that delete succeeded. Any other is kept and listed. +moved=() for older in "${superseded[@]}"; do - gh pr close "$older" --repo "$repo" --delete-branch --comment "Superseded by $url." || - echo "::warning::#$older not closed" + read -r number ref sha <<<"$older" + if git push --quiet --force-with-lease="refs/heads/$ref:$sha" origin ":refs/heads/$ref"; then + gh pr close "$number" --repo "$repo" --comment "Superseded by $url." || + gh pr comment "$number" --repo "$repo" --body "Superseded by $url." || + echo "::warning::#$number not closed" + else + moved+=("$number") + fi done +if [ "${#moved[@]}" -gt 0 ]; then + note="Older forward pull requests whose branch moved since this run read it, left open: $(printf '#%s ' "${moved[@]}")" + say "$note" + gh pr comment "$url" --repo "$repo" --body "$note" || true +fi diff --git a/SPEC.md b/SPEC.md index 214ab4b86c..f5e29df76b 100644 --- a/SPEC.md +++ b/SPEC.md @@ -693,7 +693,7 @@ Its image MUST install the pinned Rust and Lean toolchains at build, so that not **Release lines.** A release line is the branch `release/vX.Y` of the release X.Y: it is cut from `main` when work on X.Y begins, every pull request for the milestone X.Y targets it, each `vX.Y.Z` tag is made from it, and it is merged forward, by merge commit, into the next release line after each landing so that the next line carries every fix of the one before it. `main` is the newest released line: a release line is merged into `main` when its release is tagged, and nothing else lands on `main`. A release line is held to the same gate as `main`: a push to it is the whole gate under the rule above, and a pull request against it is a pull request of this repository. -**Forward merges.** `forward.yml` makes the forward merge of a line on every push to it, and when a workflow that merges onto the line with the workflow token, whose merge starts no push run, calls it with the line: when `release/vX.(Y+1)` exists and does not contain the pushed commit, `.github/scripts/forward-merge.sh` merges the commit, by merge commit, into the head of `release/vX.(Y+1)` on the branch `forward/vXY-to-vX(Y+1)-`, pushes it, and opens its pull request into `release/vX.(Y+1)`. A conflict in a generated projection or a lock (`SPEC.md`, the five projected files of `model/`, CONFORMANCE.md, ERRORS.md, `Cargo.lock`, a `lexlean.lock`, an `expected/` oracle, the golden files, the packages under `tests/production-export/*/packages/`) takes the next line's side, because `regenerate.yml` writes those files again; a file a writer reads rather than writes, such as an export's `roots.json` or a measured row of `tests/stack-bounds.json`, is authored, and its conflict is listed like any other. While the pushed line has no `spec/`, the next line's projections are written from its modules, so what the line changed in SPEC.md and `model/ids.toml` is merged against their merge base and carried into the modules by `cargo xtask spec port --merged --register `; the port refuses an added or removed register row, which is written in its module by hand. Every other conflict, a hunk both lines changed, a change of another model file, and a refused port are committed as the next line's side, and the pull request is opened as a draft naming each, for the change to be finished by hand and regenerated through `regenerate/`. Otherwise the pull request is opened ready and `regenerate.yml` is called on the merge with the branch named, so `deliver` commits the regenerated tree there and dispatches the gate, which verifies the merge as it does any pull request into the line. When the workflow token may not open pull requests, the step summary names the compare link instead, as `cut.yml`'s does. A newer push to the line cancels a forward merge job still working. Once the new pull request is open, it closes an open forward pull request of an older commit and deletes its branch only when that branch holds no commit but the workflow's merge and the regeneration delivered on it; one that carries any other commit, such as a conflict finished by hand, stays open and is named in the new pull request, and when no new pull request could be opened nothing older is closed. +**Forward merges.** `forward.yml` makes the forward merge of a line on every push to it, and when a workflow that merges onto the line with the workflow token, whose merge starts no push run, calls it with the line: when `release/vX.(Y+1)` exists and does not contain the pushed commit, `.github/scripts/forward-merge.sh` merges the commit, by merge commit, into the head of `release/vX.(Y+1)` on the branch `forward/vXY-to-vX(Y+1)-`, pushes it, and opens its pull request into `release/vX.(Y+1)`. A conflict in a generated projection or a lock (`SPEC.md`, the five projected files of `model/`, CONFORMANCE.md, ERRORS.md, `Cargo.lock`, a `lexlean.lock`, an `expected/` oracle, the golden files, the packages under `tests/production-export/*/packages/`) takes the next line's side, because `regenerate.yml` writes those files again; a file a writer reads rather than writes, such as an export's `roots.json` or a measured row of `tests/stack-bounds.json`, is authored, and its conflict is listed like any other. While the pushed line has no `spec/`, the next line's projections are written from its modules, so what the line changed in SPEC.md and `model/ids.toml` is merged against their merge base and carried into the modules by `cargo xtask spec port --merged --register `; the port refuses an added or removed register row, which is written in its module by hand. Every other conflict, a hunk both lines changed, a change of another model file, and a refused port are committed as the next line's side, and the pull request is opened as a draft naming each, for the change to be finished by hand and regenerated through `regenerate/`. Otherwise the pull request is opened ready and `regenerate.yml` is called on the merge with the branch named, so `deliver` commits the regenerated tree there and dispatches the gate, which verifies the merge as it does any pull request into the line. When the workflow token may not open pull requests, the step summary names the compare link instead, as `cut.yml`'s does. A newer push to the line cancels a forward merge job still working. Once the new pull request is open, it closes an open forward pull request of an older commit and deletes its branch only when that branch holds no commit but the workflow's merge and the regeneration delivered on it; one that carries any other commit, such as a conflict finished by hand, stays open and is named in the new pull request, and when no new pull request could be opened nothing older is closed. The delete is leased to the head the workflow inspected (`--force-with-lease`), so a branch pushed to since then refuses it, and the older pull request is closed only after its branch was deleted; one whose branch moved or whose delete failed stays open with its branch and is named on the new pull request. **Cutting a release.** A release `X.Y.Z` is cut by one push of the line's head to the branch `cut/vX.Y.Z`. `cut.yml` refuses a name that is not a version, a commit not on `release/vX.Y`, and a version already tagged; it runs `cargo xtask bump-version X.Y.Z`, which moves every site of the workspace version together (the `[workspace.package]` version and the workspace's path dependencies in `Cargo.toml`, the §2.3 block above, the identity literals of `RP-01` and `RP-12`, the changelog's `## Unreleased` heading, which becomes `## X.Y.Z`, and the workspace rows of `Cargo.lock`), refuses to write anything when a site does not read as it expects or the version does not follow the workspace's, and puts every file back when the lock cannot be updated, commits that on the pushed commit, opens the pull request into the line, and calls `regenerate.yml` on the commit, which writes what the version moves and delivers it to the branch. Merging that pull request is the decision to release. `tag.yml` runs on every push to a release line and stops at once unless the push changed the workspace version from its first parent's to one with no tag and a `## X.Y.Z` changelog entry; then it waits for this push's run of `ci.yml`, and only when that run passed it tags the commit `vX.Y.Z`, dispatches `release.yml` on the tag (a tag pushed with the workflow token starts no run), opens the pull request that merges the line into `main`, dispatches `ci.yml` on the line (a pull request opened with the workflow token starts no run), whose plan finds the run that verified the tagged tree and runs nothing again, and enables auto-merge, since the line contains `main` and the merge lands that tree. A tag pushed by hand starts `release.yml` itself; nothing here changes what a release publishes or what evidence it requires. diff --git a/crates/conformance/src/cases/repository.rs b/crates/conformance/src/cases/repository.rs index 12b0da2676..856c3ab0c9 100644 --- a/crates/conformance/src/cases/repository.rs +++ b/crates/conformance/src/cases/repository.rs @@ -2512,6 +2512,9 @@ pub(crate) fn run(id: &str) { "tests/production-export/*/packages/*)", "Regenerate the written outputs of", "superseded=()", + // The delete of a superseded branch is leased to the head + // inspected, and its pull request closes only after it. + "--force-with-lease=\"refs/heads/$ref:$sha\" origin \":refs/heads/$ref\"", ] { assert!( merge.contains(needed), From 2c39d3b13107d870ef93c5693e47bdc159c911ee Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 15 Nov 2026 00:10:25 +0000 Subject: [PATCH 5/5] Name the kept forward pull requests without a deferral phrase (R4) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3M8ULnzEQwLLngyBBX --- .github/scripts/forward-merge.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/forward-merge.sh b/.github/scripts/forward-merge.sh index bfdd796f8e..af7dc83c11 100755 --- a/.github/scripts/forward-merge.sh +++ b/.github/scripts/forward-merge.sh @@ -169,7 +169,7 @@ else draft=(--draft) fi if [ "${#kept[@]}" -gt 0 ]; then - body+=$'\n\n'"Older forward pull requests with work not yet in \`$next\`, left open: $(printf '#%s ' "${kept[@]}")" + body+=$'\n\n'"Older forward pull requests with work missing from \`$next\`, left open: $(printf '#%s ' "${kept[@]}")" fi if url=$(gh pr create --repo "$repo" --base "$next" --head "$branch" "${draft[@]}" \ --title "$title" --body "$body" 2>&1); then @@ -182,7 +182,7 @@ else superseded=() fi [ "$clean" = true ] || say "Finish by hand: $(printf '`%s` ' "${unresolved[@]}")" -[ "${#kept[@]}" -eq 0 ] || say "Left open, with work not yet in \`$next\`: $(printf '#%s ' "${kept[@]}")" +[ "${#kept[@]}" -eq 0 ] || say "Left open, with work missing from \`$next\`: $(printf '#%s ' "${kept[@]}")" # A branch is deleted only while its head is still the one inspected (a lease: # a push to it since then refuses the delete), and its pull request is closed # only once that delete succeeded. Any other is kept and listed.