Skip to content

feat: add dolt-data-dir config for custom dolt data directory#2143

Merged
steveyegge merged 4 commits intosteveyegge:mainfrom
marcodelpin:feat/dolt-data-dir
Feb 26, 2026
Merged

feat: add dolt-data-dir config for custom dolt data directory#2143
steveyegge merged 4 commits intosteveyegge:mainfrom
marcodelpin:feat/dolt-data-dir

Conversation

@marcodelpin
Copy link
Contributor

Summary

Adds a dolt_data_dir config option (+ BEADS_DOLT_DATA_DIR env var) that lets dolt store its data in a custom directory instead of the default .beads/dolt/.

This is useful for environments where the project directory lives on a slow filesystem (e.g., WSL with NTFS via 9P mount) but dolt data can be placed on a faster native filesystem for 5-10x I/O speedup.

Changes (7 files, +81 -15)

  • configfile.go: New DoltDataDir field, GetDoltDataDir() (env var + config), updated DatabasePath() to respect custom dir
  • doltserver.go: New ResolveDoltDir() helper, replaced 4 hardcoded filepath.Join(beadsDir, "dolt") calls
  • dolt.go: Added data-dir key to bd dolt set command with absolute path validation
  • init.go: 3 hardcoded dolt paths replaced with ResolveDoltDir(), passes BeadsDir to Config
  • main.go: Uses FindBeadsDir() instead of filepath.Dir(dbPath) for correct resolution when data dir is external
  • store.go: New BeadsDir field in Config for server auto-start when Path points to custom location
  • open.go: Sets BeadsDir in NewFromConfigWithOptions

Usage

# Via bd CLI
bd dolt set data-dir /fast/disk/beads-data/myproject

# Via environment variable
export BEADS_DOLT_DATA_DIR=/fast/disk/beads-data

# In metadata.json
{ "dolt_data_dir": "/fast/disk/beads-data/myproject" }

Backward compatibility

Fully backward compatible — without dolt_data_dir set, all behavior is unchanged (default .beads/dolt/).

Test plan

  • Tested on 47 projects (31 with imported issues, 2,700+ total), 0 errors
  • Verified 5-10x performance improvement (ext4 vs NTFS/9P on WSL)
  • bd init, bd stats, bd list, bd create, bd close all work with custom data dir
  • Server auto-start correctly resolves custom data dir
  • Clearing data-dir (bd dolt set data-dir "") reverts to default behavior
  • Environment variable BEADS_DOLT_DATA_DIR takes precedence over config

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
When dolt_data_dir points to an external directory (e.g., ext4 on WSL
instead of slow NTFS), the PersistentPreRun code derived beadsDir from
filepath.Dir(dbPath) which returned the parent of the custom data dir
instead of the actual .beads/ directory. This caused config loading to
fail with "issue_prefix config is missing".

Changes:
- main.go: Use beads.FindBeadsDir() instead of filepath.Dir(dbPath)
- init.go: Use ResolveDoltDir() for initDBPath (line 152)
- store.go: Add BeadsDir field to Config for correct auto-start
- open.go: Set BeadsDir in NewFromConfigWithOptions
@codecov-commenter
Copy link

codecov-commenter commented Feb 26, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
4026 1 4025 451
View the full list of 1 ❄️ flaky test(s)
::TestMain

Flake rate in main: 100.00% (Passed 0 times, Failed 9 times)

Stack Traces | 0s run time
WARN: dolt not found in PATH, skipping test server
PASS
coverage: 17.7% of statements
ERROR: test suite modified repo .beads state:
- metadata.json: exists false → true

FAIL	github..../beads/cmd/bd	14.994s

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

ResolveDoltDir called configfile.Load() which triggers a legacy
config.json → metadata.json migration, creating files in .beads/
unexpectedly during tests.

Fix: check metadata.json existence before calling Load(), and
check BEADS_DOLT_DATA_DIR env var first (no filesystem access).
FindBeadsDir() walks up from CWD and finds the repo's .beads/
directory during CI tests. This triggers version_tracking.go's
"ensure metadata.json exists" logic which creates metadata.json
in the repo's .beads/, failing the test suite's state guard.

Revert to filepath.Dir(dbPath) for beadsDir derivation while
keeping ResolveDoltDir() for the dolt data path resolution.
@steveyegge steveyegge merged commit 21ca845 into steveyegge:main Feb 26, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants