Summary
internal/copilot.Client holds and accepts a *data.Store concrete pointer. There is no interface abstraction between the AI/Copilot layer and the data access layer.
Current code
In internal/copilot/client.go:
type Client struct {
store *data.Store
...
}
func New(store *data.Store) *Client {
return &Client{store: store}
}
And in internal/copilot/tools.go, every tool function receives *data.Store directly:
func defineTools(store *data.Store) []sdk.Tool { ... }
func defineSearchSessionsTool(store *data.Store) sdk.Tool { ... }
Problem
The copilot package is a business-logic layer (AI chat, search orchestration). Depending on a concrete storage type means:
- Unit tests for copilot logic must construct (or mock) a full *data.Store, which requires a real SQLite database on disk.
- It is impossible to substitute an alternative store implementation (e.g., an in-memory store for testing, or a future remote store).
- The coupling makes the two packages harder to evolve independently.
Suggested fix
Define a SessionReader interface in internal/copilot (or a shared package) that declares only the methods the copilot tools actually call — ListSessions, GetSession, ListRepositories, SearchSessions. Accept that interface in New and defineTools instead of *data.Store. *data.Store already implements all those methods, so call sites change only at the New(...) call, and tests can pass lightweight fakes.
Summary
internal/copilot.Client holds and accepts a *data.Store concrete pointer. There is no interface abstraction between the AI/Copilot layer and the data access layer.
Current code
In internal/copilot/client.go:
And in internal/copilot/tools.go, every tool function receives *data.Store directly:
Problem
The copilot package is a business-logic layer (AI chat, search orchestration). Depending on a concrete storage type means:
Suggested fix
Define a SessionReader interface in internal/copilot (or a shared package) that declares only the methods the copilot tools actually call — ListSessions, GetSession, ListRepositories, SearchSessions. Accept that interface in New and defineTools instead of *data.Store. *data.Store already implements all those methods, so call sites change only at the New(...) call, and tests can pass lightweight fakes.