5 Commits

Author SHA1 Message Date
lizzy
9ddd7a2620 feat(config): add validate command for sync config
Add `bd config validate` command to validate sync-related configuration:

- sync.mode: validates values (local, git-branch, external)
- conflict.strategy: validates values (lww, manual, ours, theirs)
- federation.sovereignty: validates values (none, isolated, federated)
- federation.remote: ensures set when sync.mode is 'external'
- Remote URL format: validates dolthub://, gs://, s3://, file://, etc.

Also validates existing config via doctor.CheckConfigValues (sync.branch,
routing.mode, etc.)

Closes: hq-ew1mbr.29

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 14:02:28 -08:00
beads/crew/fang
6572654cdc fix: allow yaml-only config operations without database (GH#536)
Users could not run 'bd config set no-db true' without already having a
database, creating a chicken-and-egg problem. The PersistentPreRunE
would fail with 'no beads database found' before the config command
could even run.

The fix detects when a yaml-only config operation is being attempted
(config set/get with keys like no-db, no-daemon, sync.branch, etc.)
and allows it to proceed without requiring a database.

Before:
  $ bd config set no-db true
  Error: no beads database found

After:
  $ bd config set no-db true
  Set no-db = true (in config.yaml)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-02 00:02:20 -08:00
Steve Yegge
57253f93a3 Context propagation with graceful cancellation (bd-rtp, bd-yb8, bd-2o2)
Complete implementation of signal-aware context propagation for graceful
cancellation across all commands and storage operations.

Key changes:

1. Signal-aware contexts (bd-rtp):
   - Added rootCtx/rootCancel in main.go using signal.NotifyContext()
   - Set up in PersistentPreRun, cancelled in PersistentPostRun
   - Daemon uses same pattern in runDaemonLoop()
   - Handles SIGINT/SIGTERM for graceful shutdown

2. Context propagation (bd-yb8):
   - All commands now use rootCtx instead of context.Background()
   - sqlite.New() receives context for cancellable operations
   - Database operations respect context cancellation
   - Storage layer propagates context through all queries

3. Cancellation tests (bd-2o2):
   - Added import_cancellation_test.go with comprehensive tests
   - Added export cancellation test in export_test.go
   - Tests verify database integrity after cancellation
   - All cancellation tests passing

Fixes applied during review:
   - Fixed rootCtx lifecycle (removed premature defer from PersistentPreRun)
   - Fixed test context contamination (reset rootCtx in test cleanup)
   - Fixed export tests missing context setup

Impact:
   - Pressing Ctrl+C during import/export now cancels gracefully
   - No database corruption or hanging transactions
   - Clean shutdown of all operations

Tested:
   - go build ./cmd/bd ✓
   - go test ./cmd/bd -run TestImportCancellation ✓
   - go test ./cmd/bd -run TestExportCommand ✓
   - Manual Ctrl+C testing verified

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:57:23 -05:00
Steve Yegge
09e881022e Fix bd-166: Prevent duplicate issues with wrong prefix
Critical fix for silent data corruption where database created 173
duplicate issues with wrong prefix (beads- instead of bd-).

Root cause: When issue_prefix config was missing, CreateIssue fell
back to deriving prefix from database filename (beads.db → 'beads'),
while auto-import imported bd- issues from git with SkipPrefixValidation.
This created duplicates.

Changes:
1. Removed derivePrefixFromPath() - never derive prefix from filename
2. CreateIssue/CreateIssues now REJECT if issue_prefix config missing
   - Fail-fast with clear error message
3. Auto-import now SETS issue_prefix from first imported issue if missing
   - Handles fresh clone scenario safely
4. Added newTestStore() helper that sets issue_prefix for tests
5. Updated test setup in multiple files to prevent test failures

Follow-ups filed: bd-167, bd-168, bd-169

Closes bd-166

Amp-Thread-ID: https://ampcode.com/threads/T-b2ee0738-b90b-40ef-ae44-f2d93729842c
Co-authored-by: Amp <amp@ampcode.com>
2025-10-26 21:55:01 -07:00
Steve Yegge
e8eb0cb6ae Add bd config command for external integration configuration
- Add GetAllConfig/DeleteConfig methods to storage interface
- Implement config set/get/list/unset subcommands with JSON support
- Add comprehensive tests for config operations
- Create CONFIG.md with full documentation and examples
- Update README.md with config section
- Support namespace conventions (jira.*, linear.*, github.*, custom.*)

Closes bd-60

Amp-Thread-ID: https://ampcode.com/threads/T-33db7481-de7c-475e-b562-6afb7fb4bc7a
Co-authored-by: Amp <amp@ampcode.com>
2025-10-23 14:14:22 -07:00