Skip to content

fix(rename-prefix): --repair keeps each issue's suffix when its destination is free - #8473

Merged
gascity-eddie[bot] merged 13 commits into
mainfrom
fix/bd-quj8ug
Nov 18, 2026
Merged

gascity-eddie[bot] merged 13 commits into
mainfrom
fix/bd-quj8ug

Conversation

@gascity-eddie

@gascity-eddie gascity-eddie Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Both candidates agree: repair loses suffixes and no mint-only path exists. Preserve suffixes by default, re-root dotted families only on collision, and report fallbacks. Add rename-prefix --mint-only, preserving old-parent usability through allowed_prefixes. Retain family/retirement checks but reject family-size ordering and extra capability rows.

The maintainer review commit on top fixes how --repair re-points dependencies, lets the --repair that --mint-only advises finish the switch, and states the --mint-only dependency limit; see Changes after the checkpoint pipeline.

Acceptance criteria

Grades are the judge's, per candidate: glm, opus, and contributor PR #6621.

  • AC-1 (glm partial, opus pass, pr6621 partial): Given IDs taxdb-u6ch, cre-db-c2a, and kb-hand with free destinations, when bd rename-prefix kb --repair succeeds, then the first two become kb-u6ch and kb-c2a, data and relationships survive, kb-hand keeps its ID, and issue_prefix is kb.
  • AC-2 (glm pass, opus pass, pr6621 partial): Given taxdb-5su1, child taxdb-5su1.13, orphan cre-db-nwb.3, and a renamed row referencing both children, when repair to kb runs without collisions, then the children become kb-5su1.13 and kb-nwb.3, the parent-child dependency still resolves, and both text references point at the resulting IDs.
  • AC-3 (glm partial, opus pass, pr6621 fail): Given an off-target dotted family whose wanted root or member destination is live, claimed by another source family, or retired, when repair to kb succeeds, then that whole family uses one unique non-retired hash root with dotted paths intact and every fallback reports the old, wanted and assigned root and collision reason.
  • AC-4 (glm pass, opus pass, pr6621 fail): Given a declared or observed cre-db family containing cre-db-a1b and cre-db-wxyz, plus custom target ID kb-adr-0001, when repair to kb runs, then the source IDs become kb-a1b and kb-wxyz and the target ID is unchanged.
  • AC-5 (glm pass, opus pass, pr6621 fail): Given a mixed store with collisions, when repair dry-run is followed by real execution against unchanged inputs and actor, then dry-run writes nothing, both modes report every collision, and their JSON mappings agree with the resulting stored IDs.
  • AC-6 (glm partial, opus pass, pr6621 fail): Given issue_prefix=taxdb, parent taxdb-u6ch, and other issue families, when bd rename-prefix kb --mint-only succeeds, then existing IDs/text remain unchanged, future root issues mint as kb-*, and a new child under taxdb-u6ch can still be created with its original dotted prefix.
  • AC-7 (glm pass, opus pass, pr6621 fail): Given a configured store, when mint-only runs with --dry-run or incompatible --repair, then dry-run reports planned config changes without writes and the incompatible invocation fails without writes.

Prior art: #6621

Contributor PR #6621 by rjgeng (Rongjun GENG), opened 2026-09-19 for the same issue, was the first fix for #6591: --repair keeps each issue's suffix and mints a hash ID only when that ID is taken. This PR replaces it instead of building on it:

Credit: #6621's two real-store tests, TestRepairMultiplePrefixesPreservesSuffix and TestRepairMultiplePrefixesFallsBackOnCollision, are carried in cmd/bd/rename_prefix_repair_test.go and pass against this planner. The cases of its TestComputeRepairRenames_* tests (suffixes kept with a dotted child, a fallback when the ID is live, a fallback within one batch) are subtests of TestPlanPrefixRepair here. The maintainer review commit credits Rongjun GENG as co-author.

Changes after the checkpoint pipeline

