`workapi.NewStoreReader` was exported and lived in internal/workapi, which 22 cmd/bd files already import for the builders. It takes storage.DoltStorage — an interface a command already holds — so it was a one-line drop-in replacement for `store.IssueReader()` from any front door, and the wrong one: every storage decorator adds its layer in its OWN accessor (telemetry's reader-level spans, the hook store's deliberate pass-through), so a command that constructed a reader directly would get a bare unspanned one and the code would look entirely ordinary. The old doc comment said "nothing does; the accessor is the door", which is a promise, not a guard. It has real callers, so it cannot simply be unexported: dolt.DoltStore and embeddeddolt.EmbeddedDoltStore both need one shared body for their accessors, and they are in different packages. So the body moves down to internal/workapi/storereader instead, where those two are the only importers, and the cmd-bd-reader-constructor depguard rule keeps cmd/bd out. Nothing about internal/httpapi changes: depguard matches pkg by prefix, so httpapi-transport-boundary already denied the subpackage along with its parent. The two store packages' own NewIssueReader are unexported at the same time. They had no caller but their own accessor, they are in internal/ so no out-of-tree consumer can reach them, and leaving them exported would have left the same door open one package over. SEEN TO FAIL, on the golangci-lint version CI installs. `bd show --json` switched from the accessor to the constructor — the exact bypass — compiles and vets clean: $ golangci-lint run --config=.golangci.yml --build-tags=gms_pure_go ./... cmd/bd/show.go:15:2: import 'github.com/steveyegge/beads/internal/workapi/storereader' is not allowed from list 'cmd-bd-reader-constructor': a command reaches the reader role through store.IssueReader(), never through the constructor ... (depguard) exit 1 ErrUnsupported.Op moves with the function, "NewStoreReader" -> "storereader.New", so the Op still names the function that refused; its test moves with it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
26 lines
831 B
Go
26 lines
831 B
Go
//go:build cgo
|
|
|
|
package embeddeddolt
|
|
|
|
import (
|
|
"github.com/steveyegge/beads/internal/storage"
|
|
"github.com/steveyegge/beads/internal/workapi/storereader"
|
|
"github.com/steveyegge/beads/issueops"
|
|
)
|
|
|
|
// IssueReader returns the guarded issue-query surface for this store.
|
|
func (s *EmbeddedDoltStore) IssueReader() (issueops.Reader, error) {
|
|
return newIssueReader(s)
|
|
}
|
|
|
|
// newIssueReader returns guarded issue queries backed by store.
|
|
//
|
|
// The implementation is the shared one: the two Dolt-backed stores differ
|
|
// below storage.DoltStorage, not above it, so a second copy here would be a
|
|
// copy of nothing but the constructor.
|
|
func newIssueReader(store *EmbeddedDoltStore) (issueops.Reader, error) {
|
|
if store == nil {
|
|
return nil, &storage.ErrUnsupported{Op: "newIssueReader", Backend: "nil"}
|
|
}
|
|
return storereader.New(store)
|
|
}
|