Skip to content

fix(dolt): align Beads shared server storage - #2167

Merged
shunkakinoki merged 4 commits into
mainfrom
codex/fix-beads-shared-server
Jul 26, 2026
Merged

fix(dolt): align Beads shared server storage#2167
shunkakinoki merged 4 commits into
mainfrom
codex/fix-beads-shared-server

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • point the Home Manager Dolt service at Beads’ canonical shared-server data root
  • export BEADS_SHARED_SERVER_DIR so bd and launchd resolve the same storage
  • add regression coverage for both paths

Validation

  • shellspec spec/dolt_start_spec.sh (14 examples, 0 failures)
  • make nix-format-check
  • make build
  • live bd list, bd doctor --server --agent --json, bd dolt pull, and bd dolt push against the repaired v59 databases

Activation note

make switch activated the Nix configuration and restarted Dolt successfully. The enclosing target later failed in the unrelated dotagents-sync step because that project has no sync make target.


Summary by cubic

Align Dolt’s data directory with Beads’ shared-server storage and migrate safely from repo-local databases. Ensures bd and launchd share the same data.

  • Bug Fixes
    • Serve databases from ~/.beads/shared-server/dolt.
    • Export BEADS_SHARED_SERVER_DIR so bd and launchd resolve the same path.
    • Safely migrate from ~/dotfiles/.beads (skip symlinks, require .dolt, don’t overwrite; map doltdf during migration only).
    • Expand shellspec for migration and path config; use a portable fake dolt and mark Nix literals to avoid ShellCheck noise.

Written for commit b44b899. Summary will update on new commits.

Review in cubic

@indent-zero

indent-zero Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor
PR Summary