One maintainer review commit, amended after review iterations 1 to 3:

  • Edges --repair must leave alone. The re-point guard compared an edge's source by its old ID with its target by its new ID, so every edge inside a renamed family (a parent-child edge, blocks between two taxdb-* rows, a close gate an epic holds on its own child) looked cross-prefix and was removed and re-added. The re-add stamped the repair's actor and time on the edge, and its hierarchy check refused a legacy close gate, which deleted the gate and stopped the run before issue_prefix was set. The guard now compares both ends' IDs from before the repair, so an edge storage already re-pointed in place stays as it is.
  • A refused edge is kept and reported. An edge the repair does re-point moves in one transaction, so a re-add storage refuses (an edge stored across prefixes never went through the hierarchy check) rolls its removal back. The run reports the edge, in text and as unrepointed_edges under --json, goes on to the next edge and sets issue_prefix. On a SQL server each edge gets its own Dolt commit, as the store-level writes it replaces did; on an embedded store the command's post-run commit takes the whole repair, issue_prefix included.
  • The hierarchy is re-pointed first. Parent-child edges move before every other edge, so each blocking re-add is checked against the re-pointed hierarchy. In source-ID order alone, a re-add was checked against a partly re-pointed graph whose ancestry and cycle walks stop at old IDs that no longer exist: a grandchild blocked by its own grandparent landed unreported when its ID sorted first, and an epic's close gate on its own child across prefixes landed while the child's parent-child edge was refused instead.
  • A blocking edge that alone keeps the hierarchy out stays as it was. An epic's close gate on a child already on the target prefix is stored across prefixes, where blocked state never reads it. Once the epic is renamed the gate names two live issues, and storage's cycle walk, which reads every column, refused the child's parent-child edge through it; the gate was then re-added where it blocks the epic, while the child stayed detached. Before each blocking edge moves, a transaction that always rolls back removes it and retries each parent-child edge refused for a cycle. When one would land, the blocking edge is left as it was and reported with it.
  • Other than that, only a refusal is stepped over. Storage refusing an edge (a cycle, a block on the issue's own ancestor or descendant, an edge onto itself, a second type for one pair, a missing endpoint) is reported and skipped. Any other failure (a commit whose outcome is unknown, a lost connection) stops the run before issue_prefix is set, and the error names the edges refused before it. Counted as a refusal, an edge that had in fact moved was reported as left as it was.
  • The refusal report makes no readiness claim. It said a refused edge does not affect readiness, which is false for an edge between two prefixes that the database keeps in the issue column (see Limitations): a refused blocks edge there still blocks. The --repair help, the CHANGELOG and the advanced reference now also say a re-pointed edge records the repair's actor and time.
  • --repair after --mint-only. --mint-only sets issue_prefix to the new prefix while every issue may still carry the old one, and both bd rename-prefix kb and the bd rename-prefix kb --repair its warning advises refused kb as the current prefix until a kb-* issue existed. They now rename the old-prefix issues; only issues already on kb make the command a no-op.
  • --mint-only states its dependency limit on stderr, in its help, in the CHANGELOG and in the reference docs (see Limitations).
  • Text references. The CHANGELOG, the --repair help and the advanced reference now say a repair rewrites text references only inside the renamed issues, the scope the design set.
  • Planner split. planPrefixRepair is split into family grouping, the claim of wanted roots and hash-root allocation, and the dry-run report and text rewrite of repairPrefixes move to their own functions, with no change in behavior: the TestPlanPrefixRepair* tables and the repair tests pass unchanged.
  • fix(rename-prefix): preserve suffix on --repair instead of always hashing #6621's tests are carried (see Prior art).

New tests, each failing on the mutant it pins:

  • Dolt lane: TestRepairPrefixesLeavesEdgesStorageAlreadyMoved (the old guard), TestRepairPrefixesKeepsAnEdgeStorageRefusesToRepoint (aborting on a refusal; removing and re-adding outside one transaction), TestRepairPrefixesRepointsTheHierarchyFirst (re-pointing in source-ID order alone, in its first two shapes; no probe, or a probe that commits instead of rolling back, in its close gates on a child or grandchild already on the target prefix), TestRepairPrefixesStopsOnAFailureThatIsNotARefusal (every error counted as a refusal), TestRepairPrefixesReportsARefusedIssueColumnEdgeAsLeftAsItWas (the old readiness claim) and TestRepairPrefixesKeepsAnEdgeThatWouldCloseACycle (a legacy cycle across prefixes; the refusal classifier without its cycle arm, which the close-gate shapes and the unit TestIsDependencyRefusal also catch).
  • Embedded: repair_repoints_cross_prefix_edges (a Dolt commit per edge on an embedded store, which left issue_prefix uncommitted) and mint_only_then_repair_renames (the old same-prefix refusal).

At the review commit as reviewed, before the final base refresh, //cmd/bd:bd_test passed as a whole under --config=ci (7955 tests), its rename-prefix tests passed on the Dolt lane (77), the embedded rename-prefix tests passed (13), and so did the five doc guards that read the CHANGELOG and the advanced reference.

Limitations

  • --mint-only leaves dependencies between the two prefixes non-blocking. Storage classifies an edge by the part of each ID before its first hyphen and does not read allowed_prefixes, so an edge between a taxdb-* and a kb-* issue is stored as a reference to another repository, which bd ready never reads. A later bd rename-prefix kb --repair consolidates the prefixes and re-points those edges. Making the classifier treat issue_prefix and allowed_prefixes as local is a storage change for its own PR.
  • An edge between two prefixes that the database keeps in the issue column is re-added. A database older than the dependency-target split (migration 0041), or a bd rename, keeps such edges as local ones, which gate readiness. cmd/bd cannot see which column holds an edge, so the repair removes and re-adds these too: they take the repair's actor and time, and one that storage refuses to re-add stays exactly as it was (a blocks edge still blocks). Re-pointing only the edges stored as references into another repository, in place and keeping their provenance, needs an issueops primitive for its own PR, stacked below this one.
  • Two blocking paths still keep a child detached. An edge is left as it was only when removing it alone lets a parent-child edge that storage refused for a cycle land. When two blocking edges each close their own path from the parent to the child, removing either one lands nothing, so both are re-pointed; the child stays detached, and only its parent-child edge is reported.
  • Text in issues --repair does not rename keeps the old IDs, as do comments and close reasons, which neither rename path rewrites.
  • A declared prefix can only lengthen a split. An ID under the target prefix is always kept, so a declared cre-db under target cre (or beads-vscode under beads) is never consolidated, and a prefix detected on the rows (taxdb-adr) outranks a shorter declared one (taxdb).
  • An interrupted repair cannot finish its edge re-pointing. The old-to-new map lives only in memory, and a re-run sees a single prefix. A failure other than a refusal stops the run the same way, after naming the edges refused before it.

How this was built

  • Design: design.pair (anthropic-opus, moonshot-kimi, xai-grok, zhipu-glm).
  • Independent candidates: glm (pass), opus (pass), pr6621 (untested).
  • Judge (grok) composed the change per AC: AC-1 ← merge, AC-2 ← opus, AC-3 ← merge, AC-4 ← opus, AC-5 ← opus, AC-6 ← merge, AC-7 ← opus.
    • AC-1: merged by the integrator (Take opus 0ad51b5 + b88ab55 (suffix-keeping repair plus repointRepairedDependencies and its cross-family edge test: cre-db-c2a->taxdb-u6ch, kb-hand->cre-db-c2a). glm has no repointing, so cross-prefix edges stored in depends_on_external (issueops.IsExternalDepTarget) keep naming the old id after UpdateIssueID. Extend opus's repoint to the remaining case: an edge whose SOURCE was renamed onto the target prefix and whose target is an existing, unrenamed target-prefix row (taxdb-x -> kb-hand becomes kb-x -> kb-hand but stays in depends_on_external, and blocked_state.go only reads depends_on_issue_id, so it no longer blocks). Re-add it so it is stored as an ordinary issue edge, and add a test that asserts kb-x is blocked by kb-hand after the repair.)
    • AC-3: merged by the integrator (Keep opus's planner (77ca69a): claims are keyed by root namespace for every family, including orphan-only families. glm's claims hold only member ids, so after an orphan cre-db-x.3 claims kb-x.3, taxdb-x can still take kb-x and become a false parent. Port glm's TestPlanPrefixRepair table cases (1d53549, 85d0a6e: child-only namespace, earlier family's claim, retired member id, retired hash candidate skipped, known/heuristic/all-letter suffix extraction) onto opus's planPrefixRepair(ctx,target,issues,known,actor,retired) signature. Add one new case: an orphan family's root claim makes a later root family fall back with reason claimed. Keep opus's e2e TestRepairPrefixesCollisionReRootsTree and the allocation-bounded case.)
    • AC-6: merged by the integrator (Take opus 635ca13 code and its embedded e2e test. glm's mintOnlyPrefix treats an allowed_prefixes read error as unset and would then overwrite the list with only the old prefix. Opus propagates the error. Docs: keep opus's plugin guide and configuration.md text, add glm's docs/reference/advanced.md repair paragraph (c1914ea), and regenerate docs/cli-reference/rename-prefix.md from 'bd help --doc rename-prefix'. That file is AUTO-GENERATED, the design requires it, and neither candidate updated it.)
  • Canonical tests (at the pipeline head, before the maintainer review commit): bazel-test //cmd/bd:bd_test --test_filter='^(TestRepairPrefixesKeepsSuffixes|TestRepairPrefixesRepointsEdgesOntoUnrenamedTargetRows|TestRepairPrefixesKeepsSuffixesWithoutCollision|TestRepairPrefixesKeepsDottedChildren|TestRepairPrefixesCollisionReRootsTree|TestRepairPrefixesSplitsByKnownPrefix|TestRepairPrefixesDryRunMatchesRealRun|TestPlanPrefixRepair|TestPlanPrefixRepairKnownPrefixes|TestRepairRetiredLookupFindsTheDecoratedBackend|TestRepairMultiplePrefixes|TestRepairPrefixesRetargetsBeadGates|TestRenameFailureLeavesBeadGatesPending|TestRejectProtectedConfigKey|TestRewriteIssueID_.*|TestCommandTreeGolden|TestCommandHelpGolden)$' --test_env=BEADS_TEST_SKIP= --test_env=BEADS_TEST_DOLT_SERVER=local --test_env=BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 && bazel-test //cmd/bd:bd_embedded_test --config=embedded --test_sharding_strategy=disabled --test_arg='-test.run=^TestEmbeddedRenamePrefixEdgeCases$' --test_arg=-test.skip= → pass.
  • Final review (kimi): pass.

Judge rationale: Both candidates passed the independent run. The triage repro fails to build on both because generateRepairHashID/issueSort were removed, which is not evidence. Opus is the base because its planner reserves root namespaces (fixing glm's orphan-claim gap), it re-points cross-prefix dependency edges (glm leaves them dangling), it propagates config read errors (glm swallows them, risking an allowed_prefixes overwrite in mint-only), and its CLI tests run end to end. AC-1: merge (opus code + repoint extension for source-renamed edges). AC-2: opus; equivalent to glm's, with a tighter dependency type/title check. AC-3: merge (opus planner + glm's richer planner table tests). AC-4: opus; same longest-known-prefix extraction, errors propagated. AC-5: opus; single-object JSON, dry-run test asserts mapping == stored. AC-6: merge (opus code/test + glm advanced.md + regenerated cli-reference). AC-7: opus; --mint-only+--repair refused before the store opens, e2e no-write check. Contributor PR #6621 (@rjgeng) started suffix preservation, but it uses per-issue hash fallback with heuristic prefix extraction (rejected by the design: it breaks dotted ancestry) and has no mint-only; it is credited, not ported.

Correction at this head: docs/cli-reference/rename-prefix.md is not regenerated. The generated CLI reference follows the release pinned in docs/cli-docs.pin, so --mint-only appears there once the pin moves past a release that has it. #6621 is no longer "not ported" in full: its two real-store tests are carried (see Prior art).


Source bead: bd-quj8ug · checkpoint pipeline v0

Fixes #6591

@gascity-eddie gascity-eddie Bot added the status/needs-review Request PR review workflow label Nov 14, 2026
@github-actions github-actions Bot added the status/needs-triage Awaiting initial PM triage label Nov 14, 2026
@gascity-eddie

gascity-eddie Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

This PR has been added to the review queue.

Track progress: https://factory.gascity.com/city/maintainer-city/runs/gcg--9223372036829686944

@gascity-eddie gascity-eddie Bot added status/reviewing PR review workflow is running and removed status/needs-review Request PR review workflow labels Nov 14, 2026
@gascityinc-sarah gascityinc-sarah Bot added kind/bug Broken existing behavior priority/p1 High: core workflow broken labels Nov 14, 2026
@gascityinc-sarah

Copy link
Copy Markdown

Triage: kind/bug · priority/p1 — Prefix repair rewrote every id to a fresh hash, dropping mnemonic suffixes and parent links store-wide; this keeps each suffix when its destination is free and repoints edges. Core repair path, p1.
Auto-triaged by @gascityinc-sarah. Reply or relabel if this is off.

@gascityinc-sarah gascityinc-sarah Bot removed the status/needs-triage Awaiting initial PM triage label Nov 14, 2026

@bee-ghosttrack bee-ghosttrack left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes at a3dc7d3. The suffix-keeping planner, the collision fallback, the dry-run/real-run agreement and --mint-only all hold (every credited test passes in my hand in all three tiers, and the six mutants I ran on the planner, the re-point loop, the text rewrite and the mint-only write are each killed), but two things regress against main and one claim in the body is not in the PR.

  1. cmd/bd/rename_prefix.go:458: strings.HasPrefix(id, targetPrefix+"-") counts every row whose source prefix EXTENDS the target with a hyphen as already on target. Reproduced with the head bd and the merge-base bd on the same embedded rig: beads-a1b plus beads-vscode-1 (an allowed, explicit id), then bd rename-prefix beads --repair --dry-run. Main plans beads-vscode-1 -> beads-f7de9c58; the head plans "Would repair 0 issues", the real run prints "Successfully consolidated 2 prefixes into beads, 0 issues repaired", and the database is then stuck: a plain rename-prefix refuses on multiple prefixes and --repair is a no-op forever. The case is pinned on purpose (rename_prefix_rewrite_test.go:424, beads-vscode-1 under target beads wants "") to protect custom target ids like kb-adr-0001, but the trade is silent. A row whose longest known prefix (declared in allowed_prefixes, or detected) is a longer source prefix should still be renamed, or the run should refuse and name the rows it left under a second detected prefix instead of printing success.

  2. cmd/bd/rename_prefix.go:770-773: the source-renamed branch classifies the edge with IsExternalDepTarget(was, dep.DependsOnID), but dep.DependsOnID is the CURRENT target, which storage has already re-pointed for same-prefix edges (UpdateIssueIDInDependenciesInTx). So every edge that was same-prefix before the repair and has both ends renamed (every parent-child edge of a kept family, every taxdb-a -> taxdb-b blocks edge) reads as "was cross-prefix" (taxdb-a vs kb-b) and is removed and re-added. AddDependencyInTx stamps UTC_TIMESTAMP() and the actor, so created_at and created_by of those edges are reset to the repair (shown in the hand check: the kept family's parent-child edge carries the repair time on the head and the child's create time on main), the journal gets a remove/add pair per edge, and a failure between the remove and the add drops the edge, since the loop is not in a transaction. Classify against the original target instead (map dep.DependsOnID back through the old-id map before asking IsExternalDepTarget), and add an assertion on edge created_at to TestRepairPrefixesKeepsDottedChildren, which is why no credited test caught it.

  3. Credit: the body says #6621 by @rjgeng "is credited, not ported", but no commit trailer, CHANGELOG bullet or doc names @rjgeng or #6621, and the issue reporter @cpliakas is not named either. The CHANGELOG convention is there to copy ("reported and first fixed by @NahumLitvin in #7794", "#6080, reported by @dmcp718"). Please make the --repair bullet read "(#6591, reported by @cpliakas; suffix preservation first proposed by @rjgeng in #6621)".

What I ran at the head, in my hand:

CGO_ENABLED=1 go test -count=1 -tags gms_pure_go ./cmd/bd -run '^(TestPlanPrefixRepair|TestPlanPrefixRepairKnownPrefixes|TestRepairRetiredLookupFindsTheDecoratedBackend|TestRewriteIssueID_.*|TestRejectProtectedConfigKey|TestCommandTreeGolden|TestCommandHelpGolden)$' -v   # all PASS, TestPlanPrefixRepair 14/14 subtests
CGO_ENABLED=1 BEADS_TEST_DOLT_SERVER=local BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 BEADS_TEST_SKIP= go test -count=1 -p 1 -tags integration ./cmd/bd -run '^(TestRepairPrefixesKeepsSuffixes|TestRepairPrefixesRepointsEdgesOntoUnrenamedTargetRows|TestRepairPrefixesKeepsSuffixesWithoutCollision|TestRepairPrefixesKeepsDottedChildren|TestRepairPrefixesCollisionReRootsTree|TestRepairPrefixesSplitsByKnownPrefix|TestRepairPrefixesDryRunMatchesRealRun|TestRepairMultiplePrefixes|TestRepairPrefixesRetargetsBeadGates|TestRenameFailureLeavesBeadGatesPending)$' -v   # 10/10 PASS
BEADS_TEST_EMBEDDED_DOLT=1 go test -count=1 -p 1 -tags integration ./cmd/bd -run '^TestEmbeddedRenamePrefixEdgeCases$' -v   # 6/6 subtests PASS

go build ./..., CGO_ENABLED=0 go build ./..., go vet ./cmd/bd/ and gofmt are clean; the hand check of the body's AC-1/AC-2 scenario (taxdb-u6ch with a child, cre-db-c2a, kb-hand, an edge cre-db-c2a -> taxdb-u6ch) gives kb-u6ch, kb-u6ch.1, kb-c2a and the re-pointed edge on the head, and hash ids on main; --mint-only then mints kb2-* roots, kb-u6ch.2 children and accepts an explicit kb-zzzz. CI: 29 pass, 13 skipping.

Non-blocking, pre-existing (main behaves the same): text references in rows that are NOT renamed (an unchanged target-prefix row that mentions taxdb-u6ch.1) are never rewritten, since the rewrite runs only over the planned renames, and comment bodies are not touched either; the help text and the new CHANGELOG bullet both promise that "text references follow the renames". Worth a follow-up issue or a softer sentence.

gascity-eddie Bot added a commit that referenced this pull request Nov 14, 2026
…ps a refused edge

Review fixes for #8473, iterations 1 to 3.

- The re-point guard judged an edge on its source's old ID and its
  target's new ID, so every edge inside a renamed family (parent-child,
  blocks between two taxdb rows, a legacy close gate) looked cross-prefix
  and was removed and re-added. The re-add stamped the repair's actor and
  time on the edge, and its hierarchy check refused a close gate, which
  deleted the gate and stopped the run before issue_prefix was set. The
  guard now compares both ends' IDs from before the repair, so an edge
  storage already re-pointed in place stays as it is.
- An edge the repair does re-point now moves in one transaction, so a
  re-add storage refuses (an edge stored across prefixes never went through
  the hierarchy check) rolls its removal back. The run reports the edge, in
  text and as unrepointed_edges under --json, goes on to the next edge and
  sets issue_prefix. On a SQL server each edge gets its own Dolt commit, as
  the store-level writes it replaces did; on an embedded store it gets
  none, so the post-run auto-commit still takes the whole repair,
  issue_prefix included (a commit per edge there skipped it and left the
  config row uncommitted).
- Parent-child edges are re-pointed first, then every other edge, so each
  blocking re-add is checked against the re-pointed hierarchy. In
  source-ID order alone a re-add was checked against a partly re-pointed
  graph whose ancestry and cycle walks stop at old IDs that no longer
  exist: a grandchild blocked by its own grandparent landed unreported
  when it sorted first, and an epic's close gate on its child across
  prefixes landed while the child's parent-child edge was refused instead.
- A blocking edge without which storage would accept a parent-child edge
  it refused for a cycle is left as it was and reported. An epic's close
  gate on a child already on the target prefix is stored across prefixes,
  where blocked state never reads it; once the epic is renamed it names
  two live issues, and the cycle walk, which reads every column, refused
  the child's parent-child edge through it. Re-added, the gate then
  landed where it blocks the epic while the child stayed detached. Before
  each blocking edge moves, a transaction that always rolls back removes
  it and retries each parent-child move refused for a cycle; one that
  lands keeps the edge where it was.
- Only storage refusing an edge (a cycle, a block on the issue's own
  ancestor or descendant, an edge onto itself, a second type for one pair,
  a missing endpoint) is reported and stepped over. Any other failure (a
  commit whose outcome is unknown, a lost connection) stops the run before
  issue_prefix, and the error names the edges refused before it; it was
  reported as a refusal, so an edge that had moved read as left as it was.
- The refusal report no longer says a refused edge does not affect
  readiness. A database older than the dependency-target split, or a bd
  rename, keeps edges between two prefixes in the issue column, where a
  refused blocks edge still blocks. The guard cannot see the column, so
  such an edge is re-added too: the --repair help, the CHANGELOG and the
  advanced reference now say a re-pointed edge records the repair's actor
  and time. Re-pointing only rows in the external column, in place, needs
  an issueops primitive for its own PR, stacked below this one.
- After --mint-only the config names the new prefix while every issue may
  still carry the old one. bd rename-prefix <new>, and the --repair the
  --mint-only warning advises, now rename those issues instead of refusing
  <new> as the current prefix; only rows already on <new> make it a no-op.
- --mint-only now says, on stderr, in its help, the CHANGELOG and the
  reference docs, that a dependency between an old-prefix and a new-prefix
  issue does not block: storage classifies an edge by the part of each ID
  before its first hyphen and ignores allowed_prefixes, and blocked state
  never reads such an edge. Making the classifier honor issue_prefix and
  allowed_prefixes is an issueops change for its own PR, stacked below this
  one.
- The CHANGELOG, the --repair help and the advanced reference now say a
  repair rewrites text references only inside the renamed issues, the scope
  the design set.
- planPrefixRepair is split into family grouping, the claim of wanted
  roots and hash-root allocation, and repairPrefixes' dry-run report and
  text rewrite move to their own functions, with no change in behavior.
- TestRepairMultiplePrefixesPreservesSuffix and
  TestRepairMultiplePrefixesFallsBackOnCollision come from #6621 by
  Rongjun GENG, the first fix for GH#6591, and now run against this
  planner.

TestRepairPrefixesLeavesEdgesStorageAlreadyMoved and
TestRepairPrefixesKeepsAnEdgeStorageRefusesToRepoint (Dolt lane) and the
embedded repair_repoints_cross_prefix_edges subtest each fail on the
mutant they pin: the old guard; aborting on a refusal; removing and
re-adding outside one transaction; a Dolt commit per edge on an embedded
store. So do the Dolt-lane TestRepairPrefixesRepointsTheHierarchyFirst
(re-pointing in source-ID order alone; its two close gates on a child or
grandchild already on the target prefix fail with no probe, and with a
probe that commits instead of rolling back),
TestRepairPrefixesStopsOnAFailureThatIsNotARefusal (every error counted
as a refusal),
TestRepairPrefixesReportsARefusedIssueColumnEdgeAsLeftAsItWas (the old
readiness claim) and TestRepairPrefixesKeepsAnEdgeThatWouldCloseACycle
(a legacy cycle across prefixes; it, the close-gate shapes and the unit
TestIsDependencyRefusal fail with the cycle arm dropped from the refusal
classifier), and the embedded mint_only_then_repair_renames subtest (the
old same-prefix refusal).

Derived-From: pr6621/cef05ddbbc7efcbbe8de31270ef6e7a64b6bb19d
Co-authored-by: Rongjun GENG <rj.geng@gmail.com>
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
@blacksmith-sh

This comment has been minimized.

@gascity-eddie

gascity-eddie Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Factory review complete: waiting on maintainer approval

PR #8473 is ready for merge approval: #8473

What it does: bd rename-prefix --repair now keeps each issue's suffix when its destination ID is free. It moves families off live, claimed or retired roots, re-points dependencies across the consolidated families, and splits source IDs by declared and observed prefixes. It also adds --mint-only (change the prefix only for new issues; honors --dry-run, refuses --repair). Docs and the CHANGELOG are updated. 11 files, +2648/-142.

Review: attempt 4 approves, scorecard 975/1000 (threshold 850), required changes: none, review coverage identical.

Review TL;DR:

  • Iteration 1 (block): no notice on superseded contributor PR fix(rename-prefix): preserve suffix on --repair instead of always hashing #6621; a refused re-add deleted the edge and aborted the run; the re-point guard rewrote intra-family edges; --mint-only cross-prefix edges did not gate readiness; allowed_prefixes split gaps.
  • Iterations 2-3 (request_changes): order-dependent re-add validation against a partly re-pointed graph; a legacy close gate detached a child.
  • Iteration 4 (approve): a probe transaction keeps refused edges and reports them; issue_prefix is still set; the refusal classifier is fully tested; the wording is narrowed.
  • Deferred follow-ups: N6, where a non-refusal re-point error drops the run's record (a design call about the --json error contract); N2, an in-place retarget primitive; the code arms of F4/F5/F6.

Pre-merge human item: #6621 (rjgeng) is still open and approved. This PR carries the Co-authored-by credit and the ported tests, but no maintainer note has been posted on #6621 yet. The draft is in mail gcg--9223372036829659296. Please post it, or ask for it to be posted, when you approve.

Fixes applied: 13 commits, ending at 8f24615 (fix: --repair leaves already-moved edges alone and keeps a refused edge).

CI: pass. Both required checks passed (PR, Docs). Bazel Farm was skipped.

Merge path: the original PR #8473 (same-repo branch fix/bd-quj8ug), reviewed head 8f24615.


Reviewed head: 8f246155e870 · Workflow run: https://factory.gascity.com/city/maintainer-city/runs/gcg--9223372036829686944
Nothing merges until a maintainer approves. This PR carries status/awaiting-approval until then; after approval the workflow refreshes CI, posts the final review results, and hands the PR to the merge queue.

@gascity-eddie gascity-eddie Bot added the status/awaiting-approval Factory review and CI passed; waiting on maintainer sign-off label Nov 14, 2026

@bee-ghosttrack bee-ghosttrack left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes at 8f24615 (bee, r1237), narrowed to two of the three items from a3dc7d3. The edge re-pointing (item 2) is fixed and well proven; what is left is the CHANGELOG credit as asked, and item 1, which the body now documents but the command still reports as a success.

Range-diff a3dc7d3 -> 8f24615: all twelve earlier commits =, one new commit, 8f24615 (nine files, 1242+/179-): rename_prefix.go, a new rename_prefix_repair_test.go, the embedded and rewrite tests, the CHANGELOG, the command-tree golden, docs/reference/advanced.md, configuration.md and the skill page. No credited test was removed; nine test functions were added.

Item 2, fixed. repairedDependencyTarget judges an edge on both ends' pre-repair IDs (wasTarget through oldID), so an edge storage already re-pointed in place is left alone; each move is one transaction (repointDependency / moveDependencyInTx), so a refused re-add rolls its removal back; parent-child edges move first; a refusal is kept and reported (text and unrepointed_edges), and isDependencyRefusal separates a refusal from a write failure, which still ends the run. Base leg: with the head's rename_prefix_repair_test.go and rename_prefix_embedded_test.go over a3dc7d3's production (rename_prefix_rewrite_test.go kept at the base, since TestIsDependencyRefusal needs the new symbol), TestRepairPrefixesLeavesEdgesStorageAlreadyMoved, KeepsAnEdgeStorageRefusesToRepoint, KeepsAnEdgeThatWouldCloseACycle, RepointsTheHierarchyFirst, ReportsARefusedIssueColumnEdgeAsLeftAsItWas and StopsOnAFailureThatIsNotARefusal all FAIL, and the two #6621 tests pass on both; at 8f24615 all pass. The embedded mint_only_then_repair_renames subtest covers the --repair-after---mint-only change.

Item 3, half done. 8f24615 carries Co-authored-by: Rongjun GENG and Derived-From: pr6621/..., and rename_prefix_repair_test.go:206 says where its two tests come from; thank you. The CHANGELOG --repair bullet still ends in a bare (#6591): neither @cpliakas, who opened #6591, nor @rjgeng / #6621 is named there, and the CHANGELOG is the user-facing credit. The ask as written: make it "(#6591, reported by @cpliakas; suffix preservation first proposed by @rjgeng in #6621)".

Item 1, unchanged in code. groupRepairFamilies still tests strings.HasPrefix(id, targetPrefix+"-") (rename_prefix.go:527), and rename_prefix_rewrite_test.go:426 still pins beads-vscode-1 under known beads-vscode to "" for target beads. The PR body now states it as a limitation ("A declared prefix can only lengthen a split"), which is a fair design call for kb-adr-0001, but it answers neither half of what I asked. bd rename-prefix beads --repair on beads-a1b + beads-vscode-1 still prints "Successfully consolidated 2 prefixes into beads, 0 issues repaired" and leaves the database on two prefixes with no further move available. Either closes it: rename a row whose longest known prefix extends the target, or have the run name the rows it left under a second known prefix instead of reporting success (a warning line like the --mint-only one is enough, plus the same sentence in the CHANGELOG bullet and the help, which still say "issues already on the target prefix ... are left alone" without saying that a declared longer prefix counts as on target).

What I ran at 8f24615 (pinned worktree, -count=1, dolt 2.6.0):

go build ./... ; CGO_ENABLED=0 go build ./... ; go vet ./cmd/bd/ ; gofmt -l   # clean
CGO_ENABLED=1 go test -tags gms_pure_go ./cmd/bd -run '^(TestPlanPrefixRepair|TestPlanPrefixRepairKnownPrefixes|TestRepairRetiredLookupFindsTheDecoratedBackend|TestRewriteIssueID_.*|TestRejectProtectedConfigKey|TestCommandTreeGolden|TestCommandHelpGolden|TestIsDependencyRefusal)$'   # PASS
CGO_ENABLED=1 BEADS_TEST_DOLT_SERVER=local BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 BEADS_TEST_SKIP= go test -p 1 -tags integration ./cmd/bd -run '^(TestRepairPrefixes.*|TestRepairMultiplePrefixes.*)$'   # 17/17 PASS
BEADS_TEST_EMBEDDED_DOLT=1 go test -p 1 -tags integration ./cmd/bd -run '^TestEmbeddedRenamePrefix.*$'   # 3/3 PASS, 12 subtests

CI: attempt 1 of run 43556146945 went red in the embedded Dolt tier on TestEmbeddedCompactAbortsDivergentReplay (shard 41 of 50, which holds the Compact, DuplicateConcurrent and VersionedHistory tests, none touched here); attempt 2 is green and CI Gate / Required is green at 8f24615. Nothing in this PR reaches compaction, so I read it as the flake it looks like, but whoever owns that test may want the attempt-1 log.

Non-blocking, as before: text references in unrenamed rows and in comment bodies are not rewritten (pre-existing, main behaves the same); the new help sentence "Text references are rewritten only inside the renamed issues" is the right word for it.

Copy link
Copy Markdown
Collaborator

Approved by @julianknutsen in the maintainer console, for review workflow gcg--9223372036829686944 (reviewed head 8f246155e87069f1ced624342f62dc152fe4ccdb, PR head 8f246155e870). The factory relays this to the workflow's approval gate.

@gascity-eddie

gascity-eddie Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Approval from @julianknutsen relayed to review workflow gcg--9223372036829686944 at reviewed head 8f246155e870. The workflow now refreshes CI, posts the final review results and hands the PR to the merge queue.

@gascity-eddie gascity-eddie Bot removed the status/awaiting-approval Factory review and CI passed; waiting on maintainer sign-off label Nov 18, 2026
…nation is free

Repair used to mint a content hash for every off-prefix issue. It now
plans every rename up front: IDs already under the target prefix stay,
every other ID keeps its suffix under the target prefix, and a family
(an old root plus its dotted children) whose wanted root is held by a
live target ID or an earlier source family moves whole to a hash root.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 0ad51b5)

Ported-From: opus/0ad51b525af2a0f3c9c00e89b1fb19ee2ade687a
AC: AC-1
The repair plan maps each old root, virtual roots of orphan children
included, and rewrites text through that root map, so a reference to
taxdb-5su1.13 keeps its .13 tail. This pins the dotted-family behaviour
the AC-1 planner introduced.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 0f43cc8)

Ported-From: opus/0f43cc813e098cda9051a25f871b8c977228b3b6
AC: AC-2
…red roots and reports it

The repair plan now probes every wanted root and member destination
through the stores' optional RetiredIssueIDs seam (under the CLI's
decorators, as the import dry run does) and treats a retired destination
like a live one: the whole family moves to a hash root with its dotted
paths intact. Hash roots are checked against live, claimed, rejected and
retired IDs, allocation is bounded at 100 attempts, and a lookup error
fails the plan before anything is written.

Every fallback is reported with its old, wanted and assigned root, the
reason (exists, claimed, retired) and the conflicting ID. Under --json
the repair writes exactly one object, for a dry run and a real run
alike, with the complete renames and collisions and a dry_run field;
text progress is suppressed.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 77ca69a)

Ported-From: opus/77ca69a9d06f214c1245c55d3753e58faa58e9c7
AC: AC-3
…idated families

Storage keeps an edge between two different prefixes as a reference
into another repository (issueops.IsExternalDepTarget), so renaming its
target never re-points it: after a repair, kb-hand -> cre-db-c2a still
named cre-db-c2a. Once the renames land, each edge that still names a
renamed issue's old ID is re-added against the new one, which now shares
the source's prefix and is stored as an ordinary edge. References to
issues outside the store are left alone.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit b88ab55)

