Commit graph

47 commits

Author SHA1 Message Date
Jozef Izso
42064c46fe
Sync Linear milestones as local epics (#3528) 2026-05-05 07:45:30 -07:00
Kevin Glynn
ac15e099e3
feat(linear): adopt issueBatchCreate/issueBatchUpdate for 50x efficiency (#3654)
* feat(linear): adopt issueBatchCreate/issueBatchUpdate for 50x efficiency

Implements tracker.BatchPushTracker interface on linear.Tracker.
Adds BatchCreateIssues and BatchUpdateIssues methods that chunk
inputs into groups of 50 (Linear's per-call limit). Graceful
fallback to per-issue mutations on batch failure.

* fix(linear): address BatchPush correctness blockers from maphew review

Three correctness issues flagged in PR #3654 review:

1. Skip semantics: BatchPush now fetches each existing issue before
   updating and compares with PushFieldsEqual (title, description,
   priority, status). Unchanged issues are added to result.Skipped
   instead of being re-pushed unconditionally. forceIDs bypasses the
   check, matching the single-issue path in engine.go:doPush.

2. Batch-create result mapping: results are now matched by title rather
   than array index. Linear's issueBatchCreate API does not guarantee
   response order matches input order; index-based mapping silently
   associated wrong ExternalRefs with issues. Unmatched inputs are
   recorded in result.Errors with the title for debugging.

3. Multi-team state cache: build a StateCache per configured team at the
   start of BatchPush. Updates to issues belonging to non-primary teams
   resolve workflow state IDs against that team's cache, not the primary
   team's. The primary cache is used only for creates (which always target
   the primary team).

Add four regression tests covering: unchanged-issue skip, forceIDs bypass,
title-based result mapping with reversed API response, and per-team state ID
selection in a two-team setup.

* fix(linear): prevent duplicate issues from batch-create correctness gaps

Two correctness fixes addressing maphew's re-review blockers on PR #3654:

1. Title-based result correlation is unsafe for duplicate titles.
   BatchPush now detects duplicate titles before batching. Issues with
   duplicate titles are routed through single-create with idempotency
   markers (CreateIssueIdempotent) instead of the batch mutation where
   title-based correlation would silently lose one duplicate.

2. Full-chunk fallback after ambiguous batch failure risks duplicates.
   BatchCreateIssues no longer falls back to creating the entire chunk
   when the batch mutation returns success=false or an API error. Instead
   it searches for each issue's idempotency marker to discover which were
   partially created, returns only confirmed issues, and errors on the
   rest. If the recovery search itself fails, the error propagates rather
   than risking duplicates.

Supporting infrastructure ported from feat/linear-idempotency-markers:
- idempotency.go: GenerateIdempotencyMarker, AppendIdempotencyMarker
- FindIssueByDescriptionContains, CreateIssueIdempotent on Client

* fix(linear): gofmt client.go and tracker_test.go

Fix Check formatting CI failure — two files had formatting drift
from the merge conflict resolution.
2026-05-03 16:28:13 -07: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
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
matt wilkie
8cc3fea9a3
Merge pull request #3656 from kevglynn/feat/linear-idempotency-markers
feat(linear): add idempotency markers to prevent duplicate issue creation
2026-05-02 17:41:14 -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
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
kev
b8e7562f0f fix(linear): address maintainer blockers on idempotency PR
Fix 1 (double description formatting): Tracker.CreateIssue was calling
BuildLinearDescription(issue) to format the description, but the sync
engine's FormatDescription hook already calls BuildLinearDescription
before invoking CreateIssue. For issues with AcceptanceCriteria/Design/
Notes, this caused those sections to be appended twice in the Linear
description. Fix: use issue.Description directly in CreateIssue, trusting
the caller to have pre-formatted it.

Fix 2 (retry race in CreateIssueIdempotent): The previous implementation
called CreateIssue (which goes through Execute's retry loop) after the
initial marker search. If issueCreate reached Linear but the HTTP response
was lost, Execute could retry the mutation and create a duplicate issue
with the same idempotency marker. Fix: add createIssueSingleAttempt that
runs the mutation exactly once. After any failure, re-search for the
marker before returning the error so callers can safely retry
CreateIssueIdempotent without creating duplicates.

Also documents the concurrent multi-source limitation (Linear provides no
server-side uniqueness enforcement; the dedup window is bounded by search
index propagation).

Adds regression tests:
- TestCreateIssueNoDoubleFormatDescription: verifies AC/Design sections
  appear exactly once in the description sent to Linear
- TestCreateIssueIdempotentRecoverAfterAmbiguousFailure: verifies that an
  ambiguous create failure (5xx response) followed by a recovery search
  returns the already-created issue with deduped=true
2026-05-02 18:59:33 -04:00
kev
175bc23d1f fix(linear): keep lock file stable across Release cycles
Removing the lock file after unlocking creates a lifecycle race: a blocked
waiter acquires the old inode (between flock release and os.Remove), then a
third process creates a new file at the same path and locks it — both
processes believe they hold the lock.

Fix: never call os.Remove in Release(). Truncate diagnostic metadata while
still holding the flock, then release. The stable path is reused by
subsequent AcquireSyncLock calls via O_CREATE|O_RDWR.

Also:
- Handle writeLockInfo's Truncate error (was silently discarded with _ =)
- Add #nosec G304 to readLockInfo (path is program-constructed, not user input)
- Update test: assert lock file persists and is empty after Release, not removed
2026-05-02 18:55:08 -04:00
Kevin Glynn
06d385edf9
feat(linear): add type mappings for decision, spike, story, milestone (#3651)
Fix-merged for release prep: preserved the contributor Linear type mappings and added exact-only matching to avoid story false positives such as history. Auto-merge after CI.
2026-05-02 14:24:27 -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
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
kev
0ec4a99ea0 feat(linear): add idempotency markers to prevent duplicate issue creation
Embeds <!-- bd-idempotency: hash --> in Linear descriptions on create.
Pre-create dedup query uses description contains filter (validated
against Linear API). Hash uses immutable fields only (beadID +
creatorEmail + createdAtNano). Prevents duplicates under sync
interruption or multi-source create races.
2026-05-02 01:00:09 -04:00
kev
a845bc4eba feat(linear): parse Retry-After headers and add rate-limit circuit breaker
Server-hint-aware backoff: prefer Retry-After delay over computed
exponential backoff when present. Circuit breaker pauses sync when
remaining quota drops below linear.rate_limit_floor (default 100).
Addresses thundering-herd retry amplification pattern (cf. #3623).
2026-05-02 00:42:06 -04:00
matt wilkie
3e56f0b214
Document Linear external_ref pre-linking (#3517)
* Document Linear external ref prelinking (bd-ly3)
* Fix Linear sync dependency graph handling
* Fix init remote clone routing
* Fix stale gate help text
* Fix init remote cherry-pick integration
* Fix init remote flag handling
* Fix Linear prelink hydration blockers
* Fix Linear relation dependency gating
* Fix ready list parent filtering
* Deduplicate dry-run dependency previews by stored identity
2026-04-27 06:05:30 -07:00
matt wilkie
f7269b6820 Add Linear state_map dotted key regressions (bd-cba) 2026-04-25 18:05:44 -07:00
matt wilkie
c446a2ef09
fix(linear): harden push against data clobbering (#3328)
Closes #3289, #3309, #3252, #3253 — hardens Linear push: requires explicit linear.state_map.* config, rejects ambiguous state resolution, narrows push dedup to pushable fields, blocks unscoped project-filtered push from creating unlinked beads, and adds regression test for the orphan-ownership rule (parent-filtered push must not update external issues Beads hasn't claimed via external_ref).
2026-04-18 08:36:13 -07:00
natorious
0271720965
fix: linear tracker reads yaml-only config keys from config.yaml (#3315)
The Tracker.getConfig() method only checked the Dolt database and
environment variables. Since `bd config set linear.api_key` writes
to config.yaml (yaml-only key), `bd linear sync --pull` could never
find the API key. Mirror the check from cmd/bd/linear.go:getLinearConfig()
by calling config.IsYamlOnlyKey() and config.GetString() first.

Co-authored-by: mayor <root@vmi3233510.contaboserver.net>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 15:10:33 -07:00
Harry
2cd88e9426 fix: address PR review feedback
- Jira: reset body reader at top of retry loop (not just in retriable
  branch) so POST/PUT retries after network errors don't send empty bodies
- GitLab: add useServerDelay pattern matching other clients; skip jitter
  for server-mandated Retry-After delays
- Sanitize: replace custom decodeRune with stdlib utf8.DecodeRuneInString
- Ready --explain: log warnings instead of silently swallowing errors from
  GetDependencyCounts, GetDependencyRecordsForIssues, DetectCycles,
  GetIssuesByIDs
- Linear: fix pagination off-by-one; check page limit before processing
  instead of after, preventing MaxPages+1 fetches
2026-03-30 09:15:55 -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
733b8fab89 Sanitize external tracker content for terminal display and add response size limits
- Add ui.SanitizeForTerminal() to strip ANSI escape sequences, OSC sequences,
  and C0/C1 control characters from external content before terminal display.
  Preserves printable UTF-8, newlines, and tabs.
- Apply sanitization in tracker engine dry-run output (3 call sites)
- Add MaxResponseSize (50MB) and io.LimitReader to Linear client to prevent
  OOM from malformed API responses (was the only tracker without this guard)
- Add comprehensive test suite for sanitization (17 test cases including
  ANSI injection, screen clearing, OSC title change, control characters)

Fixes: bd-u9u

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:12:26 -07:00
Harry
c5e033f93e Add pagination guards to Linear and context checks to Jira client
- Linear FetchIssues/FetchIssuesSince: add MaxPages=1000 guard to prevent
  infinite loops from malformed API responses with hasNextPage=true
- Linear: add ctx.Done() checks at start of each pagination iteration
- Jira SearchIssues: add ctx.Done() check at start of each pagination iteration
- Add MaxPages constant to internal/linear/types.go

Fixes: bd-6fy

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:11:20 -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
Harry
3ae2ef3a5a feat: multi-project/team support for Linear, Jira, and ADO
Add support for syncing issues across multiple projects/teams in all
three tracker integrations, with shared infrastructure to avoid
duplicating logic.

Shared infrastructure (internal/tracker/multiproject.go):
- ParseCommaSeparated: splits comma-separated config values
- DeduplicateStrings: removes duplicates preserving order
- ResolveProjectIDs: config precedence (CLI > plural > singular)

Linear (closes #2791):
- Tracker: map[string]*Client with per-team routing
- FetchIssues iterates all teams, deduplicates by issue ID
- UpdateIssue routes to owning team via FetchIssueByIdentifier
- Config: linear.team_ids / LINEAR_TEAM_IDS + --team flag

Jira:
- projectKey string → projectKeys []string
- FetchIssues uses JQL IN clause (single query, no iteration)
- Config: jira.projects / JIRA_PROJECTS + --project flag

ADO:
- project string → projects []string
- WIQL uses TeamProject IN clause (single query)
- Config: ado.projects / AZURE_DEVOPS_PROJECTS + --project flag

All singular config keys remain supported for backward compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-28 13:40:39 -07:00
ben
622c852294 fix(linear): include stateId in push updates to sync status changes
UpdateIssue was only pushing title, description, and priority to Linear,
omitting the stateId. This meant `bd close` followed by `bd linear sync
--push` left the Linear issue in its original state instead of marking
it as Done.

Resolve the workflow state ID (via the existing findStateID helper) and
add it to the update payload, mirroring what CreateIssue already does.

Fixes #2046
2026-02-26 17:20:52 +09:00
darcy
fb8ca5fc90 fix: resolve gofmt and golangci-lint CI failures
- gofmt: 7 files had formatting issues (dolt.go, close_guard_test.go,
  init_hooks_test.go, discovery_test.go, types.go, metadata_schema_test.go,
  testdoltserver.go)
- gosec G304: suppress false positives for os.ReadFile on trusted paths
  (daemon PID files, test cleanup)
- gosec G104: handle Close() return values with _ = pattern
- errcheck: wrap os.RemoveAll in defer closure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 13:31:06 -08:00
lydia
0b95c75d68 fix(linear): correct Project sync issues from PR #2022
- Progress field: int → float64 (Linear returns 0.0-1.0)
- CreateProject: teamId → teamIds (projects span multiple teams)
- ProjectToEpic: map completedAt → ClosedAt, set CloseReason for canceled
- ProjectToEpic: canonicalize ExternalRef URL, remove raw Linear UUID as ID
- MapEpicToProjectState: map StatusInProgress → "started" for correct round-trip

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 12:24:19 -08:00
HuyNguyenDinh
e17d73ae9d feat(linear): add Project sync support
- Add Project type and related GraphQL response types
- Add FetchProjects, CreateProject, UpdateProject methods
- Add ProjectToEpic mapping function
- Resolve conflicts with upstream/main
2026-02-23 10:47:29 +07:00
Steven Syrek
634bf5d4a0 refactor(storage): define Storage interface, decouple from concrete DoltStore (bd-l3o)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 10:11:08 +01:00
beads/crew/emma
12f9037d87 refactor: replace factory/memory imports with direct dolt calls (Phase 7 cleanup)
Phase 7 (a5da57e3) deleted internal/storage/factory/ and internal/storage/memory/
but left 30+ files still importing them. This commit fixes all broken references:

- Created internal/storage/dolt/open.go with NewFromConfig/NewFromConfigWithOptions
- Replaced all factory.New/NewFromConfig/NewWithOptions with dolt equivalents
- Broke import cycles in dolt/bootstrap.go (routing/utils/audit → local types)
- Removed dead storage.Config struct
- Converted all test files from memory.New() to dolt.New() test stores
- Removed tests that depended on deleted detectPrefix/LoadFromIssues/mockRemoteStore

46 files changed, 249 insertions(+), 851 deletions(-)

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-15 13:22:06 -08:00
beads/crew/emma
a5da57e39b refactor: remove storage factory, memory backend, and provider abstraction (Phase 7)
Strip out the multi-backend storage layer: factory pattern, memory/in-memory
provider, connection string parsing, local provider, and associated tests.
Inline Dolt as the sole storage backend. Part of Dolt-Native Beads v2 epic.

WIP - SQLite removal in progress, more cleanup phases to follow.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-15 11:27:39 -08:00
beads/crew/emma
5a5407fafe refactor: wire Linear/GitLab CLI through SyncEngine, delete duplicated sync code
Phase 4 of the tracker engine migration. Rewrites `bd linear sync` and
`bd gitlab sync` to use the shared tracker.Engine instead of bespoke
pull/push/conflict-detection functions.

- Rewrite runLinearSync: create tracker → set hooks → Engine.Sync()
- Add buildLinearPullHooks (hash-based ID generation with collision avoidance)
- Add buildLinearPushHooks (FormatDescription, ContentEqual, StateCache, ShouldPush)
- Add BuildStateCacheFromTracker to internal/linear for CLI hook access
- Rewrite runGitLabSync: create tracker → set hooks → Engine.Sync()
- Add buildGitLabPullHooks (timestamp-counter-random ID generation)
- Add conflict-aware pull to Engine (skip locally-modified issues when prefer-local)
- Delete linear_sync.go (419 lines), linear_conflict.go (191 lines), gitlab_sync.go (563 lines)
- Remove tests for deleted sync functions (covered by engine_test.go)
- Keep utility function tests (generateIssueID, parseGitLabSourceSystem, getConflictStrategy)

Net: -2077 lines. CLI is now thin: parse flags, create tracker, call Engine.Sync().

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 17:29:05 -08:00
jasper
619f34a441 chore: add explanatory comments to silently ignored errors across codebase
Code health review found 30+ instances of error suppression using blank
identifier without explanation. Added comments to 82 files explaining WHY
each error is safely ignored (best-effort cleanup, advisory operations,
safe defaults, etc.) to improve code maintainability.

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

Executed-By: beads/polecats/jasper
Rig: beads
Role: polecats
2026-02-14 17:16:43 -08:00
beads/crew/emma
3c45dcbde4 refactor: inline tracker adapters into internal packages
Move IssueTracker implementations from internal/tracker/adapters/{linear,gitlab}/
directly into internal/{linear,gitlab}/ and create a new minimal Jira tracker.
Each package now registers itself via init(), eliminating the adapter indirection
layer. Delete the adapters/ directory entirely.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 16:18:37 -08:00
beads/crew/lizzy
2bb827facb style: run gofmt across entire codebase (bd-nmk12)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 19:35:20 -08:00
beads/crew/lizzy
de567cda79 chore: unexport 14 dead symbols across 8 packages
Unexport package-internal symbols that have no external callers:
- validation: ValidatePrefix, ValidatePrefixWithAllowed, ForUpdate, ForClose, ForDelete, ForReopen
- debug: PrintNormal, PrintlnNormal
- linear: IssuesQuery
- timeparsing: IsCompactDuration, ParseNaturalLanguage
- utils: FindMoleculesJSONLInDir, ParseIssueID
- testutil/fixtures: XLargeFromJSONL
- storage/sqlite: Snapshot type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 09:24:22 -08:00
Steve Yegge
0ed349b3ed
fix(linear): use project_id when creating issues via sync --push (GH#973) (#1012)
The linear.project_id config was being read and used for filtering
when pulling issues from Linear, but was not being passed when
creating new issues via --push. Now CreateIssue includes projectId
in the mutation input when configured.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:46:00 -08:00
Paddo
5254ade346
feat(linear): add project_id filter for sync (#938)
Add project_id filter for Linear sync

When linear.project_id is configured, bd linear sync will only fetch issues
belonging to that project instead of all team issues.

Closes #937
2026-01-07 20:45:00 -08:00
Steve Yegge
af432bee4e test(linear): add comprehensive tests for mapping and client functions
Added tests for:
- DefaultMappingConfig
- PriorityToBeads/PriorityToLinear
- StateToBeadsStatus/ParseBeadsStatus
- StatusToLinearStateType
- LabelToIssueType/ParseIssueType
- RelationToBeadsDep
- IssueToBeads (with parent/child handling)
- BuildLinearToLocalUpdates
- LoadMappingConfig
- BuildLinearDescription
- NewClient/WithEndpoint/WithHTTPClient
- ExtractLinearIdentifier
- IsLinearExternalRef

Linear package coverage improved from 14.3% to ~50%.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 18:30:03 -08:00
Justin Williams
df5ceb5d82
feat: Linear Integration (#655)
* Add Linear integration CLI with sync and status commands

- Add `bd linear sync` for bidirectional issue sync with Linear
- Add `bd linear status` to show configuration and sync state
- Stub pull/push functions pending GraphQL client (bd-b6b.2)

* Implement Linear GraphQL client with full sync support

- Add LinearClient with auth, fetch, create, update methods
- Implement pull/push operations with Beads type mapping
- Clean up redundant comments and remove unused code

* Add configurable data mapping and dependency sync for Linear

- Add LinearMappingConfig with configurable priority/state/label/relation maps
- Import parent-child and issue relations as Beads dependencies
- Support custom workflow states via linear.state_map.* config

* Add incremental sync support for Linear integration

- Add FetchIssuesSince() method using updatedAt filter in GraphQL
- Check linear.last_sync config to enable incremental pulls
- Track sync mode (incremental vs full) in LinearPullStats

* feat(linear): implement push updates for existing Linear issues

Add FetchIssueByIdentifier method to retrieve single issues by identifier
(e.g., "TEAM-123") for timestamp comparison during push.

Update doPushToLinear to:
- Fetch Linear issue to get internal ID and UpdatedAt timestamp
- Compare timestamps: only update if local is newer
- Build update payload with title, description, priority, and state
- Call UpdateIssue for issues where local has newer changes

Closes bd-b6b.5

* Implement Linear conflict resolution strategies

- Add true conflict detection by fetching Linear timestamps via API
- Implement --prefer-linear resolution (re-import from Linear)
- Implement timestamp-based resolution (newer wins as default)
- Fix linter issues: handle resp.Body.Close() and remove unused error return

* Add Linear integration tests and documentation

- Add comprehensive unit tests for Linear mapping (priority, state, labels, relations)
- Update docs/CONFIG.md with Linear configuration reference
- Add examples/linear-workflow guide for bidirectional sync
- Remove AI section header comments from tests

* Fix Linear GraphQL filter construction and improve test coverage

- Refactor filter handling to combine team ID into main filter object
- Add test for duplicate issue relation mapping
- Add HTTP round-trip helper for testing request payload validation

* Refactor Linear queries to use shared constant and add UUID validation

- Extract linearIssuesQuery to deduplicate FetchIssues/FetchIssuesSince
- Add linearMaxPageSize constant and UUID validation with regex
- Expand test coverage for new functionality

* Refactor Linear integration into internal/linear package

- Extract types, client, and mapping logic from cmd/bd/linear.go
- Create internal/linear/ package for better code organization
- Update tests to work with new package structure

* Add linear teams command to list available teams

- Add FetchTeams GraphQL query to Linear client
- Refactor config reading to support daemon mode
- Add tests for teams listing functionality

* Refactor Linear config to use getLinearConfig helper

- Consolidate config/env var lookup using getLinearConfig function
- Add LINEAR_TEAM_ID environment variable support
- Update error messages to include env var configuration options

* Add hash ID generation and improve Linear conflict detection

- Add configurable hash ID mode for Linear imports (matches bd/Jira)
- Improve conflict detection with content hash comparison
- Enhance conflict resolution with skip/force update tracking

* Fix test for updated doPushToLinear signature

- Add missing skipUpdateIDs parameter to test call
2025-12-19 17:58:24 -08:00