* feat(ga-p9iuv.22): add shared tracker proxy storage seam
* fix(ga-p9iuv.22): preserve tracker storage capabilities safely
* test(ga-p9iuv.22): cover tracker adapter label semantics
* test(ga-p9iuv.22): harden tracker adapter contracts
* fix(ga-p9iuv.22): reject invalid proxied tracker stores
* feat(ga-p9iuv.1): route Linear and Jira front doors through proxy store
* test(ga-p9iuv.1): exercise tracker mutations through UOW store
* fix(ga-p9iuv.1): preserve proxied Linear endpoint config
* test(ga-p9iuv.1): cover proxied Linear endpoint and direct config
* feat(ga-p9iuv.19): add typed proxied capability matrix
* feat(proxy): enforce typed capability matrix before provider
* test(proxy): cover command capability rows and claim caps
* test(proxy): check capability rows across topologies
* fix(proxy): validate capabilities before workspace side effects
* fix(proxy): refuse ready claim max rows caps
* feat(proxy): add shared maintenance capability policy
* fix(proxy): key maintenance refusals by command path
* test(proxy): cover nested maintenance refusals
* fix(proxy): enumerate nested maintenance command paths
* fix(proxy): refine compact and nested maintenance policy
* test(proxy): prove maintenance refusals preserve files
* fix(proxy): cover admin and remote maintenance refusals
* fix(proxy): refuse doctor before store initialization
* test(proxy): define history capability command matrix
* fix(proxy): wire history capability refusals to front door
* fix(proxy): refuse top-level sync history path
* fix(proxy): preserve maintenance refusal codes
* feat(proxy): classify history as supported UOW API
* feat(proxy): classify transform capability paths
* test(proxy): harden transform capability matrix
* fix(proxy): drive transform validation from exact rows
* fix(proxy): drive transform matrix from normalized flags
* fix(proxy): bound external backend dials per attempt
* test(proxy): cover bounded blocked backend dial
* fix(proxy): make transform capability policy row-driven
* fix(proxy): make transform capability policy row-driven
* fix(proxy): classify formula swarm and merge-slot refusals
* test(proxy): enforce workflow refusal contract
* fix(proxy): classify Dolt remote history boundaries
* test(proxy): enforce history refusal contract
* test(proxy): cover canceled backend dial cleanup
* test(proxy): cover real TCP blackhole cancellation
* test(proxy): cover external transport lifecycle matrix
* test(proxy): assert stable dial failure diagnostics
* test(proxy): add outage reconnect acceptance matrix
* test(proxy): make unix outage bridge restartable
* test(proxy): bound outage subprocess cleanup
* test(proxy): cover upstream restart with retained endpoint bridge
* test(proxy): stabilize managed-local outage contract
* fix(proxy): retire managed proxy when backend exits
* test(proxy): accept managed child retirement restart
* test(proxy): cover workflow refusals at bd front door
* test(proxy): cover history VC front doors
* test(proxy): pass valid workflow refusal arguments
* test(proxy): assert text and json refusal contracts
* test(proxy): assert exact workflow refusal codes
* test(proxy): guard refusal issue-row stability
* fix(proxy): expose non-mutating capability refusals
* test(proxy): match stable refusal text
* test(proxy): compare refusal artifact snapshots
* test(proxy): assert exact refusal messages
* test(proxy): retain direct workflow behavior
* test(proxy): match nested refusal messages
* test(proxy): cover direct-only front-door refusals
* test(proxy): provide valid direct-only command args
* fix(migrate): repair missing proxied sidecar on reentry
* fix: checkpoint Dolt mode migrations for safe retry
* fix: harden migration journal topology and retries
* fix: fsync migration journal removal
* fix: fail on migration journal directory sync errors
* fix: reject external ownership in every migration phase
* fix: enforce canonical shared migration topology
* fix: enforce live migration topology
* test: add migration front-door and topology regressions
* fix: require physical Dolt roots for migration
* test: strengthen migration front-door contracts
* fix: reject missing or invalid Dolt migration roots
* fix: keep shared migration dry-runs side-effect free
* fix: require Dolt repository identity for migrations
* fix: validate Dolt repository identity metadata
* fix: require typed Dolt repo state identity
* test: expand migration front-door CRUD assertions
* test: make migration JSON dry-run front-door safe
* test: sanitize Dolt environment for migration front door
* test: use cgo binary for migration front door
* test: omit empty Dolt overrides in migration front door
* test: isolate migration front door from test mode
* test: isolate home for migration front door
* test: stop supervised Dolt before reverse migration
* fix: reject empty Dolt head refs
* test: harden migration topology invariants
* test: harden external and shared topology refusals
* test: snapshot migration refusal artifacts
* test: cover external migration refusal phases
* fix: refuse stale proxied sidecars during migration
* test: strengthen migration artifact and external front door checks
* feat: type external migration refusals
* test: assert external refusal starts no proxy
* fix: validate migration journal sidecar topology
* fix: make sidecar recovery phase aware
* fix: honor persisted shared topology during migration
* test: exercise external journal migration front door matrix
* test(tracker): add shared conformance harness
* test: harden external migration matrix fixtures
* test: preserve durable dolt gate lock in matrix
* test: preseed gate lock for refusal matrix
* test: cover malformed migration state front door
* fix: type malformed migration config refusals
* fix: type migration preflight state errors
* test: separate migration JSON stdout from warnings
* test: reach typed malformed journal refusal
* test: assert migration retry phase and idempotence
* test: cover shared migration checkpoint retries
* fix: make reverse migration idempotent without sidecar
* test: cover proxied to shared retries
* fix: derive shared topology from persisted YAML
* fix: validate shared migration no-op state
* fix: allow completed proxied shared no-op
* fix: validate forward proxied no-op sidecar
* test: reject bad already-proxied sidecars
* fix: reject stale proxy controls on no-op
* fix: fail closed on malformed migration workspace yaml
* test: pin migration yaml topology precedence
* Cover forward migration no-op ownership refusals (ga-p9iuv.26.5.2)
Agent-Signature: unknown-model/unknown-reasoning
* Strengthen migration retry sentinel coverage (ga-p9iuv.26.1)
Agent-Signature: unknown-model/unknown-reasoning
* Expand migration fault retry artifact coverage (ga-p9iuv.26.1)
Agent-Signature: unknown-model/unknown-reasoning
* Add reverse migration frontdoor fault matrix (ga-p9iuv.26.1.1)
Agent-Signature: unknown-model/unknown-reasoning
* test: cover shared migration frontdoor fault matrices
* test: strengthen direct migration matrix assertions
* test: preserve migration dependency edges
* test: assert exact migration dependency edges
* test: parse migration dependency edges from batch list
* test: fix shared migration matrix compile
* test: verify shared dependencies before shutdown
* test(proxy): cover history remote front-door topology matrix
* docs: define direct-local ownership handoff contract
* fix(ci): repair pre-review CI failures on proxy parity branch
Five PR-introduced failures across the docs, PR Core, and Proxied Dolt Cmd
lanes. Each fix is scoped to the evidenced defect.
- test/docsync: TestEveryDocsPageIsPublished flagged
docs/architecture/ownership-handoff-contract.md as unpublished. It is an
internal Beads/Gas City handoff contract with no Mintlify frontmatter and
no inbound links, so move it to engdocs/design/ beside its peers rather
than publishing it.
- cmd/bd: TestProxyWorkflowRefusalContractAndNoMutation asserted on
commandDidWrite, a process-wide atomic latch set by 71 non-test sites and
never reset, so it reported an earlier test's write. Baseline and restore
it around the assertion, matching the save/reset/restore idiom already
used in proxied_lookup_failure_test.go and readonly_policy_test.go.
- cmd/bd: the new pre-provider gate short-circuited compact.go's refusal
with new wording, breaking TestProxiedServerCompactDolt/non_dolt_mode_-
rejected in an unchanged test. Restore the long-standing message; the
proxy.compact.unsupported code is unchanged.
- internal/storage/dbproxy/proxy: the unix subtests bound sockets under
t.TempDir(), whose embedded test name overflows macOS's ~104-byte
sun_path limit ("bind: invalid argument"). Add unixSocketPath() to place
them in a short temp dir.
- cmd/bd: migration topology compared recorded and canonical Dolt roots
lexically, so macOS's /var -> /private/var symlink made equivalent paths
compare unequal. Add sameMigrationRoot(), mirroring the existing
resolveExistingPrefix idiom in cmd/bd/doctor/git.go.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(review): address blocker and major findings from adopt-pr review
Maintainer review fixup for the proxy parity branch, iterations 1-2.
Blockers and majors from the review synthesis and quality scorecard.
Blockers:
- cmd/bd/migrate_dolt_mode.go: resuming from migratePrepared rebuilt the
migration plan from the current argv instead of replaying the recorded
one. A resume that omitted or changed --idle-timeout wrote a sidecar the
target_configured check then rejected, and because that check runs only
after the phase advances past migratePrepared, the block never ran again
— the workspace stayed wedged in proxied-server mode with no in-tool
recovery. Replay j.Sidecar and warn when the supplied value is ignored.
- internal/tracker/store.go: NewStore double-wrapped already-adapted values.
directStore embeds the storage.Storage interface, so *directStore also
satisfies storage.Storage and was re-wrapped as
&directStore{Storage: &directStore{...}}; the inner value can never
satisfy storage.IssueLifecycleStore, which silently degraded
ApplyIssueUpdate to a bare UpdateIssue — no labels, no lifecycle
transaction. Match the tracker's own adapters by concrete type first.
Testing value.(Store) first, as the review suggested, does not work:
storage.Storage is a strict superset of Store, so a raw direct store
satisfies Store too and would be returned un-adapted, relocating the same
bug. The branch order is documented at the call site.
Majors:
- internal/tracker/store.go: directStore.ApplyIssueUpdate now calls
syncIssueLabels, which normalizes both label sets (trim, drop empty) and
restores the semantics the pull path had before this seam moved behind
ApplyIssueUpdate. The un-normalized local copy churned remove+add on
whitespace-only differences and let an empty label reach AddLabel; it is
deleted rather than left as a second, divergent implementation.
- Both regressions were invisible to the suite. Adds
TestNewEngineKeepsDirectStoreAdaptationIntact, TestNewStoreIsIdempotent,
TestDirectStoreApplyIssueUpdateNormalizesLabels, and
TestMigrateToProxiedServer_ResumeReplaysRecordedIdleTimeout (changed /
omitted / never subtests, each also asserting the reverse-migration escape
hatch still recovers). All four were verified to fail against the
pre-fix production code with the predicted symptoms.
Non-gating follow-ups from the scorecard, fixed while nearby:
- cmd/bd/proxy_capability.go: treat ProxyOutcomeNA as "this command has no
such flag" rather than a refusal, so an assert on an N/A row cannot return
a non-nil error carrying an empty message.
- cmd/bd/errors.go: emit the rule's real Mutates value in the JSON refusal
envelope instead of a hardcoded false.
- cmd/bd/main.go: the doctor pre-provider check returned unconditionally,
so a nil result (every doctor subcommand) skipped the legacy-store guard
and autocommit-mode resolution that other skipsStoreInit commands run.
Return only on a real refusal.
- internal/tracker/engine.go: type NewEngine's store parameter as Store so
the seam names its contract, and drop the now-dead applyPullIssueUpdate.
- CHANGELOG.md: record the proxied `bd ready --claim` row-cap refusal, which
was a behavior change shipped without a release note.
Iteration 2 -- gating major (uowStore/directStore external_ref divergence):
- internal/tracker/uow_store.go: GetIssueByExternalRef resolved through a
single merged search over both storage planes, which has no plane
preference: it is a UNION ALL ordered by content and terminating in
`id ASC`, so one external_ref present on both planes resolved to whichever
row's id sorted first. The direct backend is explicitly issues-first --
issueops.GetIssueByExternalRefInTx queries `issues` and falls through to
`wisps` only on sql.ErrNoRows, and says why ("so that pushed ephemeral
beads are found during pull dedup"). The consumer is the pull dedup, which
updates whatever row comes back, so the divergence was a silent write to
the wrong local bead under --proxied-server only. Query the issues plane
first via SkipWisps, then fall back.
The fallback is the merged search rather than the review's literal
Ephemeral=true: that filter contributes an `ephemeral = 1` predicate the
direct backend's `SELECT id FROM wisps WHERE external_ref = ?` does not
have, and wisp-plane rows legitimately carry ephemeral=0 (NoHistory beads;
see types.IssueFilter.EphemeralTier). Taking it literally would have traded
one divergence for a narrower one. Verified: implementing the prescription
fails the ephemeral_flag_clear subtest below.
- internal/tracker/uow_store_engine_test.go: the engine fake now models plane
routing (SkipWisps / Ephemeral / merged) instead of one flat map, so the
contract is expressible at all. Adds
TestUOWStoreGetIssueByExternalRefPrefersIssuePlane, whose wisp id sorts
first so "first merged hit" fails it, and
TestUOWStoreGetIssueByExternalRefFallsBackToWispPlane over both ephemeral
values. Verified to fail against the pre-fix uow_store.go.
- internal/tracker/conformance: the shared suite gains a Wisps plane and
external_ref_resolution_prefers_issue_plane, so this is a contract both
backends are held to rather than one adapter's unit test.
Iteration 2 -- non-gating follow-ups from the scorecard:
- cmd/bd/migrate_dolt_mode.go: scope the migratePrepared sidecar-equivalence
check in runMigrateFromProxiedServer to reverse journals. A forward journal
at that phase records the sidecar it is about to write, so a crash in the
pre-write window leaves none on disk -- the correct state -- and the
unscoped check refused the documented escape hatch by naming a missing
file, stranding the workspace. Tested against TargetMode's forward value so
the guard stays live for both reverse targets, "server" and
"shared-server". Adds
TestMigrateFromProxiedServer_ForwardJournalAtPreparedIsNotSidecarRefused,
verified to fail against the unscoped guard.
- cmd/bd/linear.go: buildLinearClientAPIOnly returned the OAuth client inline
and never reached the WithEndpoint block, so a configured
linear.api_endpoint was honored for an API key and ignored for OAuth. Hoist
the endpoint application after the branch, as Tracker.Init does, and add
the OAuth mirror of the existing endpoint test.
- cmd/bd/ready_max_rows_proxied_test.go: pin the proxied --max-rows refusal
on `bd ready --claim`. It lives in RunE above the dispatch and nothing
below it can enforce a cap, but the existing coverage all sits below it.
Covers both cap sources (--max-rows and BEADS_MAX_ROWS) and the negative
case that the refusal is conditioned on a live cap, not on --claim.
- engdocs/design/ownership-handoff-contract.md: trim the trailing blank line
at EOF flagged by `git diff --check`.
Iteration 3 -- non-gating residual on the iteration-2 fix:
- internal/tracker/uow_store.go: the issues-first fix above split one logical
lookup across two read transactions. uow.RunTxRead opens a fresh unit of
work per call, so calling s.SearchIssues twice left the wisp fallback's
premise -- "the issues plane is already known empty" -- without a shared
snapshot: a concurrent same-ref insert into the issues plane landing between
the two reads could let the merged fallback return the wisp, re-creating the
wrong-row write that ordering exists to prevent. The consumer is the pull
dedup loop, so it runs per imported issue. Both plane reads now share a
single RunTxRead, which is also the shape the direct backend uses (both
planes inside one withReadTx). Plane ordering is unchanged.
- internal/tracker/uow_store_engine_test.go: the engine fake counts the units
of work it hands out, and
TestUOWStoreGetIssueByExternalRefUsesOneReadTransaction pins that count at 1
across the two paths that actually perform both reads -- the wisp fallback
and the miss. An issues-plane hit short-circuits after one read and would
pass either way, so it is not a case. Verified to fail against the
two-transaction version with "opened 2, want 1".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
815 lines
25 KiB
Go
815 lines
25 KiB
Go
package linear
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/steveyegge/beads/internal/config"
|
|
"github.com/steveyegge/beads/internal/tracker"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
var _ tracker.BatchPushTracker = (*Tracker)(nil)
|
|
|
|
func init() {
|
|
tracker.Register("linear", func() tracker.IssueTracker {
|
|
return &Tracker{}
|
|
})
|
|
}
|
|
|
|
// Tracker implements tracker.IssueTracker for Linear.
|
|
type Tracker struct {
|
|
clients map[string]*Client // keyed by team ID
|
|
config *MappingConfig
|
|
store tracker.Store
|
|
teamIDs []string // ordered list of configured team IDs
|
|
projectID string
|
|
}
|
|
|
|
// SetTeamIDs sets the team IDs before Init(). When set, Init() uses these
|
|
// instead of reading from config. This supports the --team CLI flag.
|
|
func (t *Tracker) SetTeamIDs(ids []string) {
|
|
t.teamIDs = ids
|
|
}
|
|
|
|
func (t *Tracker) Name() string { return "linear" }
|
|
func (t *Tracker) DisplayName() string { return "Linear" }
|
|
func (t *Tracker) ConfigPrefix() string { return "linear" }
|
|
|
|
func (t *Tracker) Init(ctx context.Context, store tracker.Store) error {
|
|
t.store = store
|
|
|
|
// Resolve authentication: OAuth client-credentials takes precedence over API key.
|
|
oauthClientID, _ := t.getConfig(ctx, "linear.oauth_client_id", "LINEAR_OAUTH_CLIENT_ID")
|
|
oauthClientSecret, _ := t.getConfig(ctx, "linear.oauth_client_secret", "LINEAR_OAUTH_CLIENT_SECRET")
|
|
hasOAuth := oauthClientID != "" && oauthClientSecret != ""
|
|
|
|
var apiKey string
|
|
if !hasOAuth {
|
|
apiKey, _ = t.getConfig(ctx, "linear.api_key", "LINEAR_API_KEY")
|
|
if apiKey == "" {
|
|
return fmt.Errorf("Linear authentication not configured\n" +
|
|
"Options:\n" +
|
|
" OAuth (for CI): export LINEAR_OAUTH_CLIENT_ID=... LINEAR_OAUTH_CLIENT_SECRET=...\n" +
|
|
" API key (devs): export LINEAR_API_KEY=... or bd config set linear.api_key \"YOUR_API_KEY\"")
|
|
}
|
|
}
|
|
|
|
// Resolve team IDs: use pre-set IDs (from CLI), or fall back to config.
|
|
if len(t.teamIDs) == 0 {
|
|
pluralVal, _ := t.getConfig(ctx, "linear.team_ids", "LINEAR_TEAM_IDS")
|
|
singularVal, _ := t.getConfig(ctx, "linear.team_id", "LINEAR_TEAM_ID")
|
|
t.teamIDs = tracker.ResolveProjectIDs(nil, pluralVal, singularVal)
|
|
if len(t.teamIDs) == 0 {
|
|
return fmt.Errorf("Linear team ID not configured (set linear.team_id, linear.team_ids, or LINEAR_TEAM_ID)")
|
|
}
|
|
}
|
|
|
|
// Read optional endpoint and project ID.
|
|
var endpoint, projectID string
|
|
if store != nil {
|
|
endpoint, _ = store.GetConfig(ctx, "linear.api_endpoint")
|
|
projectID, _ = store.GetConfig(ctx, "linear.project_id")
|
|
if projectID != "" {
|
|
t.projectID = projectID
|
|
}
|
|
}
|
|
|
|
// Read optional rate-limit floor (LINEAR_RATE_LIMIT_FLOOR env or linear.rate_limit_floor config).
|
|
var rateLimitFloor int
|
|
if floorStr, _ := t.getConfig(ctx, "linear.rate_limit_floor", "LINEAR_RATE_LIMIT_FLOOR"); floorStr != "" {
|
|
if v, err := strconv.Atoi(strings.TrimSpace(floorStr)); err == nil && v >= 0 {
|
|
rateLimitFloor = v
|
|
}
|
|
}
|
|
|
|
// Create per-team clients upfront for O(1) routing.
|
|
t.clients = make(map[string]*Client, len(t.teamIDs))
|
|
for _, teamID := range t.teamIDs {
|
|
var client *Client
|
|
if hasOAuth {
|
|
client = NewOAuthClient(OAuthConfig{
|
|
ClientID: oauthClientID,
|
|
ClientSecret: oauthClientSecret,
|
|
}, teamID)
|
|
} else {
|
|
client = NewClient(apiKey, teamID)
|
|
}
|
|
if endpoint != "" {
|
|
client = client.WithEndpoint(endpoint)
|
|
}
|
|
if projectID != "" {
|
|
client = client.WithProjectID(projectID)
|
|
}
|
|
if rateLimitFloor > 0 {
|
|
client = client.WithRateLimitFloor(rateLimitFloor)
|
|
}
|
|
t.clients[teamID] = client
|
|
}
|
|
|
|
t.config = LoadMappingConfig(&configLoaderAdapter{ctx: ctx, store: store})
|
|
return nil
|
|
}
|
|
|
|
func (t *Tracker) Validate() error {
|
|
if len(t.clients) == 0 {
|
|
return fmt.Errorf("Linear tracker not initialized")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *Tracker) Close() error { return nil }
|
|
|
|
func (t *Tracker) FetchIssues(ctx context.Context, opts tracker.FetchOptions) ([]tracker.TrackerIssue, error) {
|
|
state := opts.State
|
|
if state == "" {
|
|
state = "all"
|
|
}
|
|
|
|
seen := make(map[string]bool)
|
|
var result []tracker.TrackerIssue
|
|
|
|
for _, teamID := range t.teamIDs {
|
|
client := t.clients[teamID]
|
|
if client == nil {
|
|
continue
|
|
}
|
|
|
|
var issues []Issue
|
|
var err error
|
|
if opts.Since != nil {
|
|
issues, err = client.FetchIssuesSince(ctx, state, *opts.Since)
|
|
} else {
|
|
issues, err = client.FetchIssues(ctx, state)
|
|
}
|
|
if err != nil {
|
|
return result, fmt.Errorf("fetching issues from team %s: %w", teamID, err)
|
|
}
|
|
|
|
for _, li := range issues {
|
|
if seen[li.ID] {
|
|
continue
|
|
}
|
|
seen[li.ID] = true
|
|
result = append(result, linearToTrackerIssue(&li))
|
|
}
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
func (t *Tracker) FetchIssue(ctx context.Context, identifier string) (*tracker.TrackerIssue, error) {
|
|
// Try the primary client first (first team), then others.
|
|
for _, teamID := range t.teamIDs {
|
|
client := t.clients[teamID]
|
|
if client == nil {
|
|
continue
|
|
}
|
|
li, err := client.FetchIssueByIdentifier(ctx, identifier)
|
|
if err != nil {
|
|
continue // Issue might belong to a different team.
|
|
}
|
|
if li != nil {
|
|
ti := linearToTrackerIssue(li)
|
|
return &ti, nil
|
|
}
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (t *Tracker) CreateIssue(ctx context.Context, issue *types.Issue) (*tracker.TrackerIssue, error) {
|
|
client := t.primaryClient()
|
|
if client == nil {
|
|
return nil, fmt.Errorf("no Linear client available")
|
|
}
|
|
|
|
priority := PriorityToLinear(issue.Priority, t.config)
|
|
|
|
stateID, err := t.findStateID(ctx, client, issue.Status)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("finding state for status %s: %w", issue.Status, err)
|
|
}
|
|
|
|
labelCache, err := BuildLabelCache(ctx, client)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("loading team labels: %w", err)
|
|
}
|
|
labelIDs, unknown := ResolveLabelIDs(issue, labelCache, t.config)
|
|
for _, name := range unknown {
|
|
fmt.Fprintf(os.Stderr, "linear: bead %s: label %q not found on Linear team (skipped)\n", issue.ID, name)
|
|
}
|
|
|
|
// Use issue.Description as-is: the sync engine's FormatDescription hook
|
|
// (BuildLinearDescription) has already merged AcceptanceCriteria/Design/Notes
|
|
// into the description before calling CreateIssue. Calling BuildLinearDescription
|
|
// here a second time would duplicate those sections for issues with structured fields.
|
|
description := issue.Description
|
|
|
|
// Use idempotent creation when we have enough bead metadata to generate
|
|
// a stable marker. This prevents duplicate Linear issues when sync is
|
|
// interrupted between the API create call and the local external_ref
|
|
// write-back.
|
|
if issue.ID != "" && issue.CreatedBy != "" {
|
|
marker := GenerateIdempotencyMarker(issue.ID, issue.CreatedBy, issue.CreatedAt.UnixNano())
|
|
created, deduped, err := client.CreateIssueIdempotent(ctx, issue.Title, description, priority, stateID, labelIDs, marker)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if deduped {
|
|
fmt.Fprintf(os.Stderr, "linear: dedup — reusing existing issue %s for bead %s\n", created.Identifier, issue.ID)
|
|
}
|
|
ti := linearToTrackerIssue(created)
|
|
return &ti, nil
|
|
}
|
|
|
|
created, err := client.CreateIssue(ctx, issue.Title, description, priority, stateID, labelIDs)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
ti := linearToTrackerIssue(created)
|
|
return &ti, nil
|
|
}
|
|
|
|
func (t *Tracker) UpdateIssue(ctx context.Context, externalID string, issue *types.Issue) (*tracker.TrackerIssue, error) {
|
|
// Route to the correct team's client based on the external ID.
|
|
client := t.clientForExternalID(ctx, externalID)
|
|
if client == nil {
|
|
return nil, fmt.Errorf("cannot determine Linear team for issue %s", externalID)
|
|
}
|
|
|
|
labelCache, err := BuildLabelCache(ctx, client)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("loading team labels: %w", err)
|
|
}
|
|
_, unknown := ResolveLabelIDs(issue, labelCache, t.config)
|
|
for _, name := range unknown {
|
|
fmt.Fprintf(os.Stderr, "linear: bead %s: label %q not found on Linear team (skipped)\n", issue.ID, name)
|
|
}
|
|
mapper := &linearFieldMapper{config: t.config, labelCache: labelCache}
|
|
updates := mapper.IssueToTracker(issue)
|
|
|
|
// Resolve and include state so status changes are pushed to Linear.
|
|
stateID, err := t.findStateID(ctx, client, issue.Status)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("finding state for status %s: %w", issue.Status, err)
|
|
}
|
|
if stateID != "" {
|
|
updates["stateId"] = stateID
|
|
}
|
|
|
|
updated, err := client.UpdateIssue(ctx, externalID, updates)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
ti := linearToTrackerIssue(updated)
|
|
return &ti, nil
|
|
}
|
|
|
|
// BatchPush implements tracker.BatchPushTracker. It partitions issues into
|
|
// creates and updates, uses issueBatchCreate for new issues (chunked at 50),
|
|
// and falls back to per-issue UpdateIssue for updates (since issueBatchUpdate
|
|
// applies the same fields to all IDs, which doesn't fit per-issue field diffs).
|
|
//
|
|
// Skip semantics: existing issues are fetched and compared with PushFieldsEqual
|
|
// before updating; unchanged issues are skipped. forceIDs bypasses this check.
|
|
//
|
|
// Multi-team: state IDs are resolved using the per-team workflow state cache,
|
|
// so updates to issues belonging to different teams use the correct state list.
|
|
//
|
|
// Result mapping: batch-create results are matched by title rather than array
|
|
// index, since Linear's API does not guarantee response order matches input order.
|
|
func (t *Tracker) BatchPush(ctx context.Context, issues []*types.Issue, forceIDs map[string]bool) (*tracker.BatchPushResult, error) {
|
|
client := t.primaryClient()
|
|
if client == nil {
|
|
return nil, fmt.Errorf("no Linear client available")
|
|
}
|
|
|
|
// Build per-team state caches so that updates to issues belonging to different
|
|
// teams resolve workflow state IDs against the correct team's state list.
|
|
teamCaches := make(map[string]*StateCache, len(t.teamIDs))
|
|
for _, teamID := range t.teamIDs {
|
|
teamClient := t.clients[teamID]
|
|
if teamClient == nil {
|
|
continue
|
|
}
|
|
cache, err := BuildStateCache(ctx, teamClient)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("building state cache for team %s: %w", teamID, err)
|
|
}
|
|
teamCaches[teamID] = cache
|
|
}
|
|
|
|
// The primary team's cache is used for creates, which always target the primary team.
|
|
primaryCache := teamCaches[t.teamIDs[0]]
|
|
if primaryCache == nil {
|
|
return nil, fmt.Errorf("building state cache: no cache for primary team %s", t.teamIDs[0])
|
|
}
|
|
|
|
teamLabelCaches := make(map[string]*LabelCache, len(t.teamIDs))
|
|
for _, teamID := range t.teamIDs {
|
|
teamClient := t.clients[teamID]
|
|
if teamClient == nil {
|
|
continue
|
|
}
|
|
lc, err := BuildLabelCache(ctx, teamClient)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("building label cache for team %s: %w", teamID, err)
|
|
}
|
|
teamLabelCaches[teamID] = lc
|
|
}
|
|
primaryLabelCache := teamLabelCaches[t.teamIDs[0]]
|
|
if primaryLabelCache == nil {
|
|
return nil, fmt.Errorf("building label cache: no cache for primary team %s", t.teamIDs[0])
|
|
}
|
|
|
|
result := &tracker.BatchPushResult{}
|
|
|
|
var toCreate []*types.Issue
|
|
var toUpdate []*types.Issue
|
|
|
|
for _, issue := range issues {
|
|
extRef := ""
|
|
if issue.ExternalRef != nil {
|
|
extRef = *issue.ExternalRef
|
|
}
|
|
if extRef == "" || !IsLinearExternalRef(extRef) {
|
|
toCreate = append(toCreate, issue)
|
|
} else {
|
|
toUpdate = append(toUpdate, issue)
|
|
}
|
|
}
|
|
|
|
// Batch create new issues.
|
|
if len(toCreate) > 0 {
|
|
// Partition into unique-title (safe for batch) and duplicate-title (single-create).
|
|
// Title-based result correlation is only safe when titles are unique in the batch.
|
|
titleCount := make(map[string]int, len(toCreate))
|
|
for _, issue := range toCreate {
|
|
titleCount[issue.Title]++
|
|
}
|
|
|
|
var batchIssues []*types.Issue
|
|
var singleIssues []*types.Issue
|
|
for _, issue := range toCreate {
|
|
if titleCount[issue.Title] > 1 {
|
|
singleIssues = append(singleIssues, issue)
|
|
} else {
|
|
batchIssues = append(batchIssues, issue)
|
|
}
|
|
}
|
|
|
|
// Single-create path for duplicate-title issues using idempotency markers.
|
|
for _, issue := range singleIssues {
|
|
priority := PriorityToLinear(issue.Priority, t.config)
|
|
stateID, stateErr := ResolveStateIDForBeadsStatus(primaryCache, issue.Status, t.config)
|
|
if stateErr != nil {
|
|
result.Errors = append(result.Errors, tracker.BatchPushError{
|
|
LocalID: issue.ID,
|
|
Message: fmt.Sprintf("resolving state for status %s: %v", issue.Status, stateErr),
|
|
})
|
|
continue
|
|
}
|
|
|
|
marker := GenerateIdempotencyMarker(issue.ID, issue.CreatedBy, issue.CreatedAt.UnixNano())
|
|
labelIDs, unknown := ResolveLabelIDs(issue, primaryLabelCache, t.config)
|
|
for _, name := range unknown {
|
|
msg := fmt.Sprintf("linear: bead %s: label %q not found on Linear team (skipped)", issue.ID, name)
|
|
fmt.Fprintf(os.Stderr, "%s\n", msg)
|
|
result.Warnings = append(result.Warnings, msg)
|
|
}
|
|
created, _, createErr := client.CreateIssueIdempotent(ctx, issue.Title, issue.Description, priority, stateID, labelIDs, marker)
|
|
if createErr != nil {
|
|
result.Errors = append(result.Errors, tracker.BatchPushError{
|
|
LocalID: issue.ID,
|
|
Message: fmt.Sprintf("single create (dup title) for %q: %v", issue.Title, createErr),
|
|
})
|
|
continue
|
|
}
|
|
result.Created = append(result.Created, tracker.BatchPushItem{
|
|
LocalID: issue.ID,
|
|
ExternalRef: created.URL,
|
|
})
|
|
}
|
|
|
|
// Batch-create path for unique-title issues.
|
|
var inputs []IssueCreateInput
|
|
titleToIssue := make(map[string]*types.Issue, len(batchIssues))
|
|
for _, issue := range batchIssues {
|
|
priority := PriorityToLinear(issue.Priority, t.config)
|
|
stateID, stateErr := ResolveStateIDForBeadsStatus(primaryCache, issue.Status, t.config)
|
|
if stateErr != nil {
|
|
result.Errors = append(result.Errors, tracker.BatchPushError{
|
|
LocalID: issue.ID,
|
|
Message: fmt.Sprintf("resolving state for status %s: %v", issue.Status, stateErr),
|
|
})
|
|
continue
|
|
}
|
|
|
|
marker := GenerateIdempotencyMarker(issue.ID, issue.CreatedBy, issue.CreatedAt.UnixNano())
|
|
desc := AppendIdempotencyMarker(issue.Description, marker)
|
|
|
|
labelIDs, unknown := ResolveLabelIDs(issue, primaryLabelCache, t.config)
|
|
for _, name := range unknown {
|
|
msg := fmt.Sprintf("linear: bead %s: label %q not found on Linear team (skipped)", issue.ID, name)
|
|
fmt.Fprintf(os.Stderr, "%s\n", msg)
|
|
result.Warnings = append(result.Warnings, msg)
|
|
}
|
|
|
|
input := IssueCreateInput{
|
|
TeamID: client.TeamID,
|
|
Title: issue.Title,
|
|
Description: desc,
|
|
Priority: priority,
|
|
StateID: stateID,
|
|
LabelIDs: labelIDs,
|
|
}
|
|
if client.ProjectID != "" {
|
|
input.ProjectID = client.ProjectID
|
|
}
|
|
titleToIssue[issue.Title] = issue
|
|
inputs = append(inputs, input)
|
|
}
|
|
|
|
if len(inputs) > 0 {
|
|
created, createErr := client.BatchCreateIssues(ctx, inputs)
|
|
if createErr != nil {
|
|
result.Warnings = append(result.Warnings, fmt.Sprintf("batch create partial error: %v", createErr))
|
|
}
|
|
matched := make(map[string]bool, len(created))
|
|
for _, li := range created {
|
|
localIssue, ok := titleToIssue[li.Title]
|
|
if !ok {
|
|
result.Warnings = append(result.Warnings, fmt.Sprintf("batch create: response contained unexpected title %q", li.Title))
|
|
continue
|
|
}
|
|
matched[li.Title] = true
|
|
result.Created = append(result.Created, tracker.BatchPushItem{
|
|
LocalID: localIssue.ID,
|
|
ExternalRef: li.URL,
|
|
})
|
|
}
|
|
for title, localIssue := range titleToIssue {
|
|
if !matched[title] {
|
|
result.Errors = append(result.Errors, tracker.BatchPushError{
|
|
LocalID: localIssue.ID,
|
|
Message: fmt.Sprintf("not returned in batch create response (title: %q)", title),
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update existing issues individually (each has different field values).
|
|
for _, issue := range toUpdate {
|
|
extRef := *issue.ExternalRef
|
|
externalID := ExtractLinearIdentifier(extRef)
|
|
if externalID == "" {
|
|
externalID = extRef
|
|
}
|
|
|
|
routeClient := t.clientForExternalID(ctx, externalID)
|
|
if routeClient == nil {
|
|
result.Errors = append(result.Errors, tracker.BatchPushError{
|
|
LocalID: issue.ID,
|
|
Message: fmt.Sprintf("cannot determine Linear team for %s", externalID),
|
|
})
|
|
continue
|
|
}
|
|
|
|
// Use the per-team state cache so that multi-team setups resolve state IDs
|
|
// against the correct team's workflow states, not the primary team's.
|
|
teamCache, ok := teamCaches[routeClient.TeamID]
|
|
if !ok || teamCache == nil {
|
|
teamCache = primaryCache // defensive fallback
|
|
}
|
|
|
|
teamLabelCache := primaryLabelCache
|
|
if lc, ok := teamLabelCaches[routeClient.TeamID]; ok && lc != nil {
|
|
teamLabelCache = lc
|
|
}
|
|
|
|
// Skip issues that haven't changed since the last push, unless forced.
|
|
// This mirrors the ContentEqual / UpdatedAt skip logic in the single-issue
|
|
// push path (engine.go doPush) to avoid redundant API writes.
|
|
var remoteIssue *Issue
|
|
if !forceIDs[issue.ID] {
|
|
fetched, lookupErr := routeClient.FetchIssueByIdentifier(ctx, externalID)
|
|
if lookupErr == nil && fetched != nil {
|
|
remoteIssue = fetched
|
|
// BatchPush receives pre-formatted descriptions from the sync
|
|
// engine (FormatDescription hook). Clear structured fields before
|
|
// comparison so PushFieldsEqual does not re-append them.
|
|
comparableIssue := *issue
|
|
comparableIssue.AcceptanceCriteria = ""
|
|
comparableIssue.Design = ""
|
|
comparableIssue.Notes = ""
|
|
if PushFieldsEqual(&comparableIssue, remoteIssue, t.config, teamLabelCache) {
|
|
result.Skipped = append(result.Skipped, issue.ID)
|
|
continue
|
|
}
|
|
}
|
|
}
|
|
|
|
mapper := &linearFieldMapper{config: t.config, labelCache: teamLabelCache}
|
|
updates := mapper.IssueToTracker(issue)
|
|
|
|
stateID, stateErr := ResolveStateIDForBeadsStatus(teamCache, issue.Status, t.config)
|
|
if stateErr != nil {
|
|
result.Errors = append(result.Errors, tracker.BatchPushError{
|
|
LocalID: issue.ID,
|
|
Message: fmt.Sprintf("resolving state for status %s: %v", issue.Status, stateErr),
|
|
})
|
|
continue
|
|
}
|
|
if stateID != "" {
|
|
updates["stateId"] = stateID
|
|
}
|
|
|
|
// Prefer the UUID obtained during the skip-check fetch; fall back to a
|
|
// fresh lookup only when the skip check was bypassed (forceIDs).
|
|
issueUUID := externalID
|
|
if remoteIssue != nil {
|
|
issueUUID = remoteIssue.ID
|
|
} else if li, lookupErr := routeClient.FetchIssueByIdentifier(ctx, externalID); lookupErr == nil && li != nil {
|
|
issueUUID = li.ID
|
|
}
|
|
|
|
updated, updateErr := routeClient.UpdateIssue(ctx, issueUUID, updates)
|
|
if updateErr != nil {
|
|
result.Errors = append(result.Errors, tracker.BatchPushError{
|
|
LocalID: issue.ID,
|
|
Message: fmt.Sprintf("updating %s: %v", externalID, updateErr),
|
|
})
|
|
continue
|
|
}
|
|
|
|
result.Updated = append(result.Updated, tracker.BatchPushItem{
|
|
LocalID: issue.ID,
|
|
ExternalRef: updated.URL,
|
|
})
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
func (t *Tracker) FieldMapper() tracker.FieldMapper {
|
|
return &linearFieldMapper{config: t.config}
|
|
}
|
|
|
|
// MappingConfig returns the resolved Linear mapping configuration.
|
|
func (t *Tracker) MappingConfig() *MappingConfig {
|
|
return t.config
|
|
}
|
|
|
|
func (t *Tracker) IsExternalRef(ref string) bool {
|
|
return IsLinearExternalRef(ref)
|
|
}
|
|
|
|
func (t *Tracker) ExtractIdentifier(ref string) string {
|
|
return ExtractLinearIdentifier(ref)
|
|
}
|
|
|
|
func (t *Tracker) BuildExternalRef(issue *tracker.TrackerIssue) string {
|
|
if issue.URL != "" {
|
|
if canonical, ok := CanonicalizeLinearExternalRef(issue.URL); ok {
|
|
return canonical
|
|
}
|
|
return issue.URL
|
|
}
|
|
return fmt.Sprintf("https://linear.app/issue/%s", issue.Identifier)
|
|
}
|
|
|
|
func skipOptionalPushStateMapping(status types.Status, err error, custom []types.CustomStatus) bool {
|
|
if !strings.Contains(err.Error(), "has no configured Linear state") {
|
|
return false
|
|
}
|
|
switch status {
|
|
case types.StatusBlocked, types.StatusDeferred, types.StatusPinned, types.StatusHooked:
|
|
return true
|
|
}
|
|
for _, cs := range custom {
|
|
if types.Status(cs.Name) == status {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// ValidatePushStateMappings ensures push has explicit, non-ambiguous status
|
|
// mappings for every configured team before any mutation occurs.
|
|
func (t *Tracker) ValidatePushStateMappings(ctx context.Context) error {
|
|
if t.config == nil || len(t.config.ExplicitStateMap) == 0 {
|
|
return fmt.Errorf("%s", missingExplicitStateMapMessage)
|
|
}
|
|
statuses := []types.Status{
|
|
types.StatusOpen,
|
|
types.StatusInProgress,
|
|
types.StatusBlocked,
|
|
types.StatusClosed,
|
|
types.StatusDeferred,
|
|
types.StatusPinned,
|
|
types.StatusHooked,
|
|
}
|
|
for _, teamID := range t.teamIDs {
|
|
client := t.clients[teamID]
|
|
if client == nil {
|
|
continue
|
|
}
|
|
cache, err := BuildStateCache(ctx, client)
|
|
if err != nil {
|
|
return fmt.Errorf("fetching workflow states for team %s: %w", teamID, err)
|
|
}
|
|
for _, status := range statuses {
|
|
if _, err := ResolveStateIDForBeadsStatus(cache, status, t.config); err != nil {
|
|
if skipOptionalPushStateMapping(status, err, t.config.CustomStatuses) {
|
|
continue
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
for _, cs := range t.config.CustomStatuses {
|
|
st := types.Status(cs.Name)
|
|
if _, err := ResolveStateIDForBeadsStatus(cache, st, t.config); err != nil {
|
|
if skipOptionalPushStateMapping(st, err, t.config.CustomStatuses) {
|
|
continue
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// findStateID looks up the Linear workflow state ID for a beads status
|
|
// using the given per-team client.
|
|
func (t *Tracker) findStateID(ctx context.Context, client *Client, status types.Status) (string, error) {
|
|
cache, err := BuildStateCache(ctx, client)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return ResolveStateIDForBeadsStatus(cache, status, t.config)
|
|
}
|
|
|
|
// primaryClient returns the client for the first configured team.
|
|
func (t *Tracker) primaryClient() *Client {
|
|
if len(t.teamIDs) == 0 {
|
|
return nil
|
|
}
|
|
return t.clients[t.teamIDs[0]]
|
|
}
|
|
|
|
// clientForExternalID resolves which per-team client should handle an issue
|
|
// identified by its Linear identifier (e.g., "TEAM-123").
|
|
func (t *Tracker) clientForExternalID(ctx context.Context, externalID string) *Client {
|
|
if len(t.teamIDs) == 1 {
|
|
return t.primaryClient()
|
|
}
|
|
|
|
// Try to fetch the issue from each team's client to find the owner.
|
|
for _, teamID := range t.teamIDs {
|
|
client := t.clients[teamID]
|
|
if client == nil {
|
|
continue
|
|
}
|
|
li, err := client.FetchIssueByIdentifier(ctx, externalID)
|
|
if err == nil && li != nil {
|
|
return client
|
|
}
|
|
}
|
|
|
|
return t.primaryClient()
|
|
}
|
|
|
|
// TeamIDs returns the list of configured team IDs.
|
|
func (t *Tracker) TeamIDs() []string {
|
|
return t.teamIDs
|
|
}
|
|
|
|
// PrimaryClient returns the client for the first configured team.
|
|
// Exported for CLI code that needs direct client access (e.g., push hooks).
|
|
func (t *Tracker) PrimaryClient() *Client {
|
|
return t.primaryClient()
|
|
}
|
|
|
|
// getConfig reads a config value from storage, falling back to env var.
|
|
// For yaml-only keys (e.g. linear.api_key), reads from config.yaml first
|
|
// to match the behavior of cmd/bd/linear.go:getLinearConfig().
|
|
func (t *Tracker) getConfig(ctx context.Context, key, envVar string) (string, error) {
|
|
// Secret keys are stored in config.yaml, not the Dolt database,
|
|
// to avoid leaking secrets when pushing to remotes.
|
|
if config.IsYamlOnlyKey(key) {
|
|
if val := config.GetString(key); val != "" {
|
|
return val, nil
|
|
}
|
|
if envVar != "" {
|
|
if envVal := os.Getenv(envVar); envVal != "" {
|
|
return envVal, nil
|
|
}
|
|
}
|
|
return "", nil
|
|
}
|
|
|
|
val, err := t.store.GetConfig(ctx, key)
|
|
if err == nil && val != "" {
|
|
return val, nil
|
|
}
|
|
if envVar != "" {
|
|
if envVal := os.Getenv(envVar); envVal != "" {
|
|
return envVal, nil
|
|
}
|
|
}
|
|
return "", nil
|
|
}
|
|
|
|
// linearToTrackerIssue converts a linear.Issue to a tracker.TrackerIssue.
|
|
func linearToTrackerIssue(li *Issue) tracker.TrackerIssue {
|
|
ti := tracker.TrackerIssue{
|
|
ID: li.ID,
|
|
Identifier: li.Identifier,
|
|
URL: li.URL,
|
|
Title: li.Title,
|
|
Description: li.Description,
|
|
Priority: li.Priority,
|
|
Labels: make([]string, 0),
|
|
Raw: li,
|
|
}
|
|
|
|
if li.State != nil {
|
|
ti.State = li.State
|
|
}
|
|
|
|
if li.Labels != nil {
|
|
for _, l := range li.Labels.Nodes {
|
|
ti.Labels = append(ti.Labels, l.Name)
|
|
}
|
|
}
|
|
|
|
if li.Assignee != nil {
|
|
ti.Assignee = li.Assignee.Name
|
|
ti.AssigneeEmail = li.Assignee.Email
|
|
ti.AssigneeID = li.Assignee.ID
|
|
}
|
|
|
|
if li.Parent != nil {
|
|
ti.ParentID = li.Parent.Identifier
|
|
ti.ParentInternalID = li.Parent.ID
|
|
}
|
|
|
|
if li.ProjectMilestone != nil {
|
|
ti.Metadata = map[string]interface{}{
|
|
"linear": map[string]interface{}{
|
|
"project_milestone": li.ProjectMilestone,
|
|
},
|
|
}
|
|
}
|
|
|
|
if t, err := time.Parse(time.RFC3339, li.CreatedAt); err == nil {
|
|
ti.CreatedAt = t
|
|
}
|
|
if t, err := time.Parse(time.RFC3339, li.UpdatedAt); err == nil {
|
|
ti.UpdatedAt = t
|
|
}
|
|
if li.CompletedAt != "" {
|
|
if t, err := time.Parse(time.RFC3339, li.CompletedAt); err == nil {
|
|
ti.CompletedAt = &t
|
|
}
|
|
}
|
|
|
|
return ti
|
|
}
|
|
|
|
// BuildStateCacheFromTracker builds a StateCache using the tracker's primary client.
|
|
// This allows CLI code to set up PushHooks.BuildStateCache without accessing the client directly.
|
|
func BuildStateCacheFromTracker(ctx context.Context, t *Tracker) (*StateCache, error) {
|
|
client := t.primaryClient()
|
|
if client == nil {
|
|
return nil, fmt.Errorf("Linear tracker not initialized")
|
|
}
|
|
return BuildStateCache(ctx, client)
|
|
}
|
|
|
|
// BuildLabelCacheFromTracker builds a LabelCache using the tracker's primary client.
|
|
// This allows CLI push hooks to compare label sets without reaching into the client.
|
|
func BuildLabelCacheFromTracker(ctx context.Context, t *Tracker) (*LabelCache, error) {
|
|
client := t.primaryClient()
|
|
if client == nil {
|
|
return nil, fmt.Errorf("Linear tracker not initialized")
|
|
}
|
|
return BuildLabelCache(ctx, client)
|
|
}
|
|
|
|
// configLoaderAdapter wraps storage.Storage to implement linear.ConfigLoader.
|
|
type configLoaderAdapter struct {
|
|
ctx context.Context
|
|
store tracker.Store
|
|
}
|
|
|
|
func (c *configLoaderAdapter) GetAllConfig() (map[string]string, error) {
|
|
return c.store.GetAllConfig(c.ctx)
|
|
}
|