Ported-From: opus/b88ab55a09f9772e78764210470a55a5fb2d8217
AC: AC-1
…ed prefixes

Repair now reads issue_prefix and allowed_prefixes and adds the prefixes
it detected, so a multi-hyphen family such as cre-db-wxyz maps to kb-wxyz
instead of the heuristic's kb-db-wxyz. IDs already on the target prefix,
like kb-adr-0001, stay as they are.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 3422309)

Ported-From: opus/342230956cfbd36fc3a784b1ac5a344201711190
AC: AC-4
… run does

Pins that a dry run against unchanged inputs writes nothing, and that its
JSON renames and collisions equal the real run's, whose mapping is what the
store then holds.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit f4f0692)

Ported-From: opus/f4f06929bc43e947c0e24c9052d8b09624f143bf
AC: AC-5
…ues only

bd rename-prefix <new> --mint-only sets issue_prefix and keeps the old
prefix valid through allowed_prefixes, without enumerating or rewriting any
issue. Existing IDs and text stay as they are, new roots mint under the new
prefix, and children of existing issues can still be created. A stderr
warning names a config.yaml issue-prefix that would override the change,
and the issue_prefix protected-key hint now lists the option.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 635ca13)

Ported-From: opus/635ca13dfbeeda6b81f3430051d820db8a733f7c
AC: AC-6
A mint-only dry run reports the issue_prefix change and the
allowed_prefixes entry it would add, in text or as one JSON object, and
writes nothing. --mint-only with --repair fails before opening the store.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 5ea6a3b)

Ported-From: opus/5ea6a3b0eaad3bb43d1a531b7fc381e632712d30
AC: AC-7
Help text, the plugin command guide, the configuration reference and the
CHANGELOG describe how --repair now keeps suffixes and reports family
moves, and how --mint-only changes the prefix for new issues only. The
generated CLI reference is pinned to v1.3.4 (docs/cli-docs.pin), so it is
left for the release bump.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit fa96ece)

Ported-From: opus/fa96eced8f5acc1875d0feaefd21e80f4758bd3e
AC: -
…e target prefix

An edge from an off-prefix issue to a target-prefix row (taxdb-x ->
kb-hand) is stored in the external column. Renaming its source to kb-x
left it there, and blocked state reads only the issue column, so kb-x no
longer showed as blocked by kb-hand. Repair now re-adds every edge that
the source's rename turned from cross-prefix into same-prefix, so it is
stored as an ordinary issue edge.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>

AC: AC-1
Derived-From: opus/b88ab55a09f9772e78764210470a55a5fb2d8217
…lit cases

Port glm's planner table onto planPrefixRepair: free suffixes with a
retained custom target ID, a live root, a child-only target namespace, an
earlier family's claim, a retired member destination, a retired hash
candidate skipped after a natural destination is reserved, and the
known-prefix, heuristic and all-letter suffix splits. Add the case glm's
member-keyed claims missed: an orphan family's virtual root claims kb-x,
so a later taxdb-x falls back with reason claimed instead of becoming a
false parent of kb-x.3.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>

