Commit graph

53 commits

Author SHA1 Message Date
Trillium Smith
336728882a
feat(config): add central server config library (#3258)
* test(config): add specs for central server config library

Add test cases for LoadCentralConfig, ApplyCentralDefaults, and
DefaultCentralConfigPath with stub implementations. Tests define
the expected behavior; implementations follow in the next commit.

* feat(config): implement central server config library

Implement LoadCentralConfig and ApplyCentralDefaults to satisfy
the specs from the previous commit. LoadCentralConfig reads and
parses ~/.config/beads/server.json; ApplyCentralDefaults merges
server-only fields into per-project config at zero values.

* test(config): add integration specs for central config wiring

Add tests that verify applyCentralConfigDefaults loads the central
server config and merges it into the per-project config. Stub
implementation is a no-op; tests define expected behavior before
the wiring is implemented.

* feat(config): wire central config into store open paths

Implement applyCentralConfigDefaults and call it in both
NewFromConfigWithOptions and NewFromConfigWithCLIOptions so that
server fields from ~/.config/beads/server.json are applied as
defaults before per-project config resolution.
2026-04-27 12:54:11 -07:00
Shaun Cutts
4fbfd97f07
fix(config): consult config.yaml for dolt.host (#3471)
fix(config): consult config.yaml for dolt.host

Co-authored-by: Shaun Cutts <shauncutts@factfiber.com>
2026-04-25 12:21:30 -07:00
Shaun Taheri
a78e58388f
feat: support Unix domain sockets for Dolt server connections (#3300)
Add ServerSocket config field and BEADS_DOLT_SERVER_SOCKET env var to
connect to Dolt via unix sockets instead of TCP. This eliminates port
conflicts between concurrent projects and simplifies sandbox integration.

- Wire --server-socket CLI flag through bd init and bd dolt set (dolt.socket)
- Add GetDoltServerSocket() to configfile with env var precedence
- Socket mode disables auto-start with socket-specific error hints
- TLS settings honored regardless of transport
- Integration test: starts dolt sql-server --socket, verifies end-to-end SQL
- Document in README.md server mode table

Closes #2939
2026-04-21 22:12:15 -07:00
coffeegoddd☕️✨
fa87dd2bdd feat: add global beads_global database for shared-server mode
Adds a project-agnostic beads_global database to shared-server mode so
clients can track issues globally across all projects on the server.

- Add EnsureGlobalDatabase() to create the DB during shared server init
- Add --global persistent flag to switch CLI commands to the global DB
- Add global_dolt_database field to metadata.json for connection info
- Seed global DB with issue_prefix="global" and sentinel project ID
- Export/import default to global-issues.jsonl with --global flag
- --global errors when not in shared-server mode (additive, no breakage)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 09:18:43 -07:00
Sam
7e4da9ab20
Add credentials file support for Dolt server passwords (#2854)
* feat: add credentials file support for Dolt server passwords

Add INI-style credentials file (~/.config/beads/credentials) as a
fallback for Dolt server passwords, keyed by [host:port] section.
This lets users working with multiple servers avoid juggling env vars
per project.

Lookup order: BEADS_DOLT_PASSWORD env var > credentials file > empty.
Path overridable via BEADS_CREDENTIALS_FILE env var.
Warns on overly permissive file permissions (unix only, mirrors ssh).

* docs: document credentials file in DOLT.md

Add credentials file section to the Dolt backend docs covering file
format, default location, permission warnings, and password resolution
order. Update the config reference and env var table to reference the
new feature.

* fix: use resolved runtime port for credentials file lookup

The credential file lookup in GetDoltServerPassword() used the port
from metadata.json, but the actual connection port comes from
doltserver.DefaultConfig() which has its own priority chain (port file >
config.yaml > metadata.json). When these diverge — e.g., IAP tunnel on
3308 vs local Dolt on 3307 — the credentials file lookup used the wrong
[host:port] section.

Add GetDoltServerPasswordForPort() that accepts an explicit port, and
use it in main.go where the resolved runtime port is already known.
Existing GetDoltServerPassword() delegates to the new method for
backward compatibility.

* fix: use mysql.Config.FormatDSN for proper password escaping

Passwords with special characters (& < > / % etc.) were inserted raw
into the DSN string, breaking go-sql-driver/mysql parsing. Passwords
like "zId&z,L9P4X,%k4n4rylGV<Ibos9<)/p" would cause "Access denied"
errors even though the password was correct.

Switch from manual fmt.Sprintf DSN construction to mysql.Config's
FormatDSN(), which handles escaping correctly. This also consolidates
timeout and TLS configuration into the typed Config struct instead of
string concatenation.

* test: add DSN special character password roundtrip tests

Covers passwords with &, <, >, /, ?, %, @, :, and () — all of which
broke the old fmt.Sprintf DSN construction. Verifies that FormatDSN
produces a parseable DSN and the password survives the roundtrip.
2026-04-02 20:35:56 -07:00
matt wilkie
baa9d02457
fix: treat --shared-server as server mode for DoltMode (#2947)
* fix: prevent silent fallback to embedded mode when shared-server is active (GH#2949)

Root cause: ResolveServerMode() and IsDoltServerMode() checked
metadata.json dolt_mode=embedded BEFORE runtime env vars, so stale
persisted metadata silently overrode active shared-server config.

Fixes:
- ResolveServerMode: env vars (BEADS_DOLT_SERVER_MODE, BEADS_DOLT_SHARED_SERVER)
  now checked before metadata.json, preventing stale embedded override
- IsDoltServerMode: now checks BEADS_DOLT_SHARED_SERVER env var (shared-server
  implies server-backed storage)
- warnSharedServerEmbeddedMismatch -> repairSharedServerEmbeddedMismatch:
  auto-repairs stale dolt_mode=embedded in metadata.json instead of just warning
- Added 6 regression tests covering the upgrade path

Closes #2949

Amp-Thread-ID: https://ampcode.com/threads/T-019d4b84-cddd-725a-a3c6-ee7e3631f2aa
Co-authored-by: Amp <amp@ampcode.com>

* fix: treat --shared-server as server mode for metadata.json DoltMode (#2946)

--shared-server sets BEADS_DOLT_SHARED_SERVER for directory resolution but
never set initServerMode, so metadata.json recorded DoltMode as "embedded"
and all subsequent commands used embedded Dolt despite config.yaml having
dolt.shared-server: true.

Also override metadata.json at runtime when dolt.shared-server is set,
so existing installs with stale metadata.json are handled without re-init.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: ensure shared server runs during init and fix isEmbeddedMode check

Two additional fixes for GH#2946:

1. Init auto-starts the shared Dolt server if not already running,
   since ResolveServerMode classifies shared-server as External
   which suppresses the normal auto-start path.

2. isEmbeddedMode() now checks doltserver.IsSharedServerMode() as a
   fallback. Dolt subcommands (status, start, stop) skip DB init in
   PersistentPreRun, so serverMode is never set from metadata.json.
   Without this, "bd dolt status" would still report embedded mode
   even with dolt.shared-server: true in config.yaml.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: apply shared-server override to loadServerModeFromConfig()

Closes the gap flagged in PR review: no-db commands (bd dolt start,
bd dolt status, bd doctor, etc.) go through loadServerModeFromConfig()
which didn't have the shared-server override for stale metadata.json.

This ensures isEmbeddedMode() returns false for all command paths when
dolt.shared-server is true in config.yaml, not just commands that pass
the no-db guard in PersistentPreRun.

GH#2946

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d4f6f-01f8-72d4-b474-f75d7909b8b9

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:52:20 -07:00
garnet
3dae6bb3df refactor: remove gastown/Gas Town string references from beads code and docs (bd-1ue8)
Replace gastown-specific references with generic alternatives throughout
the codebase:

- Rename --gastown flag to --orchestrator in bd doctor
- Rename gastownMode/gastownThreshold params to orchestratorMode/orchestratorThreshold
- Rename isGasTownTownRoot() to isOrchestratorRoot()
- Replace "gastown" in CLI examples with generic rig names (my-project, other-project)
- Update comments replacing "Gas Town" with "orchestrator" or "multi-agent workspace"
- Update active docs (DOLT.md, CONFIG.md, ADVANCED.md, etc.)
- Update test data to use generic names instead of "gastown"
- Update role templates (deacon, witness, refinery) to use generic language

Preserved as historical (not changed):
- CHANGELOG.md entries (historical record)
- ARTICLES.md (links to real published articles)
- info.go version notes (historical release notes)
- gastown/ file path references in dolt-concurrency.md (point to actual repo)
2026-03-20 18:39:50 -07:00
jane
b7cc484441 feat: replace hash-derived dolt ports with OS-assigned ephemeral ports (GH#2415)
Replace DerivePort() (FNV-32a hash into 1000-port range) with OS-assigned
ephemeral ports via net.Listen(":0"). This eliminates birthday-problem port
collisions (#2098) and complements Layer 2 identity verification (c6e41803)
for defense-in-depth against cross-project data leakage (#2372).

Start() now allocates ephemeral ports with a retry loop (10 attempts) for
TOCTOU races. Explicit port config (env var, config.yaml, metadata.json)
is preserved with conflict detection via reclaimPort.

Closes #2098. Partially addresses #2372.

Co-Authored-By: Tim Visher <194828183+timvisher-dd@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:39:43 -07:00
beads/crew/emma
84494b7e1a cleanup: remove daemon infrastructure remnants (GH#2431)
Remove all BEADS_NO_DAEMON env var handling from test files (dead code
since daemon removal in v0.50.0), delete stopRepoDaemon() and daemon
file guards from test setup, remove no-daemon config key from tests,
and update daemon→server wording in docs and comments.

37 files changed, -193 lines net.

Co-Authored-By: davetashner <davetashner@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:24:27 -07:00
beads/crew/emma
401da9df71 fix: backfill project_id into pre-GH#2372 Dolt stores via bd doctor --fix (GH#2490)
Projects initialized before GH#2372 have no project_id in metadata.json
or _project_id in the database metadata table. Adds a doctor check that
detects missing fields and --fix path that backfills a UUID into both
stores, protecting against cross-project data leakage.

Co-Authored-By: timvisher-dd <timvisher-dd@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 11:56:15 -07:00
beads/crew/emma
7d06e6c2df fix: add BEADS_DOLT_PORT fallback in GetDoltServerPort() (GH#2486)
Gas Town sets BEADS_DOLT_PORT to route bd commands to the correct Dolt
server. This adds it as a fallback after BEADS_DOLT_SERVER_PORT but
before config/default.

Co-Authored-By: joshuavial <joshuavial@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 11:50:53 -07:00
beads/crew/emma
c6e41803a5 fix(dolt): idle-monitor single-instance lock, port config isolation, project UUID verification (GH#2367, GH#2372)
Three P1 fixes for the Dolt server stabilization epic (bd-109c):

1. Idle-monitor single-instance enforcement (GH#2367): RunIdleMonitor now
   acquires an exclusive file lock at startup. If another monitor is already
   running, the new one exits immediately. This prevents the accumulation
   bug where Start() called from within the monitor watchdog would fork
   additional monitors (one per minute, ~32MB each).

2. Port config isolation (GH#2372): The port file (dolt-server.port, now
   gitignored) is elevated to primary source for port resolution, ahead of
   metadata.json and config.yaml which are git-tracked and can propagate
   to collaborators. metadata.json DoltServerPort emits a deprecation
   warning when used.

3. Client-side project identity verification (GH#2372): bd init now generates
   a UUID stored in both metadata.json (project_id) and the database metadata
   table (_project_id). On every store open, these are compared. A mismatch
   means the client is connected to the wrong projects Dolt server and the
   connection is refused with a clear diagnostic message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:44:09 -08:00
beads/crew/lizzy
2329f4ef5c docs: update embedded Dolt references for upcoming reintroduction
Embedded Dolt is being reintroduced for standalone/solo Beads users
(Dolt team delivering improved embedded support). Update docs and code
comments that asserted embedded was permanently removed. Gas Town
continues to use server mode exclusively.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 21:45:47 -08:00
Marco Del Pin
e75491ebb1 fix: strip absolute dolt_data_dir from metadata.json on save (GH#2251)
metadata.json is committed to git and propagates to other clones.
Absolute paths in dolt_data_dir are machine-specific and cause data
loss when other clones try to use the wrong directory.

- Save() now strips absolute dolt_data_dir before writing
- bd dolt set data-dir warns about absolute paths and points to
  BEADS_DOLT_DATA_DIR env var for persistence
2026-03-03 01:26:47 +01:00
gastown/crew/mel
87493ce917 fix: remove Beads Classic SQLite backend and migration infrastructure
SQLite is dead. Dolt is the only backend.

- Remove BackendSQLite constant and all SQLite branches from configfile
- GetBackend() now always returns "dolt" (ignores BEADS_BACKEND env var for sqlite)
- DatabasePath() no longer has SQLite path resolution (GH#2016 compat removed)
- Delete 13 SQLite→Dolt migration files (migrate_auto, migrate_dolt, migrate_shim,
  migrate_import, migrate_safety and their tests/nocgo variants)
- Remove --to-dolt flag from bd migrate command
- Remove autoMigrateSQLiteToDolt() call from main.go startup path
- Delete broken_migration doctor check/fix (SQLite residue detection)
- Rescue CheckEmbeddedModeConcurrency into its own file (Dolt-specific, not legacy)
- Update federation and configfile tests to reflect Dolt-only world
- Net: -7,045 lines

Closes: hq-x8jhj, hq-1jaou

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 12:42:09 -08:00
beads/crew/collins
0f2a62659a fix: repair CI failures - test fix and gofumpt formatting
Fix TestCheckDoltLocks_NotDoltBackend by adding metadata.json to test
fixture so non-Dolt backend is correctly detected. Apply gofumpt to
4 files with formatting drift.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 22:13:05 -08:00
quartz
6dd42f6e31 fix: federation checks use wrong PID path and hardcoded port (bd-uz1x)
- Use doltserver.IsRunning(beadsDir) instead of manually checking PID file
  at filepath.Join(doltPath, "dolt-server.pid") — PID file lives in beadsDir,
  not doltPath. This also handles Gas Town daemon PID files correctly.
- Read remotesapi port from config (DoltRemotesAPIPort field, env var
  BEADS_DOLT_REMOTESAPI_PORT) instead of hardcoding 8080.
- Add configfile.GetDoltRemotesAPIPort() getter with DefaultDoltRemotesAPIPort.
- Add test coverage for all federation check functions.

Executed-By: beads/polecats/quartz
Rig: beads
Role: polecats
2026-03-01 19:13:46 -08:00
Eduardo Koloma Jr
02e37c79c5 style: fix gofmt errors 2026-02-27 18:20:23 +00:00
Aaron Lippold
49aed46c85
fix: harden SQLite→Dolt migration safety, old-schema compat, and doctor recovery (#2156)
* fix(configfile): respect backend field in metadata.json

GetBackend() was hardcoded to always return "dolt", ignoring the
backend field in metadata.json. This forced all SQLite users onto
Dolt with no migration path and no way to opt out.

- Add BackendSQLite constant and case-insensitive normalization
- GetBackend() reads backend field: sqlite → sqlite, empty/dolt → dolt
- DatabasePath() routes to SQLite or Dolt path based on backend
- BEADS_BACKEND env var override as escape hatch for corrupted configs
- CapabilitiesForBackend handles sqlite backend
- Warning on unrecognized BEADS_BACKEND values
- 55 tests covering all paths including env var, case normalization,
  roundtrip persistence, and DatabasePath routing

Fixes #2016.

Authored by: Aaron Lippold<lippold@gmail.com>

* feat(migrate): add shared migration safety functions

Extract reusable safety functions for SQLite→Dolt migration:
- backupSQLite: file copy with O_EXCL + 0600 permissions
- verifyServerTarget: TCP + SQL check to prevent wrong-server writes
- verifyMigrationCounts: source vs target count verification
- finalizeMigration: atomic metadata update (last step only)
- rollbackMetadata: restore original config on failure

22 unit tests covering all functions including counter overflow,
non-MySQL server detection, deps-only mismatch, nil config rollback,
server config preservation, and no-metadata scenarios.

Authored by: Aaron Lippold<lippold@gmail.com>

* refactor(migrate): use safety functions in auto-migration

Refactor both CGO and non-CGO auto-migration paths to use shared
safety functions instead of inline logic:

Phase 1 (pre-flight):
- Always backup SQLite before any migration attempt
- Verify server target to prevent writing to wrong Dolt server
- Skip migration when backend explicitly set to sqlite (GH#2016)
- Use GetBackend() for SQLite guard, strings.EqualFold for Dolt
  stale-leftover detection (preserves legacy empty-backend migration)

Phase 2 (import):
- Unchanged: extract from SQLite, create Dolt store, import data

Phase 3 (verify + finalize):
- Verify issue counts match before updating metadata
- Atomic finalization via finalizeMigration (metadata last)
- Rollback with warning on failure (not silent discard)

Clear, actionable error messages at every failure point showing
backup path. 13 unit tests including new SQLite backend guard test.

Authored by: Aaron Lippold<lippold@gmail.com>

* fix(main): clear error when SQLite backend detected

When GetBackend() returns "sqlite" (user opted to stay on SQLite or
migration was skipped), print a clear error with migration instructions
instead of falling through to dolt.New() which produces a confusing
Dolt connection failure.

Fixes #2016.

Authored by: Aaron Lippold<lippold@gmail.com>

* feat(doctor): detect and fix broken migration states

Add three new doctor checks for migration-related issues:

CheckBrokenMigrationState: detects metadata claiming Dolt backend
but no Dolt directory present (with server-mode awareness). Offers
bd doctor --fix to restore SQLite backend from beads.db or
beads.db.migrated files.

CheckSQLiteResidue: detects leftover beads.db after successful
migration. Fix renames to .migrated (with backend guard to prevent
accidentally renaming active SQLite database).

CheckEmbeddedModeConcurrency: detects embedded mode with lock
contention indicators (dolt-access.lock, noms LOCK files).
Recommends switching to server mode for multi-agent workflows.
Addresses #2086.

19 doctor tests covering all detection paths including server mode,
backup file detection, .migrated-only recovery, zero-byte files,
concurrent access with access locks and noms locks.

Fixes #2086.

Authored by: Aaron Lippold<lippold@gmail.com>

* test(migrate): add integration tests for migration safety

8 integration tests covering key business flows:
- Full migration lifecycle (SQLite → backup → Dolt → bd list works)
- Failed migration recovery (corrupt SQLite → backup exists → intact)
- Doctor detects broken state and fix restores SQLite backend
- Doctor fixes beads.db.migrated rename-back recovery
- Idempotent retry (second migration is no-op)
- SQLite guard prevents auto-migration (data intact, no backup)
- Backup content matches source byte-for-byte
- Metadata JSON valid with all required fields after migration

Authored by: Aaron Lippold<lippold@gmail.com>

* feat(scripts): add migrate-audit.sh for batch SQLite→Dolt migration

Utility script to audit and batch-migrate beads boards:
- Scans all .beads/ directories under a configurable root
- Reports backend state, issue count, and schema version for each board
- --dry-run: shows what --migrate would do without changes
- --migrate: batch converts eligible SQLite boards to Dolt
- --exclude PATTERN: skip projects matching regex (e.g., "backup|test")
- --port/--host: target a specific Dolt server

Safety features:
- Backs up metadata.json before modifying each board
- Restores original metadata.json on migration failure
- Skips boards with old schema (missing owner column)
- bd binary handles SQLite backup, server verification, count verification
- Uses jq for JSON (consistent with existing scripts, no python dependency)

Companion tool for the migration safety PR (GH#2016, GH#2086).

Authored by: Aaron Lippold<lippold@gmail.com>

* fix(migrate): handle all schema versions in SQLite extract

Databases from older beads versions are missing columns added over time
(owner, created_by, crystallizes, mol_type, work_type, quality_score,
source_system, and others). The extract functions hardcoded COALESCE
for all columns, causing "no such column" errors.

Fix: make ALL non-id columns use sqliteOptionalTextExpr via a DRY
opt() helper in both CGO extract and shim extract paths. Missing
columns default to empty/zero/null. Also adds empty/corrupt beads.db
handling to the migrate-audit.sh script.

Tested against 12 real-world databases spanning multiple beads versions,
from the earliest (~30 columns) to the current schema (50+ columns).
All 28 boards migrated successfully.

Authored by: Aaron Lippold<lippold@gmail.com>
2026-02-26 15:48:47 -08:00
Marco Del Pin
7228991214 feat: add dolt-data-dir config for custom dolt data directory
Add support for placing dolt data on a different filesystem than .beads/.
This is useful on WSL where the project lives on a slow NTFS mount (9P)
but dolt data can be placed on native ext4 for 5-10x I/O speedup.

Configuration:
- metadata.json: "dolt_data_dir": "/path/to/fast/storage"
- Environment: BEADS_DOLT_DATA_DIR=/path/to/fast/storage
- CLI: bd dolt set data-dir /path/to/fast/storage

When set, the dolt sql-server uses the custom directory instead of
.beads/dolt/. The JSONL source of truth remains in .beads/ — only the
dolt database (which is fully recreatable from JSONL) moves.

Changes:
- configfile: add DoltDataDir field, GetDoltDataDir() getter, update
  DatabasePath() to check custom dir first
- doltserver: add ResolveDoltDir() helper, update Start(), IsRunning(),
  and reclaimPort() to use it instead of hardcoded path
- cmd/bd/dolt: add "data-dir" key to bd dolt set command
2026-02-26 05:48:52 +01:00
sms
046fa03339 fix: use doltserver.DefaultConfig for port resolution across codebase (#2112)
Callers were using configfile.GetDoltServerPort() or hardcoded 3307
instead of doltserver.DefaultConfig(beadsDir) which correctly resolves
all three cases: explicit config, Gas Town (3307), and hash-derived
standalone ports (13307-14306).

- Add BEADS_DOLT_SERVER_PORT env var to doltserver.DefaultConfig() as
  highest-priority override (parity with configfile.GetDoltServerPort)
- Fix testDoltConnection, testServerConnection, openDoltServerConnection
  in cmd/bd/dolt.go to use resolved port
- Replace three hardcoded 3307 literals in cmd/bd/doctor/perf_dolt.go
- Fix migrate_auto.go connection port and remove 3307 persistence
- Fix init.go display output to show resolved port
- Update help text from "default: 3307" to "auto-detected"
- Deprecate configfile.GetDoltServerPort() with guidance comment
2026-02-25 09:51:05 -05:00
beads/crew/elinor
c980b96baf fix: remove JSONL storage functions and config field (bd-9ni.2)
Remove FindJSONLPath, FindJSONLInDir, JSONLExport config field, and
JSONL bootstrap detection code. Simplify post-merge hook to no-op since
Dolt handles sync internally. Update hook descriptions to remove stale
JSONL references. 19 files changed, ~850 lines removed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:36:00 -08:00
beads/crew/emma
bd68c87b00 fix: remove stale embedded Dolt references after server-only migration
Delete broken store_nocgo_test.go (references undefined errNoCGO),
remove dead bootstrapEmbeddedDolt/hasDoltSubdir functions, and clean up
stale comments and docs that still referenced embedded mode, CGO
requirements, or in-process Dolt across 20 files.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-21 16:59:44 -08:00
beads/crew/emma
c34742920c feat: add Hosted Dolt support (TLS, auth, explicit branch)
Four fixes enabling Hosted Dolt instances:

1. TLS support: ServerTLS config + BEADS_DOLT_SERVER_TLS env var
2. Remote auth: --user flag for DOLT_PUSH/DOLT_PULL with Hosted Dolt
3. Explicit branch in Pull() to avoid "did not specify a branch" errors
4. Config plumbing for server user/password/TLS through to dolt.Config

Also adds bd dolt push/pull commands (already referenced by bd sync
deprecation messages) and ForcePush() for overwriting remote state.

Refactors DSN construction into buildServerDSN() helper, eliminating
duplicated connection string building.

Note: bd dolt commit was omitted as bd vc commit already exists.

Co-authored-by: bryanhirsch <bryanhirsch@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-16 20:27:22 -08:00
beads/crew/emma
ff0b469154 chore: Clean up stale daemon references in code comments and doctor messages
Update comments and user-facing messages across 17 production files to
reflect the current Dolt-native architecture (no daemon):

- Gitignore template: reorganized, daemon/SQLite entries moved to legacy section
- Doctor fix messages: removed references to non-existent bd daemon commands
- Doctor federation: updated fix suggestions to use gt dolt start / server mode
- Doctor integrity: removed "daemon won't start" messaging
- Code comments: replaced daemon mode references with current architecture terms
- Lock handling: marked daemon.lock as legacy cleanup

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-16 19:25:17 -08:00
beads/crew/emma
b62e495943 refactor: restore --to-dolt migration, fix tests for Dolt-only backend (bd-h0zvj.3)
Restore bd migrate --to-dolt for users still on SQLite. Update all tests
that referenced .db files to use dolt/ directories. Fix FindAllDatabases
to detect dolt directories. Remove daemon-related test expectations
removed in Phase 8.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-15 17:14:53 -08:00
beads/crew/emma
6c82467b71 refactor: remove SQLite migration code and legacy backend detection (bd-h0zvj.3) [WIP]
Phase 3 of Dolt-Native Pruning. Removed ~1,855 lines:
- Deleted migrate_dolt_cmd.go, migrate_dolt_cmd_nocgo.go, migration_hint.go
- Gutted migrate_dolt.go to just listMigrations()
- Removed SQLite codepaths from migrate.go (detectDatabases, getDBVersion, etc.)
- Removed BackendSQLite constant from configfile
- Removed GetConfiguredBackend, LegacyDatabaseNames from beads.go
- Removed NewSQLiteStorage from public API
- Simplified findDatabaseInBeadsDir (no more .db file scanning)
- Simplified backend_migration doctor check (always Dolt)
- Removed SQLite migration hint from main.go

WIP: Need to restore bd migrate --to-dolt as user migration path,
and fix remaining test failures in configfile, beads, cmd/bd packages.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-15 17:00:55 -08:00
beads/crew/emma
5ffd625b40 refactor: Phase 8 CLI & config cleanup - remove SQLite/daemon remnants (dolt-1s40.8)
Remove all vestiges of the SQLite backend, daemon system, and JSONL auto-sync
from CLI flags, config keys, doctor checks, init flows, and the bd backend command.

Key changes:
- Delete bd backend command and tests (backend selection obsolete)
- Remove --backend, --skip-merge-driver flags from bd init
- Remove --lock-timeout flag from main; use fixed 30s default
- Remove deprecated config keys: no-daemon, no-auto-flush, no-auto-import,
  auto-start-daemon, lock-timeout, daemon.* keys
- Remove auto-sync daemon setup wizard (Step 4) from bd init --team
- Clean up doctor checks: remove SQLite mtime divergence check, SQLite-only
  migrations, obsolete boolean config validation
- Replace all "bd init --backend dolt" references with "bd init"
- Simplify storage/dolt/open.go to always create Dolt store
- Change configfile.GetBackend() default from SQLite to Dolt
- Fix pre-existing build errors: AsVersioned removal, duplicate imports,
  missing compact/dirty stubs, signature mismatches, undefined functions

Also adds bridge/stub files for functions removed in prior phases:
- sync_bridge.go: exportToJSONL, importFromJSONL, doSyncFromMain, etc.
- import_shared.go: ImportOptions, ImportResult, importIssuesCore
- stubs.go: findJSONLPath, clearAutoFlushState, readFromGitRef
- dolt/compact.go, dolt/dirty_issues.go: no-op method stubs

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-15 15:43:11 -08:00
jasper
619f34a441 chore: add explanatory comments to silently ignored errors across codebase
Code health review found 30+ instances of error suppression using blank
identifier without explanation. Added comments to 82 files explaining WHY
each error is safely ignored (best-effort cleanup, advisory operations,
safe defaults, etc.) to improve code maintainability.

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

Executed-By: beads/polecats/jasper
Rig: beads
Role: polecats
2026-02-14 17:16:43 -08:00
beads/crew/emma
2137693dad revert: restore embedded Dolt mode (was only supposed to be removed from Gas Town)
Revert commits e5330641 and 0df41523 which removed embedded Dolt mode
from the beads codebase. The embedded Dolt removal was only intended for
Gas Town, not for Beads.

Restores:
- dolthub/driver dependency and embedded connection path
- Advisory flock (AccessLock) for concurrent process protection
- Embedded connector lifecycle management in DoltStore
- All CGO build tags across ~45 files
- Vendored go-icu-regex library
- nocgo stub files for non-CGO builds
- Bootstrap and embedded_uow helpers
- factory_dolt_test.go and dolt_singleprocess_test.go

Merge conflict resolutions:
- store.go: TCP fail-fast check wrapped inside if cfg.ServerMode
- store.go: backtick-quoting for embedded CREATE DATABASE (prefix-based names)
- perf_dolt.go: port references updated from 3306 to 3307
- ci.yml: restored continue-on-error for Nix (dolthub/driver requires Go 1.25.6+)

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-07 21:21:24 -08:00
obsidian
e533064122 feat: remove embedded Dolt mode, keep server-only connections (bd-esqfe)
Remove the embedded Dolt driver (dolthub/driver) and all associated code,
keeping only server-mode connections via MySQL protocol to dolt sql-server.

Key changes:
- Remove dolthub/driver dependency and go-icu-regex vendored dep
- Remove embedded connection path, access locks, bootstrap, nocgo stubs
- Remove CGO build tags from all ~40 files
- Remove CGO/ICU settings from Makefile and scripts/test.sh
- Simplify configfile: Dolt is always server mode now
- Update doctor checks, factory, daemon guard for server-only
- Binary size reduced from ~120MB to ~44MB

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

Executed-By: beads/polecats/obsidian
Rig: beads
Role: polecats
2026-02-05 21:30:53 -08:00
mayor
fe8d7c1f14 fix: eliminate dolt split-brain root cause (B1+B2) and fix CGO build
B1: DatabasePath() now always resolves to .beads/dolt/ for dolt backend,
ignoring stale Database field values like town, wyvern, beads_rig
that caused bd to look in the wrong directory.

B2: bootstrapEmbeddedDolt() now blocks JSONL auto-import in dolt-native
sync mode. If the dolt DB does not exist, it returns an error instead of
silently creating a new database from stale JSONL backup.

B-build: Makefile and scripts/test.sh now detect Homebrew keg-only
icu4c and export CGO_CFLAGS/CGO_CPPFLAGS/CGO_LDFLAGS so dolt
go-icu-regex dependency can compile and link.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 20:29:34 -08:00
mayor
0b25ff2468 feat: make embedded Dolt the default, server mode opt-in
- Remove auto-detection of running dolt sql-server in bd init; server
  mode now requires explicit --server flag
- Delete dead init_dolt_cgo.go and init_dolt_nocgo.go
- Doctor server check: embedded mode returns StatusOK not StatusWarning
- Update configfile comments to reflect embedded as default
- Fix store.go initSchemaOnDB using wrong receiver (s.db → db)
- Guard auto-import in dolt-native sync mode
- Update sync mode defaults and staleness checks for embedded-first

Closes: gt-dolt-embedded-default

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 16:23:24 -08:00
Eduardo Koloma Junior
7810c630b1 feat(config): add env var overrides for Dolt server connection settings
Enable Gas Town agent tmux sessions to configure Dolt server mode via
BEADS_DOLT_SERVER_* environment variables without modifying metadata.json.

Adds IsDoltServerMode(), GetDoltServerHost/Port/User/Database() getter
methods to configfile.Config with env var → config → default precedence.
Wires factory to populate server opts from config when server mode is active.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 20:18:21 +01:00
Ryan
27d6a8c2da
feat(doctor): make stale closed issues check configurable (#1291)
Add stale_closed_issues_days config option to metadata.json:
- 0 (default): Check disabled - repos keep unlimited beads
- >0: Enable check with specified day threshold

Design philosophy: Time-based cleanup is a crude proxy for the real
concern (database size). Disabled by default since a repo with 100
closed issues from 5 years ago doesn't need cleanup.

Also adds a warning when check is disabled but database has >10,000
closed issues, recommending users enable the threshold.

Co-Authored-By: SageOx <ox@sageox.ai>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-25 16:56:33 -08:00
mayor
13c362e67e feat(dolt): add server mode support for multi-client access
- Add dolt_mode, dolt_server_host, dolt_server_port fields to configfile.Config
- Add IsDoltServerMode(), GetDoltServerHost(), GetDoltServerPort() helpers
- Update factory to read server mode config and set Options accordingly
- Skip bootstrap in server mode (database lives on server)
- Pass Database name to dolt.Config for USE statement after connecting
- Disable dolt stats collection to avoid lock issues in embedded mode

This enables bd to connect to a running dolt sql-server (started via
'gt dolt start') instead of using embedded mode, allowing multi-client
access without file locking conflicts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 22:35:34 -08:00
beads/crew/emma
db0c6fbd3f fix(dolt): enable server mode for Gas Town integration (bd-nnjik)
- Skip Bootstrap when ServerMode is true (bootstrap is for embedded cold-start)
- Fix doltExists() to follow symlinks using os.Stat
- Pass database name from metadata.json to DoltStore config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 22:24:55 -08:00
emma
433115725b fix(dolt): server mode should support multi-process access
Code review fix: In server mode, Dolt connects to an external sql-server
and should NOT be single-process-only. The whole point of server mode is
to enable multi-writer access.

Changes:
- Add Config.GetCapabilities() method that considers server mode
- Update daemon_guard, daemon_autostart, daemons, main to use GetCapabilities()
- Add TestGetCapabilities test
- Update init command help text to document server mode flags

The existing CapabilitiesForBackend(string) is kept for backward compatibility
but now includes a note to use Config.GetCapabilities() when the full config
is available.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 20:20:59 -08:00
emma
484cd9d5fd feat(dolt): add server mode config to metadata.json schema (bd-dolt.2.2)
Add Dolt server mode configuration to metadata.json for multi-writer access:

- Add DoltMode, DoltServerHost, DoltServerPort, DoltServerUser fields to Config
- Add helper methods with sensible defaults (127.0.0.1:3306, root user)
- Update factory to read server mode config and pass to dolt.Config
- Add --server, --server-host, --server-port, --server-user flags to bd init
- Validate that --server requires --backend dolt
- Add comprehensive tests for server mode configuration

Example metadata.json for server mode:
{
  "backend": "dolt",
  "database": "dolt",
  "dolt_mode": "server",
  "dolt_server_host": "192.168.1.100",
  "dolt_server_port": 3306,
  "dolt_server_user": "beads"
}

Password should be set via BEADS_DOLT_PASSWORD env var for security.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 20:01:46 -08:00
Test
7ed6849d19 /{cmd,docs,internal,website}: make dolt backend explicitly single process 2026-01-20 16:51:14 -08:00
coffeegoddd☕️✨
422bc838ed /{website,internal,docs,cmd}: integration tests and more split backend fixes 2026-01-20 13:39:04 -08:00
mayor
669ea40684 feat(storage): add --backend flag for Dolt backend selection
Phase 2 of Dolt integration - enables runtime backend selection:

- Add --backend flag to bd init (sqlite|dolt)
- Create storage factory for backend instantiation
- Update daemon and main.go to use factory with config detection
- Update database discovery to find Dolt backends via metadata.json
- Fix Dolt schema init to split statements for MySQL compatibility
- Add ReadOnly mode to skip schema init for read-only commands

Usage: bd init --backend dolt --prefix myproject

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 21:42:31 -08:00
Steve Yegge
f4b8a7ad4f feat: change deletions TTL default from 7 to 3 days
Reduces the default retention period for deletion manifest entries.
Shorter TTL limits blast radius of stale deletions that can poison
beads installations when agents get out of sync.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 22:44:59 -08:00
Steve Yegge
dd8c7595ba fix: store version in gitignored .local_version to prevent notification spam (bd-tok)
Root cause: metadata.json is tracked in git and contains last_bd_version.
When git operations (pull, checkout, merge) reset metadata.json to the
committed version, the upgrade notification would fire repeatedly.

Fix: Store the last used bd version in .beads/.local_version which is
gitignored, so git operations don't affect version tracking.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 23:38:20 -08:00
Steve Yegge
ff3352ab23 bd-6xd: Standardize on issues.jsonl as canonical filename
- Change default JSONL filename from beads.jsonl to issues.jsonl
- Add bd doctor check and fix to auto-migrate legacy beads.jsonl configs
- Update FindJSONLPath to prefer issues.jsonl over beads.jsonl
- Add CheckLegacyJSONLConfig and CheckLegacyJSONLFilename checks
- Add LegacyJSONLConfig fix to rename files and update config
- Update .gitattributes to reference issues.jsonl
- Fix tests to expect new canonical filename
- Add bd-6xd to v0.25.1 release notes

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 22:02:59 -08:00
Steve Yegge
3f84ec3774 feat(deletions): add pruning and git history fallback
Implements two P1 tasks for the deletions manifest epic:

bd-v2x: Add deletions pruning to bd compact
- PruneDeletions function removes records older than retention period
- Default retention: 7 days (configurable via metadata.json)
- CLI --retention flag for override
- Atomic file rewrite prevents corruption
- Called automatically during all compact operations

bd-pnm: Add git history fallback for pruned deletions
- Catches deletions where manifest entry was pruned
- Uses git log -S to search for ID in JSONL history
- Batches multiple IDs for efficiency (git -G regex)
- Self-healing: backfills manifest on hit
- Conservative: keeps issue if git check fails (shallow clone)

Tests added for both features with edge cases covered.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 12:41:36 -08:00
Steve Yegge
d1641c7d2e Fix bd-afd: Auto-fix metadata.json jsonl_export mismatch
## Summary

When metadata.json gets deleted (git clean, merge conflict, rebase), the
version tracking code auto-recreates it using DefaultConfig() which hardcoded
jsonl_export to 'issues.jsonl'. But many repos (including beads itself) use
'beads.jsonl', causing a mismatch between config and actual JSONL file.

## Changes

1. **bd doctor --fix auto-detection** (cmd/bd/doctor/fix/database_config.go)
   - New DatabaseConfig() fix function that auto-detects actual JSONL file
   - Prefers beads.jsonl over issues.jsonl (canonical name)
   - Skips backup files and merge artifacts
   - Wired into doctor.go applyFixes()

2. **Version tracking auto-detection** (cmd/bd/version_tracking.go)
   - trackBdVersion() now scans for existing JSONL files before defaulting
   - Prevents mismatches when metadata.json gets recreated
   - Added findActualJSONLFile() helper function

3. **Canonical default name** (internal/configfile/configfile.go)
   - DefaultConfig() changed from issues.jsonl to beads.jsonl
   - Aligns with canonical naming convention

4. **FindJSONLPath preference** (internal/beads/beads.go)
   - Now prefers beads.jsonl over issues.jsonl when scanning
   - Default changed from issues.jsonl to beads.jsonl

5. **Test coverage**
   - Added comprehensive tests for DatabaseConfig fix
   - Updated configfile tests for new default
   - Verified backup file skipping logic

## Testing

- All existing tests pass
- New tests verify auto-fix behavior
- Integration tested with simulated mismatches

Closes: bd-afd
2025-11-23 23:11:08 -08:00
Steve Yegge
1f2a79dfce feat: Add built-in version tracking to bd (bd-loka)
Implement automatic bd version tracking and upgrade awareness:

- Add LastBdVersion field to Config struct in metadata.json
- Auto-update version on every bd command in PersistentPreRun
- Add 'bd upgrade' command with status/review/ack subcommands
- Show upgrade notifications on 'bd ready' and 'bd list'
- Non-intrusive: only shows once per session, skipped for JSON output

The system tracks version changes automatically and helps users stay
aware of bd upgrades without manual intervention. Notifications are
graceful - failures don't break commands.

Example output on bd ready after upgrade:
  🔄 bd upgraded from v0.22.0 to v0.24.2 since last use
  💡 Run 'bd upgrade review' to see what changed

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 17:09:17 -08:00
Steve Yegge
c4c5c8063a Fix: Change default JSONL filename from beads.jsonl to issues.jsonl
The canonical beads database name is issues.jsonl. Tens of thousands of users
have issues.jsonl, and beads.jsonl was only used by the Beads project itself
due to git history pollution.

Changes:
- Updated bd doctor to warn about beads.jsonl instead of issues.jsonl
- Changed default config from beads.jsonl to issues.jsonl
- Reversed precedence in checkGitForIssues to prefer issues.jsonl
- Updated git merge driver config to use issues.jsonl
- Updated all tests to expect issues.jsonl as the default

issues.jsonl is now the canonical default; beads.jsonl is legacy

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 23:34:22 -08:00
Steve Yegge
734579b1a2 Remove version field from metadata.json
- Removes noisy version mismatch warnings on every bd upgrade
- Version field in metadata.json was redundant with daemon version checking via RPC
- Daemon version mismatches still detected via HealthResponse
- Removes checkVersionMismatch() function and related test file
- Updates .beads/.gitignore to properly ignore merge artifacts

Amp-Thread-ID: https://ampcode.com/threads/T-7ba8aff2-97a0-4d0c-9008-e858bdfadd61
Co-authored-by: Amp <amp@ampcode.com>
2025-11-08 18:16:39 -08:00