Aligns the home-manager-managed dolt sql-server data directory with beads' canonical shared-server layout (~/.beads/shared-server/dolt/) so bd in shared-server mode and the launchd/systemd-supervised sql-server operate on the same on-disk tree, and safely migrates pre-existing databases from the old per-project location into it.

  • Moves beadsDir from ${repoDir}/.beads to ${homeDir}/.beads/shared-server/dolt and introduces legacyBeadsDir = "${repoDir}/.beads" in home-manager/services/dolt/default.nix.
  • Exports BEADS_SHARED_SERVER_DIR = sharedServerDir in home.sessionVariables so bd's SharedServerPath() and the sql-server resolve the same root.
  • Rewrites start.sh migration: instead of a blanket ${beadsDir}/dolt → df rename, it iterates ${legacyBeadsDir}/*, skips entries lacking a .dolt marker (so config.yaml/README.md are left alone), skips symlinks, never overwrites an existing destination, and remaps a legacy dolt database name to df only when df doesn't already exist in the shared root.
  • spec/dolt_start_spec.sh gains four behavior tests (using a Before/After harness that renders start.sh into a temp dir) covering the happy-path migration, non-overwrite of existing shared-root DBs, the legacy dolt → df name mapping, and non-interference with a legitimate dolt DB in the shared root. The default.nix Describe is hoisted to the top level so file/spec grouping stays clean.

Issues

All clear! No issues remaining. 🎉

3 issues already resolved
  • Data at the old ~/dotfiles/.beads/<db>/ location isn't migrated to the new ~/.beads/shared-server/dolt/ tree, so on any machine that already ran the previous version bd will silently appear to lose history (bytes stay on disk, just aren't served) until the user copies them by hand — trigger: first activation on a pre-existing installation. (fixed by commit 5ec5369)
  • start.sh still runs mv "${beadsDir}/dolt" "${beadsDir}/df" on boot, but ${beadsDir} is now bd's shared per-database root — trigger: if any bd project ever ends up with a database literally named dolt (e.g. bd init in a dir called dolt), the shared server will rename that whole database to df on next launch. (fixed by commit 5ec5369)
  • The new Describe 'home-manager/services/dolt/default.nix' block in spec/dolt_start_spec.sh is opened before the outer Describe 'home-manager/services/dolt/start.sh' closes, so assertions about default.nix run grouped under a parent that documents a different file. (fixed by commit 5ec5369)

CI Checks

Waiting for CI checks...

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@mesa-dot-dev

mesa-dot-dev Bot commented Jul 26, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@shunkakinoki
shunkakinoki enabled auto-merge (squash) July 26, 2026 18:39
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Dolt Home Manager module now stores beads data beneath homeDir/.beads/shared-server, serves databases from its dolt subdirectory, and exports BEADS_SHARED_SERVER_DIR. Shell specifications verify the updated path derivation and environment variable.

Changes

Dolt shared-server configuration

Layer / File(s) Summary
Shared-server path and validation
home-manager/services/dolt/default.nix, spec/dolt_start_spec.sh
The module derives sharedServerDir from homeDir, uses its dolt subdirectory for beadsDir, exports BEADS_SHARED_SERVER_DIR, and adds assertions covering these values.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Poem

A bunny found a shared-server trail,
Where beads and Dolt databases sail.
The path is neat, the tests agree,
An exported variable hops free!
Flip-flop, configured happily.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly reflects the main change: aligning Dolt storage with Beads shared-server storage.
Description check ✅ Passed The description is directly related to the changeset and accurately summarizes the storage path and regression coverage updates.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-beads-shared-server

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
spec/dolt_start_spec.sh (1)

70-87: 🗄️ Data Integrity & Integration | 🔵 Trivial | 🏗️ Heavy lift

Assert evaluated configuration rather than source text.

These grep checks only prove that the literal assignments exist in default.nix; they do not verify that Home Manager evaluates them or that bd and launchd receive the same path. Prefer the repository’s Nix/Home Manager test harness, or add evaluated-value assertions plus a regression check that the old path is no longer used.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@spec/dolt_start_spec.sh` around lines 70 - 87, The tests in the “Describe
home-manager/services/dolt/default.nix” block currently grep source text instead
of validating evaluated Home Manager configuration. Replace these checks with
the repository’s Nix/Home Manager test harness, asserting the evaluated
sharedServerDir, beadsDir, and BEADS_SHARED_SERVER_DIR values are identical and
verifying launchd/bd receive that path; also assert the obsolete path is absent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@spec/dolt_start_spec.sh`:
- Around line 70-87: The tests in the “Describe
home-manager/services/dolt/default.nix” block currently grep source text instead
of validating evaluated Home Manager configuration. Replace these checks with
the repository’s Nix/Home Manager test harness, asserting the evaluated
sharedServerDir, beadsDir, and BEADS_SHARED_SERVER_DIR values are identical and
verifying launchd/bd receive that path; also assert the obsolete path is absent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b2156c67-2a8b-4f5c-b13e-1e956eb9108d

📥 Commits

Reviewing files that changed from the base of the PR and between 52fa213 and 2dd22b5.

📒 Files selected for processing (2)
  • home-manager/services/dolt/default.nix
  • spec/dolt_start_spec.sh

Comment thread home-manager/services/dolt/default.nix
Comment thread spec/dolt_start_spec.sh

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@shunkakinoki

Copy link
Copy Markdown
Owner Author

Addressed the review findings in 5ec5369d:

  • startup now migrates real Dolt databases from the legacy ~/dotfiles/.beads root into the canonical shared-server root
  • existing canonical databases always win, so activation cannot overwrite a newer clone
  • the old dolt name maps to df only while crossing the legacy-root boundary; a legitimate canonical dolt database is preserved
  • the module spec is now top-level, and migration coverage executes the rendered startup script against temporary old/new database trees

Revalidated: shellspec spec/dolt_start_spec.sh (16/16), make nix-format-check, and make build.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="home-manager/services/dolt/start.sh">

<violation number="1" location="home-manager/services/dolt/start.sh:21">
P2: A dangling symlink at a canonical database path makes Dolt fail to start instead of preserving the existing destination. Treat symlinks as occupied targets before invoking `mv`.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

target_name="df"
fi

if [ -e "@beadsDir@/$target_name" ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: A dangling symlink at a canonical database path makes Dolt fail to start instead of preserving the existing destination. Treat symlinks as occupied targets before invoking mv.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/services/dolt/start.sh, line 21:

<comment>A dangling symlink at a canonical database path makes Dolt fail to start instead of preserving the existing destination. Treat symlinks as occupied targets before invoking `mv`.</comment>

<file context>
@@ -1,15 +1,29 @@
+    target_name="df"
+  fi
+
+  if [ -e "@beadsDir@/$target_name" ]; then
+    continue
+  fi
</file context>
Suggested change
if [ -e "@beadsDir@/$target_name" ]; then
if [ -e "@beadsDir@/$target_name" ] || [ -L "@beadsDir@/$target_name" ]; then

@shunkakinoki
shunkakinoki merged commit 6f4affb into main Jul 26, 2026
35 checks passed
@shunkakinoki
shunkakinoki deleted the codex/fix-beads-shared-server branch July 26, 2026 19:23
@shunkakinoki
shunkakinoki restored the codex/fix-beads-shared-server branch July 26, 2026 19:37
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.

1 participant