AC: AC-3
Derived-From: glm/1d5354991e01, glm/85d0a6ec941d, opus/77ca69a9d06f214c1245c55d3753e58faa58e9c7
… in the advanced reference

The advanced reference still described --repair only as "consolidates
them". It now says each issue keeps its suffix, that a family whose
destination is taken moves whole to a generated root with the collision
reported, how to preview the complete plan (--dry-run --json), and points
at --mint-only for changing only the prefix new issues get.

docs/cli-reference/rename-prefix.md is not regenerated: the generated CLI
reference is pinned to the v1.3.4 release (docs/cli-docs.pin), so a copy
generated from this branch would fail the CLI docs drift check and publish
flags the release lacks. The release bump regenerates it.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>

AC: AC-6
Derived-From: glm/f474174711605a203669622a4b214806eaaa549e, opus/fa96eced8f5acc1875d0feaefd21e80f4758bd3e
…ps a refused edge

Review fixes for #8473, iterations 1 to 3.

- The re-point guard judged an edge on its source's old ID and its
  target's new ID, so every edge inside a renamed family (parent-child,
  blocks between two taxdb rows, a legacy close gate) looked cross-prefix
  and was removed and re-added. The re-add stamped the repair's actor and
  time on the edge, and its hierarchy check refused a close gate, which
  deleted the gate and stopped the run before issue_prefix was set. The
  guard now compares both ends' IDs from before the repair, so an edge
  storage already re-pointed in place stays as it is.
