Repository navigation
docs(agents): allow rewriting an unmerged pull request's history with safeguards - #2531
Conversation
… safeguards The rule said the only allowed rewrite is a rebase onto develop. The maintainer's policy is that other rewrites of an unmerged pull request, such as splitting a commit, are acceptable but not ideal, and agents may do them on their own judgment. State that policy and its safeguards: keep every step, prefer a new commit on top, confirm the final tree, update and map every reference to the old commit ids, note the rewrite in the PR body, and never rewrite develop, main, or merged history. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The commit-reference safeguard ambiguously permits replacing stale SHAs with new unstable SHAs.
1 open finding
What changed in this PR
Updates repository guidance to permit safeguarded history rewrites on unmerged pull requests.
Changes:
- Separates rebase guidance from general history-preservation rules.
- Documents safeguards for rewriting PR history.
- Preserves prohibitions on hiding superseded work or rewriting merged branches.
| File | Description |
|---|---|
AGENTS.md |
Defines the revised pull-request history policy and safeguards. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
"Update every reference to the old commit ids" could be read as replacing them with the rewritten branch's new ids, which a later rewrite can change too. Say that repository artifacts and the PR body cite the commit subject, as the open-pull-request skill requires, and keep the audit mapping for review comments, which cannot be edited. PR torrust#2531 review finding F1 by Copilot. Co-authored-by: Copilot <[email protected]>
Record Copilot review 5520675793 and its finding F1 as fixed and replied to. Co-authored-by: Copilot <[email protected]>
|
ACK b65cd96 |
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at b65cd96cb71fd4d16165c53dbdac7e0b1a7a6ade (post-merge). Recomputed from the bytes at the merged head, against the merge base 988c3bc76; the PR merged at 16:09:13Z as 3b0b40047.
Label: POST_MERGE_FINDINGS — My review was requested at 15:35:04Z. The PR merged before this round ran. The findings below stand at the merged head, and byte-for-byte on develop 48c4d3013, for a follow-up. No ACK follows a merged PR.
Delta. The history is linear: 3bcb49818, then 12971bfd9 (AGENTS.md +6/−4: replace old ids in repository artifacts and the PR body with the commit subject, and map the ids that review comments cite in the audit), then b65cd96cb (the audit, 98 lines). The merge 3b0b40047 has first parent 988c3bc76 and the same tree as b65cd96cb. AGENTS.md lines 360-371, and everything from line 378 on, are byte-identical to 3bcb49818. Seven files cited by my unposted first round have identical blobs at 3bcb49818, the merged head and 48c4d3013: open-pull-request, process-pr-review and its validator, both templates, task-reviewer and the rebase ADR.
Review bot F1: fixed by docs(agents): replace rewritten commit ids with commit subjects. The rule now names the replacement (the subject, not the new id) and keeps the map for review comments.
First-round findings. F2, F3, F4 and F6 stand on unchanged bytes. F5 stands at the new sentence: "repository artifacts" still includes append-only records. Two findings are new: F7 and F8.
Audit. The F1 row is correct on every field:
- Severity is Minor, matching the comment's bracket, so it is not inferred.
FIXED/RESOLVEDmatches the resolved thread.- The Source review ID and the Reply URL match the capture.
- The resolution reference is the subject of
12971bfd9.
Ownership, Status Values and Completion Rules match the template verbatim. The Processing Log (15:49, 15:51, 15:53) is in order, each stamp is within a minute of the commit (15:50:28Z) or the reply (15:53:42Z), and all precede the audit commit (15:54:14Z). The offline validator (--base 988c3bc76) exits 0: 1 row, 3 log entries, 0 failures.
Hygiene. Both commits have Conventional subjects and bodies that match their diffs. Author equals committer, each has one well-formed trailer line, git diff --check is clean, and lines wrap at 99 columns or less. The PR body was never updated, and the merge commit copied it (F8).
Findings. F2 Minor, F3 Suggestion, F4 Nit, F5 Minor, F6 Minor, F7 Nit, F8 Minor, all inline.
Checked, no finding. The bot's F1 is fixed, and the reply's two quoted current-tree phrases appear at lines 372-375. The audit's "Reviewer finding ID: F1" for a kept ID departs from the skill's "otherwise use N/A", but 83 earlier detail entries do the same, so I did not raise it. develop 48c4d3013 changes none of the cited files. The new lines keep the list form and wrap.
Checks
On the loop's compute hub at the merged head, merge base 988c3bc76 (the first parent of the merge commit 3b0b40047; receipt server-gates-krkavec-295): pre-commit profile gate exit 0 (83 s); linter markdown, linter cspell, linter lychee exit 0; frontmatter-validator --all: 19 errors / 4 warnings at this head and 19 / 4 at 988c3bc76 re-measured, none in the files this PR touches; validate-audit-record.py --pr-number 2531 exit 0 against this head's audit record (1 row, 3 log entries, 0 failures). GitHub checks at this head at posting time: "Docs Lint: completed/success". At posting, develop is 48c4d3013.
| preserved as training material for humans and AI agents; the only allowed rewrite is a rebase | ||
| onto `develop`, which is recommended when cheap and required on conflicts (see | ||
| preserved as training material for humans and AI agents. Never propose squashing as a cleanup. | ||
| - A rebase onto `develop` is recommended when cheap and required on conflicts (see |
There was a problem hiding this comment.
[Minor][F2] The id safeguards apply only to "Other rewrites", so a rebase during a review round requires no replacement and no id map
This is unchanged at the merged head: lines 360-371 are byte-identical to the first commit. A rebase onto develop rewrites every id, just as a split does (ADR lines 48-51 and 87-89), and the #2524 audit mapped the cited ids after its plain rebase too. Suggest stating the id replacement and the review-audit map for every rewrite, the rebase included.
| - Other rewrites of an unmerged pull request's history, such as splitting a commit that mixes | ||
| independent changes, are allowed but not ideal; agents may do them on their own judgment. Prefer | ||
| a new commit on top when it achieves the same result, especially during a review round, whose | ||
| cited commit ids a rewrite invalidates. A rewrite may separate or reorder steps but must keep |
There was a problem hiding this comment.
[Suggestion][F3] Name a reword among the allowed rewrites
This line is unchanged. "A rewrite may separate or reorder steps" can be read as the full list of permitted operations. A subject that misdescribes its diff can be fixed only by a reword, because a new commit on top cannot change it, and a reword keeps every step. Naming it next to the split example removes the doubt.
| a new commit on top when it achieves the same result, especially during a review round, whose | ||
| cited commit ids a rewrite invalidates. A rewrite may separate or reorder steps but must keep | ||
| every one of them, including superseded steps and corrections. After it, confirm the final tree | ||
| is unchanged unless the rewrite intends a change, and push with `--force-with-lease`. Replace |
There was a problem hiding this comment.
[Nit][F4] "Confirm the final tree", the PR-body note and the linked id check have no procedure in the skills
No file says how to confirm the tree; the #2524 audit used git range-diff. The open-pull-request body list (lines 120-125) has no place for the note required on line 376. That skill still runs its id check only "Before pushing after a rebase" (line 78); the blob is unchanged at the merged head and on develop 48c4d3013. A short rewrite paragraph next to open-pull-request lines 70-87 would give all three a home.
| cited commit ids a rewrite invalidates. A rewrite may separate or reorder steps but must keep | ||
| every one of them, including superseded steps and corrections. After it, confirm the final tree | ||
| is unchanged unless the rewrite intends a change, and push with `--force-with-lease`. Replace | ||
| every old commit id in repository artifacts and the PR body with the commit's Conventional Commit |
There was a problem hiding this comment.
[Minor][F5] "Replace every old commit id in repository artifacts" conflicts with append-only records
docs/templates/AGENT-REVIEW-REPORTS.md lines 12-13 (applied by .github/agents/task-reviewer.agent.md lines 76-78) and docs/templates/PR-REVIEW-TEMPLATE.md lines 112-113 forbid editing earlier entries. The task reviewer is never asked to cite by subject. The mapping exception on line 375 covers only review comments, so the only way to replace a branch id in a pre-PR review entry or a Processing Log is an in-place edit. Suggest extending the mapping to append-only records, for example a new entry that maps the ids.
| is unchanged unless the rewrite intends a change, and push with `--force-with-lease`. Replace | ||
| every old commit id in repository artifacts and the PR body with the commit's Conventional Commit | ||
| subject, not with its new id, which a later rewrite can change too (see the `open-pull-request` | ||
| skill). Review comments cannot be edited, so map the ids they cite to commit subjects in the pull |
There was a problem hiding this comment.
[Nit][F7] "Review comments cannot be edited" is true only of other people's comments
The author can edit their own review replies, and open-pull-request lines 75-77 count those replies as durable references that must cite subjects. Read literally, this sentence exempts them from replacement. The review bot's wording, "reviewer comments that the author cannot edit", was exact. Suggest: replace ids in your own replies, and map the ids in comments you cannot edit.
| every old commit id in repository artifacts and the PR body with the commit's Conventional Commit | ||
| subject, not with its new id, which a later rewrite can change too (see the `open-pull-request` | ||
| skill). Review comments cannot be edited, so map the ids they cite to commit subjects in the pull | ||
| request's review audit. Say in the PR body that the history was rewritten. Never rewrite |
There was a problem hiding this comment.
[Minor][F6] The review-audit id map has no place in the audit skill or template
Neither .github/skills/dev/pr-reviews/process-pr-review/SKILL.md nor docs/templates/PR-REVIEW-TEMPLATE.md has a section for the map. Both still give "the branch can be rebased" as the only reason ids are unstable (skill line 84, template lines 130-131). The blobs are unchanged at the merged head and on develop 48c4d3013. The #2524 audit added an unlisted "Commit IDs Cited by Reviewers" section. Suggest adding that section to the template and the skill.
| - 2026-10-14 15:49 UTC - Started audit: read Copilot review 5520675793 (one inline finding); Cameron | ||
| has not submitted a review yet. | ||
| - 2026-10-14 15:51 UTC - Fixed F1 in its own commit. | ||
| - 2026-10-14 15:53 UTC - Pushed the fix (pre-push checks passed) and replied on the F1 thread; the |
There was a problem hiding this comment.
[Minor][F8] The PR body was not updated after the fix and audit commits, and the merge commit kept the stale text
The body is outside the diff; it is anchored here at the push that should have refreshed it. The body is byte-identical to its text from when the PR had one commit, and 3b0b40047 carries it into develop. It still says "One … docs commit to AGENTS.md", but the PR has three commits in two files. It also still uses the "update every reference to the old commit ids" wording that F1 replaced, in both Why and Change. open-pull-request lines 26 and 202 require the body to match the commit range after edits. The merge commit cannot change, so a follow-up can only record the discrepancy, for example in this audit.
…es separately Since PR torrust#2531 merged, AGENTS.md allows rewrites of an unmerged pull request's history that are not rebases onto develop, while the baseline counts every force-push as a rebase. The measurement now adds a third class, not a rebase, reports the total and the rebase-only figures, and lists the policy change among the confounders. Co-authored-by: Copilot <[email protected]>
…or PR torrust#2531 The specification gave 16:06 UTC, which is the merge commit's time. GitHub reports merged_at 16:09:13 UTC, the figure the specification uses for the other pull requests it cites. Co-authored-by: Copilot <[email protected]>
…merged_at The specification gives 16:09 UTC, the time GitHub reports, while the evidence it cites dates merges by Git committer time (16:06 UTC for the same merge). Label the figure so a reader comparing the two does not meet an unexplained three-minute gap. Co-authored-by: Copilot <[email protected]>
…and move the measurement to #2547 b2d33e1 docs(pr-reviews): add the reply URL of the eighth review round of PR #2550 (Jose Celano) 514cef3 docs(pr-reviews): record the eighth review round of PR #2550 (Jose Celano) d1a5498 docs(pr-reviews): add the reply URL of the seventh review round of PR #2550 (Jose Celano) af0da1a docs(pr-reviews): record the seventh review round of PR #2550 (Jose Celano) 759278c docs(pr-reviews): add the reply URL of the sixth review round of PR #2550 (Jose Celano) 2fb9cb0 docs(pr-reviews): record the sixth review round of PR #2550 (Jose Celano) d5537ac docs(pr-reviews): add the reply URLs of the fifth review round of PR #2550 (Jose Celano) c22fc52 docs(issues): [#2507] log the fifth PR #2550 review round (Jose Celano) db1d2e4 docs(pr-reviews): record the fifth review round of PR #2550 (Jose Celano) 04d82d3 docs(issues): [#2547] state the selection rules as this specification's own (Jose Celano) 36ca2d1 docs(pr-reviews): add the reply URLs of the fourth review round of PR #2550 (Jose Celano) 09792d3 docs(issues): [#2507] log the fourth PR #2550 review round (Jose Celano) a1bfb60 docs(pr-reviews): record the third dismissal and the fourth review round of PR #2550 (Jose Celano) 91a39a1 docs(issues): [#2547] limit the shared population to the force-push measures (Jose Celano) b7a547d docs(pr-reviews): add the reply URLs of the third review round of PR #2550 (Jose Celano) 916925c docs(issues): [#2507] log the third PR #2550 review round (Jose Celano) 4b92ec0 docs(pr-reviews): record the second dismissal and the third review round of PR #2550 (Jose Celano) 1aecd2b docs(issues): [#2507] name the contradiction in the second re-review's scope (Jose Celano) cbf2b8b docs(issues): [#2547] count and classify the force-pushes of the PRs merged in the window (Jose Celano) 7386f69 docs(pr-reviews): record the dismissed approval and the second review round of PR #2550 (Jose Celano) c20f6cc docs(issues): [#2507] log the second PR #2550 review round (Jose Celano) 3e6f931 docs(issues): [#2547] label the PR #2531 merge time as merged_at (Jose Celano) 014c0e7 docs(issues): [#2507] state what the second re-review did not check (Jose Celano) 1dea064 docs(issues): [#2507] classify the V4 force-pushes by whether the push moved the base (Jose Celano) e774c1d docs(issues): [#2507] set the evidence stamp to its newest edit (Jose Celano) 0dbe53d docs(issues): [#2547] classify a force-push by whether it moved the base (Jose Celano) 2562247 docs(pr-reviews): add the PR #2550 review audit (Jose Celano) 975501e docs(issues): [#2507] record the Task Reviewer's re-review of the close-out fixes (Jose Celano) 3fa9bca docs(issues): [#2547] log the edits that moved the last-updated stamp (Jose Celano) c72184d docs(issues): [#2547] use the merge time that GitHub reports for PR #2531 (Jose Celano) 436a91d docs(issues): [#2507] account for every force-push of the 18 merges in V4 (Jose Celano) a2eb4c1 docs(issues): [#2507] describe M1 as inferred, not proven (Jose Celano) 4b1c567 docs(issues): [#2507] attribute the delivery-sequence log line to the #2525 spec (Jose Celano) 08d1e07 docs(issues): [#2507] label the force-push event commits and record how to fetch them (Jose Celano) 7a3d1cc docs(issues): [#2547] classify force-pushes that are not rebases separately (Jose Celano) b2bcd00 docs(issues): [#2547] use the merge's target tip as the refresh-path cutoff (Jose Celano) 2733f2e docs(issues): [#2547] limit the rebase-fallout baseline to 1 to 13 October (Jose Celano) f4d1817 docs(issues): [#2525] record the agreed delivery sequence (Jose Celano) 3cb3548 docs(issues): [#2507] record the close-out verification and move the measurement to #2547 (Jose Celano) 38658d8 docs(issues): add issue specification for #2547 (Jose Celano) Pull request description: Related to #2507 ## Summary Closes out #2507 without waiting two weeks, records the follow-up issue #2547 that takes over its measurement, and records the agreed delivery sequence for #2525. Documentation only: every change is under `docs/issues/open/`. ### #2547 specification (`docs(issues)`) New `docs/issues/open/2547-measure-effect-of-optional-rebases/`. The maintainer approved the draft and the issue was created on GitHub. It takes over #2507 task T7 and acceptance criterion AC9: compare 2026-10-15 to 2026-10-28 with the #2507 baseline, classify each force-push as required (conflict) or recommended, and count merges through the merge tool's recorded-base refresh. It starts no earlier than 2026-10-29. ### #2507 close-out (`docs(issues)`) - **Manual verification** from the 18 real merges from PR #2526 to #2543 (`manual-verification-evidence.md`, section "Merges Under the New Policy"): - nine pull requests merged while behind `develop` without a rebase at merge time (M2), and every merged head stays reachable from `develop` (M3); - six were merged through the recorded-base refresh (M1). This is indirect evidence: the tool output was not captured, so the reasoning from GitHub state is spelled out in section V1; - #2532 and #2537 took the conflict rebase path (M4); - code and documentation-only merges happened with no ruleset changed (M5, M6), and first-parent history has one merge per pull request (M8). - **Acceptance criteria:** AC1 to AC4 and AC6 ticked with evidence. The maintainer accepted AC6 while no check is required, with the required `CI gate` tracked by #2525. AC9 and T7 were reworded as moved to #2547. - **New Closure Plan (C1 to C7)** in the spec, so the remaining steps are written down. After this PR merges, #2507 is closed manually on GitHub and its spec is archived with `cleanup-completed-issues`. - **New files:** `implementation-retrospective.md` and `agent-review-reports.md`, the latter holding the Task Reviewer report. The Task Reviewer's first verdict was `REVIEW FAILED` (five should-fix and three nit findings, all fixed); a later re-review first failed on residual wording and then passed, and each verdict is its own entry. ### #2525 delivery sequence (`docs(issues)`) - **Rust first:** pure-Rust tasks T1 to T3, then the sandbox decision gates T4 and T5. - **Before-baseline:** recorded before the orchestrator merges. - **Gate not required at first (T6):** `CI gate` lands reporting but not required, and is observed on real code and documentation-only pull requests. - **Then required (T7):** only with maintainer approval, with the ruleset JSON saved and a rollback documented. - **Measurement split (T8):** moved to a follow-up issue created when the gate becomes required, so #2525 can close without a waiting period. ## Validation - `TORRUST_GIT_HOOKS_LOG_DIR=.tmp ./contrib/dev-tools/git/hooks/pre-commit.sh --format=json`: pass. - `TORRUST_GIT_HOOKS_LOG_DIR=.tmp ./contrib/dev-tools/git/hooks/pre-push.sh --format=json` (nightly and stable Rust toolchains): pass, after rebasing onto `develop`. - `python3 contrib/dev-tools/git/tests/test-github-merge-symlinks.py` (Python 3.14.4): 51 tests OK. `bash contrib/dev-tools/git/tests/test-merge-pull-request.sh`: passed. - Independent Task Reviewer re-derived the evidence from `git` and `gh api`; its reports and two re-reviews are in `agent-review-reports.md`. - Review round: the findings of Copilot and da2ce7 are fixed in separate signed commits and recorded in `docs/pr-reviews/pr-2550-review/PR-REVIEW.md`; `validate-audit-record.py --pr-number 2550` reports no failures. ## Notes for reviewers - The PR-branch commit-id check from the `open-pull-request` skill reports the before and after commits of the #2532 and #2537 force-pushes (for example `55a414e98`) once a clone has fetched them. They are not commits of this branch: V4 cites them as the `beforeCommit` and `afterCommit` values of GitHub's `HeadRefForcePushedEvent`, with the fetch step and the full ids recorded. The skill defines no exception for this case. - The evidence cites `develop` at `fd04ac51e`. This branch was then rebased onto `30b368f0f` before opening; the two newer merges (#2500 and #2544) are outside the evidence window. ACKs for top commit: da2ce7: ACK b2d33e1 — the round-9 correction entry against the captured times, the audit's twenty-nine rows against the captured reviews, thread, reply and timeline, and the commit-id check were recomputed with no finding josecelano: ACK b2d33e1 Tree-SHA512: 17030dd5806832cc53121a800b1681b816fb6ea61c560c7c390cee34aa8a95d3f6d59d3fdff78991f463ba1278ae8d37951c8497014f0e4221269974e8dd46eb

Aligns the root
AGENTS.mdhistory rule ("Commit history and PR scope") with the maintainer's policy.Why
The rule said "the only allowed rewrite is a rebase onto
develop". PR #2524 was rewritten at the maintainer's choice: an interactive rebase split the leftover removals out of the fix commit, a late review finding on the spec PR #2506. The maintainer's policy is that rewriting an unmerged pull request's history is acceptable but not ideal, and agents may do it on their own judgment, provided no superseded step is hidden and every reference to the old commit ids is updated.Change
One signed docs commit to
AGENTS.md:--force-with-lease;open-pull-requestskill;develop,main, or merged history.No other file states this rule; the rebase ADR covers only rebases.
Validation
linter all); pre-push checks passed.