Skip to content

feat(dolt): persist beads_global to GitHub on every dolt commit - #1800

Merged
shunkakinoki merged 2 commits into
mainfrom
dolt-fix
May 17, 2026
Merged

feat(dolt): persist beads_global to GitHub on every dolt commit#1800
shunkakinoki merged 2 commits into
mainfrom
dolt-fix

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Assert pkgs.dolt >= 1.86 so the home-manager dolt service can use the git+https remote scheme that backs up beads_global to refs/dolt/data.
  • Add a second launchd/systemd-path agent (dolt-backup-main) that watches the dolt manifest and pushes a JSONL snapshot of the live DB to refs/heads/main of the beads repo, so the data renders in the GitHub UI (the native dolt push only writes refs/dolt/data, which GitHub does not render).
  • Trigger: launchd WatchPaths on ~/dotfiles/.beads/beads_global/.dolt/noms/manifest with ThrottleInterval = 60; systemd path unit with PathChanged for the Linux equivalent.
  • Payload: bd --global export --all > issues.jsonl, then git diff --quiet-gated commit and push.
  • Mirror checkout lives at ~/.cache/beads-jsonl-mirror.

Test plan

  • shellcheck clean for home-manager/services/dolt/backup-dolt-main.sh and spec/backup_dolt_main_spec.sh
  • shellspec full suite: 1520 examples, 0 failures (new spec adds 17 examples; coverage spec updated)
  • nix fmt no changes
  • Verified on galactica: launchd-managed dolt is now 1.86.6 and dolt push origin main returns "Everything up-to-date" against the existing refs/dolt/data remote
  • Verify after make switch that dolt-backup-main agent loads and produces an issues.jsonl push on the next dolt commit

@indent-zero

indent-zero Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor
PR Summary

