Skip to content

fix(github): leave transferred issues alone and stop GHE push duplicates - #7948

Open
gascity-eddie[bot] wants to merge 4 commits into
mainfrom
fix/bd-ijkgro
Open

gascity-eddie[bot] wants to merge 4 commits into
mainfrom
fix/bd-ijkgro

Conversation

@gascity-eddie

@gascity-eddie gascity-eddie Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

#8068 fixed #7781 on main first, with its own design: GitHub refs
resolve only within the configured repository, and Init learns the
repository's other names. This PR is rebuilt on that fix. It keeps
#8068's code and policy and carries the rest of this PR onto it.

Transferred issues. GitHub follows a transfer, so fetching a bead's
issue returned it under the other repository's URL. Conflict detection
compared the bead with it, a push could send the bead's content to its
old URL, and a selective pull (by bead ID or issue number) or a
pre-linked hydration imported it as a new bead, or wrote it over a bead
already linked to its new URL. Now:

  • Conflict detection and push leave such an issue alone, and the push
    says why it skipped the bead.
  • A selective pull or a hydration skips an issue that comes back under
    a URL the configured repository cannot address, whichever bead holds
    that URL.
  • A row from the repository's issue list under such a URL is the
    repository's own issue, served under a name the tracker does not
    know. The pull takes it into the bead that links its number in the
    configured repository, under the usual local-edit guard, and imports
    it when no bead does. That bead keeps its link, so the push still
    updates the issue: relinked under the new name, it would drop out of
    push and conflict detection.

Push and conflict detection infer a transfer only when the tracker
knows its target's names (new optional tracker.TargetNamesReporter;
GitHub: Init read the repository's current name). Without them an issue
of a renamed repository looks transferred, so when GitHub answers that
lookup with a 404, push and conflict detection treat the issue as the
configured repository's, as main does. Any other failure stops the
command, as on main since #8399. The README says so.

Warnings. A push says when it skips a bead linked outside the
configured repository: in one line for a bulk push, including one a
rate limit cuts short, and once per bead for a push by ID. A pull says
when an issue came back under a URL outside the configured repository,
and which ones it skipped. The warnings name the configured repository
(new optional tracker.TargetDescriber).

Hosts. IsExternalRef recognizes an issue URL that contains github.com in
any letter case or, once the tracker is initialized, sits on a host of
the configured repository. On a GitHub Enterprise host whose name lacks
"github.com", a push now updates the linked issue instead of creating a
second issue and relinking the bead to it. RefScope accepts the host
respellings the legacy parse did: a www. prefix, a missing scheme, an
explicit default port, a trailing dot. Init records the host of the
repository's html_url with its name, and that host counts as the
configured host, so an API proxy in front of github.com addresses the
github.com refs it returns.