- An edge the repair does re-point now moves in one transaction, so a
  re-add storage refuses (an edge stored across prefixes never went through
  the hierarchy check) rolls its removal back. The run reports the edge, in
  text and as unrepointed_edges under --json, goes on to the next edge and
  sets issue_prefix. On a SQL server each edge gets its own Dolt commit, as
  the store-level writes it replaces did; on an embedded store it gets
  none, so the post-run auto-commit still takes the whole repair,
  issue_prefix included (a commit per edge there skipped it and left the
  config row uncommitted).
- Parent-child edges are re-pointed first, then every other edge, so each
  blocking re-add is checked against the re-pointed hierarchy. In
  source-ID order alone a re-add was checked against a partly re-pointed
  graph whose ancestry and cycle walks stop at old IDs that no longer
  exist: a grandchild blocked by its own grandparent landed unreported
  when it sorted first, and an epic's close gate on its child across
  prefixes landed while the child's parent-child edge was refused instead.
- A blocking edge without which storage would accept a parent-child edge
  it refused for a cycle is left as it was and reported. An epic's close
  gate on a child already on the target prefix is stored across prefixes,
  where blocked state never reads it; once the epic is renamed it names
  two live issues, and the cycle walk, which reads every column, refused
  the child's parent-child edge through it. Re-added, the gate then
  landed where it blocks the epic while the child stayed detached. Before
  each blocking edge moves, a transaction that always rolls back removes
  it and retries each parent-child move refused for a cycle; one that
  lands keeps the edge where it was.
- Only storage refusing an edge (a cycle, a block on the issue's own
  ancestor or descendant, an edge onto itself, a second type for one pair,
  a missing endpoint) is reported and stepped over. Any other failure (a
  commit whose outcome is unknown, a lost connection) stops the run before
  issue_prefix, and the error names the edges refused before it; it was
  reported as a refusal, so an edge that had moved read as left as it was.
- The refusal report no longer says a refused edge does not affect
  readiness. A database older than the dependency-target split, or a bd
  rename, keeps edges between two prefixes in the issue column, where a
  refused blocks edge still blocks. The guard cannot see the column, so
  such an edge is re-added too: the --repair help, the CHANGELOG and the
  advanced reference now say a re-pointed edge records the repair's actor
  and time. Re-pointing only rows in the external column, in place, needs
  an issueops primitive for its own PR, stacked below this one.
- After --mint-only the config names the new prefix while every issue may
  still carry the old one. bd rename-prefix <new>, and the --repair the
  --mint-only warning advises, now rename those issues instead of refusing
  <new> as the current prefix; only rows already on <new> make it a no-op.
- --mint-only now says, on stderr, in its help, the CHANGELOG and the
  reference docs, that a dependency between an old-prefix and a new-prefix
  issue does not block: storage classifies an edge by the part of each ID
  before its first hyphen and ignores allowed_prefixes, and blocked state
  never reads such an edge. Making the classifier honor issue_prefix and
  allowed_prefixes is an issueops change for its own PR, stacked below this
  one.
