Add validateWorkspaceIdentity() preflight in PersistentPreRun that compares project_id from metadata.json with _project_id in the database. Blocks writes on mismatch to prevent cross-project data corruption. Escape hatch: BEADS_SKIP_IDENTITY_CHECK=1. Add 'bd bootstrap' command as non-destructive alternative to 'bd init --force'. Auto-detects recovery action: sync from remote, restore from backup, or create fresh. Supports --dry-run and --json. Co-Authored-By: matt wilkie <maphew@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
669 B
Go
25 lines
669 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateWorkspaceIdentity_NilStore(t *testing.T) {
|
|
// When store is nil, validateWorkspaceIdentity should be a no-op
|
|
// (no panic, no os.Exit)
|
|
origStore := store
|
|
store = nil
|
|
defer func() { store = nil; store = origStore }()
|
|
|
|
validateWorkspaceIdentity(nil, "/nonexistent")
|
|
// If we got here, no os.Exit was called — pass
|
|
}
|
|
|
|
func TestValidateWorkspaceIdentity_NonexistentDir(t *testing.T) {
|
|
// When beadsDir doesn't exist, configfile.Load fails and we skip validation
|
|
origStore := store
|
|
store = nil
|
|
defer func() { store = origStore }()
|
|
|
|
validateWorkspaceIdentity(nil, "/nonexistent/path/that/does/not/exist")
|
|
}
|