Commit graph

10 commits

Author SHA1 Message Date
Sam
bcf4da3c65
feat(github): sync epic/child and blocks relationships to GitHub (#5971)
* feat(github): sync epic/child and blocks relationships to GitHub

bd github sync only ever pushed issue content (title/body/labels/state);
Epic-child links and beads "blocks" dependencies never reached GitHub's
relationships panel. Adds a GitHub relationship-sync pass, mirroring the
existing GitLab dependency-link push, using GitHub's sub-issues and issue
dependencies REST APIs:

- internal/github/client.go: AddSubIssue/ListSubIssues and
  AddBlockedBy/ListBlockedBy against GitHub's sub_issues and
  dependencies/blocked_by endpoints.
- internal/github/links.go: DependencyLink + LinkResolver, converting beads
  epic/child parent-child dependencies into GitHub sub-issues and beads
  "blocks" dependencies into GitHub blocked_by relationships. Idempotent
  (lists current relationships before creating) and additive (stale remote
  relationships are left untouched).
- cmd/bd/github.go, cmd/bd/sync_push_pull.go: wires the push pass into both
  `bd github sync` and `bd github push`.

Verified against a live GitHub repo (create, list, and idempotent re-push
all confirmed via the real API), in addition to httptest-mocked unit tests.

Fixes gastownhall/beads#5970

* fix(github): update last_sync after relationship push to prevent sync churn

When AddSubIssue or AddBlockedBy is called, GitHub updates the issue's
updated_at timestamp as a side effect. Without updating last_sync after
the relationship push completes, the next sync would see those issues as
'changed' and pull/push them again, causing unnecessary churn.

This fix updates last_sync to the current time after a successful
relationship push (only if links were created), accounting for any
timestamp changes GitHub made during relationship creation.

Fixes continuous sync churn observed when running bd github sync
multiple times with no local changes.

* fix(github): use relationship reader for link sync

* fix(bazel): enumerate links.go and its tests in internal/github BUILD.bazel

The base advance added internal/github/BUILD.bazel with explicitly
enumerated srcs (gazelle-generated). This PR adds links.go,
links_test.go and review_fixes_test.go, which the base-generated
enumeration cannot know about, so //internal/github:github failed to
build:

  internal/github/tracker.go:41:35: undefined: LinkResolver
  internal/github/tracker.go:244:30: undefined: RefScope

Regenerated with `bazel run //:gazelle` (not hand-edited). Purely
additive; no deps change is needed because links.go only imports
//internal/types, already declared.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(github): scope the relationship pass to --parent and report skipped links

Maintainer review fixup for PR #5971, adopt-pr review iterations 1 and 3.

filterGitHubLinkScopedIssues reimplemented four of the SyncOptions
selectors and dropped ParentID, so `bd github sync --push --parent X`
narrowed the content push to the subtree and then created GitHub
sub-issue and blocked-by links for every GitHub-linked issue in the
workspace -- outward API writes on issues the user had excluded. It now
resolves the subtree and requires membership in it. The traversal moves
from gitlab.go to sync_flags.go as buildSyncDescendantSet, beside the
--parent flag that populates the field, and the GitLab and GitHub link
passes share the one copy. The doc comments that claimed parity with the
engine's push loop now enumerate the selectors this path actually
applies, and name the three it does not (State, ExcludeIDPrefix,
ExcludeIDPatterns -- no GitHub command sets them today).

PushLinkResult.UnsupportedSkipped had no reader anywhere in the repo, so
a host without the sub-issue/dependency APIs reported nothing at all.
pushGitHubDependencyLinks now emits one curated line for it, and a 404
on the source issue is classified apart from a 404 on the relationship
endpoint: collapsing the two reported a deleted, renumbered or
permission-hidden issue as an unsupported host. The classifying probe is
memoized per issue number, so a source carrying both link types costs
one extra read.

`bd github push --dry-run` printed "Synced N relationship links" for
links it had only planned, because PushLinks counts planned links in
Created. The `bd github sync` twin already gated that line on its
dry-run flag; the push side now does too.

Tests: a table test over filterGitHubLinkScopedIssues with a row per
selector -- its three ParentID rows fail without the scope fix -- plus a
direct pin that a blocks-edge dependent is not a descendant, and
httptest cases driving 404 through the list call, the create call and
the source-issue probe.

Not fixed here: the PR body still describes a `lastSync` advance that
commit ee6d65692 removed from this PR. That is a PR-surface edit, not a
code change, and is left to the finalize step.

Also not fixed here, and named in buildSyncDescendantSet's doc comment
so the shared helper does not read as covering every tracker: the ADO
link pass has the same scope hole this commit closes for GitHub.
pushADOLinks takes no sync options, so `bd ado sync --push --parent X`
still writes ADO relations for the whole workspace. That predates this
PR, and ADO is outside its diff.

Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Julian Knutsen <julian@gastownhall.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
2026-10-01 01:22:00 -07:00
Kevin Glynn
9827c66319
fix(github): content-based dedup on push to stop re-PATCHing every issue (#4214) (#4329)
* fix(github): content-based dedup on push to stop re-PATCHing every issue

GitHub sync never wired engine.PushHooks, so `doPush` fell back to
timestamp-only dedup. Because linking and any local write bump a beads
issue's updated_at past GitHub's second-granularity updated_at, every
`github sync --push-only` / `github push` reconciled and PATCHed the
entire backlog on every run — O(N) REST calls that drain the shared
installation's primary rate limit even when nothing changed.

Add github.PushFieldsEqual, comparing only the fields a push mutates
(title, body, state, and the label set BeadsIssueToGitHubFields sends,
order-insensitive). Wire a ContentEqual push hook (buildGitHubPushHooks)
into both runGitHubSync and runGitHubPush so the engine skips issues
already in sync — mirroring the existing Linear/Jira push hooks.

Dry-run still makes 0 REST calls (unchanged); this targets the live
re-PATCH storm. A push-side incremental cursor to also avoid the
per-issue fetch is a noted follow-up.

Fixes #4214

Co-authored-by: Cursor <cursoragent@cursor.com>

* perf(sync): skip per-issue fetch on no-op push via persisted content hash

The ContentEqual hook added for #4214 stops the redundant PATCH but still
fetches every linked issue (one GET each), so a no-op `github sync --push-only`
still drains the REST rate limit. Add a ContentHash push hook: the engine
persists each issue's pushed content hash in the dolt-ignored local_metadata
table and consults it before FetchIssue. When the local content is unchanged
since the last push, the fetch and update are skipped entirely.

Also record the hash when ContentEqual reports a match (so the first
post-restart pass repopulates hashes) and consult it in dry-run, so an
unchanged issue previews as a skip instead of always reporting "Would update".

Refs gastownhall/beads#4214

Co-authored-by: Cursor <cursoragent@cursor.com>

* shrink(github): simplify PushContentHash framing and labelSetsEqual

Replace length-prefix binary framing in PushContentHash with NUL-separated
fields — the hash is only self-compared, so the simpler scheme is sufficient.
Replace hand-rolled counting map in labelSetsEqual with slices.Sort +
slices.Equal. Drop unused encoding/binary, strconv, sort imports in favor
of slices.

Agent-Signature: cursor-opus-4.6-unknown-reasoning on behalf of kevglynn
Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(sync): bind push cache to remote target

Agent-Signature: codex-gpt-5.6-sol-medium on behalf of matt wilkie

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-08-02 22:53:06 -07:00
coffeegoddd☕️✨
b9050ff63b /cmd/bd: error on unsupported proxied-server commands 2026-07-13 15:03:04 -07:00
coffeegoddd☕️✨
d7d7a34607 : refactor to use RunE, emit usage metrics, skip metrics in CI
(cherry picked from commit 9596c7233d)
2026-06-22 20:44:43 +00:00
matt wilkie
e54bc625fd
fix: correct 'bd config' hints to 'bd config set' in error messages (#3141)
Ten error messages across github, gitlab, and ado commands recommend
'bd config {key} {value}' but the CLI requires the 'set' verb:
'bd config set {key} {value}'.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 10:11:00 -07:00
matt wilkie
64678bcb34
fix: show diverged-history guidance on auto-push failure (#3138)
* fix: show diverged-history guidance on auto-push failure

When dolt auto-push fails with a 'no common ancestor' error, the user
only sees a cryptic warning. The explicit 'bd dolt push' and 'bd dolt
pull' commands already detect this and print recovery guidance via
printDivergedHistoryGuidance(), but the auto-push path did not.

Now auto-push also calls isDivergedHistoryErr() and prints the same
actionable recovery options (bootstrap, force-push, or re-init).

Amp-Thread-ID: https://ampcode.com/threads/T-019d6ee7-e46d-74f8-8b6e-2a0fc1b2d4d7
Co-authored-by: Amp <amp@ampcode.com>

* fix: store secret config keys in config.yaml, not Dolt DB

Keys like github.token and linear.api_key were stored in the Dolt
database's config table. When auto-push sends that data to a GitHub
remote, GitHub's push protection blocks the push because it detects
embedded secrets in the Dolt data files.

Fix: add github.token and linear.api_key to YamlOnlyKeys so they're
written to .beads/config.yaml (local-only, gitignored) instead of
the Dolt database. Update the read paths in getGitHubConfigValue()
and getLinearConfig() to check YAML config first for these keys.

Amp-Thread-ID: https://ampcode.com/threads/T-019d6ee7-e46d-74f8-8b6e-2a0fc1b2d4d7
Co-authored-by: Amp <amp@ampcode.com>

---------

Co-authored-by: Amp <amp@ampcode.com>
2026-04-08 15:55:37 -07:00
Harry Miller
d802687869
feat: add --issues flag, push pull subcommands, and --parent port (#2975)
Adds CLI layer for selective sync on top of #2957:
- --issues flag registered on all 6 tracker sync commands via shared helpers
- New push/pull subcommands with --dry-run support
- --parent flag ported from Linear-only to ADO, Jira, GitHub, GitLab

Co-authored-by: Harry <harry_miller@trimble.com>
2026-04-05 22:27:46 -07:00
emma
3af3ea1505 fix(cmd/bd): preserve repo config when reopening stores by path (PR #2628)
Several helper paths (list, completions, github, gitlab, linear) reopen
Dolt with only a raw path when the global store is nil. This loses
repo-local metadata like custom dolt_database names and server ports,
falling back to the wrong database or port.

Add a shared openReadOnlyStoreForDBPath() helper that maps dbPath back
to its owning .beads dir and reopens with full metadata. Also fix port
resolution in applyConfigDefaults to use BeadsDir (the .beads/ config
directory) instead of Path (the dolt data directory).

Fixes #2627

Co-Authored-By: Gary <gary@algorune.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 13:57:10 -07:00
beads/crew/emma
8386380437 fix: YAML config prefix takes precedence over DB in shared-server mode (GH#2469)
In shared-server mode, the DB issue_prefix belongs to whichever project
initialized first. This caused all projects sharing a server to use the
wrong prefix for issue creation, ID generation, and imports.

Fix: YAML config.yaml issue-prefix now takes precedence over the DB value
in create.go, github.go, gitlab.go, linear.go, orphans.go, and merge_slot.go
(which already had the correct pattern).

Also: EnsureRunning() now calls KillStaleServers() before starting a new
server, cleaning up orphaned dolt sql-server processes that accumulate when
parent processes crash without graceful shutdown (GH#2372).

Also: add cross-project data isolation tests (5 tests covering read isolation,
port collision, same-prefix isolation, concurrent writes, and concurrent
read-write mix). Based on tests by @PabloLION (PR #2472).

Co-Authored-By: PabloLION <dev@pablolion.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:18:19 -07:00
beads/crew/emma
0cf8666fff feat: add GitHub Issues integration (tracker plugin) (GH#2373)
Implements tracker.IssueTracker and tracker.FieldMapper interfaces for
GitHub Issues, mirroring the existing GitLab integration pattern. Adds
bd github sync/status/repos commands for bidirectional issue sync with
scoped label mapping, pagination, rate-limit handling, and GitHub
Enterprise support.

Co-Authored-By: StefanTrockel <StefanTrockel@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:53:31 -07:00