Commit graph

21 commits

Author SHA1 Message Date
Jozef Izso
42064c46fe
Sync Linear milestones as local epics (#3528) 2026-05-05 07:45:30 -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
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
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
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
2f60a10fc5
Import Linear relations as dependencies (#3519)
* Fix gate and cook regressions (bd-r2l)

* Import Linear relations as dependencies (bd-ly3)
2026-04-26 20:30:02 -07:00
coffeegoddd☕️✨
50f715b124 /{cmd,internal}: move local only state to dolt ignored tables 2026-04-14 14:47:30 -07:00
Harry Miller
ef621e5be5
feat: add IssueIDs filter to SyncOptions for selective sync (#2957)
Adds engine-level IssueIDs filter to SyncOptions, enabling selective sync for both push and pull paths.

Co-authored-by: Harry <harry_miller@trimble.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 22:24:47 -07:00
Harry
870cb83e37 fix: remove dead rig routing code and unused variable after rebase
openStoreForRig was removed by upstream refactor (d7629204). Remove
the --rig flag and rig routing from runReadyExplain. Also remove
unused 'now' variable in engine.go introduced during conflict
resolution.
2026-03-30 09:23:01 -07:00
Harry
8d41e70e2d Surface sync engine warnings in SyncResult and fix silent failure paths
- Collect warnings in Engine.warnings during Sync() and populate
  result.Warnings (field existed but was never used)
- Fix createDependencies: return error count, stop silently discarding
  GetIssueByExternalRef errors (previously used _ discard)
- Fix external_ref update failure: now increments stats.Errors when
  the local link-back fails after creating an external issue
- Add Errors field to PullStats and propagate to SyncResult
- Dependency creation failures now counted as Skipped in pull stats

Fixes: bd-5cx

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:12:55 -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
emma
083181e1ea feat: reimplement Notion sync on REST data sources (fix-merge PR #2759)
Adds internal/notion/ package with direct REST API client, field mapping,
and tracker adapter. Adds bd notion init/connect/status/sync commands.
Enhances tracker engine: conflict detection before pull, label sync,
no-op skip, batch push interface, RFC3339Nano timestamps. Removed dead
matchesFetchOptions function, added gosec nolint for Notion API client.

Co-Authored-By: Osamu Okano <okano.osamu@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 19:20:40 -07:00
gregorycollins-usmobile
5297286bb2
feat(linear): add --parent flag to limit sync push to a ticket tree (PR #2853)
* feat(linear): add --parent flag to limit sync push to a ticket tree

Adds --parent=TICKET to bd linear sync --push, restricting the push
to the named beads ticket and all its transitive descendants via
parent-child dependencies.

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

* test(tracker): add tests for ParentID push filter

Six cases: basic parent+children, deep transitive descendants,
leaf with no children, non-parent-child edges not followed,
empty ParentID pushes all, dry-run with parent filter.

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

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 19:30:42 -07:00
Pierre-Alexandre Entraygues
6e4ad9b283
feat(otel): opt-in OpenTelemetry instrumentation (#1940)
* feat(otel): comprehensive OpenTelemetry instrumentation

Phase 1 (telemetry foundation + SQL + CLI + AI):
- Add internal/telemetry package: Init/Shutdown, Tracer/Meter helpers,
  stdout + OTLP/gRPC exporters, noop providers when disabled
- Add internal/telemetry/storage.go: InstrumentedStorage decorator for
  SDK consumers with bd.storage.* counters and duration histograms
- Instrument DoltStore SQL layer (execContext, queryContext, queryRowContext)
  with dolt.exec / dolt.query / dolt.query_row spans
- Instrument Anthropic API calls in compact/haiku.go and find_duplicates.go
  with bd.ai.input_tokens, bd.ai.output_tokens, bd.ai.request.duration
- Add bd.command.<name> span in PersistentPreRun/PostRun with actor attribute

Phase 2 (VC ops, hooks, sync, metrics):
- Add dolt.commit / dolt.push / dolt.force_push / dolt.pull / dolt.branch /
  dolt.checkout / dolt.merge spans for Dolt version-control procedures
  (these bypass execContext so needed dedicated spans)
- Add bd.db.retry_count counter in withRetry (server mode retries)
- Add bd.db.lock_wait_ms histogram in AcquireAccessLock (flock contention)
- Add ephemeral.count / ephemeral.nuke spans for SQLite ephemeral store
- Add hook.exec spans in hooks_unix/windows runHook (background root spans)
- Add tracker.sync / tracker.pull / tracker.push / tracker.detect_conflicts
  spans with per-phase stats attributes in tracker/engine.go
- Add bd.issue.count gauge (by status) in InstrumentedStorage.GetStatistics
- Fix: call initAIMetrics via sync.Once in newHaikuClient so ai metrics
  are actually registered

Configuration:
  BD_OTEL_ENABLED=true              enable (default: off, zero overhead)
  BD_OTEL_STDOUT=true               write to stdout for dev/debug
  OTEL_EXPORTER_OTLP_ENDPOINT=...  ship to Jaeger/Grafana/Honeycomb/etc.

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

* refactor(otel): align with VictoriaMetrics HTTP stack

- Switch metric exporter: gRPC → HTTP (otlpmetrichttp)
- Activation: BD_OTEL_METRICS_URL presence (no more BD_OTEL_ENABLED flag)
  matches GT_OTEL_METRICS_URL convention from the local observability stack
- BD_OTEL_METRICS_URL=http://localhost:8428/opentelemetry/api/v1/push
- BD_OTEL_LOGS_URL=http://localhost:9428/insert/opentelemetry/v1/logs (reserved)
- Traces: stdout only (BD_OTEL_STDOUT=true); noop otherwise since VictoriaMetrics
  is a metrics-only backend — no trace overhead in production
- Remove: otlptracegrpc, otlpmetricgrpc
- Update docs/OBSERVABILITY.md to match the diffusiontown README style

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

* feat(otel): capture hook stdout/stderr and bd.args in spans

- hook.exec span now records stdout and stderr as span events after
  the hook process exits (including partial output on timeout)
- Output is truncated to 1024 bytes; the event carries both the text
  (output) and the original size (bytes) as attributes
- bd.command.<name> span now includes bd.args with the raw CLI
  arguments (e.g. "create 'title' -p 2")

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

* fix(otel): address review feedback — stale comment, span leak, hot-path alloc

1. Fix stale BD_OTEL_ENABLED comment in main.go (actual env vars are
   BD_OTEL_METRICS_URL and BD_OTEL_STDOUT)
2. Use defer+named returns in Merge() to prevent span leaks
3. Cache doltSpanAttrs() via sync.Once to avoid per-call allocation

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

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: beads/crew/emma <steve.yegge@gmail.com>
2026-02-22 15:36:57 -08: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
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
8f00fb7e76 refactor: wire Jira CLI through SyncEngine, delete duplicated sync code
Replace Python-script-based Jira sync with native Go REST API client.
Jira CLI now follows same thin pattern as Linear/GitLab: create tracker,
create engine, call engine.Sync(). Completes Phase 4 of dolt-y60t.

- Implement Jira REST API v3 client (search, get, create, update)
- Add ADF (Atlassian Document Format) plain text conversion
- Wire Jira tracker IssueTracker methods with real API calls
- Complete jiraFieldMapper.IssueToBeads/IssueToTracker
- Delete conflict.go (Engine handles conflicts), scripts.go (Python
  dependency removed), Jira-specific stat types (Engine types used)
- Fix engine pull guard: skip locally-modified issues unconditionally,
  let Phase 2 conflict detection handle them

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 17:59:33 -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
beads/crew/emma
7de76f36ac fix: wire FormatDescription hook in doPush, add GenerateID/FormatDescription tests
Self-review found two issues:
1. FormatDescription was declared in PushHooks but never called in doPush.
   Now applied to a shallow copy before CreateIssue/UpdateIssue to avoid
   mutating local data.
2. GenerateID hook had no test coverage. Added tests for both success and
   error (collision) cases, plus FormatDescription test that verifies
   local issue is not mutated.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 17:00:44 -08:00
beads/crew/emma
3728ac1f08 feat: add PullHooks/PushHooks to SyncEngine for battle-tested CLI behaviors
Phase 3 of tracker refactor (dolt-y60t.3). Adds optional hook callbacks
to the Engine so tracker adapters can opt into proven CLI patterns:

PullHooks: ShouldImport (filter before conversion), TransformIssue
(description formatting/normalization), GenerateID (hash-based IDs).

PushHooks: ShouldPush (custom filtering), ContentEqual (content-hash
dedup to skip unnecessary API calls), FormatDescription (tracker-specific
rendering), BuildStateCache/ResolveState (batch workflow state resolution).

Also adds ExcludeEphemeral to SyncOptions for wisp filtering on push.

Dropped from original plan: tombstone filtering (Dolt handles natively),
UseImporter delegation (importer package tied to dying JSONL/SQLite infra).

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 16:47:07 -08:00
beads/crew/emma
9d29ffd236 feat: add plugin-based issue tracker framework (GH#1150)
Implements shared interfaces and sync engine for external tracker
integrations (Linear, GitLab, Jira, etc.), eliminating duplication
between adapters. Design from PRs #1564-#1567, updated for Dolt-only.

- IssueTracker: 14-method plugin interface for tracker adapters
- FieldMapper: bidirectional field conversion between beads and trackers
- Engine: Pull→Detect→Resolve→Push sync with conflict resolution
- Registry: thread-safe plugin registration via init() functions

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 14:09:40 -08:00