beads/cmd/bd/issueops_adapter.go
Julian Knutsen b92442d1a3
feat(storage): one guarded issue-lifecycle surface for the CLI and linked consumers (#5191)
Adds issueops.Lifecycle — Create, Update, Close, Reopen — reached from the storage handle via
store.IssueLifecycle(), implemented once and shared by the CLI and linked library consumers. Three backends
implement it and a shared conformance suite asserts them against one spec. The bd CLI's create, update,
close and reopen now route through it.

Fixes several defects that predate this change and became visible once the write paths were forced to
agree: swallowed metadata-edit failures, a claim applied before field validation, missing value validation
on title/priority/estimate, silently dropped create edges to missing targets, infra-typed creates landing in
the wrong table, a dropped SourceRepo, closed_by_session written but never read, and a compound update
writing twice.

Behavior changes needing release notes: create with an occupied explicit id now fails instead of silently
overwriting; a compound update is one atomic operation with one hook and one version commit; reparenting
replaces all parent edges; reopening something not closed reports nothing to do.
2026-07-31 11:26:38 -07:00

27 lines
1.1 KiB
Go

package main
import (
"github.com/steveyegge/beads"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/issueops"
)
// newIssueOperations asks a store for its guarded issue-lifecycle surface.
// It is a variable purely as a test seam: the write-verb parity tests
// substitute a counting facade so "which operations did this command perform"
// stays observable. Production always calls the store's own accessor.
var newIssueOperations = func(st beads.Storage) (issueops.Lifecycle, error) {
return st.IssueLifecycle()
}
// writeOps returns the issue-lifecycle surface for st, the store a write verb
// is actually writing to.
//
// Callers build it per write site — the global store, a RoutedResult's store,
// or a --repo target — rather than once per command, because each store hands
// back a lifecycle carrying its own decorator stack. Building it over the
// store that owns the issue is what keeps a routed write hookless and a local
// write hooked, exactly as the direct store calls did.
func writeOps(st storage.DoltStorage) (issueops.Lifecycle, error) {
return newIssueOperations(st)
}