Skip to content

Add Linear round-trip fidelity integration test (#3187)#3199

Open
harry-miller-trimble wants to merge 10 commits intogastownhall:mainfrom
harry-miller-trimble:main
Open

Add Linear round-trip fidelity integration test (#3187)#3199
harry-miller-trimble wants to merge 10 commits intogastownhall:mainfrom
harry-miller-trimble:main

Conversation

@harry-miller-trimble
Copy link
Copy Markdown
Contributor

Summary

Implements the round-trip fidelity integration test requested in #3187.

What's included

TestLinearRoundTripCoreFields — Full push→pull integration test that:

  1. Seeds 3 issues with varied priority (P0/P1/P3) and status (open/in_progress/closed)
  2. Pushes to a stateful mock Linear GraphQL server
  3. Pulls into a fresh database
  4. Asserts title, description, priority, status, and external_ref all survive the round-trip

TestLinearRoundTripRelationships — Skipped spec test documenting that parent-child hierarchy, blocking dependencies, and issue type do not yet survive a round-trip (push doesn't send parent/relation/label fields). Becomes a regression gate when those features land.

Mock server design

The mockLinearServer is a stateful httptest.Server that:

  • Only stores what the client actually sends (no fabricated fields)
  • Routes by string match on GraphQL operations (no parser needed)
  • Handles: issueCreate, issueUpdate, issues query, team states
  • Assigns sequential identifiers (MOCK-1, MOCK-2, ...)

Key design decisions

  • Engine-level testing (not CLI) — wires the same hooks as runLinearSync but avoids global state/flag noise
  • Matches by external_ref — pulled IDs are hash-generated so they won't match source IDs
  • Split into two tests — keeps assertions honest by only testing what the integration actually supports today

What's NOT asserted (documented gap)

Per the issue's assertion table, these fields are requested but push doesn't currently support them:

Property Current status
Epic parent Push doesn't send parentId
Dependencies Push doesn't create relations
Issue type Push doesn't send labels for type

The skipped spec test documents this gap and will automatically become a regression gate when those features are implemented.

Closes #3187

harry-miller-trimble and others added 10 commits April 13, 2026 07:55
…#3187)

Add TestLinearRoundTripCoreFields which verifies that a push→pull
round-trip through Linear preserves title, description, priority,
status, and external_ref. Uses a stateful mock GraphQL server that
only stores what the client actually sends.

Also adds TestLinearRoundTripRelationships as a skipped spec test
documenting that parent-child, blocking deps, and issue type don't
yet survive the round-trip (push doesn't send these fields). This
becomes a regression gate when those features land.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add cross-project inbox infrastructure for the inbox pattern feature:

- Migration 0027: CREATE TABLE beads_inbox with UUID PK, sender dedup
  constraint, imported/rejected/expires tracking, and JSON columns
  aligned with the issues table schema
- InboxItem type in internal/types with full JSON serialization
- InboxStore interface in internal/storage (separate sub-interface)
- DoltStore CRUD: Add/Get/GetPending/MarkImported/MarkRejected/Clean/Count
- EmbeddedDoltStore CRUD: matching implementation via withConn pattern
- ON DUPLICATE KEY UPDATE semantics for idempotent resends

Closes: bd-2pz

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bd send: deliver issues to other projects via shared Dolt server
bd inbox: list/import/reject/clean pending inbox items

Part of the cross-project inbox epic (bd-fhk).
Closes bd-4sl, bd-vz8.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When pending inbox items exist, bd ready now shows:
- JSON mode: adds inbox_pending count to response object
- Text mode: appends notification with inbox commands

Closes bd-ftn.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests cover: add/get, idempotent resend, pending filtering,
import/reject marking, clean, count, and expiry filtering.

Fix: include inbox_id in INSERT, default empty labels/metadata
to valid JSON ([] and {}) to avoid Dolt JSON validation errors.

Closes bd-jls.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Covers bd send, bd inbox, bd ready integration, schema details,
idempotent resends, import process, and example workflow.

Closes bd-803.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Runs a polling loop that checks for pending inbox items and logs
when the count changes. Useful for long-running server deployments.

  bd inbox watch                  # poll every 60s
  bd inbox watch --interval 30    # poll every 30s

Closes bd-k3a.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1. SQL injection: validate --to flag against strict regex, use dedicated
   sql.Conn instead of pool, defer DB context restore on all paths
2. Dependency-aware import: serialize blocking deps in metadata during
   send, topological sort (Kahn's algorithm) on import
3. Atomic import: check GetIssueByExternalRef before creating to prevent
   duplicate issues on retry/crash
4. Fix resend test: verify title actually updated (was passing accidentally)

Also: remove unsafe 'beads' fallback from getCurrentDatabase, add UUID
generation for inbox items during send, batch all inserts into single
DOLT_COMMIT in target.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1. Labels/metadata preserved: serialize labels to JSON during send,
   parse and AddLabel on import
2. Prefix lookup: GetInboxItemByPrefix with LIKE + LIMIT 2 for
   ambiguity detection; resolveInboxItem tries exact then prefix
3. --expires flag: bd send --expires 7d sets TTL via timeparsing
4. Federation scope: docs clarified as shared-server-only for now
5. Send transaction: already batched in P1 fix (single DOLT_COMMIT)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace all SQL NOW() with parameterized time.Now().UTC() in both
  DoltStore and EmbeddedDoltStore for consistent timezone behavior
- Extract raw SQL from cmd/bd/send.go into DoltStore.SendToInbox()
  so CLI layer no longer touches raw DB connections
- Add ValidateInboxItem() with max size limits (title 500, desc 100K,
  metadata 50K) enforced in AddInboxItem and SendToInbox
- Add TestInboxSizeValidation covering all validation paths

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 18.36506% with 729 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
internal/storage/dolt/inbox.go 0.00% 270 Missing ⚠️
cmd/bd/inbox.go 3.46% 251 Missing ⚠️
cmd/bd/send.go 6.15% 122 Missing ⚠️
internal/storage/embeddeddolt/inbox.go 69.01% 58 Missing and 8 partials ⚠️
cmd/bd/ready.go 0.00% 12 Missing ⚠️
internal/storage/inbox.go 0.00% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: Round-trip fidelity integration test

2 participants