* feat(storage): add downstream backend registry seam (bd-7oj) Salvage the name-keyed extension contract from PR #4859 on current main while preserving the Dolt-only OSS policy. Stock builds register no alternate backends; tombstones and unknown names still fail closed. Downstream builds can register read-write/read-only opens and workspace discovery without editing shared dispatch. Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com> Agent-Signature: codex-gpt-5-unknown-reasoning on behalf of CI Bot * fix(storage): dispatch and fail-closed for registered backends Address review majors on the backend registry seam: - bd init rejects a registered backend (open-existing-workspace-only) instead of silently provisioning Dolt and persisting backend: dolt. - OpenBestAvailable dispatches registered backends before any Dolt path in both CGO and non-CGO builds, mirroring the CLI store factories. - Public FindDatabasePath discovers WorkspaceIsBeadsDir workspaces via the shared registry authority instead of returning no database. - Root command reuses the resolved .beads directory for hook-runner and molecule-catalog setup instead of filepath.Dir(dbPath). For a registered WorkspaceIsBeadsDir backend dbPath is the .beads directory itself, so filepath.Dir(dbPath) loaded hooks from <repo>/hooks and molecules from <repo>/molecules.jsonl instead of .beads/hooks and .beads/molecules.jsonl. Add a single WorkspaceIsBeadsDir authority, document the init-time registration invariant, and cover the paths with tests, including a root-command test proving the .beads hook and molecule directories are selected for WorkspaceIsBeadsDir backends. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: CI Bot <ci@beads.test> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package backends_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/steveyegge/beads/internal/configfile"
|
|
"github.com/steveyegge/beads/internal/storage/backends"
|
|
)
|
|
|
|
func TestRegisteredCustomNameIsSupportedAndPreserved(t *testing.T) {
|
|
const name = "enterprise-fixture"
|
|
cfg := &configfile.Config{Backend: name}
|
|
|
|
if configfile.IsSupportedBackend(name) {
|
|
t.Fatalf("unregistered backend %q unexpectedly supported", name)
|
|
}
|
|
if got := cfg.GetBackend(); got != configfile.BackendDolt {
|
|
t.Fatalf("unregistered backend GetBackend() = %q, want Dolt fallback", got)
|
|
}
|
|
|
|
backends.Register(name, fixtureBackend())
|
|
t.Cleanup(func() { backends.Deregister(name) })
|
|
|
|
if !configfile.IsSupportedBackend(name) {
|
|
t.Fatalf("registered backend %q is not supported", name)
|
|
}
|
|
if got := cfg.GetBackend(); got != name {
|
|
t.Fatalf("registered backend GetBackend() = %q, want %q", got, name)
|
|
}
|
|
}
|
|
|
|
func TestRegistrationCanActivateRemovedNameWithoutChangingOSSPolicy(t *testing.T) {
|
|
const name = configfile.BackendPostgres
|
|
cfg := &configfile.Config{Backend: name}
|
|
|
|
if configfile.IsSupportedBackend(name) {
|
|
t.Fatal("PostgreSQL tombstone must remain unsupported without a registrant")
|
|
}
|
|
if got := cfg.GetBackend(); got != name {
|
|
t.Fatalf("PostgreSQL tombstone GetBackend() = %q, want %q", got, name)
|
|
}
|
|
|
|
backends.Register(name, fixtureBackend())
|
|
t.Cleanup(func() { backends.Deregister(name) })
|
|
|
|
if !configfile.IsSupportedBackend(name) {
|
|
t.Fatal("registered PostgreSQL backend is not supported")
|
|
}
|
|
if got := cfg.GetBackend(); got != name {
|
|
t.Fatalf("registered PostgreSQL GetBackend() = %q, want %q", got, name)
|
|
}
|
|
}
|