Merge SQL user authentication with Emma federation sync implementation:
- Add federation_peers table for encrypted credential storage
- Add credentials.go with AES-256-GCM encryption, SHA-256 key derivation
- Extend FederatedStorage interface with credential methods
- Add --user, --password, --sovereignty flags to bd federation add-peer
- Integrate credentials into PushTo/PullFrom/Fetch via withPeerCredentials
- DOLT_REMOTE_USER/PASSWORD env vars protected by mutex for concurrency
Credentials automatically used when syncing with peers that have stored auth.
Continues: bd-wkumz.10, Closes: bd-4p67y
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add peer-to-peer synchronization for Dolt-backed beads databases:
- New FederatedStorage interface with PushTo, PullFrom, Fetch, ListRemotes,
RemoveRemote, and SyncStatus methods
- DoltStore implementation using DOLT_PUSH, DOLT_PULL, DOLT_FETCH
- Full bd federation command with subcommands:
- sync: bidirectional sync with conflict resolution (--strategy ours|theirs)
- status: show ahead/behind counts and conflict state
- add-peer/remove-peer/list-peers: manage federation remotes
- Comprehensive tests for all federation APIs
Closes: bd-wkumz.4
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements hq-ew1mbr.27: The sync.mode config now actually changes how
bd sync operates:
- git-portable (default): JSONL exported on push, imported on pull
- realtime: JSONL exported on every change (placeholder for daemon hook)
- dolt-native: Uses Dolt Push/Pull, skips JSONL workflow entirely
- belt-and-suspenders: Both Dolt remotes AND JSONL for redundancy
Changes:
- Add sync_mode.go with mode constants, Get/Set functions, and helpers
- Update bd sync --status to show actual mode from config
- Add --set-mode flag to bd sync for configuring the mode
- Modify doExportSync to respect mode (Dolt push for dolt-native)
- Modify doPullFirstSync to use Dolt pull for dolt-native mode
- Add RemoteStorage interface for Push/Pull operations
- Add comprehensive tests for sync mode functionality
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extends Storage interface with Dolt-specific version control capabilities:
- New VersionedStorage interface in storage/versioned.go with:
- History queries: History(), AsOf(), Diff()
- Branch operations: Branch(), Merge(), CurrentBranch(), ListBranches()
- Commit operations: Commit(), GetCurrentCommit()
- Conflict resolution: GetConflicts(), ResolveConflicts()
- Helper types: HistoryEntry, DiffEntry, Conflict
- DoltStore implements VersionedStorage interface
- New CLI commands:
- bd history <id> - Show issue version history
- bd diff <from> <to> - Show changes between commits/branches
- bd branch [name] - List or create branches
- bd vc merge <branch> - Merge branch to current
- bd vc commit -m <msg> - Create a commit
- bd vc status - Show current branch/commit
- Added --as-of flag to bd show for time-travel queries
- IsVersioned() helper for graceful SQLite backend detection
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>