beads/internal/tracker
Vishnu J acf961f566
fix(tracker): gate externalRefChangedAfter on capability, not DB() presence (#4549) (#4734)
* feat(storage): add ExternalRefHistoryQuerier capability for external-ref history

Introduce ExternalRefHistoryQuerier (HistoryViewer + PreviousExternalRef)
and implement it on DoltStore and EmbeddedDoltStore via a shared
issueops.PreviousExternalRefInTx helper. This lets callers resolve what a
given issue's external_ref was as of a point in time by querying Dolt's
dolt_history_issues system table, without requiring a raw *sql.DB —
EmbeddedDoltStore executes SQL through its own transaction-scoped
connection helper rather than a pooled *sql.DB, so it could never satisfy
a DB()-presence check even though it has the history table.

Refs #4549

* fix(tracker): gate externalRefChangedAfter on ExternalRefHistoryQuerier capability, not DB() presence

externalRefChangedAfter's dolt_history_issues fast path was gated on
whether the store exposed a raw *sql.DB (dbProvider). Embedded-Dolt
stores execute SQL through a transaction-scoped connection helper rather
than a pooled *sql.DB, so they never took the fast path even though they
support the dolt_history_issues query — they silently fell back to the
coarser CreatedAt/UpdatedAt timestamp heuristic, which can disagree with
the precise history-table answer.

Rewire the gate to type-assert (unwrapping decorators via
storage.UnwrapStore) for the new storage.ExternalRefHistoryQuerier
capability instead, so embedded-Dolt stores take the fast path too.

Adds pure-Go mock coverage for the capability-detection and gating logic,
plus cgo-tagged integration tests exercising the real EmbeddedDoltStore
and DoltStore backends.

Refs #4549

* test(tracker): lock NULL-historical-ref contract in externalRefChangedAfter (#4549)

PreviousExternalRefInTx surfaces a NULL historical external_ref column as
("", found=true), not "not found" (internal/storage/issueops/history.go:126).
Add a pure-Go fast-path test asserting the fast path compares that empty
string against currentRef like any other value, rather than treating it as
an unconditional "changed" the way the old inline !previousRef.Valid check
did.

---------

Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-12 14:12:54 -07:00
..
engine.go fix(tracker): gate externalRefChangedAfter on capability, not DB() presence (#4549) (#4734) 2026-07-12 14:12:54 -07:00
engine_external_ref_history_test.go fix(tracker): gate externalRefChangedAfter on capability, not DB() presence (#4549) (#4734) 2026-07-12 14:12:54 -07:00
engine_history_gate_cgo_test.go fix(tracker): gate externalRefChangedAfter on capability, not DB() presence (#4549) (#4734) 2026-07-12 14:12:54 -07:00
engine_ratelimit_test.go test: split tracker pure-go helpers (#4183) 2026-05-26 16:31:17 -07:00
engine_selective_test.go feat: add IssueIDs filter to SyncOptions for selective sync (#2957) 2026-04-05 22:24:47 -07:00
engine_test.go feat(linear): linear.exclude_id_prefix and linear.exclude_id_patterns (#4613) 2026-07-06 22:33:06 -07:00
errors.go github: classify rate-limit 403s and stop the push loop when one hits (#3624) 2026-05-02 14:24:57 -07:00
multiproject.go feat: multi-project/team support for Linear, Jira, and ADO 2026-03-28 13:40:39 -07:00
multiproject_test.go feat: multi-project/team support for Linear, Jira, and ADO 2026-03-28 13:40:39 -07:00
registry.go feat: add plugin-based issue tracker framework (GH#1150) 2026-02-14 14:09:40 -08:00
registry_test.go feat: add plugin-based issue tracker framework (GH#1150) 2026-02-14 14:09:40 -08:00
test_helpers_pure_test.go fix(tracker): repair sync engine bugs unmasked by born-failing engine tests (bd-578h9.1) 2026-06-11 10:26:36 -04:00
testmain_test.go test: split tracker pure-go helpers (#4183) 2026-05-26 16:31:17 -07:00
tracker.go feat: reimplement Notion sync on REST data sources (fix-merge PR #2759) 2026-03-27 19:20:40 -07:00
types.go feat(gitlab): sync issue dependency links on push (#4294) 2026-07-08 08:00:41 -07:00