Commit Graph

1738 Commits

Author SHA1 Message Date
Steve Yegge
abd3feb761 fix(lint): check error return from provider.Close() (#1250)
Two lint errors introduced in recent commits:
- cmd/bd/doctor/git.go:896 - unchecked provider.Close()
- cmd/bd/orphans.go:120 - unchecked provider.Close()

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 21:11:33 -08:00
Roland Tritsch
b63e7b8cf0 fix: auto-route create with explicit ID to correct database
When bd create --id=pq-xxx is called with an ID prefix that does not
match the current database, automatically route to the correct database
based on routes.jsonl configuration.

Changes:
- Add auto-routing logic before explicit --rig/--prefix handling
- Extract prefix from explicit ID and look it up in routes.jsonl
- If prefix matches a different rig, call createInRig automatically
- Update createInRig to accept explicitID parameter
- Pass explicitID through to issue creation

This fixes the prefix mismatch error when creating issues with
explicit IDs across rigs in multi-repo setups like Gas Town.

Example:
  cd ~/gt  # Root with hq- prefix
  bd create --id=pq-xxx --title="Test"
  # Now automatically routes to pgqueue/.beads/beads.db

Fixes: gt doctor --fix failing to create agent beads
Closes: #1188

Cherry-picked from Team-Ailtir/beads PR #1188 with build fix.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 20:44:45 -08:00
beads/crew/jane
2a56aab92c refactor(storage): move LocalProvider to internal/storage package
Move LocalProvider from cmd/bd/doctor/git.go to internal/storage/local_provider.go
where it belongs alongside StorageProvider. Both implement IssueProvider for
orphan detection - LocalProvider for direct SQLite access (--db flag),
StorageProvider for the global Storage interface.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 20:41:53 -08:00
Steve Yegge
9c3c21efe3 feat(cli): add 'view' as alias for 'show' command (#1249)
Users naturally try 'bd view <id>' when they want to see an issue.
Adding 'view' as an alias improves discoverability and UX.

Fixes bd-bpx35

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 19:58:49 -08:00
Peter Chanthamynavong
c11fa799be fix(orphans): honor --db flag for cross-repo orphan detection (#1200)
* fix(orphans): honor --db flag for cross-repo orphan detection

Problem:
- `bd orphans --db /path` ignored the --db flag entirely
- FindOrphanedIssues() hardcoded local .beads/ directory

Solution:
- Introduce IssueProvider interface for abstract issue lookup
- Add StorageProvider adapter wrapping Storage instances
- Update FindOrphanedIssues to accept provider instead of path
- Wire orphans command to create provider from --db flag

Closes: steveyegge/beads#1196

* test(orphans): add cross-repo and provider tests for --db flag fix

- Add TestFindOrphanedIssues_WithMockProvider (table-driven, UT-01 through UT-09)
- Add TestFindOrphanedIssues_CrossRepo (validates --db flag honored)
- Add TestFindOrphanedIssues_LocalProvider (backward compat RT-01)
- Add TestFindOrphanedIssues_ProviderError (error handling UT-07)
- Add TestFindOrphanedIssues_IntegrationCrossRepo (IT-02 full)
- Add TestLocalProvider_* unit tests

Coverage for IssueProvider interface and cross-repo orphan detection.

* docs: add bd orphans command to CLI reference

Document the orphan detection command including the cross-repo
workflow enabled by the --db flag fix in this PR.
2026-01-21 19:52:31 -08:00
Bo
a0dac11e42 refactor: reduce cyclomatic complexity in repair.go and config_values.go (#1214)
- repair.go: Extract validateRepairPaths(), findAllOrphans(), printOrphansText()
- config_values.go: Extract findConfigPath(), validateDurationConfig(), etc.
- Target: CC < 20 for each extracted function
2026-01-21 19:50:03 -08:00
beads/crew/lydia
9a9704b451 feat(sync): add per-field merge strategies for conflict resolution
Implements configurable per-field merge strategies (hq-ew1mbr.11):

- Add FieldStrategy type with strategies: newest, max, union, manual
- Add conflict.fields config section for per-field overrides
- compaction_level defaults to "max" (highest value wins)
- estimated_minutes defaults to "manual" (flags for user resolution)
- labels defaults to "union" (set merge)

Manual conflicts are displayed during sync with resolution options:
  bd sync --ours / --theirs, or bd resolve <id> <field> <value>

Config example:
  conflict:
    strategy: newest
    fields:
      compaction_level: max
      estimated_minutes: manual
      labels: union

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 19:40:39 -08:00
cheedo
e0dc3a37c3 feat(create): add -m as alias for --description flag
Add --message/-m as a hidden alias for --description on bd create,
matching the git commit -m convention for muscle memory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 19:34:29 -08:00
aleiby
0b6df198a5 fix(ready): exclude molecule steps from bd ready by default (#1246)
* fix(ready): exclude molecule steps from bd ready by default (GH#1239)

Add ID prefix constants (IDPrefixMol, IDPrefixWisp) to types.go as single
source of truth. Update pour.go and wisp.go to use these constants.

GetReadyWork now excludes issues with -mol- in their ID when no explicit
type filter is specified. Users can still see mol steps with --type=task.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(ready): config-driven ID pattern exclusion (GH#1239)

Add ready.exclude_id_patterns config for excluding IDs from bd ready.
Default patterns: -mol-, -wisp- (molecule steps and wisps).

Changes:
- Add IncludeMolSteps to WorkFilter for internal callers
- Update findGateReadyMolecules and getMoleculeCurrentStep to use it
- Make exclusion patterns config-driven via ready.exclude_id_patterns
- Remove hardcoded MolStepIDPattern() in favor of config
- Add test for custom patterns (e.g., gastown's -role-)

Usage: bd config set ready.exclude_id_patterns "-mol-,-wisp-,-role-"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: remove -role- example from ready.go comments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: remove GH#1239 references from code comments

Issue references belong in commit messages, not code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 19:30:15 -08:00
beads/crew/jane
97d4b174d0 fix(migrate): address code review issues in Dolt migration
Fixes from code review:

1. **Data completeness**: Now migrates events (including comments)
   and all config values, not just issues/labels/deps

2. **formatJSONArray**: Fixed to use JSON encoding for waiters field
   to match Dolt schema (was using comma-separated format)

3. **Cleanup on failure**: Removes partial Dolt directory or SQLite
   files if import fails mid-way

4. **Progress indicator**: Shows "Importing issues: N/M" for large
   migrations (100+ issues)

5. **Code deduplication**: Extracted common logic into:
   - migrationData struct
   - storageReader interface
   - extractFromStore() shared extraction
   - Helper functions for output formatting

6. **Improved dry-run output**: Now shows event count and config
   key count in migration plan

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 19:27:01 -08:00
Oliver Jägle
0877e1428e fix(list): stabilize tree ordering for consistent --tree output (#1228)
Motivation:
The ○ bd-e3r ● P2 Responsible-Vibe Development: beads
├── ○ bd-e3r.7 ● P1 Test feature B
│   ├── ○ bd-e3r.7.1 ● P2 Subfeature B1
│   └── ○ bd-e3r.7.2 ● P2 Subfeature B2
├── ○ bd-e3r.6 ● P1 Test feature A
│   ├── ○ bd-e3r.6.2 ● P2 Subfeature A2
│   └── ○ bd-e3r.6.1 ● P2 Subfeature A1
│       ├── ○ bd-e3r.6.1.1 ● P3 Task A1.1
│       └── ○ bd-e3r.6.1.2 ● P3 Task A1.2
├── ○ bd-e3r.8 ● P2 Test identical priority A
├── ○ bd-e3r.9 ● P2 Test identical priority B
├── ○ bd-e3r.1 ● P3 Reproduce
├── ○ bd-e3r.2 ● P3 Analyze
├── ○ bd-e3r.4 ● P3 Verify
├── ○ bd-e3r.5 ● P3 Finalize
└── ○ bd-e3r.3 ● P3 Fix

--------------------------------------------------------------------------------
Total: 16 issues (16 open, 0 in progress)

Status: ○ open  ◐ in_progress  ● blocked  ✓ closed  ❄ deferred command produced non-deterministic ordering between
consecutive executions, making [?1049h(B[?7h[?25lEvery 2.0s: bd list --treebwpm-D6KDQ60Q6R: 08:29:46in 0.343s (0)○ bd-e3r ● P2 Responsible-Vibe Development: beads
├── ○ bd-e3r.6 ● P1 Test feature A
│   ├── ○ bd-e3r.6.1 ● P2 Subfeature A1
│   │   ├── ○ bd-e3r.6.1.1 ● P3 Task A1.1
│   │   └── ○ bd-e3r.6.1.2 ● P3 Task A1.2
│   └── ○ bd-e3r.6.2 ● P2 Subfeature A2
├── ○ bd-e3r.7 ● P1 Test feature B
│   ├── ○ bd-e3r.7.2 ● P2 Subfeature B2
│   └── ○ bd-e3r.7.1 ● P2 Subfeature B1
├── ○ bd-e3r.8 ● P2 Test identical priority A
├── ○ bd-e3r.9 ● P2 Test identical priority B
├── ○ bd-e3r.1 ● P3 Reproduce
├── ○ bd-e3r.4 ● P3 Verify
├── ○ bd-e3r.5 ● P3 Finalize
├── ○ bd-e3r.2 ● P3 Analyze
└── ○ bd-e3r.3 ● P3 Fix
--------------------------------------------------------------------------------Total: 16 issues (16 open, 0 in progress)
Status: ○ open  ◐ in_progress  ● blocked  ✓ closed  ❄ deferred
[?12l[?25h[?1049l
[?1l> unusable due to
constantly changing output. Root issues and children with identical
priorities appeared in different orders across runs.

Key Changes:
- Add compareIssuesByPriority() function with primary sort by priority
  and secondary sort by ID for deterministic behavior
- Apply stable sorting to root issues in buildIssueTreeWithDeps()
- Apply stable sorting to children in childrenMap for complete consistency
- Update printPrettyTree() to use same comparison function

Side-Effects:
- Tree output now consistently orders by priority (P0→P1→P2→P3→P4)
- Items with identical priority are sorted alphabetically by ID
- Adds comprehensive TestStableTreeOrdering test with 5-run stability verification
- Minor performance overhead from sorting (negligible for typical issue counts)
- Fixes indentation inconsistencies in existing test code via gofmt
2026-01-21 19:11:25 -08:00
beads/crew/emma
bb4549abdd fix(daemon): allow read-only daemon commands with Dolt backend
The daemon guard was blocking ALL daemon commands when using Dolt
backend, including read-only commands like `status`, `stop`, `logs`.

Changes:
- Rename guard to `guardDaemonStartForDolt` (more accurate)
- Remove `PersistentPreRunE` from `daemonCmd` and `daemonsCmd`
- Add `PreRunE` guard only to `daemonStartCmd` and `daemonsRestartCmd`
- Update test to use new function name and test start command

Now:
- `bd daemon status` works with Dolt backend
- `bd daemon start` blocked unless `--federation` flag
- `bd daemon start --federation` works (starts dolt sql-server)

Fixes: bd-n7o47

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 18:06:06 -08:00
beads/crew/jane
4e3e9d1441 feat(migrate): add SQLite to Dolt migration tooling (hq-ew1mbr.6)
Add `bd migrate --to-dolt` and `bd migrate --to-sqlite` commands for
migrating between SQLite and Dolt storage backends.

Features:
- `--to-dolt`: Migrate from SQLite to Dolt backend
  - Creates backup of SQLite database before migration
  - Imports all issues, labels, and dependencies
  - Updates metadata.json to use Dolt backend
  - Preserves JSONL export configuration

- `--to-sqlite`: Escape hatch to migrate back to SQLite
  - Exports all data from Dolt to new SQLite database
  - Updates metadata.json to use SQLite backend

Both commands support:
- `--dry-run` flag to preview changes
- `--yes` flag for automated/scripted usage
- `--json` flag for machine-readable output
- Non-cgo stub for builds without CGO support

This implements Part 7 (Migration Tooling) of DOLT-STORAGE-DESIGN.md.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:46:15 -08:00
matt wilkie
e74cab8c6d Fix CI failures (bd 1zo sandbox tests) (#1244)
* Fix sandboxed daemon autostart tests and lint cleanup (bd-1zo)

* Restore issues jsonl to main state (bd-1zo)

* Remove .beads changes from PR (bd-1zo)

* Fix Windows build for dolt SysProcAttr (bd-1zo)

* Reset .beads/issues.jsonl to upstream main (bd-1zo)

* Reset .beads/issues.jsonl to upstream main (bd-1zo)

* Reset .beads/issues.jsonl to upstream main (bd-1zo)

* Fix Windows password prompt fd type (bd-1zo)

* Reset .beads/issues.jsonl to upstream main (bd-1zo)

---------

Co-authored-by: Amp <amp@example.com>
Co-authored-by: beads/crew/darcy <steve.yegge@gmail.com>
2026-01-21 16:59:51 -08:00
Nelson Melo
0eb3dd05a9 fix(daemon): prevent stack overflow in handleStaleLock (#1238)
Remove recursive tryAutoStartDaemon calls from handleStaleLock that
caused infinite recursion when daemon start lock cleanup looped.

The call chain was: acquireStartLock -> handleStaleLock ->
tryAutoStartDaemon -> acquireStartLock -> ... (unbounded)

Now handleStaleLock just cleans up stale locks and returns false,
letting the caller's bounded retry loop handle retries.

Co-authored-by: Nelson Melo <nmelo@users.noreply.github.com>
2026-01-21 16:51:56 -08:00
Steve Yegge
caf4c368c4 Merge pull request #1240 from coffeegoddd/db/import-export
Enable full-fidelity JSONL import/export for Dolt backend
2026-01-21 16:40:03 -08:00
Test
01fa2d9f3f /cmd/bd/federation.go: fix windows build issue again 2026-01-21 14:08:40 -08:00
Test
b849f598d7 /{cmd,docs,internal}: support import export for dolt backends 2026-01-21 13:13:24 -08:00
collins
7cf67153de refactor(types): remove Gas Town type constants from beads core (bd-w2zz4)
Remove Gas Town-specific type constants (TypeMolecule, TypeGate, TypeConvoy,
TypeMergeRequest, TypeSlot, TypeAgent, TypeRole, TypeRig, TypeEvent, TypeMessage)
from internal/types/types.go.

Beads now only has core work types built-in:
- bug, feature, task, epic, chore

All Gas Town types are now purely custom types with no special handling in beads.
Use string literals like "gate" or "molecule" when needed, and configure
types.custom in config.yaml for validation.

Changes:
- Remove Gas Town type constants from types.go
- Remove mr/mol aliases from Normalize()
- Update bd types command to only show core types
- Replace all constant usages with string literals throughout codebase
- Update tests to use string literals

This decouples beads from Gas Town, making it a generic issue tracker.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 10:36:59 -08:00
emma
4a0f4abc70 feat(doctor): add patrol pollution detection and fix
Add CheckPatrolPollution to detect stale patrol beads:
- Patrol digests matching 'Digest: mol-*-patrol'
- Session ended beads matching 'Session ended: *'

Includes auto-fix via 'bd doctor --fix' to clean up pollution.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 23:15:37 -08:00
emma
1a7f8efc9e feat(doctor): add federation health checks (bd-wkumz.6)
Add 5 federation health checks:
- CheckFederationRemotesAPI: verifies remotesapi port accessibility
- CheckFederationPeerConnectivity: checks peer remote reachability
- CheckFederationSyncStaleness: detects commits behind peers
- CheckFederationConflicts: detects unresolved merge conflicts
- CheckDoltServerModeMismatch: detects embedded vs server mode mismatch

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 23:13:02 -08:00
beads/crew/collins
c3f68caf7a feat(federation): enhance bd federation status command (bd-wkumz.5)
Improve the federation status command to show more comprehensive
information similar to `git remote -v` with health info:

- Show peer URLs alongside peer names
- Display pending local changes count (uncommitted)
- Test connectivity to each peer (via fetch)
- Track and display last sync time in metadata table
- Show reachability status with error messages on failure

Changes:
- cmd/bd/federation.go: Enhanced status output with URLs, connectivity
  checks, pending changes, and last sync time
- internal/storage/dolt/federation.go: Added getLastSyncTime/setLastSyncTime
  methods using metadata table, record sync time on successful sync

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 23:12:33 -08:00
beads/crew/lydia
63c2e50158 feat(sync): add incremental export for large repos
For repos with 1000+ issues where less than 20% are dirty,
incremental export reads the existing JSONL, merges only
changed issues, and writes back - avoiding full re-export.

- Add exportToJSONLIncrementalDeferred as new default export path
- Add shouldUseIncrementalExport to check thresholds
- Add performIncrementalExport for merge-based export
- Add readJSONLToMap helper for fast JSONL parsing
- Falls back to full export when incremental is not beneficial

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 21:26:17 -08:00
beads/crew/jane
d3d2326a8b feat(federation): add SQL user authentication for peer sync
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>
2026-01-20 21:15:11 -08:00
beads/crew/darcy
ea51c4b0bd fix(federation): add configurable ports, password support, fix log leak
- Add --federation-port and --remotesapi-port flags (default 3306/8080)
- Fix log file leak in server.go - track and close on Stop()
- Add BEADS_DOLT_PASSWORD env var for server mode authentication
- Update DSN to include password when set

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:55:27 -08:00
beads/crew/lydia
83e3c75635 fix(ci): resolve lint errors and test failures
- Fix errcheck: handle watcher.Close() and Set() return values
- Fix unparam: remove always-nil error from NewActivityWatcher
- Fix unparam: remove unused sinceTime param, delete dead code
- Fix version mismatch: update MCP __init__.py to 0.48.0
- Fix routing tests: change CWD so routing can find town root

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:50:59 -08:00
beads/crew/darcy
8807a171d3 fix(federation): allow daemon mode with --federation flag for dolt
Update guards to allow daemon commands when --federation is set.
Federation mode runs dolt sql-server which enables multi-writer
support, unlike embedded Dolt which is single-process only.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:49:54 -08:00
beads/crew/darcy
da4584ae57 feat(federation): add dolt sql-server mode for daemon (bd-wkumz.2)
Add --federation flag to bd daemon start that runs dolt sql-server
instead of the embedded driver. Enables multi-writer support and
exposes remotesapi on port 8080 for peer-to-peer push/pull.

Changes:
- Add --federation flag to daemon start command
- Create dolt server manager (internal/storage/dolt/server.go)
- Update DoltStore to support server mode via MySQL protocol
- Integrate server lifecycle into daemon (auto-start/stop)
- Add tests for server management and server mode connections

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:48:24 -08:00
beads/crew/emma
6190dd9362 feat(federation): implement bd federation sync command
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>
2026-01-20 20:47:18 -08:00
joshuavial
cf6356b98a fix(init): error when redirect target already has database
When running `bd init` from a directory with a .beads/redirect file
pointing to a canonical .beads/ that already has a database, init
now errors instead of silently overwriting the existing database.

This prevents accidental data loss when:
- A project uses redirect to share a canonical database
- Someone runs `bd init` from the redirected location
- The canonical database was already initialized

The error message clearly explains:
- What happened (redirect target already has database)
- Where the redirect points to
- How to use the existing database (just run bd commands normally)
- How to reinitialize if needed (rm the database first)

Adds test: TestInitWithRedirectToExistingDatabase

Part of GH#bd-0qel

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:03:28 -08:00
joshuavial
d41fb30720 fix(redirect): follow redirect when creating database (GH#bd-0qel)
When bd runs with --no-daemon or during init in a directory that has a
.beads/redirect file, it now correctly follows the redirect to create
the database in the target location instead of locally.

The bug occurred because:
1. init.go hardcoded .beads/beads.db without checking for redirects
2. main.go's fallback path for auto-bootstrap also used local .beads

Both code paths now call beads.FollowRedirect() to resolve the correct
.beads directory before constructing the database path.

Added TestInitWithRedirect to verify the fix.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:02:56 -08:00
beads/crew/jane
1676f0de45 Merge origin/main into db/fix-2 (resolve conflicts) 2026-01-20 19:49:12 -08:00
beads/crew/elinor
4b2d1791ee refactor(hooks): consolidate duplicate JSONL file lists into shared constant
- Add jsonlFilePaths constant to eliminate duplicate file list definitions
- Update all usages in hook.go and hooks.go to use the shared constant
- Include beads.jsonl for backwards compatibility with older installations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 19:15:18 -08:00
beads/crew/lizzy
2fe15e2328 feat(hooks): add jujutsu (jj) version control support
Add detection and hook support for jujutsu repositories:

- IsJujutsuRepo(): detects .jj directory
- IsColocatedJJGit(): detects colocated jj+git repos
- GetJujutsuRoot(): finds jj repo root

For colocated repos (jj git init --colocate):
- Install simplified hooks without staging (jj auto-commits working copy)
- Worktree handling preserved for git worktrees in colocated repos

For pure jj repos (no git):
- Print alias instructions since jj doesn't have native hooks yet

Closes: hq-ew1mbr.12

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 19:13:02 -08:00
beads/crew/wickham
e00f013bda feat(activity): use fsnotify for real-time feed (hq-ew1mbr.17)
Replace polling with filesystem watching for near-instant wake-up
(<50ms vs 250ms avg). Watches .beads/dolt/.dolt/noms for Dolt commits.
Falls back to polling if fsnotify unavailable.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 19:07:26 -08:00
beads/crew/wickham
a3ef7722f9 feat(cmd): add 'bd children <id>' command (bd-scbxh)
Convenience alias for 'bd list --parent <id>'. Lists all child beads
of a specified parent, supporting all standard list flags (--json,
--pretty, etc.).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 19:07:26 -08:00
beads/crew/emma
d72f37551b feat(rename): add bd rename command for renaming issue IDs
Add new `bd rename <old-id> <new-id>` command that:
- Updates the issue's primary ID
- Updates text references in other issues (title, description, etc.)
- Handles dependencies via storage layer's UpdateIssueID

Also fix sync.go build error where hasSyncBranchConfig/syncBranchName
were referenced but not defined - should use sbc.IsConfigured()/sbc.Branch.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 18:49:44 -08:00
Dustin Brown
d3ccd5cfba Fix Dolt backend init/daemon/doctor; prevent accidental SQLite artifacts; add integration tests; clean up lint (#1218)
* /{cmd,internal}: get dolt backend init working and allow issue creation

* /{website,internal,docs,cmd}: integration tests and more split backend fixes

* /{cmd,internal}: fix lint issues

* /cmd/bd/doctor/integrity.go: fix unable to query issues bug with dolt backend

* /cmd/bd/daemon.go: remove debug logging
2026-01-20 17:34:00 -08:00
Test
7ed6849d19 /{cmd,docs,internal,website}: make dolt backend explicitly single process 2026-01-20 16:51:14 -08:00
coffeegoddd☕️✨
47a31a3e6e /cmd/bd/daemon.go: remove debug logging 2026-01-20 14:08:58 -08:00
Roland Tritsch
c1ac69da3e feat(mol): add 'bd mol seed --patrol' command (#1149)
* Fix doctor DB-JSONL sync check to exclude ephemeral wisps

The DB-JSONL Sync check was showing a false positive warning when wisps
(ephemeral issues) existed in the database. Wisps are intentionally
excluded from JSONL exports, so they shouldn't be counted when comparing
database and JSONL issue counts.

Changes:
- Updated CheckDatabaseJSONLSync to exclude ephemeral issues from count
  using 'WHERE ephemeral = 0 OR ephemeral IS NULL'
- Added 'ephemeral' column to test database schema
- Added test case to verify ephemeral issues are excluded from count
- Updated TestCheckDatabaseJSONLSync_MoleculePrefix to include ephemeral column

This prevents false warnings like 'database has 92 issues, JSONL has 30'
when the difference is entirely due to wisps that should not be exported.

* feat(mol): add 'bd mol seed --patrol' command

Adds `bd mol seed` command to verify formula accessibility before
patrols attempt to spawn work.

## Problem

Gas Town's `gt rig add` calls `bd mol seed --patrol` but this command
didn't exist in beads, causing the call to always fail and fall back
to creating non-functional placeholder beads.

## Solution

Implemented `bd mol seed` with two modes:

1. **With --patrol flag**: Verifies all three patrol formulas are accessible
   - mol-deacon-patrol
   - mol-witness-patrol
   - mol-refinery-patrol

2. **Without --patrol**: Verifies a specific formula is accessible

## Implementation

The command uses `resolveAndCookFormulaWithVars` to verify formulas:
- Checks formula search paths (.beads/formulas/, ~/.beads/formulas/, $GT_ROOT/.beads/formulas/)
- Validates formula syntax and resolution
- Confirms formula can be cooked to subgraph

## Usage

```bash
bd mol seed --patrol                    # Verify all patrol formulas
bd mol seed mol-feature                 # Verify specific formula
bd mol seed mol-review --var name=test  # With variable substitution
```

## Testing

-  Command compiles without errors
-  Help text displays correctly
-  `--patrol` succeeds when formulas accessible (town level)
-  `--patrol` fails with clear error when formulas missing (rig level)
-  Follows existing beads command patterns (cobra, flags, error handling)

## Impact

- Enables Gas Town's intended patrol formula verification flow
- Eliminates creation of unnecessary placeholder beads
- Provides health check command for formula accessibility
- Foundation for future seed commands (data initialization, etc.)

Fixes the missing command referenced in steveyegge/gastown#715

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Roland Tritsch <roland@ailtir.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-20 14:06:57 -08:00
Roland Tritsch
09355eee8c Add --gastown flag to bd doctor for gastown-specific checks (#1162)
When running in gastown multi-workspace mode, two checks produce false
positives that are expected behavior:

1. routes.jsonl is a valid configuration file (maps issue prefixes to
   rig directories), not a duplicate JSONL file
2. Duplicate issues are expected (ephemeral wisps from patrol cycles)
   and normal up to ~1000, with GC cleaning them up automatically

This commit adds flags to bd doctor for gastown-specific checks:
- --gastown: Skip routes.jsonl warning and enable duplicate threshold
- --gastown-duplicates-threshold=N: Set duplicate tolerance (default 1000)

Fixes false positive warnings:
  Multiple JSONL files found: issues.jsonl, routes.jsonl
  70 duplicate issue(s) in 30 group(s)

Changes:
- Add --gastown flag to bd doctor command
- Add --gastown-duplicates-threshold flag (default: 1000)
- Update CheckLegacyJSONLFilename to skip routes.jsonl when gastown mode active
- Update CheckDuplicateIssues to use configurable threshold when gastown mode active
- Add test cases for gastown mode behavior with various thresholds

Co-authored-by: Roland Tritsch <roland@ailtir.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-20 14:06:53 -08:00
John Zila
f336e669e9 fix(sync): use sync-branch worktree for --full --no-pull (#1183)
* fix(sync): use sync-branch worktree for --full --no-pull (#1173)

Bug 1: PullFromSyncBranch was copying uncommitted worktree changes to
main repo when remoteAhead==0. This corrupted the 3-way merge because
local changes appeared as remote changes. Fixed by copying only the
committed state from HEAD instead of the working directory.

Bug 2: doExportOnlySync was checking main repo for changes via
gitHasBeadsChanges, but when sync-branch is configured, changes go to
the worktree, not main. Fixed by detecting sync-branch config and using
CommitToSyncBranch which operates on the worktree.

Fixes #1173

* refactor(sync): consolidate sync-branch detection and commit/push logic

Extract repeated patterns into reusable helpers:

- SyncBranchContext struct: holds branch name and repo root
- getSyncBranchContext(): detects sync-branch config from store
- commitAndPushBeads(): handles both sync-branch and regular git workflows

This eliminates duplicated sync-branch detection code (was in 3 places)
and the duplicated commit/push conditional logic (was in 2 places).

Net reduction of ~20 lines while improving maintainability.

* fix: remove unused bool return from commitAndPushBeads
2026-01-20 14:06:22 -08:00
Oliver Jägle
d929c8f974 feat: add hierarchical tree display for --tree --parent combination (#1211)
Motivation:
The existing --parent flag only shows direct children in a flat list,
but users often need to see the complete hierarchy including grandchildren
and deeper levels. This limitation made it difficult to understand the
full scope of work under an epic or parent issue.

Key changes:
- Enhanced list command to detect --tree --parent combination
- Implemented recursive parent filtering instead of GetDependencyTree
- Added DRY refactoring with withStorage() and getHierarchicalChildren() helpers
- Eliminated duplication between daemon and direct modes
- Added comprehensive test coverage with TestHierarchicalChildren
- Fixed cross-repository compatibility issues

Side-effects:
- No breaking changes: existing --parent behavior unchanged
- --tree --parent now shows hierarchical tree instead of flat list
- Parent issue is included as root of the displayed tree
- Works consistently across all repositories and storage modes
- Improved code maintainability with DRY architecture
- Better test coverage ensures reliability and prevents regressions
2026-01-20 14:06:17 -08:00
Zachary Piazza
ee44498659 feat(linear): add --type and --exclude-type flags for sync filtering (#1205)
* feat(linear): add --type and --exclude-type flags for sync filtering

Add type filtering support to `bd linear sync --push` to allow users to
control which issue types are synced to Linear.

New flags:
- --type: Only sync issues matching these types (e.g., --type=task,feature)
- --exclude-type: Exclude issues of these types (e.g., --exclude-type=wisp)

Use cases:
- Sync only work items (tasks, features, bugs) while excluding internal
  telemetry (wisps, messages)
- Push only specific issue types to Linear

Fixes #1204

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(linear): update test to match new doPushToLinear signature

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 14:05:48 -08:00
Eugene Sukhodolin
4ccdd7a2df fix(routing): close original store before replacing with target store (#1215)
* fix(routing): close original store before replacing with target store

Fix "database is closed" error during auto-flush when contributor routing
redirects issue creation to a different repository (e.g., ~/.beads-planning).

When a user is detected as a contributor (based on git remote URL pattern),
the default configuration routes new issues to ~/.beads-planning instead of
the current repository. This routing caused auto-flush to fail with:

  Warning: auto-flush failed: failed to get stored JSONL hash:
  failed to get jsonl_file_hash: sql: database is closed

In create.go, when switching to the planning repo:
1. targetStore was opened for the planning database
2. A defer was set to close targetStore at function end
3. store = targetStore replaced the global store pointer
4. Issue was created successfully
5. Command Run ended → defer closed targetStore
6. PersistentPostRun tried to flush using the global store → error!

The bug: the defer closed targetStore, but the global `store` variable
pointed to the same object. When PersistentPostRun called flushManager.Shutdown(),
it tried to use the already-closed store for the flush operation.

- Remove the defer that prematurely closed targetStore
- Explicitly close the ORIGINAL store before replacing it (it won't be used)
- Let PersistentPostRun close whatever store is current at exit time

This ensures proper store lifecycle:
- Original store: closed when replaced (no longer needed)
- Target store: closed by PersistentPostRun after flush completes

1. Have a git repo with a remote URL that doesn't match maintainer patterns
   (e.g., github-a:org/repo.git instead of git@github.com:org/repo.git)
2. Have ~/.beads-planning directory with beads initialized
3. Run: cd /path/to/repo && bd create "Test issue"
4. Observe: Issue created successfully, but followed by:
   Warning: auto-flush failed: ... sql: database is closed

Added debug prints to SQLiteStorage.Close() and GetJSONLFileHash() which
revealed two different databases were involved:
- /path/to/repo/.beads/beads.db (closed first, unexpectedly)
- ~/.beads-planning/.beads/beads.db (used for flush after being closed)

* fix(test): resolve race condition in TestAutoFlushOnExit

Not directly related to the previous routing fix, but exposed by CI timing.

Root cause: The test had a latent race condition between two channel operations:
1. markDirtyAndScheduleFlush() sends event to markDirtyCh
2. Shutdown() sends request to shutdownCh

Without any delay, Go's scheduler might process the shutdown event first.
Since isDirty was still false (markDirty event not yet processed), the
FlushManager would skip the flush entirely, causing the test to fail with
"Expected JSONL file to be created on exit".

The race was always present but only manifested in CI environments with
different timing characteristics (CPU contention, virtualization, scheduler
behavior).

Fix: Add a 10ms sleep after markDirtyAndScheduleFlush() to allow the
FlushManager's background goroutine to process the event before shutdown.
This mimics real-world behavior where there's always some time between
CRUD operations and process exit.
2026-01-20 14:05:40 -08:00
Perttu Landström
9ed74ca233 fix(types): show custom types when daemon is running (#1216)
The `bd types` command only checked `if store != nil` to fetch custom
types. In daemon mode, `store` is nil (daemonClient handles RPC instead),
so custom types were never displayed even when configured.

This caused a mismatch where `bd config get types.custom` showed the
correct values but `bd types` showed none.

Fix by calling ensureDirectMode() at the start of the command, matching
the pattern used by `bd config get`. This falls back from daemon mode
to direct storage access when needed.

Co-authored-by: Perttulands <perttu.landstrom@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 14:05:03 -08:00
Wilhelm Uschtrin
f7134954b9 fix(worktree): correct redirect path computation in bd worktree create (#1217)
Computes the relative path from the worktree root instead of the .beads directory. This ensures that FollowRedirect resolves paths correctly relative to the parent of .beads.
2026-01-20 14:04:51 -08:00
coffeegoddd☕️✨
4e386c8adf /cmd/bd/doctor/integrity.go: fix unable to query issues bug with dolt backend 2026-01-20 14:00:37 -08:00
coffeegoddd☕️✨
a097fc546b /{cmd,internal}: fix lint issues 2026-01-20 13:46:57 -08:00