Commit graph

9 commits

Author SHA1 Message Date
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
Mike Taylor
c2c37605de
fix(github) bd github sync (GitHub issues integration) (#3929)
* fix(github): read github.token from config.yaml in tracker.Init

The github tracker's getConfig() only checked store.GetConfig (Dolt DB)
and the env var, but github.token is a yaml-only secret key and is
never stored in the DB. As a result, `bd github sync` errored with
"GitHub token not configured" even when the token was correctly set
in .beads/config.yaml via `bd config set github.token <token>`.

Mirror the pattern already used by internal/linear/tracker.go and
cmd/bd/github.go:getGitHubConfigValue(): check config.IsYamlOnlyKey
first and read from config.yaml for those keys.

Also adds TestGetConfig_YamlOnlyKeyBypassesStore: constructs a Tracker
with a nil store and verifies getConfig still resolves github.token via
env-var fallback — proof that yaml-only keys no longer deref the store.
Without the fix this test would panic on the nil store.

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

* test(github): cover yaml-read path for github.token getConfig

The original regression test (TestGetConfig_YamlOnlyKeyBypassesStore)
only proves the env-var fallback path through the yaml-only branch. It
does not assert the primary behavior the PR fixes: that github.token is
actually read from config.yaml when set there.

Add TestGetConfig_YamlOnlyKeyReadsFromYaml: writes a temp .beads/config.yaml
containing github.token, runs config.Initialize (with HOME/XDG isolated
and BEADS_TEST_IGNORE_REPO_CONFIG=1 so only the temp file loads), and
verifies tr.getConfig returns the yaml value with GITHUB_TOKEN unset.

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

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 08:47:39 -07:00
Sean Brandt
b78a62cf10
github: classify rate-limit 403s and stop the push loop when one hits (#3624)
Fix-merged for release prep: preserved the contributor rate-limit handling and added the maintainer fix to avoid sleeping after the final retry attempt. Auto-merge after CI.
2026-05-02 14:24:57 -07:00
Kevin Glynn
b3241665f3
fix(github): map decision, spike, story, milestone GitHub type labels (GH#3604) (#3639)
Merged after maintainer review for release prep. CI was green and PR was approved.
2026-05-02 14:02:06 -07:00
Harry Miller
33cab03193
fix: recognize ado:NNNNN shorthand in IsExternalRef and ExtractIdentifier (#2966)
* fix: recognize ado:NNNNN shorthand in IsExternalRef and ExtractIdentifier

IsExternalRef and ExtractIdentifier only matched full ADO URLs
(/_workitems/edit/\d+), but BuildExternalRef produces ado:NNNNN
shorthand when org/project config is unavailable. This caused the
sync engine to treat existing beads as new, creating duplicate ADO
work items instead of updating existing ones.

Fixes harry-miller-trimble/beads#28

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: add shorthand ref support to GitHub/GitLab trackers, tighten ado:0

Address PR #2966 review feedback:

- GitHub tracker: add ghShorthandPattern (github:{id}) to IsExternalRef
  and ExtractIdentifier, fixing the same duplicate-creation bug as ADO
- GitLab tracker: add glShorthandPattern (gitlab:{id}) to IsExternalRef
  and ExtractIdentifier, fixing the same duplicate-creation bug as ADO
- ADO tracker: tighten regex from ^ado:(\d+)$ to ^ado:([1-9]\d*)$ to
  reject ado:0 which is invalid in practice
- Add test cases for shorthand format in all three trackers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-02 19:20:30 -07:00
Harry
860ef5969b lint: suppress gosec G404 for retry jitter (math/rand is fine for backoff)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:15:53 -07:00
Harry
73f786ffb8 github,ado: fix Retry-After jitter in retry loops
Apply the same fix as the Jira client: only add jitter to our own
exponential backoff delays, not to server-mandated Retry-After values.
Adding jitter to Retry-After could violate rate limit contracts by
waiting less than the server-specified duration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:15:52 -07:00
Harry
00b78da749 Add retry logic to Jira client and jitter to all tracker HTTP clients
- Add retry with exponential backoff to Jira doRequest (was single-attempt)
- Add MaxRetries, RetryDelay, MaxResponseSize constants to jira/types.go
- Add response body size limit via io.LimitReader to Jira client
- Handle permanent errors (400/401/403/404) without retry
- Parse Retry-After header for rate-limited responses
- Add jitter (0-50% of delay) to backoff in all 5 tracker clients:
  GitHub, GitLab, Linear, ADO, and Jira
- Guard rand.Int64N against zero delay to prevent panics
- Add retry tests: 429, 503, no-retry-on-400, max-retries-exceeded

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:11: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