feat(FAFF-368): re-validate ADR numbering at the merge gate, renumber on collision#288
Merged
Merged
Conversation
… on collision Concurrent grafts allocate the same ADR number at branch-base time and both merge, landing a duplicate on main that reddens `faff adr validate` on every open PR until an out-of-band hotfix renumbers one. Add a mechanical guard at the graft merge gate that detects the duplicate against the merge-target tree and renumbers the incoming ADR to a free number before ship. - New `faff adr renumber <selector> --to <NNNN|next> [--ref-scope f,f...]`: the deterministic collision-repair primitive — move one ADR to a free number, fix its heading + in-`ref-scope` canonical back-refs, re-validate. git-agnostic (pure fs; the caller stages the rename). Refuses (exit 1) an occupied target, an ambiguous bare number, or a still-red re-validate, leaving no partial move. - `faff adr validate` now names every colliding file on a duplicate number (`duplicate ADR number NNNN — f1, f2`), serving both the CI backstop and the graft guard. - faff-graft Step 10 gains the ADR-collision merge guard, folded into the concurrent rebase-revalidate before the single CI re-confirm; fail-closed needs-human on pre-existing-broken-main / ambiguous / non-zero-renumber. - adr --selftest + test/adr.test.mjs cover the two-branch collision regression, ref-scope bound (in-scope follows, out-of-scope byte-identical, asymmetric → red), occupied/ambiguous refusals, and the sharpened duplicate message. - docs/guide/cli.md + the `adr` usage line document `renumber`.
…touch a non-ADR path) Adversarial review flagged that --ref-scope entries were read/rewritten without verifying they are ADR files, so an arbitrary or path-traversed entry could in principle be touched. Keep only basenames matching ADR_FILE_RE, so the rewrite blast radius is bounded to this-PR ADR files under docs/adr/ — upholding the spec's 'never touch main's untouched files' invariant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a mechanical guard so a concurrent-graft ADR-number collision can't reach
main(FAFF-368). Two grafts allocate the same ADR number at branch-base time and both merge → duplicate onmainreddensfaff adr validateon every open PR until an out-of-band hotfix (the live incident: PR #264/#265 both minted ADR-0043).Changes
faff adr renumber <selector> --to <NNNN|next> [--ref-scope f,f…]— the deterministic merge-time collision-repair primitive: move one ADR to a free number, fix its heading + in-ref-scopecanonical back-refs, re-validate. git-agnostic (purefs; the caller stages the rename). Refuses (exit 1) an occupied target, an ambiguous bare number, or a still-red re-validate, leaving no partial move. Ref-scope is bounded to realdocs/adr/ADR files (basename +ADR_FILE_RE) so it never touches a file this PR didn't create.faff adr validatenow names every colliding file:duplicate ADR number NNNN — f1, f2(serves the CI backstop and the graft guard).needs-humanon pre-existing-broken-main / ambiguous / non-zero-renumber / still-red re-validate.docs/guide/cli.md+ theadrusage line documentrenumber.adr --selftest(+12 cases) andtest/adr.test.mjs(+6 tests) cover the two-branch collision regression, ref-scope bound (in-scope follows, out-of-scope byte-identical, asymmetric → red exit 1, non-ADR entry ignored), occupied/ambiguous refusals, and the sharpened duplicate message.Spec:
docs/specs/2026-07-07-FAFF-368-adr-renumber-merge-gate-design.md