- The CHANGELOG, the --repair help and the advanced reference now say a
  repair rewrites text references only inside the renamed issues, the scope
  the design set.
- planPrefixRepair is split into family grouping, the claim of wanted
  roots and hash-root allocation, and repairPrefixes' dry-run report and
  text rewrite move to their own functions, with no change in behavior.
- TestRepairMultiplePrefixesPreservesSuffix and
  TestRepairMultiplePrefixesFallsBackOnCollision come from #6621 by
  Rongjun GENG, the first fix for GH#6591, and now run against this
  planner.

TestRepairPrefixesLeavesEdgesStorageAlreadyMoved and
TestRepairPrefixesKeepsAnEdgeStorageRefusesToRepoint (Dolt lane) and the
embedded repair_repoints_cross_prefix_edges subtest each fail on the
mutant they pin: the old guard; aborting on a refusal; removing and
re-adding outside one transaction; a Dolt commit per edge on an embedded
store. So do the Dolt-lane TestRepairPrefixesRepointsTheHierarchyFirst
(re-pointing in source-ID order alone; its two close gates on a child or
grandchild already on the target prefix fail with no probe, and with a
probe that commits instead of rolling back),
TestRepairPrefixesStopsOnAFailureThatIsNotARefusal (every error counted
as a refusal),
TestRepairPrefixesReportsARefusedIssueColumnEdgeAsLeftAsItWas (the old
readiness claim) and TestRepairPrefixesKeepsAnEdgeThatWouldCloseACycle
(a legacy cycle across prefixes; it, the close-gate shapes and the unit
TestIsDependencyRefusal fail with the cycle arm dropped from the refusal
classifier), and the embedded mint_only_then_repair_renames subtest (the
old same-prefix refusal).

Derived-From: pr6621/cef05ddbbc7efcbbe8de31270ef6e7a64b6bb19d
Co-authored-by: Rongjun GENG <rj.geng@gmail.com>
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
@gascity-eddie gascity-eddie Bot added status/merge-ready PR is ready for merge workflow status/merge-queued Queued for deterministic PR-review merge and removed status/merge-ready PR is ready for merge workflow status/reviewing PR review workflow is running labels Nov 18, 2026
@gascity-eddie
gascity-eddie Bot added this pull request to the merge queue Nov 18, 2026
@gascity-eddie

gascity-eddie Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer Adoption Review

Thanks for the contribution, @rjgeng, and thanks to @cpliakas for reporting #6591! This PR makes bd rename-prefix --repair keep each issue's suffix when its destination ID is free (taxdb-u6ch becomes kb-u6ch, cre-db-c2a.3 becomes kb-c2a.3), moves a whole family to one hash root only when its root is taken, re-points dependencies across the consolidated prefixes, and adds bd rename-prefix <new> --mint-only to change the prefix for new issues only. That makes consolidating prefixes usable on a real database instead of replacing every ID with a random hash, and it answers both asks of #6591. It builds on the suffix-keeping repair first proposed in #6621: that PR's two real-store tests are carried as written, and the review commit credits Rongjun GENG as co-author.

This PR was reviewed and adopted with maintainer fixes pushed directly to the PR branch.

Original PR Review

Decision: block (pass 1), then request_changes (passes 2 and 3), resolved to approve (pass 4).

