Commit graph

3,504 commits

Author SHA1 Message Date
Jozef Izso
42064c46fe
Sync Linear milestones as local epics (#3528) 2026-05-05 07:45:30 -07:00
Harry Miller
4a25937df2
fix: replace deprecated --force flag with --reinit-local in init error messages (#3695)
* fix: replace deprecated --force flag with --reinit-local in init error messages

Four error messages in init.go suggested 'bd init --force --prefix <x>'
when a workspace was already initialized. The --force flag was deprecated
in favor of --reinit-local, but the error messages were never updated.

Fixes #3684

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

* test: add regression tests for GH#3684 --reinit-local in error messages

Add TestCheckExistingBeadsData_SuggestsReinitLocal with two subtests
(embedded_dolt, sqlite_db_file) that verify the 'already initialized'
error messages recommend --reinit-local instead of the deprecated --force.

Also strengthen existing guard tests (server_mode_with_dolt_dir_blocks_init,
embedded_mode_with_existing_db_blocks_init, embedded_metadata_ignores_ambient)
with GH#3684 assertions.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-04 11:42:47 -07:00
Bella-Giraffety
5a2fc61f7a
fix: repair shared-server bootstrap and doctor metadata drift (#3242)
Reconcile local metadata.json against the authoritative server state in
shared-server/server mode. Repairs two drift cases:
1. Stale dolt_database when another server DB matches the local project_id
2. Stale/missing local project_id when the configured DB has one

Also hardens the server metadata probe:
- Escapes backticks in database names to prevent SQL injection
- Distinguishes expected probe errors (table/DB not found) from unexpected
  ones (permission denied, connection failures) so reconciliation does not
  act on an incomplete server inventory

Co-authored-by: Bella-Giraffety <thalia.geraghty@fiserv.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-03 14:42:21 -07:00
kev
dccfa20829 fix(graph): emit [] not null for empty links in HTML output (GH#3592)
Go nil slices marshal to JSON `null`, which breaks d3.forceLink() for
single-node components. Use make() to ensure empty arrays serialize as
`[]`.
2026-05-03 01:46:01 -04:00
matt wilkie
890950f388
Merge pull request #3661 from kevglynn/pr3-oauth-client-credentials
feat(linear): OAuth client-credentials support for service identity
2026-05-02 19:31:14 -07:00
maphew
425ae20683 Merge main into OAuth client credentials branch 2026-05-02 19:14:05 -07:00
maphew
f4a1a211df Merge main into staleness signal branch 2026-05-02 19:09:01 -07:00
matt wilkie
9c41669cf4
Merge pull request #3657 from kevglynn/feat/linear-sync-concurrency-lock
feat(linear): add per-workspace concurrency lock on sync
2026-05-02 19:05:23 -07:00
matt wilkie
a9e437a0a8
Merge pull request #3655 from kevglynn/feat/linear-retry-after-adaptive-backoff
feat(linear): parse Retry-After headers and add rate-limit circuit breaker
2026-05-02 19:05:11 -07:00
matt wilkie
acd2b7d97d
Merge pull request #3559 from kevglynn/feat/conditional-dolt-push-template
feat(setup): omit bd dolt push from template when no remote configured
2026-05-02 19:04:41 -07:00
maphew
f118303741 Merge main into OAuth client credentials branch 2026-05-02 18:40:54 -07:00
maphew
d33687481e fix(linear): clean staleness lint 2026-05-02 18:38:36 -07:00
maphew
cb1a0700b0 fix(linear): clean sync lock lint 2026-05-02 18:38:36 -07:00
maphew
dc4cd8b649 fix(linear): clean rate-limit lint 2026-05-02 18:38:36 -07:00
maphew
261fdbb996 fix(setup): format conditional push template 2026-05-02 18:38:36 -07:00
matt wilkie
6fa7549c8c
Merge pull request #3667 from maphew/fix/3560-cli-deps-only
fix(create): handle dependency aliases in --deps
2026-05-02 18:25:40 -07:00
maphew
ea9fa3efca Merge remote-tracking branch 'origin/main' into fix/export-exclude-memories
# Conflicts:
#	cmd/bd/export_test.go
2026-05-02 17:44:16 -07:00
matt wilkie
32b4430e39
Merge pull request #3659 from kevglynn/fix/export-exclude-wisps
fix(export): exclude ephemeral wisps from bd export by default
2026-05-02 17:41:40 -07:00
kev
6584ff8f8f feat(linear): add ambient staleness signal for auto-fresh data
Add staleness detection so agents and devs automatically get fresh
Linear data without retry infrastructure.

- New staleness library (internal/linear/staleness.go): WriteLastPull,
  ReadLastPull, IsPullStale, IsWithinDebounce, GetStalenessInfo
- --pull-if-stale flag on bd linear sync with configurable --threshold
  (default 20m) and 5-minute debounce to prevent agent loops
- bd prime auto-pulls when stale and LINEAR_API_KEY is set
- Per-session stderr warning on any bd command when data is stale
- 14 new tests covering all staleness functions

Design validated by three adversarial reviewers (architecture,
performance, agent-native). Morning storm (50 devs) = 1% of rate
limits. Scales to 500 devs safely.

Refs: PLAN.md d16, btl-seo
2026-05-02 20:08:33 -04:00
kev
46584d8222 fix(linear): address maintainer feedback on OAuth client-credentials PR
OAuth-only sync path (no LINEAR_API_KEY required):
- Tracker.Init() now checks for OAuth credentials first
  (LINEAR_OAUTH_CLIENT_ID + LINEAR_OAUTH_CLIENT_SECRET), constructs
  NewOAuthClient per team when present, and only falls back to API key
  when OAuth is absent. Missing both is a clear error naming both options.

Lint fixes:
- oauth.go: add //nolint:gosec on DefaultOAuthTokenURL (G101 false
  positive — URL path component, not a credential)
- oauth.go: change defer resp.Body.Close() to
  defer func() { _ = resp.Body.Close() }() to satisfy errcheck
- .golangci.yml: add unparam exclusion for getLinearConfig (ctx param
  kept for context propagation)

Docs/code precedence alignment:
- getLinearConfig: env vars now take precedence over config.yaml for
  yaml-only keys (was reversed). Matches documented precedence:
  OAuth > LINEAR_API_KEY > config file.

Tests:
- TestTrackerInitOAuthOnly: validates OAuth client construction without
  API key
- TestTrackerInitNoAuthFails: validates error message when no auth
  configured
2026-05-02 19:04:20 -04:00
kev
609dce0ad9 test(export): add export globals to saveAndRestoreGlobals for isolation
The PR introduced exportIncludeMemories as a new package-level flag but
did not add it to saveAndRestoreGlobals, making test outcomes
order-dependent when export tests toggle it.

Add all six export flag globals (exportOutput, exportAll,
exportIncludeInfra, exportScrub, exportNoMemories,
exportIncludeMemories) to the savedGlobals snapshot so that
saveAndRestoreGlobals atomically covers all export state. Tests that
already call saveAndRestoreGlobals now get full isolation without manual
t.Cleanup per-global.

Addresses maintainer feedback on GH#3660.
2026-05-02 19:00:53 -04:00
kev
3e804cd39f fix(linear): address maintainer feedback on PR #3655
- Format types.go (struct field alignment was off by one space)
- parseRetryAfter: use http.ParseTime for HTTP-date form (RFC 1123 /
  RFC 850 / ANSI C) instead of time.Parse(time.RFC1123) — the latter
  requires an exact timezone abbreviation while http.ParseTime accepts
  the canonical GMT form mandated by RFC 9110 §10.2.3
- Add MaxRetryAfterDelay (300s) cap on server-provided Retry-After
  delays; log a warning to stderr and clamp when the hint exceeds the cap
- Wire linear.rate_limit_floor / LINEAR_RATE_LIMIT_FLOOR through both
  Tracker.Init() and getLinearClient() so the config key is functional
  via `bd config set linear.rate_limit_floor <n>` and the env var
- ErrRateLimitExhausted now implements RateLimitExhausted() bool;
  engine.go uses an interface check (no import cycle) to abort the
  push loop immediately on quota exhaustion instead of cascading the
  error across every remaining issue
- Tests: extend TestParseRetryAfter with HTTP-date future/past cases;
  add TestExecute_RetryAfterCapApplied to confirm the cap path is taken
2026-05-02 19:00:25 -04:00
matt wilkie
2f854001b0
Merge branch 'main' into fix/3560-cli-deps-only 2026-05-02 14:25:52 -07:00
Kevin Glynn
f0b6d4973f
fix(dep): show dependency type in bd dep tree output (GH#3565) (#3647)
Fix-merged for release prep: preserved the contributor dependency tree edge-label work and added focused text/JSON coverage. Auto-merge after CI.
2026-05-02 14:25:33 -07:00
maphew
21c55f489f fix(create): handle dependency aliases in --deps
Carry forward the useful CLI dependency parsing fix from gastownhall/beads PR #3560 while excluding unrelated governance/template and Dolt subsystem changes.

blocked-by:<id> and depends-on:<id> now store a blocks dependency from the new issue to the target, while explicit blocks:<id> continues to invert direction so the target depends on the new issue.

Also reject unknown create --deps dependency types using the centralized well-known dependency type policy.

Co-authored-by: kev <kglynn@pryoninc.com>
2026-05-02 14:08:01 -07:00
Kevin Glynn
a028506ec6
fix(graph): merge components for bd graph --all --html (GH#3592) (#3648)
Merged after maintainer review for release prep. CI was green and PR was approved.
2026-05-02 14:02:24 -07:00
Kevin Glynn
0c51997203
fix(comments): helpful error for misplaced bd comments list (GH#3542) (#3641)
Merged after maintainer review for release prep. CI was green and PR was approved.
2026-05-02 14:02:12 -07:00
matt wilkie
58ac2dee72
Merge pull request #3664 from ebrevdo/codex-plugin-slice1
Add shared Beads plugin package
2026-05-02 13:48:09 -07:00
Kevin Glynn
918eb8e4c5
fix(config): refuse to write secret keys to git-tracked config.yaml (#3652)
* fix(config): refuse to write secret keys to git-tracked config.yaml

P0 security fix. bd config set for secret keys (api_key, secret, token,
password) now detects git tracking of the target config file and refuses
the write with an actionable error pointing to env var alternatives.

Adds --force-git-tracked escape hatch for tests. Updates stale template
documentation and setup guides to lead with env var approach.

* fix(config): scope secret git safety check to YAML-backed keys

Use real environment variable hints for known secret config keys and avoid blocking database-backed secret-looking keys such as notion.token.

Maintainer follow-up for PR #3652.

* fix(config): silence gosec on env var hint names

The map contains environment variable names, not secret values.

---------

Co-authored-by: matt wilkie <maphew@gmail.com>
2026-05-02 13:45:25 -07:00
Eugene Brevdo
43715adde7 Add shared Beads plugin package 2026-05-02 10:59:40 -07:00
kev
097ed1cf16 feat(linear): add OAuth client-credentials support
Add OAuthTokenManager for machine-to-machine authentication using
Linear's client_credentials grant. This enables CI workers to use a
service identity (actor=application) instead of personal API keys.

Key changes:
- New OAuthTokenManager with lazy acquisition, caching, thread-safe
  refresh (5-min buffer before expiry), and Invalidate() for 401 retry
- AuthMode enum (APIKey vs OAuth) on Client with appropriate header
  format: API keys use "Authorization: <key>", OAuth uses "Bearer"
- NewOAuthClient() constructor and WithOAuth() option
- 401 auto-retry: invalidate token and re-acquire on first 401
- Auth precedence: LINEAR_OAUTH_CLIENT_ID/SECRET env vars >
  LINEAR_API_KEY env var > bd config
- Mark oauth_client_secret as secret key (uses IsSecretKey from PR-1)
- 12 new tests covering acquisition, caching, refresh, invalidation,
  error handling, thread safety, and header format

Validated against Linear sandbox: client_credentials grant works with
scope=read,write, actor=application gives bot identity, 30-day TTL.

Refs: gastownhall/beads integration charter, PLAN.md §6 PR-3
2026-05-02 09:35:08 -04:00
kev
61e85bc319 fix(export): exclude memories from bd export by default (GH#3650)
Memories (from `bd remember`) may contain sensitive agent context — API
patterns, debugging notes, credential hints. They were included in both
`bd export` and auto-export (pre-commit hook) by default, leaking
private data into git history.

Changes:
- auto-export: pass includeMemories=false to exportToFile
- bd export: flip default to exclude memories; add --include-memories
  opt-in flag; --all also includes memories
- --no-memories is preserved (hidden) for backward compat but is now
  the default behavior

Adds TestExportExcludesMemoriesByDefault to verify default exclusion
and that --include-memories / --all still include them.
2026-05-02 01:28:12 -04:00
kev
7978fae1ad fix(export): exclude ephemeral wisps from bd export by default (GH#3649)
Wisps are private/transient and must not reach git history or external
integrations. Both bd export and auto-export (pre-commit hook) included
wisps because the SearchIssues filter had Ephemeral=nil (match all).

Set filter.Ephemeral=false (persistent-only) in both export.go and
export_auto.go. The --all flag overrides to include everything.

Adds TestExportExcludesWispsByDefault to verify default exclusion and
that --all still includes wisps.
2026-05-02 01:25:27 -04:00
kev
989d0f9496 feat(linear): add per-workspace concurrency lock on sync
Acquires .beads/.linear-sync.lock at start of bd linear sync to
serialize concurrent invocations. Stale lock detection via PID
check. Clean release on SIGTERM via defer. Prevents duplicate
creates and conflict thrash from overlapping sync runs.
2026-05-02 01:02:55 -04:00
coffeegoddd☕️✨
a58228d7d2 /cmd/bd/main.go: remove promote gate 2026-05-01 17:46:37 -07:00
coffeegoddd☕️✨
e97532ab5e :remove uneccessary locking 2026-05-01 17:46:37 -07:00
coffeegoddd☕️✨
2f1cd4f818 /cmd/{cmd, internal}: make exports atomic writes 2026-05-01 16:42:47 -07:00
coffeegoddd☕️✨
275bdb5776 auto-import: remove redundant commandDidWrite in fallback path
The fallback (non-embedded) path already calls s.Commit() explicitly.
Setting commandDidWrite afterward would cause PersistentPostRun to
run maybeAutoCommit again redundantly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-01 15:31:33 -07:00
coffeegoddd☕️✨
a2db80a247 auto-import: don't print progress message before confirming import needed
The "auto-importing N bytes..." message was printed before
ImportJSONLData checked whether the database was empty. When
auto-export had created issues.jsonl (the default), every subsequent
command printed the message to stderr even though the DB already had
issues and the import was a no-op. Tests using CombinedOutput() saw
the message mixed into their expected output, breaking ID parsing
and JSON deserialization.

Move the message inside the `imported > 0` branch so it only prints
when an import actually occurs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-01 15:24:06 -07:00
coffeegoddd☕️✨
e211188bbd /{cmd,internal}: fix import jsonl 2026-05-01 14:34:45 -07:00
coffeegoddd☕️✨
1ad7009874 /cmd/bd/main.go: default auto-commit on 2026-05-01 11:34:28 -07:00
coffeegoddd☕️✨
e5bebbd7a5 /cmd/bd/dolt.go: revert message flag requirement 2026-05-01 11:30:10 -07:00
coffeegoddd☕️✨
7e0d09cbf8 /{internal,cmd}: fix CommitPending 2026-05-01 11:15:02 -07:00
matt wilkie
8694c53589
doctor: detect AGENTS.md / CLAUDE.md user-authored divergence (#3600)
* doctor: detect AGENTS.md / CLAUDE.md user-authored divergence

Adds CheckAgentDocDivergence to bd doctor and bd preflight. The check
flags cases where AGENTS.md and CLAUDE.md exist as independent regular
files whose content outside the BEGIN/END BEADS INTEGRATION markers has
drifted apart — a common drift mode when agents hand-edit one of the
pair without mirroring the change.

Skipped when:
  - Either file is missing
  - The pair is symlinked or shares an inode (hardlink)
  - Normalized user-authored content matches
  - Either file contains the opt-out marker
    <!-- bd-doctor-divergence: ok --> (for projects that intentionally
    keep distinct files for different audiences, like beads itself)

Adds the opt-out marker to AGENTS.md so the upstream beads repo, whose
AGENTS.md and CLAUDE.md serve intentionally different audiences, does
not regress its own preflight.

Closes mybd-31m.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(lint): hyphenate hardlinked to satisfy misspell linter

misspell flags 'hardlinked' as a typo for 'hardline'. Hyphenating to
'hard-linked' is a common alternate spelling and sidesteps the false
positive without changing meaning.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: CI Bot <ci@beads.test>
2026-04-30 13:26:31 -07:00
coffeegoddd☕️✨
05251d1b7c /{cmd,internal}: some cleanup 2026-04-30 12:46:54 -07:00
coffeegoddd☕️✨
73f2ab613b /{cmd,internal}: maybe fix tool tip closed store bug 2026-04-29 16:35:16 -07:00
coffeegoddd☕️✨
58dc2e1b8b /{beads_cgo,cmd,internal}: cache open embedded stores deterministically to prevent deadlocking when multiple store open attempts are made against an opened store 2026-04-29 15:49:51 -07:00
matt wilkie
7bd46eac58
Merge pull request #3578 from maphew/fix/3570-atomic-ready-claim
Add atomic ready queue claiming
2026-04-28 08:08:06 -07:00
matt wilkie
5983d69901
Merge pull request #3577 from maphew/fix/nix-ci-go126-timeouts
fix(setup): align Claude PreCompact hook docs
2026-04-28 07:20:56 -07:00
matt wilkie
a97eec9739 Add atomic ready claim (GH-3570) 2026-04-28 07:11:13 -07:00