Merge pull request #8818 from deepseek-harness/turtle/prefer-rebase-rerere-639b61438d11
docs(agents): prefer rebase with rerere for PR branch refreshes
This commit is contained in:
commit
c1286be3bf
12 files changed
+102
-15
No files matched your search
+2
-2
@@ -3,8 +3,8 @@
|
||||
# After editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write .agents/notes/implemented/process/2026-08-02-native-github-stacks-and-optional-rebases.md
|
||||
/agent-note-native-github-stacks-and-optional-pr-rebases:
|
||||
en: 9427ca53db68d50b
|
||||
zh: 9e72b34deee3bb9f
|
||||
en: b20dd8917f43b935
|
||||
zh: c9d6f3d2a04da072
|
||||
/agent-note-native-github-stacks-and-optional-pr-rebases/problem:
|
||||
en: 21312af191207fa6
|
||||
zh: 86306b4c6dd08a0c
|
||||
|
||||
+2
@@ -4,6 +4,8 @@ Status: implemented
|
||||
|
||||
English | [中文](2026-08-02-native-github-stacks-and-optional-rebases.zh.md)
|
||||
|
||||
The equal choice between merge-forward and rebase below is superseded by [rebase with rerere](2026-11-19-prefer-rebase-with-rerere.md), which keeps merge-forward for an explicit PR author request. Stack linkage, landing, lease protection, and post-rewrite audits remain current.
|
||||
|
||||
## Problem
|
||||
|
||||
A dependent PR chain represented only by base branches has no official stack identity. Landing it requires manually merging one PR at a time, preserving intermediate branches, retargeting every child, and reconstructing whether the chain survived. GitHub's native stacked-PR feature instead carries the order, applies trunk rules and CI to every layer, and owns bottom-up merges and retargeting.
|
||||
|
||||
+2
@@ -4,6 +4,8 @@ Status: implemented
|
||||
|
||||
[English](2026-08-02-native-github-stacks-and-optional-rebases.md) | 中文
|
||||
|
||||
下文在 merge-forward 与 rebase 之间同等选择的规定已被 [使用 rerere 的 rebase](2026-11-19-prefer-rebase-with-rerere.zh.md) 取代,后者仅在 PR 作者明确要求时保留 merge-forward。堆叠关联、落地、lease 保护和改写后的审计仍然有效。
|
||||
|
||||
## 问题
|
||||
|
||||
仅以 base 分支表示的依赖 PR(Pull Request)链没有官方的堆叠身份。要让它落地,就必须逐个手动合并 PR、保留中间分支、调整每个子 PR 的 base,并重新查证这条链是否仍然完整。GitHub 原生的堆叠 PR 功能则会承载顺序,对每一层应用 trunk 规则和 CI,并负责自底向上的合并与 base 调整。
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Bilingual-pair consistency record for 2026-11-19-prefer-rebase-with-rerere.md (docs/i18n/README.md): per heading
|
||||
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
||||
# After editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write .agents/notes/implemented/process/2026-11-19-prefer-rebase-with-rerere.md
|
||||
/agent-note-prefer-rebase-with-rerere-for-pr-refreshes:
|
||||
en: bee37c92f02c4b62
|
||||
zh: da3f086fc09072b3
|
||||
/agent-note-prefer-rebase-with-rerere-for-pr-refreshes/problem:
|
||||
en: 3c585b97c13a98b1
|
||||
zh: 040d30dcaadfbdf2
|
||||
/agent-note-prefer-rebase-with-rerere-for-pr-refreshes/decision:
|
||||
en: 8c6753ecfaf6b246
|
||||
zh: d6850cd7ee0afb2a
|
||||
/agent-note-prefer-rebase-with-rerere-for-pr-refreshes/alternatives-considered:
|
||||
en: 35d2f27bc5712a11
|
||||
zh: 5bd1eaaaa200666f
|
||||
/agent-note-prefer-rebase-with-rerere-for-pr-refreshes/consequences:
|
||||
en: c29ffb478f78ddfe
|
||||
zh: 4d11a569f2e1c5d7
|
||||
@@ -0,0 +1,32 @@
|
||||
# Agent Note: Prefer rebase with rerere for PR refreshes
|
||||
|
||||
Status: implemented
|
||||
|
||||
English | [中文](2026-11-19-prefer-rebase-with-rerere.zh.md)
|
||||
|
||||
## Problem
|
||||
|
||||
The [native stack decision](2026-08-02-native-github-stacks-and-optional-rebases.md) allows merge-forward and rebase equally for standalone and stacked PR branches. Agents therefore pick a history per refresh, and long-lived branches accumulate merge commits that reviewers must skip. Rebasing also asks again for conflict resolutions already made when a rebase is aborted and retried, when a stack child is rebased after its parent was rewritten, or when several commits of one rebase touch the same hunk.
|
||||
|
||||
## Decision
|
||||
|
||||
Agents refresh standalone and stacked PR branches by rebase, including after review. Before rebasing, the agent enables, once per clone, Git's reuse of recorded resolutions with `git config rerere.enabled true`, so Git records each resolved conflict and applies the recorded resolution when the same conflict recurs in a later rebase. The agent leaves `rerere.autoUpdate` unset, so Git leaves a replayed resolution unstaged for inspection; the agent reviews and stages it before continuing the rebase.
|
||||
|
||||
Merge-forward is used only when the PR author explicitly asks for it. The incremental merge-forward procedure and its rule to preserve an in-progress checkpoint before taking a newer base remain available for that case.
|
||||
|
||||
Lease protection is unchanged: a standalone rewrite publishes with `--force-with-lease=<branch>:<observed-oid>`, `gh stack push` and `gh stack sync` supply lease protection for their managed branches, and raw `--force` is forbidden. The native stack decision continues to own stack linkage, landing, and post-rewrite review audits.
|
||||
|
||||
## Alternatives considered
|
||||
|
||||
**Keep merge-forward and rebase equally allowed.** This leaves the history choice to each refresh and keeps the merge commits the rebase preference removes.
|
||||
|
||||
**Require rebase without exception.** A PR author can have a reason to keep merge checkpoints, such as preserving a large completed conflict resolution as a recovery point; the author request keeps that option.
|
||||
|
||||
**Rebase without rerere.** Retried rebases and stack cascades would ask for conflict resolutions already made, which costs time and can produce inconsistent resolutions.
|
||||
|
||||
## Consequences
|
||||
|
||||
- PR branches keep linear history, and reviewers see the branch's own commits on top of the current base.
|
||||
- Every refresh rewrites commit OIDs, so the post-rewrite audit of heads, review threads, approvals, mergeability, and checks applies to every refresh.
|
||||
- A recorded resolution can apply to a conflict whose correct resolution changed; the agent still inspects every replayed resolution before staging it.
|
||||
- Recorded resolutions live in `rr-cache` under the repository's common Git directory, so linked worktrees of one clone share them and other clones do not.
|
||||
@@ -0,0 +1,32 @@
|
||||
# Agent Note: 以启用 rerere 的 rebase 刷新 PR 分支
|
||||
|
||||
Status: implemented
|
||||
|
||||
[English](2026-11-19-prefer-rebase-with-rerere.md) | 中文
|
||||
|
||||
## 问题
|
||||
|
||||
[原生堆叠决策](2026-08-02-native-github-stacks-and-optional-rebases.zh.md)对独立 PR 分支和堆叠 PR 分支同等允许 merge-forward 与 rebase。因此 agent 每次刷新都要选择一种历史,长期存在的分支会积累评审者必须跳过的合并提交。中止后重试 rebase、在父层被改写后 rebase 堆叠子层,或一次 rebase 中多个提交改动同一 hunk 时,rebase 还会要求重新解决已经解决过的冲突。
|
||||
|
||||
## 决策
|
||||
|
||||
agent 以 rebase 刷新独立 PR 分支和堆叠 PR 分支,包括评审后。rebase 前,agent 在每个克隆中用 `git config rerere.enabled true` 启用一次 Git 的已记录冲突解决复用(rerere),Git 会记录每个已解决的冲突,并在之后的 rebase 中再次出现相同冲突时应用记录的解决结果。agent 不设置 `rerere.autoUpdate`,因此 Git 把复用的解决结果留在未暂存状态以供检查;agent 检查并暂存后再继续 rebase。
|
||||
|
||||
只有 PR 作者明确要求时才使用 merge-forward。增量 merge-forward 流程,以及在合入更新的 base 之前保留进行中检查点的规则,仍可用于这种情况。
|
||||
|
||||
lease 保护不变:独立分支的改写以 `--force-with-lease=<branch>:<observed-oid>` 发布,`gh stack push` 与 `gh stack sync` 为其管理的分支提供 lease 保护,禁止直接使用 `--force`。原生堆叠决策继续负责堆叠关联、落地,以及改写后的评审审计。
|
||||
|
||||
## 曾考虑的替代方案
|
||||
|
||||
**继续同等允许 merge-forward 与 rebase。** 这会把历史选择留给每次刷新,并保留 rebase 优先所消除的合并提交。
|
||||
|
||||
**无例外地要求 rebase。** PR 作者可能有理由保留合并检查点,例如把一次已完成的大规模冲突解决保留为恢复点;作者要求这一例外保留了该选项。
|
||||
|
||||
**不启用 rerere 的 rebase。** 重试的 rebase 和堆叠级联 rebase 会要求重新解决已经解决过的冲突,既耗时,也可能产生不一致的解决结果。
|
||||
|
||||
## 后果
|
||||
|
||||
- PR 分支保持线性历史,评审者看到的是位于当前 base 之上的分支自身提交。
|
||||
- 每次刷新都会改写 commit OID,因此每次刷新后都要审计 head、评审线程、批准状态、可合并性和检查结果。
|
||||
- 记录的解决结果可能应用到正确解决方式已经变化的冲突上;agent 仍要在暂存前检查每个复用的解决结果。
|
||||
- 记录的解决结果存放在仓库公共 Git 目录下的 `rr-cache` 中,因此同一克隆的关联 worktree 共享这些记录,其他克隆则不共享。
|
||||
@@ -5,7 +5,7 @@ description: Use when landing a stack of dependent GitHub PRs (A ← B ← C, wh
|
||||
|
||||
# Landing an official GitHub PR stack
|
||||
|
||||
Land dependent PRs through GitHub's native stack object and `gh stack merge`. Do not reproduce stack semantics by merging and retargeting individual PRs with `gh pr merge` and `gh pr edit`. The root [AGENTS.md](../../../AGENTS.md) owns the allowed merge-forward and rebase histories; the [stack review guide](../../../docs/cookbook/responding-to-pr-review-on-a-stack.md) owns review-fix propagation.
|
||||
Land dependent PRs through GitHub's native stack object and `gh stack merge`. Do not reproduce stack semantics by merging and retargeting individual PRs with `gh pr merge` and `gh pr edit`. The root [AGENTS.md](../../../AGENTS.md) owns the rebase-with-rerere default and the author-requested merge-forward exception; the [stack review guide](../../../docs/cookbook/responding-to-pr-review-on-a-stack.md) owns review-fix propagation.
|
||||
|
||||
## Require native stack support
|
||||
|
||||
@@ -67,10 +67,10 @@ Never dissolve, reorder, or rebuild an existing stack automatically; `gh stack l
|
||||
|
||||
## Refresh only when needed
|
||||
|
||||
Do not rewrite branches merely because a refresh mechanism exists. When the live merge state or repository rules require an updated trunk, choose either allowed history:
|
||||
Do not rewrite branches merely because a refresh mechanism exists. When the live merge state or repository rules require an updated trunk, enable rerere (`git config rerere.enabled true`), then rebase; inspect each replayed resolution before staging it. Use merge-forward only when the PR author explicitly asks for it:
|
||||
|
||||
- **Native cascading rebase:** check out the remote stack with `gh stack checkout <pr-or-stack>` when it is not tracked locally, then run `gh stack sync`. The command may rebase and lease-protected force-push every active layer before local validation. Immediately inspect the rewritten scope, run the relevant checks for every affected layer, and do not merge or claim readiness until they pass. If sync detects a rebase conflict, use `gh stack rebase`, resolve and validate it, then publish with `gh stack push`. If checkout or sync reports divergent local and remote stack compositions, cancel and ask rather than deleting or recreating the remote stack automatically.
|
||||
- **Incremental merge-forward:** merge the trunk into the bottom affected branch, then propagate each updated parent into its child in bottom-to-top order and push normally. If the base advances during an in-progress merge, preserve that checkpoint before merging the newer tip.
|
||||
- **Incremental merge-forward, on the PR author's explicit request:** merge the trunk into the bottom affected branch, then propagate each updated parent into its child in bottom-to-top order and push normally. If the base advances during an in-progress merge, preserve that checkpoint before merging the newer tip.
|
||||
|
||||
Any history rewrite is allowed after review, but it invalidates commit-OID assumptions. Re-fetch exact heads and re-audit unresolved review threads, approvals, mergeability, and checks after the push. Never use raw `--force` or overwrite a concurrently advanced remote head.
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ Run the complete local approximation only when the user explicitly requests it,
|
||||
|
||||
## Protect history-rewriting pushes
|
||||
|
||||
Rebase is allowed for standalone and stacked PR branches, including after review. Before a standalone history rewrite, fetch the current remote branch and record its exact OID; publish with `--force-with-lease=<branch>:<observed-oid>` so a concurrent update aborts the push. `gh stack push` and `gh stack sync` supply lease protection for their managed branches. Raw `--force` is never allowed.
|
||||
Rebase is the default refresh for standalone and stacked PR branches, including after review; the root [AGENTS.md](../../../AGENTS.md) owns that choice and its rerere setting. Before a standalone history rewrite, fetch the current remote branch and record its exact OID; publish with `--force-with-lease=<branch>:<observed-oid>` so a concurrent update aborts the push. `gh stack push` and `gh stack sync` supply lease protection for their managed branches. Raw `--force` is never allowed.
|
||||
|
||||
After any rewritten push, fetch the live heads again and re-audit unresolved review threads, approvals, mergeability, and checks. Commit hashes and inline-comment anchors from before the rewrite are not current evidence.
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ Real-API tests/demos read `DEEPSEEK_API_KEY`, optional `DEEPSEEK_BASE_URL`, and
|
||||
- **Design each tool's UI presentation up front.** Host presenters stay pure; Web cards derive from raw events and persisted result metadata ([cookbook](docs/cookbook/adding-a-tool.md)).
|
||||
- **Plan unit, e2e, and snapshot coverage** for capability seams, lifecycle paths, and transcript output; include missing snapshot-harness support in the same change.
|
||||
- **Both SDKs project the loop.** Agent-loop, session-lifecycle, and `SessionEventMap` changes update the TypeScript and Python SDK expected outputs in the same PR; `pnpm run test` covers neither ([surfaces](docs/testing.md#when-a-snapshot-test-is-required)).
|
||||
- **Choose PR history deliberately.** Split independent changes and fix the introducing PR before propagation. Standalone/stack branches may merge-forward or rebase. Rewrites use `--force-with-lease`, abort on remote movement, never raw `--force`; preserve an in-progress merge-forward checkpoint before taking a newer base ([rationale](.agents/notes/implemented/process/2026-08-02-native-github-stacks-and-optional-rebases.md)).
|
||||
- **Choose PR history deliberately.** Split independent changes and fix the introducing PR before propagation. Rebase branches with `rerere.enabled`; merge-forward only on the PR author's explicit request, keeping in-progress checkpoints. Rewrites use `--force-with-lease`, abort on remote movement, never raw `--force` ([rationale](.agents/notes/implemented/process/2026-11-19-prefer-rebase-with-rerere.md)).
|
||||
- **Labels:** one PR `kind/*`, all material `area/*`, and native Issue Type ([taxonomy](.agents/notes/implemented/process/2026-08-08-unified-github-label-taxonomy.md)).
|
||||
- **PR descriptions:** write and update every PR description with [dsh-pr-description](.agents/skills/dsh-pr-description/SKILL.md).
|
||||
- TODO markers: `FIXME`/`TODO`/`XXX` by urgency ([semantics](docs/development.md)).
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
en: f41561de1c6dbfef
|
||||
zh: 83b863e1ac91d913
|
||||
/responding-to-review-across-a-stacked-pr-chain/ground-rules:
|
||||
en: 5545e41aea74b5d6
|
||||
zh: 7105f51939753a1a
|
||||
en: e5b1b3c2b7db3d92
|
||||
zh: 2fb7defc040f453d
|
||||
/responding-to-review-across-a-stacked-pr-chain/resolve-comments-through-the-stack:
|
||||
en: 4d58b207c8ecbcaa
|
||||
zh: 38673a460674b8d6
|
||||
en: 0699f3b7a2791606
|
||||
zh: 6ca53b1dc25bd38d
|
||||
/responding-to-review-across-a-stacked-pr-chain/verify:
|
||||
en: 07cfbae7602fc30e
|
||||
zh: 19782f06ee3c4a74
|
||||
@@ -10,15 +10,15 @@ Review comments may target several PRs in a dependent stack (`A ← B ← C …`
|
||||
2. **GitHub's stack object is authoritative.** Base branches establish the expected dependency order, while `PullRequest.stack` and `stackEntry.position` prove that GitHub recognizes it. Do not treat a matching branch chain as an official stack without checking those fields.
|
||||
3. **A fix lands on the PR that INTRODUCED the issue, then flows up-stack.** When a comment on PR `B` points at code `B` introduced, fix it on `B` and propagate `B` into `C` — even if `C` also carries the file. Originating the fix downstream leaves `B` shipping the unfixed code and hides the fix from `B`'s reviewer.
|
||||
4. **Each review fix remains a distinct commit.** A later rebase may change its OID, but do not amend a reviewed fix out of the branch history. Amend only your own not-yet-pushed, not-yet-reviewed work.
|
||||
5. **Choose merge-forward or rebase deliberately.** Both histories are allowed after review. A rewritten push must be lease-protected and must abort rather than overwrite a concurrently advanced remote head; raw `--force` is forbidden.
|
||||
5. **Propagate by rebase with rerere.** Run `git config rerere.enabled true` before rebasing so Git replays recorded conflict resolutions; inspect each replayed resolution before staging it. Use merge-forward only when the PR author explicitly asks for it. A rewritten push must be lease-protected and must abort rather than overwrite a concurrently advanced remote head; raw `--force` is forbidden ([rationale](../../.agents/notes/implemented/process/2026-11-19-prefer-rebase-with-rerere.md)).
|
||||
|
||||
## Resolve comments through the stack
|
||||
|
||||
1. Triage every comment on the merits before acting: verify the claim against the code — a reviewer flagging the right symptom can still misdiagnose the cause.
|
||||
2. Map each accepted finding to its originating PR and fix it there.
|
||||
3. Propagate the fixed layer through every affected child in order:
|
||||
- **Merge-forward:** merge the fixed parent branch into its child, validate the child, and continue upward. Preserve each in-progress checkpoint.
|
||||
- **Native cascading rebase:** use `gh stack rebase`, validate the rewritten layers, then publish with `gh stack push`; or use `gh stack sync`, which may publish first and therefore requires immediate post-sync validation under [dsh-pre-push-checks](../../.agents/skills/dsh-pre-push-checks/SKILL.md).
|
||||
- **Merge-forward, only on the PR author's explicit request:** merge the fixed parent branch into its child, validate the child, and continue upward. Preserve each in-progress checkpoint.
|
||||
4. Treat delegated fixes as trust-but-verify: a sub-agent's report describes intent, not necessarily what landed. Re-run the gates yourself on the actual tree, and for a regression guard, prove it FAILS on the unfixed code (introduce the regression, watch red, revert) — a guard that passes both ways guards nothing. A sub-agent that reframes a problem as already handled is a signal to dig in personally.
|
||||
5. Reply in the review thread (`gh api repos/{owner}/{repo}/pulls/{pr}/comments/{id}/replies`), not as a top-level comment, stating the fix and the current commit or head that carries it.
|
||||
6. After any rewritten push, re-read unresolved threads, approvals, mergeability, and checks. A force-pushed commit OID or outdated inline anchor is not current evidence that the finding remains resolved.
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
2. **GitHub 的 stack 对象是权威依据。** base 分支确定预期的依赖顺序,`PullRequest.stack` 和 `stackEntry.position` 则证明 GitHub 已识别该堆叠。未经检查这些字段,不得仅凭分支链吻合就将其视为官方堆叠。
|
||||
3. **修复落在引入问题的那个 PR 上,然后沿堆叠向上流动。** 当 PR `B` 上的评论指向 `B` 引入的代码时,在 `B` 上修复,再将 `B` 的变更传播到 `C`,即使 `C` 也包含该文件。把修复发起在下游会导致 `B` 带着未修复的代码交付,并对 `B` 的评审者隐藏修复。
|
||||
4. **每项评审修复都保留为独立 commit。** 后续 rebase 可能改变其 OID,但不得通过 amend 把已经评审的修复从分支历史中抹去。只有你自己尚未推送且尚未评审的工作才可以 amend。
|
||||
5. **明确选择 merge-forward 或 rebase。** 评审后允许采用这两种历史更新方式。改写历史的推送必须受 lease 保护;如果远端 head 在此期间前移,操作必须中止,不得将其覆盖。禁止直接使用 `--force`。
|
||||
5. **以启用 rerere 的 rebase 传播修复。** rebase 前运行 `git config rerere.enabled true`,让 Git 复用已记录的冲突解决结果;暂存前检查每个复用的解决结果。只有 PR 作者明确要求时才使用 merge-forward。改写历史的推送必须受 lease 保护;如果远端 head 在此期间前移,操作必须中止,不得将其覆盖。禁止直接使用 `--force`([理由](../../.agents/notes/implemented/process/2026-11-19-prefer-rebase-with-rerere.zh.md))。
|
||||
|
||||
## 沿堆叠解决评审意见
|
||||
|
||||
1. 在行动之前先就事论事地审视每条评论:对照代码验证其论断——评审者指出了正确的症状,但仍可能误诊原因。
|
||||
2. 将每个被接受的发现映射到引入该问题的 PR,并在那里修复。
|
||||
3. 将修复后的层按顺序传播到每个受影响的子 PR:
|
||||
- **Merge-forward:** 将修复后的父分支合并到其子分支,验证子分支,然后继续沿堆叠向上传播。保留每个正在处理的检查点。
|
||||
- **原生级联 rebase:** 使用 `gh stack rebase`,验证所有已改写的层,然后通过 `gh stack push` 发布;也可以使用 `gh stack sync`,该命令可能先发布,因此必须按照 [dsh-pre-push-checks](../../.agents/skills/dsh-pre-push-checks/SKILL.md) 在同步后立即验证。
|
||||
- **Merge-forward(仅在 PR 作者明确要求时):** 将修复后的父分支合并到其子分支,验证子分支,然后继续沿堆叠向上传播。保留每个正在处理的检查点。
|
||||
4. 委派的修复需要信任但验证:subagent 的报告描述的是意图,不一定是实际落地的内容。请亲自在实际代码树上重新运行门禁;对于回归守卫,要证明它在未修复的代码上**失败**(引入回归、观察变红、再还原)——两种情况都通过的守卫什么也守不住。subagent 将问题重新定性为「已处理」时,这是一个需要亲自深入的信号。
|
||||
5. 在评审线程中回复(`gh api repos/{owner}/{repo}/pulls/{pr}/comments/{id}/replies`),而非发顶层评论;说明修复内容及当前承载修复的 commit 或 head。
|
||||
6. 每次改写推送后,都要重新读取未解决线程、批准状态、可合并性和检查结果。经 force-push 改写的 commit OID 或已过时的内联锚点,都不足以证明该发现当前仍处于已解决状态。
|
||||
|
||||
Reference in new issue
Block a user