Skip to content

Commit 330e5a6

Browse files
authored
Update the prompts I used to propagate changes and rebase the various feature PRs (#1692)
* Updates from trial run After completing all the work the first time, make the following corrections. * Experience with rebase prompt Update this prompt based on what was learned rebasing the C# 9 prompts. * Update prompts from experience Update the prompts to match the experience in updating the V11 PRs.
1 parent 88169c1 commit 330e5a6

2 files changed

Lines changed: 83 additions & 18 deletions

File tree

.github/prompts/post-meeting-propagate.prompt.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ You are propagating the changes merged into the current "starting" draft branch
1111

1212
- The committee secretary has already merged all approved PRs into the starting branch (default: `draft-v8`). Do **not** merge any other open PRs.
1313
- The `.github/workflows/update-on-merge.yaml` workflow will open an automated PR titled "Automated Section renumber and grammar extraction" on each branch that receives a push. These auto-PRs **must be merged** before the next propagation hop.
14+
- Auto-PRs may show a `BLOCKED` merge state due to branch protection rules requiring review approval — this is normal and not a CI failure. Wait for checks to pass, then merge.
1415
- You have `git` and `gh` available, and push permission to this repo.
1516

1617
## Propagation chain
@@ -19,17 +20,26 @@ Walk these branches in order. Each step merges the previous branch into the next
1920

2021
1. `draft-v8` (starting branch — no merge in; just merge its auto-PR)
2122
2. `draft-v9` ← merges `draft-v8`
22-
3. `v9-alpha` ← merges `draft-v9`
23-
4. `draft-v10` ← merges `v9-alpha`
24-
5. `v10-alpha` ← merges `draft-v10`
25-
6. `draft-v11` ← merges `v10-alpha`
23+
3. `alpha-v9` ← merges `draft-v9`
24+
4. `draft-10` ← merges `alpha-v9`
25+
5. `alpha-v10` ← merges `draft-10`
26+
6. `draft-v11` ← merges `alpha-v10`
2627
7. `v11-alpha` ← merges `draft-v11`
2728
8. `draft-v12` ← merges `v11-alpha`
2829

29-
> When new version branches are added (v12-alpha, draft-v13, etc.), append
30-
> them here in the same pattern: each `draft-v(N+1)` merges `vN-alpha`, and
31-
> each `vN-alpha` merges `draft-vN`. Also add the new branches to
30+
> **Branch-naming is inconsistent across versions** (e.g. `alpha-v9` vs
31+
> `v11-alpha`, `draft-10` vs `draft-v11`). Always verify actual branch
32+
> names with `git branch -r | grep upstream/` before starting.
33+
>
34+
> When new version branches are added, append them here using the actual
35+
> branch names on the remote. Also add any new branches to
3236
> `.github/workflows/update-on-merge.yaml` `on.push.branches`.
37+
>
38+
> Note: `update-on-merge.yaml` currently only triggers on `standard-v6`,
39+
> `standard-v7`, `draft-v8`, `draft-v9`, `draft-v11`, and `draft-v12`.
40+
> Alpha branches are **not** covered, so no auto-PR will appear on those
41+
> branches — the renumber/grammar tools must be run by a later merge into
42+
> the next draft branch.
3343
3444
If the user names a different starting branch, start there and propagate to
3545
every later branch in the list.
@@ -63,7 +73,8 @@ for the duration of the run.
6373
```bash
6474
for b in <chain>; do
6575
git --no-pager grep -nE '<!--[^>]*(vNext|v[0-9]+|future|upcoming|TODO)' \
66-
"origin/$b" -- 'standard/*.md' > /tmp/vnext-baseline-$b.txt || true
76+
"origin/$b" -- 'standard/*.md' | sed "s|^origin/$b:||" \
77+
> /tmp/vnext-baseline-$b.txt || true
6778
done
6879
```
6980

@@ -107,6 +118,13 @@ Before starting, confirm the chain with the user and show which branches will be
107118
prose in `standard/*.md`. Doing so can silently resurrect text the
108119
committee deleted on the downstream branch in this cycle or a prior
109120
one.
121+
- **Never use `git checkout --theirs <file>` or `git checkout --ours <file>`**
122+
to resolve conflicts — these commands replace the *entire file* with
123+
one side, not just the conflicted hunks, silently discarding all
124+
non-conflicting changes from the other side. Resolve each hunk
125+
individually in the conflict markers instead. If you accidentally
126+
run `checkout --theirs/--ours`, recover with `git checkout -m <file>`
127+
to restore the conflict markers.
110128
- For each conflicted hunk in `standard/*.md`:
111129
a. Cross-check the hunk's file and line range against the deletion inventory captured in Pre-flight (`/tmp/starting-deletions.patch`) **and** against any prior `Post-meeting propagation:` merges on the downstream branch (`git log --grep '^Post-meeting propagation:' -p origin/<branch> -- <file>`).
112130
b. If the downstream side intentionally removed the text, keep the deletion and re-apply only non-overlapping upstream edits to the surrounding region.
@@ -117,6 +135,14 @@ Before starting, confirm the chain with the user and show which branches will be
117135
- the generated TOC in `standard/README.md`.
118136
- For any conflict in `tools/`, `.github/`, or any prose conflict you are not 100% sure is mechanical: **abort the merge** and stop.
119137
3. After conflicts are resolved (or if the merge was clean), **do not push yet**. Run Steps B.5 and B.6 below first.
138+
4. **Section-number drift in alpha branches.** Alpha branches often have
139+
additional sections inserted (e.g. new feature clauses), which shift
140+
subsequent section numbers. When merging upstream changes into an alpha
141+
branch, check for duplicate section headers (e.g. two `## 14.5` headings)
142+
caused by the merge combining the upstream's numbering with the alpha's
143+
shifted numbering. The StandardAnchorTags tool will crash with
144+
`System.InvalidOperationException: Duplicate section header` if this
145+
happens. Fix by renumbering the duplicated header to its correct value.
120146

121147
### Step B.5 — Cross-reference validation
122148

@@ -127,7 +153,7 @@ Run the section-renumber tool in dry-run mode against the post-merge working tre
127153
--owner dotnet --repo csharpstandard --dryrun )
128154
```
129155

130-
1. **Broken references.** Any `TOC002` ("`<ref>` not found") diagnostic is a **hard stop**. Reset the merge commit (`git reset --hard origin/<branch>`), report the failing references to the user, and do not push.
156+
1. **Broken references.** Any *new* `TOC002` ("`<ref>` not found") diagnostic that was not already present on `upstream/<branch>` before the merge is a **hard stop**. Compare the tool output against a pre-merge run (or `git stash && run && git stash pop`) to distinguish new from pre-existing. Pre-existing TOC002s from incomplete feature PRs on alpha branches are expected and should be reported but do not block the merge.
131157
2. **Concept drift.** Count how many section numbers the dry run would change (lines beginning with `§` in the tool's diff output). If more than ~25 sections shift, sections have drifted enough that surviving cross-references like `§X.Y (Foo)` may now point at a different concept — the renumber tool fixes the *number* but cannot detect when the *concept* (parenthetical name, surrounding prose) is now wrong. Pause, list the affected references to the user, and proceed only on explicit confirmation.
132158
3. The actual renumber/grammar regeneration runs in the auto-PR opened by `update-on-merge.yaml` after push (Step A on the next iteration); do not commit dry-run output.
133159

@@ -138,11 +164,15 @@ against the Pre-flight baseline to surface anything new this propagation brought
138164

139165
```bash
140166
git --no-pager grep -nE '<!--[^>]*(vNext|v[0-9]+|future|upcoming|TODO)' \
141-
HEAD -- 'standard/*.md' > /tmp/vnext-current-<branch>.txt
167+
HEAD -- 'standard/*.md' | sed 's|^HEAD:||' > /tmp/vnext-current-<branch>.txt
142168
diff /tmp/vnext-baseline-<branch>.txt /tmp/vnext-current-<branch>.txt \
143169
> /tmp/vnext-delta-<branch>.txt || true
144170
```
145171

172+
> Strip the `HEAD:` prefix with `sed` so diffs against the baseline
173+
> (which uses `upstream/<branch>:` as prefix) don't produce false
174+
> positives on every line.
175+
146176
For each *new* comment in the delta, record:
147177

148178
- file path and line number,

.github/prompts/post-meeting-rebase-prs.prompt.md

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ For every open PR P with base `draft-vN`:
2626
2. Look for prior commits on `vN-alpha` by the same author touching the same files:
2727

2828
```bash
29-
git log origin/vN-alpha --author='<login>' -- <files…>
29+
git log upstream/vN-alpha --author='<login>' -- <files…>
3030
```
3131

3232
3. If prior commits exist and the current PR head SHA introduces changes to those files not yet on `vN-alpha`, record P as **"alpha has stale version"**.
@@ -58,7 +58,11 @@ If `vN` is missing or unparseable from the comment, list the entry as unrouted a
5858

5959
### Step 1 — List target base branches
6060

61-
List target base branches (the propagation chain — see the propagate prompt). Default: `draft-v8 draft-v9 v9-alpha draft-v10 v10-alpha draft-v11 v11-alpha draft-v12`. Allow the user to override.
61+
List target base branches (the propagation chain — see the propagate prompt). Default: `draft-v8 draft-v9 alpha-v9 draft-10 alpha-v10 draft-v11 v11-alpha draft-v12`. Allow the user to override.
62+
63+
> **Branch-naming is inconsistent across versions** (e.g. `alpha-v9` vs
64+
> `v11-alpha`, `draft-10` vs `draft-v11`). Always verify actual branch
65+
> names with `git branch -r | grep upstream/` before starting.
6266
6367
### Step 2 — For each base branch, list and process open PRs
6468

@@ -72,20 +76,51 @@ gh pr list --base <base> --state open \
7276
For each PR returned:
7377

7478
- If `headRepositoryOwner.login` matches this repo's owner (`dotnet`), the head is in this repo. **Rebase it:**
75-
1. `gh pr checkout <num>`
79+
1. `gh pr checkout <num>` — if this fails to fast-forward (branch has
80+
diverged from upstream), run `git reset --hard upstream/<headRefName>`
81+
to sync to the upstream version of the PR branch before proceeding.
7682
2. **Capture the pre-rebase SHA** so we can recover if the post-rebase cross-reference check fails: `PRE=$(git rev-parse HEAD)`.
77-
3. `git fetch origin <base>`
78-
4. `git rebase origin/<base>`
79-
5. **If the rebase has conflicts:** `git rebase --abort`, record the PR as "needs manual rebase", post the **attempted-rebase** comment below, and move on. Do not attempt to resolve feature-text conflicts.
83+
3. `git fetch upstream <base>`
84+
4. `git rebase upstream/<base>`**use `upstream/`** (the main repo
85+
remote), not `origin/`. The PR branches track `upstream`.
86+
5. **If the rebase has conflicts:**
87+
- **Binary conflicts** in `.github/workflows/dependencies/` (e.g.
88+
`GrammarTestingEnv.tgz`): resolve by taking the PR's version
89+
(`git checkout --theirs <file> && git add <file>`) and continue
90+
the rebase. These are feature-specific test artifacts and the PR's
91+
version is correct.
92+
- **Formatting-only conflicts** in `standard/*.md` (e.g. table
93+
pipe characters, smart-quote vs straight-quote differences):
94+
take the PR's version (`git checkout --theirs <file> && git add
95+
<file>`) and continue. The PR's formatting fix is the intended
96+
change.
97+
- **Independent additive conflicts** in `standard/*.md` (two
98+
features each added text to the same list or paragraph, but the
99+
additions are logically independent): combine both additions in
100+
the correct order, resolve, and continue.
101+
- **Structural/semantic conflicts** in `standard/*.md` (e.g.
102+
grammar reorganization where the base refactored a production
103+
hierarchy and the PR uses the old structure), or conflicts in
104+
`tools/`: `git rebase --abort`, record the PR as "needs manual
105+
rebase", and move on. Do not attempt to resolve conflicts that
106+
require the author's design decision.
80107
6. **Cross-reference check before push.** Run the renumber tool in dry-run mode against the rebased worktree:
81108

82109
```bash
83110
( cd tools && dotnet run --project StandardAnchorTags -- \
84111
--owner dotnet --repo csharpstandard --dryrun )
85112
```
86113

87-
If any `TOC002` diagnostic fires, the rebase has produced broken cross-references. Recover with `git reset --hard "$PRE"`, record the PR as "needs manual rebase", and post the **attempted-rebase** comment below with the failing references quoted in the body. Do not push.
88-
7. Otherwise: `git push --force-with-lease`. Record success with the new SHA.
114+
If any *new* `TOC002` diagnostic fires that was not already present
115+
on the PR branch before rebase, the rebase has introduced broken
116+
cross-references. Recover with `git reset --hard "$PRE"`, record
117+
the PR as "needs manual rebase", and move on. To distinguish new
118+
from pre-existing: check the same ref against
119+
`upstream/<headRefName>` (the pre-rebase state). Pre-existing
120+
TOC002s from incomplete feature work are expected and do not block
121+
the push.
122+
7. Otherwise: `git push --force-with-lease upstream <headRefName>`.
123+
Record success with the new SHA.
89124

90125
- If the head is on a fork, **do not attempt to rebase.** Post the
91126
**please-rebase** comment below. Avoid duplicate comments: skip if any existing comment on the PR already contains the marker `<!-- post-meeting-rebase-notice -->`.

0 commit comments

Comments
 (0)