Specific gaps fixed:

  • The re-point guard judged an edge by its source's old ID and its target's new ID, so every edge inside a renamed family was removed and re-added, which re-stamped its created_by/created_at, and a refused re-add deleted a legacy close gate and stopped the run before issue_prefix was set. The final patch judges both ends by their IDs from before the repair and leaves an edge that storage already moved in place alone.
  • An edge the repair does re-point now moves in one transaction: a re-add that storage refuses rolls its removal back, the edge is kept and reported (in text, and as unrepointed_edges under --json), and the run still sets issue_prefix. Any other failure stops the run and names the edges refused before it.
  • Parent-child edges are re-pointed before every other edge, so each blocking re-add is checked against the re-pointed hierarchy. A blocking edge whose removal alone would let a refused parent-child edge land (an epic's legacy close gate on its own child) is held back and reported instead of landing active while the child stays detached. The check is a transaction that always rolls back; the reviewers traced the rollback on both the SQL-server and embedded stores.
  • bd rename-prefix <new> and --repair after --mint-only now rename the old-prefix issues instead of refusing <new> as the current prefix, and --mint-only says on stderr, in its help, in the CHANGELOG and in the reference docs that a dependency between an old-prefix and a new-prefix issue does not block yet.
  • fix(rename-prefix): preserve suffix on --repair instead of always hashing #6621 was being superseded without a word. The review commit carries Co-authored-by: Rongjun GENG and the two carried tests, and before this handoff an explanation with credit went on fix(rename-prefix): preserve suffix on --repair instead of always hashing #6621: fix(rename-prefix): preserve suffix on --repair instead of always hashing #6621 (comment)
  • Validated: required CI is green on the final head 01a97c881f. Locally, the CHANGELOG and doc guards, the command-tree goldens and the rename-prefix tests of the ci lane pass on the final head, and the rename-prefix Dolt-lane (20) and embedded (8 subtests) tests passed one base refresh earlier with the same code.

bee-ghosttrack's review at 8f246155e8 still requests changes. Item 2 (edge re-pointing) is fixed, as that review confirms. Item 1 is filed below as bd-mynaf9. Item 3, naming the reporter and #6621 in the CHANGELOG bullet, did not make it into this PR: the squash keeps the bullet's bare (#6591), so the credit is recorded here, in the commit trailer and on #6621.

Review findings addressed:

  • Behavioral Correctness (major, high, claude + codex, pass 1): the re-point guard compared the source's old ID with the target's new ID and re-added every edge inside a renamed family. Fixed by 01a97c8.
  • Error Handling & Resilience (major, high, claude + codex, pass 1): a refused re-add deleted the edge, aborted after every rename and left issue_prefix unset. Fixed by 01a97c8.
  • Concurrency, Ordering & State Safety (major, pass 2): one pass in source-ID order checked re-adds against a partly re-pointed graph. Fixed by 01a97c8 (the hierarchy moves first).
  • Concurrency, Ordering & State Safety (major, pass 3): a legacy close gate on a child already on the target prefix landed active and detached the child. Fixed by 01a97c8 (the rolled-back probe).
  • Test Evidence Quality (minor, pass 3): only the hierarchy arm of the refusal classifier was tested. Fixed by 01a97c8 (TestIsDependencyRefusal, TestRepairPrefixesKeepsAnEdgeThatWouldCloseACycle).
  • Behavioral Correctness (major, pass 2): edges a database older than the dependency-target split keeps in the issue column were re-added while the refusal report claimed readiness was unaffected. 01a97c8 drops that claim and documents that a re-pointed edge records the repair's actor and time; keeping their provenance is bd-twjgzp below.
  • Change Impact / Blast Radius (blocker, medium, claude, pass 1): silent supersession of fix(rename-prefix): preserve suffix on --repair instead of always hashing #6621. The code half (co-author trailer, carried tests) is in 01a97c8; the notice on fix(rename-prefix): preserve suffix on --repair instead of always hashing #6621 was posted before this handoff.
  • Change Impact / Blast Radius (major, high, codex, pass 1): --mint-only old-to-new dependencies never gate readiness. 01a97c8 states the limitation everywhere the review asked, as the required change allowed; the storage fix stays open as Same-database cross-prefix blocks dependencies are stored as external and ignored by bd ready #8299 below.

Non-blocking follow-ups (shared for visibility — NOT completed in this PR):

Filed as follow-up beads:

  • bd-mynaf9: Behavioral Correctness (minor): bd rename-prefix beads --repair on beads-a1b plus beads-vscode-1 prints "Successfully consolidated 2 prefixes" with 0 issues repaired, and a plain rename then refuses and points back at the same no-op --repair (bee-ghosttrack item 1; review finding F6).
  • bd-31zqv2: Behavioral Correctness (open risk, pre-existing): a plain bd rename-prefix <new> rewrites text references only for all-digit IDs, so hash-ID references such as taxdb-u6ch go stale although the help promises all text references.
  • bd-twjgzp: Change Impact / Blast Radius (major, carried): --repair re-stamps created_by/created_at on every dependency it re-points, including issue-column edges that needed no move; the fix is an in-place issueops primitive.
  • Same-database cross-prefix blocks dependencies are stored as external and ignored by bd ready #8299: Change Impact / Blast Radius (major, carried): after --mint-only, a dependency between an old-prefix and a new-prefix issue is stored as an external reference and never blocks; open PR fix(storage): treat same-database cross-prefix dependency targets as local #8300 would classify it as local. This run's evidence is on its bead (bd-6jk1y2).

Not filed (below the follow-up bar):

  • Test Evidence Quality (minor, high, claude + codex; cmd/bd/rename_prefix.go:903-905, :933-955, cmd/bd/rename_prefix_repair_test.go:799, :816, :842): nothing pins that the probe holds back only the edge that closes the cycle; a "hold back every blocking edge" mutant and a "probe only the first refused edge" mutant pass every rename-prefix test. Test-only.
  • Change Impact / Blast Radius (minor, high, codex, claude as an open risk; cmd/bd/rename_prefix.go:933-955, :1035-1056): the probe costs one rolled-back transaction per blocking move and cycle-refused parent-child move, including moves whose stored target is a renamed issue's dead old ID, and a transient probe error names the blocking edge rather than the probed move. Performance and hardening; the misattribution is on a transient-failure path.
  • Contract & Interface Fidelity (nit, high, codex; cmd/bd/rename_prefix.go:54-57, :1029, :1122, the rename-prefix help in tree.golden, docs/reference/advanced.md:44-46): the help, the reference and two run messages describe only storage refusals, not a held-back edge (the CHANGELOG does). Help text and docs.
  • Test Evidence Quality (open risk, claude + codex; cmd/bd/rename_prefix_embedded_test.go:269, internal/storage/embeddeddolt/store.go:548-551): no embedded test reaches a refused re-add or a probe rollback. Test-only.
  • Error Handling & Resilience (minor, carried, claude + codex; cmd/bd/rename_prefix.go:771-774, :1020-1032): a re-point failure other than a refusal (a lost connection, a commit of unknown outcome) ends the run after every rename and before issue_prefix, the collision report and the --json object, and an interrupted repair cannot finish re-pointing because the old-to-new map lives only in memory. It needs an infrastructure failure mid-run, the edges left behind keep the readiness they had before the repair, and the error-path --json contract is a design call; the PR body lists it under Limitations.
  • Concurrency, Ordering & State Safety (minor, carried, claude + codex; cmd/bd/rename_prefix.go:933-955): with two independent blocking paths from an epic to its child, neither probe lands, both edges are re-added and the child stays detached; codex adds an order-dependent variant. Reported in unrepointed_edges; legacy shapes only, since normal adds refuse the pair; listed under Limitations.
  • Behavioral Correctness (carried decision, claude + codex): a legacy close gate in the issue column is held back and reported, and the child stays detached; whether a repair may drop such a gate is a design decision. Reported, readiness unchanged.
  • Behavioral Correctness (trade-off on record, codex, with claude's "edges in series" note; no change asked): the hold-back rule is general, so in a legacy 3-cycle the epic's own dependency also stays inert, and every blocking edge in series on one path is held back. Reported, never worse than before the repair.
  • Behavioral Correctness (carried, claude + codex; bee-ghosttrack's non-blocking note): text references in rows that --repair does not rename, comment bodies and close reasons are not rewritten. Pre-existing and documented scope ("Text references are rewritten only inside the renamed issues"); the plain-rename case is folded into bd-31zqv2.
  • Error Handling & Resilience (carried): transient write conflicts are not retried. Any retry belongs below cmd/bd; hardening.
  • Concurrency, Ordering & State Safety (note, pass 3, codex): verdicts of the second pass's cycle check depend on edge order. Deterministic, legacy rows only.
  • Contract & Interface Fidelity (note, pass 3): after --mint-only and a later consolidating rename, the old prefix stays in allowed_prefixes. No wrong result shown.
  • Release Safety (bee-ghosttrack item 3; the --repair bullet in CHANGELOG.md): the bullet ends in a bare (#6591) instead of naming the reporter and fix(rename-prefix): preserve suffix on --repair instead of always hashing #6621. CHANGELOG wording; the credit is in the commit trailer, on fix(rename-prefix): preserve suffix on --repair instead of always hashing #6621 and in this comment.
  • Merge interactions (carried): test(bootstrap): pin that bootstrap never rewrites an existing issue_prefix (GH#3494) #7909 edits the same rejectProtectedConfigKey hint; fix(rename): rewrite whole-ID references and list the ones it leaves (#7040) #8196, fix(rename): rewrite close_reason and the renamed issue's own text (#7040) #7399 and fix(rename): accept target prefixes bd init produces (#6068) #8440 add tests to cmd/bd/rename_prefix_repair_test.go; bd-91bzp: make issue prefix mutations explicit #4175's BEADS_ALLOW_PREFIX_MUTATION guard would refuse the issue_prefix write of --mint-only unless whichever PR lands second wraps it (its refusal prints a remedy that works, and the merged result fails the embedded --mint-only tests). Two-PR merges; the merge queue tests the merged result.
  • CI (bee-ghosttrack): attempt 1 of run 43556146945 at 8f246155e8 went red on TestEmbeddedCompactAbortsDivergentReplay, a known flake in a test this PR does not touch (fix open in test(compact): hold updated_at fixed in the straddled-cutoff fixture #8232). Test-only; the final head's CI passed on its first attempt.

Maintainer Changes

Final Review Status

Ready for the merge queue: final head 01a97c881f has passing required GitHub checks, and the merge-ready metadata is in place. I marked this PR status/merge-ready and handed it to the merge queue before posting this summary.

CI: https://github.com/gastownhall/beads/actions/runs/44343767152

Review Iterations

4 review passes. Pass 1 blocked on the silent supersession of #6621 and three major re-pointing findings, and passes 2 and 3 asked for the re-pointing order and the legacy close gate; each was fixed by amending the one maintainer commit. Pass 4 approved with no code change. A maintainer approved the reviewed head, and finalize rebased it onto main (CHANGELOG-only conflicts) before the handoff.


Adopted via /adopt-pr workflow. Original contributor commits preserved.

Merged via the queue into main with commit 0e5fe00 Nov 18, 2026
43 checks passed
@gascity-eddie
gascity-eddie Bot deleted the fix/bd-quj8ug branch November 18, 2026 17:00
@gascity-eddie gascity-eddie Bot removed the status/merge-queued Queued for deterministic PR-review merge label Nov 18, 2026
@github-actions github-actions Bot mentioned this pull request Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Broken existing behavior priority/p1 High: core workflow broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rename-prefix --repair replaces every id with a random hash; no way to consolidate prefixes while keeping suffixes, or to change the mint prefix alone

2 participants