Not carried from this PR's first design: its per-sync TargetResolver
and that resolver's failure policy (a failed lookup stopped the sync;
main's Init goes on with the configured name after a 404, and since
#8399 fails on any other error), its wording of the
pull-by-bead-ID warning (#8068's stays), and reading a path below an
issue (/issues/42/comments) as that issue, which #8068's
TestExtractIdentifierScopedToRepository rejects.

Known limits:

  • When GitHub answers the lookup of the repository's names with a 404,
    sync cannot tell a renamed repository's issue from a transferred one.
    A selective pull or a hydration skips either as outside the
    repository, while the same sync's push can write the bead over it,
    as main's push can.
  • bd github push --dry-run does not fetch issues, so it still previews
    "Would update" for a bead whose issue was transferred; the real run
    skips it.

Testing at 0a7afb5, with bazel-test (--config=ci):

  • //internal/github:github_test: 195 passed, 0 skipped.
  • //internal/tracker:tracker_test: 151 passed, 70 Dolt-backed tests
    skipped; //internal/tracker:tracker_dolt_test with --config=doltserver:
    222 passed, 0 skipped.
  • //internal/ado:ado_test, //internal/gitlab:gitlab_test,
    //internal/jira:jira_test, //internal/linear:linear_test,
    //internal/notion:notion_test and
    //internal/tracker/conformance:conformance_test: all passed.

The tests this PR adds include TestSync_TransferredIssue,
TestSync_RenamedRepositoryWithoutItsNames, TestPush_RenamedRepository,
TestPush_SkipsBeadLinkedToOtherRepo,
TestPush_UpdatesLinkedIssueOnEnterpriseHost,
TestResolveRepositoryNamesLearnsTheIssueHost,
TestIsExternalRefRecognizesConfiguredHost,
TestEngineWarnsOnceForUnaddressableRefs and
TestEngineReportsUnaddressablePushSkipsOnRateLimitAbort.
TestPullFallbackKeyIsRepoScoped (the #7781 triage repro) and
TestEngineDryRunSkipsUnaddressableRef pin behavior #8068 shares.


Source bead: bd-ijkgro · checkpoint pipeline v0

Fixes #7781

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

gascity-eddie Bot commented Oct 28, 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--9223372036829329568

The review restarted at 2026-11-18 13:36 UTC; the link above follows the current run.

@gascity-eddie gascity-eddie Bot added status/reviewing PR review workflow is running and removed status/needs-review Request PR review workflow labels Oct 28, 2026
@gascityinc-sarah gascityinc-sarah Bot added kind/bug Broken existing behavior priority/p0 Critical: data, security, or basic operation blocked labels Oct 28, 2026
@gascityinc-sarah

Copy link
Copy Markdown

Triage: kind/bug · priority/p0 — Ranked p0 with #7781, the bug it fixes: an ordinary bd github pull against one repo silently overwrote the title, body and external_ref of a bead linked to another repo. Unrequested data loss.
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 Oct 28, 2026
@gascity-eddie

gascity-eddie Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Factory review complete: waiting on maintainer approval

Approval request: #7948
Title: test(github): sync reports no conflict with a foreign-linked bead
Branch: fix/bd-ijkgro -> main (same-repository; reviewed head pushed to the PR)
Reviewed head: 6fcfe7b

What it does:

  • Scopes GitHub issue matching to the configured repository, so a bead linked to another repo (e.g. bug: bd github pull matches issues by number only, overwriting a bead from another repo #7781 cross-repo same-number issue) is never pulled/pushed/conflicted against the wrong issue.
  • Tracker engine counts an unaddressable external ref as skipped (push, pull, dry-run preview, conflict detection).
  • Renamed/transferred repositories: ResolveTarget learns old and new owner/repo names by GitHub repository ID before any ref is read, so sync updates and relinks instead of importing duplicates or losing remote edits. Transferred issues are skipped; enterprise hosts recognized after init.
  • 15 files, +2183/-35 (mostly tests), CHANGELOG entry.

Review: attempt 4 decision APPROVE, scorecard 881/1000 (threshold 850), required changes: none, review coverage identical.

Review TL;DR:
Reached approval after 3 fix iterations.

  • Iter 1 (request_changes): warn when a fetched issue's ref is unaddressable (renamed/transferred repo).
  • Iter 2 (request_changes): bind pull cursor to target; skip unaddressable push updates/conflicts; relink by immutable repo identity; host-based URL recognition.
  • Iter 3 (request_changes): remote edits lost between remedy steps; quiet repo duplicates; new-URL beads invisible to conflict detection.
  • Iter 4 (approve), validated by claude+codex: manual remedy removed, names learned by repository ID under either config; new-URL refs resolve; selective pull works; bug: bd github pull matches issues by number only, overwriting a bead from another repo #7781 cross-repo case safe (404/403 never addressable); transferred issue skipped; enterprise host push works; alias-probe transport errors abort before reads.

Fixes applied:

  • 6fcfe7b fix(github): sync a renamed repository's issues without duplicates or lost edits
  • ae12340 test(github): sync reports no conflict with a foreign-linked bead
  • f48bc52 fix(tracker): count an unaddressable ref as skipped in the push preview
  • 0223b35 test(github): push skips a bead linked to another repository
  • 9ea723c test(github): pin repo-scoped matching against over-scoping
  • b0747d0 fix(github): scope issue matching to the configured repository

CI: pass (PR success, PR Risk success; trusted-fork farm and rbe sync skipped as N/A).

Merge path: original PR #7948 (same-repo branch, live head = reviewed head).


Reviewed head: 6fcfe7b6bb3b · Workflow run: https://factory.gascity.com/city/maintainer-city/runs/gcg--9223372036835930272
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 Oct 28, 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.

APPROVE at 6fcfe7b.

Read: the full production diff — internal/github/{links,tracker,client}.go, internal/tracker/{engine,tracker}.go and the new engine_unaddressable.go. The fix is the one #7794 pointed at: once the tracker has a client, ExtractIdentifier goes through RefScope.IssueNumberFromRef, so a ref to another repository (or another host) yields "" and the engine's pull-fallback key can no longer collide on the bare number. IsExternalRef stays repo-agnostic (now also case-insensitive and GHE-aware via onHost), which is what lets the engine tell "linked outside the configured repository" from "no ref". splitIssueURLPath reads the first issues/{n} pair, so the REST form, the /api/v3 prefix, a repo literally named issues, and /issues/42/comments all resolve as the comments say. ResolveTarget learns the repository's other names by ID through GET /repos/{owner}/{repo} (one call for the configured name, one per distinct foreign owner/repo named in local refs; an HTTP status skips the name, a transport or rate-limit error stops the sync, as the interface doc says).

Ran locally (dolt 2.6.0 on PATH, go test -count=1): the canonical 8 — TestExtractIdentifierScopedToRepository TestExtractIdentifier TestPullFallbackKeyIsRepoScoped TestPull_SameNumberInOtherRepoCreatesNewBead TestPull_SameRepoRespellingsUpdateInPlace TestPush_SkipsBeadLinkedToOtherRepo TestSync_NoConflictWithBeadLinkedToOtherRepo TestEngineDryRunSkipsUnaddressableRef → ok internal/github, ok internal/tracker. gofmt -l clean, go vet clean on both packages.

Mutant: restored the legacy repo-agnostic parse in Tracker.ExtractIdentifier (dropped the t.client != nil branch) → 5 red in internal/github (TestPullFallbackKeyIsRepoScoped, TestPull_SameNumberInOtherRepoCreatesNewBead, TestPush_SkipsBeadLinkedToOtherRepo, TestSync_NoConflictWithBeadLinkedToOtherRepo, TestExtractIdentifierScopedToRepository); internal/tracker stays green, as expected for its fake tracker. Restored.

Notes, none blocking:

  • CHANGELOG.md conflicts with main (git merge-tree): rebase owed before the queue.
  • The title says test(github): … but this is a +2183/−35 fix across the github and tracker packages with a new TargetResolver interface; a fix(github): title would describe what lands.
  • Engine.resolveTarget runs Store.SearchIssues(ctx, "", IssueFilter{}) on every Sync to collect refs, on top of the pull/push's own full reads: one more full scan per sync. Fine for correctness; worth a follow-up if sync time on a large store matters.
  • CI: proxied-server tier and the Dolt tiers are SKIPPING on this PR (as on every PR), so the local run above is the only read of those packages.

Supersedes contributor #7794 for #7781 (same ExtractIdentifier scoping, plus the warnings, changelog and engine tests it lacked).

Copy link
Copy Markdown
Collaborator

Approved by @julianknutsen in the maintainer console, for review workflow gcg--9223372036835930272 (reviewed head 6fcfe7b6bb3b53cd4b3a01a1f3071de42d8c8af7, PR head 6fcfe7b6bb3b). The factory relays this to the workflow's approval gate.

@gascity-eddie

gascity-eddie Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

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

@gascity-eddie

gascity-eddie Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer Adoption Review

Thanks for the contribution, @NahumLitvin! This PR carries your fix from #7794 for the bug you reported in #7781. bd github pull, push and sync matched issues by their bare number, so pulling one repository's issue 42 overwrote a bead linked to another repository's issue 42. Your report pinned down the cause with a two-command repro: matching ignored the owner/repo in the stored URL. The repository scoping from your #7794 is the core of the final patch. It closes a silent data-loss path for anyone whose beads link to more than one GitHub repository.

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

Original PR Review

Decision: request_changes resolved to approve.

Specific gaps fixed:

  • Scoping refs to the configured repository first broke renamed and transferred repositories. With the configuration on either name, a pull imported a second bead per issue, and edits made in between could be overwritten. The final patch drops the manual "repoint, then reconfigure" remedy. Each sync now asks GitHub which repository the configured name answers with (GET /repos/{owner}/{repo}) and treats every name that answers with the same repository ID as that repository. A pull updates and relinks the bead, and push and conflict detection keep addressing it (TestSync_RenamedRepositoryKeepsRemoteEdits, TestPull_RenamedRepository).
  • Spellings of the configured repository's URLs that synced before the scoping resolve again: www.github.com, no scheme, an explicit :443, or a path below the issue such as /issues/42/comments (TestPull_SameRepoRespellingsUpdateInPlace).
  • GitHub Enterprise hosts without github.com in their name, and mixed-case hosts, now count as GitHub. A push updates the linked issue instead of creating a second one (TestPush_UpdatesLinkedIssueOnEnterpriseHost).
  • A bead linked to another repository is skipped on push with a warning, also when a rate limit aborts the push, and --dry-run counts it as skipped. An issue transferred to another repository is left alone by pull, push and conflict detection (TestSync_TransferredIssue).
  • The no-conflict sync test now serves repo-B's issue 42 and asserts that it is never read, so a regressed conflict check can no longer pass it.

Review findings addressed (all in maintainer commit 877fc35c81, the reviewed 6fcfe7b6bb rebased onto current main):

  • Change Impact / Blast Radius (major, claude): after a repository rename with the configuration still on the old name, every pull duplicated each issue, and the duplicates could never push.
  • Behavioral Correctness (minor, codex+claude): www., scheme-less and :443 spellings of the configured repository were skipped on push and duplicated on pull.
  • Debuggability & Operability (minor, claude): bd github push <id> for a bead linked to another repository exited 0 with no warning.
  • Test Evidence Quality (minor, claude+codex): the Conflicts == 0 assertion in TestSync_NoConflictWithBeadLinkedToOtherRepo could not fail.
  • Behavioral Correctness (major, claude): the rename skip advanced github.last_sync past the issues it dropped, so they never came back.
  • Concurrency, Ordering & State Safety (major, claude): with a stale configuration, push wrote the bead's stale content over a remote edit the pull had skipped, and conflict detection missed it.
  • Change Impact / Blast Radius (major, codex): the warning's remedy order made the next pull duplicate every issue.
  • Contract & Interface Fidelity (major, codex+claude): Enterprise and mixed-case hosts bypassed the new skip.
  • Debuggability & Operability (minor, codex): a same-repository /issues/42/comments ref was reported as linked to another repository.
  • Concurrency, Ordering & State Safety (major, claude): a bd github command run between the remedy's two steps let the next sync overwrite a skipped remote edit.
  • Behavioral Correctness (major, claude+codex): a quiet repository, or a configuration already on the new name, imported duplicates without a warning.
  • Concurrency, Ordering & State Safety (major, codex): a bead imported under the new URL was invisible to conflict detection.
  • Contract & Interface Fidelity (minor, codex): bd github pull <id> refused a bead that a bulk pull updated.

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

Filed as follow-up beads:

Not filed (below the follow-up bar):

  • Behavioral Correctness (minor, claude, internal/github/tracker.go:315-333, internal/tracker/engine.go:486-493): a pull relinks only the beads whose issues it lists or hydrates, so a bead whose issue never changes keeps the old URL. If another repository later claims the old name, that bead stops syncing and its issue's next edit imports a second bead. The CHANGELOG's "a pull relinks a bead to its issue's new URL" (CHANGELOG.md:1126-1127) reads broader than that. Outside ordinary use: another repository has to claim the old name, and the push then warns that the bead is linked outside the configured repository.
  • Test Evidence Quality (minor, claude+codex, internal/github/tracker_renamed_repo_test.go:63-65): the rename fixtures answer the old name with 200, not with GitHub's 301 (reads) or 307 (writes), so no test pins the redirect handling the name learning relies on. Test-only.
  • Behavioral Correctness (blocker raised by codex, refuted in synthesis, internal/github/client.go:22-32, internal/github/tracker.go:339-343): a write under a renamed repository's old name was said to be followed as a bodyless GET after a 301. GitHub answers writes on a renamed repository with 307, which replays the method and body. The remaining suggestion (refuse method-changing redirects, and let answeredWithStatus accept only 4xx) is hardening.
  • Error Handling & Resilience (open risk, claude, internal/github/tracker.go:323-334): a probe failure other than an HTTP status (5xx after retries, rate limit, timeout) for an owner/repo that a bead names stops every bd github sync, pull and push until it clears. The error names the repository rather than the bead, and each ref synced in from a shared Dolt remote adds a request. Transient by design: a retry clears it, and no persistent trigger was shown. Capping the probes is hardening.
  • Contract & Interface Fidelity (open risk, claude, internal/github/tracker.go:300-302): an API proxy that serves the issue endpoints but answers GET /repos/{owner}/{repo} with 404 leaves the issue host unlearned, so pushes skip every linked bead. Unverified: no such proxy was shown.
  • Release Safety (minor, codex, internal/tracker/engine.go:1262): bd github push --dry-run previews "Would update" for a bead whose issue was transferred to another repository, while the real push skips it with a warning. Preview only.
  • Debuggability & Operability (open risk, claude, internal/github/tracker.go:295, internal/tracker/engine_unaddressable.go:15-20): every sync, dry runs and bd github push <one id> included, sends one uncached GET /repos for the configured repository plus one per other owner/repo the beads link to, and reads every local bead one more time (also noted in @bee-ghosttrack's review). Performance; the CHANGELOG states the request cost.
  • Debuggability & Operability (open risk, claude, internal/tracker/engine_unaddressable.go:100): the warning for a bead whose issue was transferred to another repository recurs on every sync and names no way to retire the link. Warning wording; the skip itself is correct.
  • Debuggability & Operability (open risk, claude, internal/github/tracker.go:347): DescribeTarget names owner/repo, but not the host or the name GitHub answers with after a rename. Wording.
  • Behavioral Correctness (open risk, codex, internal/github/links.go:88): a protocol-relative //github.com:443/... ref keeps its port and does not match github.com. Outside ordinary use: bd never writes that spelling.
  • Concurrency, Ordering & State Safety (open risk, claude, internal/tracker/engine.go:848, :515): repointing a bead with bd update --external-ref makes the next pull hydrate it from GitHub over unpushed local edits. Pre-existing pre-link design: a ref set after the last sync adopts the remote issue, as TestEnginePullHydratesOlderIssueWhenExternalRefAddedAfterLastSync pins. Renames no longer need a repoint.
  • Stale configuration (open risk, claude): a configuration that still names an old name another repository has since claimed syncs against that repository. Pre-existing (base behaves the same) and outside ordinary use.
  • Data repair (open risk, claude): beads that bug: bd github pull matches issues by number only, overwriting a bead from another repo #7781 overwrote before this fix stay linked to the wrong repository. Damage left by older versions; nothing at the final head causes it.
  • Contract & Interface Fidelity (open risk, claude): a github:N shorthand ref binds to whichever repository is configured at sync time. Documented behavior (CHANGELOG).
  • Change Impact / Blast Radius (codex, unresolved uncertainty, cmd/bd/github.go:685): the relationship push was said to turn an old-repository URL into an issue number. At the final head it builds links through the repository-scoped RefScope with the learned names (internal/github/links.go:275-314), so another repository's ref yields no link. Unverified: the trace shows no defect.
  • Maintainability (complexity measurement, internal/tracker/engine.go:345, :1104): doPull and doPush grow more complex. The remaining unaddressable and moved-issue branches could move into engine_unaddressable.go helpers. Refactor.
  • External review notes (@bee-ghosttrack, non-blocking):
    • The test(github): … title undersells a fix. Wording.
    • PR CI skips the Dolt and proxied-server tiers. CI lanes; this finalize ran //internal/tracker:tracker_test with Dolt locally, and all 179 tests passed.
    • The CHANGELOG conflict with main was resolved at finalize (see below).

Maintainer Changes

877fc35c81 fix(github): sync a renamed repository's issues without duplicates or lost edits: 13 files changed, 1452 insertions(+), 49 deletions(-). This is the review loop's fixes as one maintainer commit on top of the contributor commits. At finalize the branch was rebased onto current main (7b80f4c924). The only conflict was the ### Fixed list in CHANGELOG.md, resolved by keeping both sides; every other file is byte-identical to the reviewed head.

Final Review Status

Ready for the merge queue: final head 877fc35c81 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.

GitHub shows a conflict again because #7933 (fix(github): version the push hash to repair issues left open pre-fix) reached main after this head was pushed. It collides on a CHANGELOG.md bullet and on the go_test srcs list in internal/tracker/BUILD.bazel, where each side adds one test file. engine.go, tracker.go and tracker_test.go merge without a textual conflict. The merge queue resolves this and tests the merged result, so nothing is needed from the contributor.

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

Review Iterations

4 review passes: the first three requested changes (rename and transfer handling, URL spellings, Enterprise hosts, warnings, conflict detection), and the fourth approved. At finalize, one base refresh onto current main, with the PR's package tests re-run on the rebased head: //internal/github:github_test passed 131 tests, and //internal/tracker:tracker_test passed 179, including the Dolt-backed ones.


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

@gascity-eddie gascity-eddie Bot removed the status/awaiting-approval Factory review and CI passed; waiting on maintainer sign-off label Nov 1, 2026
@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 1, 2026
@gascity-eddie
gascity-eddie Bot enabled auto-merge November 1, 2026 09:52
@NahumLitvin

Copy link
Copy Markdown
Contributor

Awesome! Can I consider myself as contributor?

@gascity-eddie
gascity-eddie Bot disabled auto-merge November 1, 2026 10:23
@gascity-eddie gascity-eddie Bot added status/merge-failed PR-review merge queue needs operator attention and removed status/merge-queued Queued for deterministic PR-review merge labels Nov 1, 2026
@julianknutsen julianknutsen added status/needs-review-auto Request automated PR review workflow and removed status/merge-failed PR-review merge queue needs operator attention labels Nov 5, 2026
@gascity-eddie gascity-eddie Bot added status/reviewing PR review workflow is running and removed status/needs-review-auto Request automated PR review workflow labels Nov 5, 2026
gascity-eddie Bot added a commit that referenced this pull request Nov 5, 2026
#8068 landed its own fix for #7781 while this PR waited
for the merge queue, so this PR's scoping commits no longer apply: the
rebase onto it keeps #8068's code and drops theirs. Two of their
regression tests pin behavior #8068 shares and cover what its tests do
not. TestPullFallbackKeyIsRepoScoped, the triage repro, checks that a
bead linked to another repository's issue never shares the pull
fallback key of the configured repository's same-numbered issue.
TestEngineDryRunSkipsUnaddressableRef pins the sequential push
preview's skip of a ref the tracker cannot address for any tracker, with
counts equal to the real run's.

Derived-From: 16ab73f, 692c979
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
gascity-eddie Bot added a commit that referenced this pull request Nov 5, 2026
…lone

Review of #7948 found two holes in its transferred-issue handling.

A pull by bead ID, or a hydration, of an issue GitHub serves under another
repository's URL skipped it only when no bead held that URL. A bead linked
to the new URL was not asked for and is linked outside the configured
repository, yet the pull wrote the issue over it, on a first sync without
even the last_sync guard for its local edit. The pull now skips every
issue it fetched on its own under a ref the tracker cannot address,
whichever bead holds that ref.

When Init cannot read the configured repository (its lookup fails while
the issue endpoints answer), every issue of a renamed repository comes
back under a name the tracker does not know and looked transferred: a push
skipped its bead with a warning about a transfer that never happened, the
conflict check dropped a bead edited on both sides while last_sync moved
past the remote edit, and the next healthy sync wrote the older local edit
over it. A tracker can now report whether it knows its target's names
(tracker.TargetNamesReporter; GitHub: Init read the repository's current
name), and push and conflict detection infer a transfer only when it does.
A pull takes an issue from the repository's own issue list into the bead
that links its number in the configured repository, under the conflict
guard, instead of skipping it, so a conflict resolved for the remote edit
lands in that bead rather than nowhere.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
@gascity-eddie gascity-eddie Bot changed the title test(github): sync reports no conflict with a foreign-linked bead fix(github): leave transferred issues alone and stop GHE push duplicates Nov 5, 2026
gascity-eddie Bot added a commit that referenced this pull request Nov 5, 2026
#8068 landed its own fix for #7781 while this PR waited
for the merge queue, so this PR's scoping commits no longer apply: the
rebase onto it keeps #8068's code and drops theirs. Two of their
regression tests pin behavior #8068 shares and cover what its tests do
not. TestPullFallbackKeyIsRepoScoped, the triage repro, checks that a
bead linked to another repository's issue never shares the pull
fallback key of the configured repository's same-numbered issue.
TestEngineDryRunSkipsUnaddressableRef pins the sequential push
preview's skip of a ref the tracker cannot address for any tracker, with
counts equal to the real run's.

Derived-From: 16ab73f, 692c979
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
gascity-eddie Bot added a commit that referenced this pull request Nov 5, 2026
…lone

Review of #7948 found two holes in its transferred-issue handling.

A pull by bead ID, or a hydration, of an issue GitHub serves under another
repository's URL skipped it only when no bead held that URL. A bead linked
to the new URL was not asked for and is linked outside the configured
repository, yet the pull wrote the issue over it, on a first sync without
even the last_sync guard for its local edit. The pull now skips every
issue it fetched on its own under a ref the tracker cannot address,
whichever bead holds that ref.

When Init cannot read the configured repository (its lookup fails while
the issue endpoints answer), every issue of a renamed repository comes
back under a name the tracker does not know and looked transferred: a push
skipped its bead with a warning about a transfer that never happened, the
conflict check dropped a bead edited on both sides while last_sync moved
past the remote edit, and the next healthy sync wrote the older local edit
over it. A tracker can now report whether it knows its target's names
(tracker.TargetNamesReporter; GitHub: Init read the repository's current
name), and push and conflict detection infer a transfer only when it does.
A pull takes an issue from the repository's own issue list into the bead
that links its number in the configured repository, under the conflict
guard, instead of skipping it, so a conflict resolved for the remote edit
lands in that bead rather than nowhere.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
@gascity-eddie gascity-eddie Bot added status/merge-queued Queued for deterministic PR-review merge and removed status/reviewing PR review workflow is running labels Nov 5, 2026
@gascity-eddie

gascity-eddie Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Factory review complete: waiting on maintainer approval

Adopt-PR approval request: #7948
fix(github): leave transferred issues alone and stop GHE push duplicates (fix/bd-ijkgro -> main)

What it does:
GitHub sync no longer writes a transferred issue (now in another repo) over a bead, and it now says when it skips a ref it cannot address. Rebuilt on main on top of #8068's fix, which landed first: it keeps main's design and adds #7948's repo-scope regressions, the transferred-issue skip in pull, push and conflict detection, a TargetNamesKnown gate so a failed repo lookup does not make a renamed repo's own issues look transferred, and GHE / API-proxy host handling that stops duplicate pushes. 16 files, +1754/-16 (mostly tests).

Review: attempt 2 = approve, scorecard 906/1000 (threshold 850), required changes: none. Coverage: delta_review.
Review TL;DR:

CI: pass. Both required checks pass (PR, PR Risk green).
Merge path: original PR #7948, same-repo branch, head 04d2b7d (the reviewed head).


Reviewed head: 04d2b7d36461 · Workflow run: https://factory.gascity.com/city/maintainer-city/runs/gcg--9223372036832363680
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 status/awaiting-approval Factory review and CI passed; waiting on maintainer sign-off status/reviewing PR review workflow is running and removed status/merge-queued Queued for deterministic PR-review merge labels Nov 5, 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.

APPROVE (delta review at 04d2b7d, rebased onto main c28ee23; previously approved at 6fcfe7b, r1066)

With #8068's repo-scope fix now on main, this PR keeps #8068's code and policy and adds what #8068 does not have: transferred-issue handling (conflict detection and push skip an issue GitHub serves under another repository's URL; a pull by ID or a pre-linked hydration skips such an issue), the push-preview skipped count and one-line skip warnings naming the configured repository (TargetDescriber), RefScope host respellings (www., no scheme, default port, trailing dot) plus the html_url host for an API proxy, and IsExternalRef recognizing a GitHub Enterprise host without "github.com" in its name, so a push updates the linked issue instead of creating a second one.

What ran at 04d2b7d: go vet ./internal/github ./internal/tracker rc=0. internal/github, -run over TestPullFallbackKeyIsRepoScoped|TestIsExternalRef|TestExtractIdentifier|TestPull_|TestPush_|TestSync_|TestResolveRepositoryNames|TestRenamedRepository|TestDetectConflicts|TestInit_ (go test -list: 24 tests): 24 top-level pass, 56 subtests pass, 0 fail, 0 skip. internal/tracker, -run over the unaddressable, dry-run, selective, pull, push, conflict and match-key families (-list: 69): 69 top-level pass, 46 subtests pass, 0 fail, 0 skip (local Dolt server, so the Dolt-backed tests ran). CI at this head: 29 pass, 11 skipped (the Dolt-server tiers), 0 failing.

Mutants against the new behaviour, all bitten:

  • leftTarget ignores TargetNamesKnown (engine_unaddressable.go:37): bitten by TestSync_RenamedRepositoryWithoutItsNames, TestPush_RenamedRepository/configured acme/old without the repository's names, and TestEngineWarnsOnceForUnaddressableRefs/push of an issue served under another name, target names unknown.
  • the tip's pull guard reverted to existing == nil only (engine.go:492): bitten by TestSync_TransferredIssue/pull by bead ID with the new URL linked to another bead, .../pull hydrating with the new URL linked to another bead, and TestEngineWarnsOnceForUnaddressableRefs/pull by ID.
  • unaddressablePull reverted to the approved skip-when-matched (engine_unaddressable.go:65): bitten by TestSync_RenamedRepositoryWithoutItsNames and TestEngineWarnsOnceForUnaddressableRefs/pull.
  • IsExternalRef without the onHost arm (github/tracker.go:343): bitten by TestPull_RenamedRepositoryOnEnterpriseHost, TestPush_UpdatesLinkedIssueOnEnterpriseHost and TestIsExternalRefRecognizesConfiguredHost.
  • TargetNamesKnown always true (github/tracker.go:399): bitten by TestSync_RenamedRepositoryWithoutItsNames and TestPush_RenamedRepository/...without the repository's names.
  • withIssueHost a no-op (links.go:97): bitten by TestResolveRepositoryNamesLearnsTheIssueHost.

Approved semantics that changed, each deliberately and named in the PR body: (1) the per-sync TargetResolver is gone; #8068's Init learns the names, and a failed lookup no longer stops the sync, it keeps the configured name. The new TargetNamesReporter guard makes push and conflict detection fall back to main's behaviour in that case instead of taking a renamed repository's issues for transferred ones. (2) A bulk-list row under an unaddressable URL that a bead links by number in the configured repository is now taken into that bead under the usual local-edit guard; the approved head skipped it, so the remote edit was never pulled and the cursor passed it. (3) A pull by ID or a hydration now skips a transferred issue even when a bead holds its new URL; the approved head wrote over that bead. (4) A path below an issue (/issues/42/comments) is no longer read as that issue, per #8068's TestExtractIdentifierScopedToRepository. The push-preview skipped count is unchanged and is now pinned for any tracker by TestEngineDryRunSkipsUnaddressableRef.

The two carried tests do not contradict #8068's. TestPullFallbackKeyIsRepoScoped is a unit-level twin of #8068's engine-level TestPull_SameNumberInOtherRepoCreatesNewBead. TestEngineDryRunSkipsUnaddressableRef pins at engine level, for any tracker, what #8068 covers only through GitHub (TestPush_OtherRepoBeadLeavesConfiguredRepoIssueAlone). They overlap but cost little. GHE and host handling did not regress: the respellings narrow nothing, a non-default port on github.com stays foreign, and userinfo and suffix spoofs (ghe.example.test@evil.test, ghe.example.test.evil.test) are rejected in TestIsExternalRefRecognizesConfiguredHost.

Non-blocking notes:

  • internal/tracker/engine_unaddressable.go:61-65 with engine.go:580 (buildPullIssueUpdates): when Init cannot read the names, the bulk pull takes a renamed repository's issue into the bead linked under the old name and relinks that bead to the new-name URL. That URL is unaddressable until a later sync reads the names, so meanwhile a push skips the bead as "linked outside" and its local edits wait. TestSync_RenamedRepositoryWithoutItsNames asserts the relink and the recovery. The README's known limit (README.md:383-389) and the PR body describe the selective-pull and hydration side of this but not the relink; one sentence would cover it, or keep the bead's addressable ref when taking such a row.
  • IsExternalRef still matches /issues/42/comments while ExtractIdentifier rejects it, so a push reports such a bead as "linked outside" the repository. The message is slightly off, but this is #8068's behaviour and the PR body declines to change it.

#8068 landed its own fix for #7781 while this PR waited
for the merge queue, so this PR's scoping commits no longer apply: the
rebase onto it keeps #8068's code and drops theirs. Two of their
regression tests pin behavior #8068 shares and cover what its tests do
not. TestPullFallbackKeyIsRepoScoped, the triage repro, checks that a
bead linked to another repository's issue never shares the pull
fallback key of the configured repository's same-numbered issue.
TestEngineDryRunSkipsUnaddressableRef pins the sequential push
preview's skip of a ref the tracker cannot address for any tracker, with
counts equal to the real run's.

Derived-From: 16ab73f, 692c979
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
@gascity-eddie gascity-eddie Bot removed the status/awaiting-approval Factory review and CI passed; waiting on maintainer sign-off label Nov 18, 2026
gascity-eddie Bot and others added 3 commits November 18, 2026 14:43
…a ref

PR #8068 scoped GitHub refs to the configured repository and learns its
other names at Init, which this PR did through a tracker TargetResolver
at the start of each sync. The rebase onto it keeps #8068's design and
policy and carries the rest of this PR onto them.

An issue transferred out of the configured repository: GitHub follows
the transfer, so fetching a bead's issue returns it under the other
repository's URL. Conflict detection compared the bead with it, a push
could write the bead over it, and a pull by bead ID or a pre-linked
hydration imported it as a new bead. Now conflict detection and the push
leave it alone, and a pull skips such an issue when it fetched it on its
own, or, from the issue list, when a bead already links the configured
repository's issue with that number.

Warnings: a push says when it skips a bead linked outside the configured
repository, in one line for a bulk push (a rate-limit abort included)
and once per bead for a push by ID, and a pull says when an issue came
back under a URL outside it, naming the configured repository (new
optional tracker.TargetDescriber).

Hosts: IsExternalRef recognizes an issue URL on the configured host and
github.com in any letter case, so on a GitHub Enterprise host whose name
lacks "github.com" a push updates a linked issue instead of creating a
second one and relinking the bead. RefScope accepts the host respellings
the legacy parse did (a www. prefix, a missing scheme, an explicit
default port, a trailing dot), and the host of the repository's
html_url, which Init now records with its name, so an API proxy in front
of github.com addresses the github.com refs it returns.

Not carried: the TargetResolver and its failure policy (a failed lookup
stopped the sync; #8068's Init keeps the configured name and goes on),
this PR's wording of the pull-by-bead-ID warning (#8068's stays), and
reading a path below the issue (/issues/42/comments) as that issue,
which #8068's TestExtractIdentifierScopedToRepository rejects. The
renamed-repository tests resolve names as Init does, and still pin that
a renamed repository's refs raise none of these skips or warnings.

Derived-From: 877fc35, 08ec414, af3248b
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
…lone

Review of #7948 found two holes in its transferred-issue handling.

A pull by bead ID, or a hydration, of an issue GitHub serves under another
repository's URL skipped it only when no bead held that URL. A bead linked
to the new URL was not asked for and is linked outside the configured
repository, yet the pull wrote the issue over it, on a first sync without
even the last_sync guard for its local edit. The pull now skips every
issue it fetched on its own under a ref the tracker cannot address,
whichever bead holds that ref.

When Init cannot read the configured repository (its lookup fails while
the issue endpoints answer), every issue of a renamed repository comes
back under a name the tracker does not know and looked transferred: a push
skipped its bead with a warning about a transfer that never happened, the
conflict check dropped a bead edited on both sides while last_sync moved
past the remote edit, and the next healthy sync wrote the older local edit
over it. A tracker can now report whether it knows its target's names
(tracker.TargetNamesReporter; GitHub: Init read the repository's current
name), and push and conflict detection infer a transfer only when it does.
A pull takes an issue from the repository's own issue list into the bead
that links its number in the configured repository, under the conflict
guard, instead of skipping it, so a conflict resolved for the remote edit
lands in that bead rather than nowhere.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude <noreply@anthropic.com>
When Init cannot read a renamed repository's names (the lookup answers
404) and the configuration names the old one, a bulk pull returns issue
N under the new name, a URL the tracker cannot address.
unaddressablePull takes the row into the bead linked to issue N under
the configured repository, but the pull then wrote the row's URL into
that bead's external_ref. From the next sync on, conflict detection
skipped the bead and the push skipped it as linked outside the
configured GitHub repository, so a local edit never reached GitHub and
the next remote edit overwrote it. Base imported a duplicate instead
and kept the bead pushable, and the README says that after a 404 push
and conflict detection handle the issue as the configured repository's.

unaddressablePull now also returns the ref to link the row under: the
matched bead's own ref when the tracker can address it, else the row's
URL (with no match the import keeps the row's URL, as on base). The
pull uses that ref for the update, the equality check, the label check,
the push hash and the dry-run preview, so the bead keeps its link until
Init reads the names, after which a pull relinks it to the current-name
URL as before.

TestSync_RenamedRepositoryWithoutItsNames now expects the bead to keep
its acme/old link after the first sync, and a new subtest makes a local
edit and syncs again without the names: the push PATCHes
/repos/acme/old/issues/42 and the bead stays linked under acme/old.
TestEngineWarnsOnceForUnaddressableRefs checks that the matched beads
keep their refs; its fake store now applies an external_ref update, as
the real stores do, so that check can fail.

Review: PR #7948 iteration 1 (Behavioral Correctness, major).

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

gascity-eddie Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Factory review complete: waiting on maintainer approval

PR #7948 — fix(github): leave transferred issues alone and stop GHE push duplicates
#7948
Head for approval: 0a7afb5 (on main @ 36a4823)

What it does:
Rebuilt on main keeping #8068's repo-scope fix (which landed first) and carries only #7948's unique behavior: GitHub sync leaves a transferred issue (and the bead linked to its new URL) alone instead of hydrating/pushing it, warns when sync skips a ref it cannot address, carries #7948's repo-scope regression tests, and makes tracker pull keep a matched bead's own addressable ref. 17 files, +1818/-16 (mostly tests).

Review: attempt 2 = approve, scorecard 906/1000 (threshold 850), required changes: none, review coverage: identical.

Review TL;DR:
Iteration 1: request_changes

  • [major] bulk pull with a 404 repo lookup relinked a renamed repo's bead to an unaddressable ref (local edits never push, later overwritten)
  • [minor] dry-run push previewed "Would update" for a transferred issue the real push skips
  • [minor] PR body overstated the fallback / cited pre-rebase test results
  • [minor] re-committed commit lost the first body line
    Fixes applied: 0a7afb5 fix(tracker): pull keeps a matched bead's addressable ref; afe083f message restored; others carried.
    Iteration 2: approve — major fix validated (TestSync_RenamedRepositoryWithoutItsNames pins the kept acme/old link; fails with fix reverted); commit-message fix validated; transferred-issue protection still covered by TestSync_TransferredIssue.

CI: pass — both required checks green (PR, PR Risk); Bazel Farm (trusted forks) skipped.

Merge path: original PR #7948 (same-repository branch fix/bd-ijkgro, updatable by maintainers).


Reviewed head: 0a7afb5c6865 · Workflow run: https://factory.gascity.com/city/maintainer-city/runs/gcg--9223372036829329568
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 18, 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.

Delta approve at 0a7afb5c68 (bee, r1256) over the head I approved, 04d2b7d364: a rebase from main c28ee2357a onto 36a4823240 (the three earlier commits range-diff =) plus one production commit.

0a7afb5c68: when a bulk pull takes a row that came back under a URL the tracker cannot address (a renamed repository whose names Init could not read) into the bead linked under the configured repository's ref, the pull used to write the row's URL into that bead's external_ref, after which push and conflict detection skipped it as linked outside the repository and the next remote edit overwrote the unpushed local edit. unaddressablePull now also returns the ref to link under — the matched bead's own ref when the tracker can address it, else the row's URL — and doPull uses that ref from there on (update, equality check, label check, push hash, dry-run preview). I read the call site: outsideRefs is appended before the ref is replaced, so the once-per-sync warning still names the URL the row came back under; the skip path (i >= bulkRows) returns the ref unchanged, so skippedOutsideRefs is as before; with no match existing is nil and the row imports under its own URL, as on base.

Base leg: with this head's test files over 04d2b7d364's engine.go and engine_unaddressable.go, TestEngineWarnsOnceForUnaddressableRefs fails on the two kept-ref assertions (external_ref = ".../foreign/EXT-3", want ".../EXT-3") and TestSync_RenamedRepositoryWithoutItsNames fails on still linked to acme/old, on the PATCH the local edit must produce (wrote [], want ["PATCH /repos/acme/old/issues/42"]) and on the Skipped local issue bd-o42 warning. On the unmodified head both pass. The engineIssueUC fake now applies external_ref updates, which is what lets the tracker-package check fail at all.

What I ran at 0a7afb5c68 in a fresh worktree: go build ./... rc 0; go test -count=1 ./internal/tracker ./internal/github -run 'Renamed|Unaddressable|TestSync_|TestPush_' PASS; the base leg above. Every check is green at this head.

This branch has not been deployed

No deployments
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/p0 Critical: data, security, or basic operation blocked status/awaiting-approval Factory review and CI passed; waiting on maintainer sign-off status/reviewing PR review workflow is running

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: bd github pull matches issues by number only, overwriting a bead from another repo

3 participants