Builds out a "GitHub UI mirror" on top of the existing dolt sql-server service: when beads_global dolt commits flush the noms manifest, a launchd/systemd watcher fires a oneshot script that exports the beads dataset to issues.jsonl and pushes it to refs/heads/main of shunkakinoki/beads, so the data is browseable on github.com (dolt's native git+https push only writes refs/dolt/data). The earlier pkgs.dolt >= 1.86 activation assertion is unchanged in this revision.

  • Add home-manager/services/dolt/backup-dolt-main.sh: shallow-clone (first run) → fetch+reset to origin/mainbd --global export --all to a tempfile → atomic rename → diff check → commit (authored as beads-backup <shunkakinoki@gmail.com>) → git push origin main.
  • Extend home-manager/services/dolt/default.nix with doltManifest, mirrorDir, remoteUrl, userEmail, and a backupScript built via pkgs.replaceVars.
  • Darwin: new launchd.agents.dolt-backup-main with WatchPaths=[doltManifest], ThrottleInterval=60, RunAtLoad=false, KeepAlive=false, logs to /tmp/dolt-backup-main.{log,error.log}.
  • Linux: new systemd.user.services.dolt-backup-main (Type=oneshot) plus systemd.user.paths.dolt-backup-main (PathChanged=doltManifest, WantedBy=default.target).
  • Spec coverage: new spec/backup_dolt_main_spec.sh (surface-level shellspec checks) and matching entries in spec/coverage_spec.sh.

Issues

2 potential issues found:

  • Mirror keeps a stale origin URL if remoteUrl changes — the cache at ~/.cache/beads-jsonl-mirror only gets the new URL on first clone, so updating remoteUrl in default.nix would silently keep pushing to the old repo until the cache directory is wiped (trigger: any future rename/fork of the beads remote). → Autofix
  • First-run snapshot never commits: git diff --quiet -- issues.jsonl is checked before git add, so on the bootstrap run the file is untracked and the diff exits 0 ("no changes"), the script logs "no JSONL changes; skipping commit" and exits without ever seeding the mirror — repeated runs do the same until someone manually puts an issues.jsonl on origin/main. → Autofix
1 issue already resolved
  • Assertion message contains the literal HTML entity &gt;= instead of >=, so the activation failure will read "needs >= 1.86 ..." (verified with cat -A); the same artifact appears in the commit subject.

CI Checks

Waiting for CI checks...


⚡ Autofix All Issues

@coderabbitai

coderabbitai Bot commented May 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Dolt service module in Home Manager is updated to enforce a minimum version constraint of 1.86 for the pkgs.dolt package, adding a versioned assertion with an explanatory error message tied to git+https remote scheme functionality required by the beads global GitHub backup.

Changes

Dolt service version enforcement

Layer / File(s) Summary
Version constant and assertion
home-manager/services/dolt/default.nix
Introduces doltMinVersion = "1.86" constant and adds an assertion within the existing lib.mkIf enabled block that validates pkgs.dolt.version >= doltMinVersion, with an error message explaining the requirement for git+https:// remote scheme functionality.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • shunkakinoki/dotfiles#1276: Adds the dolt package to the default Home Manager package list, complementing this PR's version constraint enforcement.
  • shunkakinoki/dotfiles#1485: Earlier modification to the Dolt Home Manager service module logic, providing context for this version requirement update.

Poem

🐰 A rabbit hops through Nix with glee,
Dolt must be version eighty-three—
Plus another six for the push so right,
git+https shines in the moonlit night!

🚥 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 focuses on persisting beads_global to GitHub via dolt commits, but the primary change shown in the raw summary is enforcing a minimum dolt version (1.86) with an assertion. The title is partially related but doesn't highlight the main technical change.
Description check ✅ Passed The description is directly related to the changeset, providing context about the dolt version assertion, backup mechanisms, and test plan coverage.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 dolt-fix

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 and usage tips.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a version check for the Dolt package in the Home Manager service configuration. It adds a minimum version requirement of 1.86 to support the git+https remote scheme used for backups and includes an assertion to ensure the installed version meets this requirement. I have no feedback to provide.

@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 1 file

Re-trigger cubic

Comment thread home-manager/services/dolt/default.nix
@shunkakinoki shunkakinoki changed the title feat(dolt): assert dolt >= 1.86 for git+https remote push feat(dolt): persist beads_global to GitHub on every dolt commit May 17, 2026
@shunkakinoki
shunkakinoki merged commit 46aad99 into main May 17, 2026
28 of 29 checks passed
@shunkakinoki
shunkakinoki deleted the dolt-fix branch May 17, 2026 18:42
mv issues.jsonl.tmp issues.jsonl

if "${GIT}" diff --quiet -- issues.jsonl; then
echo "no JSONL changes; skipping commit"

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.

First-run bug: bootstrap commit is silently skipped.

At this point issues.jsonl is still untracked in the mirror — we've only mv'd it into the working tree. git diff --quiet -- issues.jsonl only reports differences for tracked files, so on an untracked file it returns 0 (no diff). The script logs no JSONL changes; skipping commit and exits 0 without ever running git add / git commit / git push, so the mirror never gets seeded.

Reproducer:

cd $(mktemp -d) && git init -q && git commit --allow-empty -m init -q
echo hi > issues.jsonl
git diff --quiet -- issues.jsonl; echo $?   # prints 0

Since the script's first effective run on any fresh machine starts with a mirror that doesn't yet contain issues.jsonl (we just reset --hard origin/main), this is the case that always hits. Subsequent runs are also stuck because git add never runs.

Fix: stage first, then check the index:

"${GIT}" add issues.jsonl
if "${GIT}" diff --cached --quiet -- issues.jsonl; then
  echo "no JSONL changes; skipping commit"
  exit 0
fi

Verified: after git add on the untracked file, git diff --cached --quiet -- issues.jsonl exits 1, so the commit/push path runs.

Suggested change
echo "no JSONL changes; skipping commit"
"${GIT}" add issues.jsonl
if "${GIT}" diff --cached --quiet -- issues.jsonl; then
echo "no JSONL changes; skipping commit"
exit 0
fi
"${GIT}" \


if [ ! -d "${MIRROR}/.git" ]; then
"${GIT}" clone --depth 1 "${REMOTE}" "${MIRROR}"
fi

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.

Latent: mirror never picks up a changed remoteUrl.

The git clone is gated by [ ! -d "${MIRROR}/.git" ], and nothing later calls git remote set-url. Because the mirror lives in ~/.cache/beads-jsonl-mirror (persisted across home-manager rebuilds), any future change to remoteUrl in default.nix (rename, fork, switch to SSH) will be silently ignored — fetch/push keep hitting whatever URL is baked into the existing .git/config.

Trigger condition: changing remoteUrl in home-manager/services/dolt/default.nix while the cache directory already exists.
Consequence: push silently goes to the wrong repo or fails with a 404/permission error until the user manually rm -rf ~/.cache/beads-jsonl-mirror.

Fix: make it idempotent by always reconciling the URL after the clone gate, e.g.:

"${GIT}" -C "${MIRROR}" remote set-url origin "${REMOTE}"
Suggested change
fi
if [ ! -d "${MIRROR}/.git" ]; then
"${GIT}" clone --depth 1 "${REMOTE}" "${MIRROR}"
fi
"${GIT}" -C "${MIRROR}" remote set-url origin "${REMOTE}"

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