Skip to content

fix: remote dolt server support — backup, push, pull#3595

Draft
trillium wants to merge 20 commits into
gastownhall:mainfrom
trillium:fix/backup-remote-server-path
Draft

fix: remote dolt server support — backup, push, pull#3595
trillium wants to merge 20 commits into
gastownhall:mainfrom
trillium:fix/backup-remote-server-path

Conversation

@trillium

@trillium trillium commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes multiple operations that break when beads connects to a remote dolt server (e.g., host: mini2) instead of localhost.

Root cause: Several code paths assume local filesystem access — sending file:// URLs to a remote server, or requiring a local dolt CLI directory that doesn't exist.

Fixed so far

  • backup export: Detects remote server, falls back to JSONL export instead of CALL DOLT_BACKUP with local path
  • push/pull: Skips CLI-dir guard clauses for remote servers, falls through to SQL path (CALL DOLT_PUSH/CALL DOLT_PULL)

Coming

  • backup init: Same file:// URL problem as backup export
  • BackupDatabase() store method: Underlying store function needs remote guard

🚧 Work in progress — more changes coming

Test plan

  • TestIsRemoteHost — 10 subtests (local/remote host detection)
  • TestIsRemoteDoltServer — 4 subtests (config-based detection)
  • TestIsRemoteServer — 8 subtests (store-level detection)
  • TestRemoteServerPushSkipsCLIDirGuard
  • TestRemoteServerPullSkipsCLIDirGuard
  • TestLocalServerPushStillRequiresCLIDir
  • Backup init remote guard tests (coming)
  • BackupDatabase store method tests (coming)

@trillium trillium force-pushed the fix/backup-remote-server-path branch from e8fa487 to 11983f3 Compare April 29, 2026 20:04
@trillium trillium changed the title fix(backup): skip DOLT_BACKUP for remote servers, fall back to JSONL fix: remote dolt server support — backup, push, pull Apr 29, 2026
@codecov-commenter

codecov-commenter commented Apr 29, 2026

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@trillium trillium force-pushed the fix/backup-remote-server-path branch from 7ce0b17 to 773d23f Compare April 30, 2026 20:56
@maphew maphew requested a review from coffeegoddd May 6, 2026 04:26
@trillium trillium force-pushed the fix/backup-remote-server-path branch 18 times, most recently from 4ec26be to 2a36d35 Compare May 16, 2026 13:43
@trillium trillium force-pushed the fix/backup-remote-server-path branch 7 times, most recently from dad87a1 to 63db715 Compare May 17, 2026 22:33
@trillium trillium force-pushed the fix/backup-remote-server-path branch 10 times, most recently from 224c8aa to df8604f Compare June 11, 2026 18:17
trillium added 20 commits June 15, 2026 20:54
Add tests for isRemoteHost() and isRemoteDoltServerForDir() that verify
remote hosts (LAN IPs, hostnames, FQDNs) are correctly identified.

These tests currently FAIL because isRemoteHost() is stubbed to always
return false — it does not yet detect remote servers. The next commit
will implement the fix.
… (green)

Implement isRemoteHost() to correctly identify non-localhost hosts.
In runBackupExport(), check isRemoteDoltServer() before calling
DOLT_BACKUP. When the server is remote, fall back to JSONL export
via exportToFile() which queries data through SQL SELECT and writes
locally — working correctly regardless of server location.

This prevents DOLT_BACKUP('add', ..., 'file:///local/path') from
sending local filesystem paths to remote servers, which would cause
the remote server to create garbage directories on its own filesystem.
…g (red)

Tests verify that pushToRemote and pullFromRemote on a remote Dolt server
(e.g., host=mini2) skip the CLI-dir guard and fall through to the SQL path
(CALL DOLT_PUSH/DOLT_PULL). Currently fails to compile because the
serverHost field and isRemoteServer method don't exist yet.
When beads is configured with dolt_mode: server pointing at a remote
host (e.g., mini2), pushToRemote and pullFromRemote now skip the
CLI-dir error guards and fall through to the SQL path (CALL DOLT_PUSH /
CALL DOLT_PULL). The SQL command is sent to the remote server which
executes it server-side, so no local CLI directory is needed.

Changes:
- Add serverHost field to DoltStore, populated from Config.ServerHost
- Add isRemoteServer() method using existing isLocalHost() helper
- Guard the two CLI-dir error paths in pushToRemote with !isRemoteServer()
- Guard the two CLI-dir error paths in pullFromRemote with !isRemoteServer()
- Tests verify remote servers bypass the guard, local servers still hit it
…ds (red)

Tests verify that BackupDatabase() and RestoreDatabase() on DoltStore reject
remote servers (file:// URLs sent to remote hosts create dirs on wrong machine),
and that backup init with file:// URL + remote server returns an error while
DoltHub/cloud URLs still work.

User stories: docs/REMOTE_SERVER_USER_STORIES.md (Backup section)
… (green)

BackupDatabase() and RestoreDatabase() on DoltStore now check isRemoteServer()
and return a clear error instead of sending file:// URLs to the remote host.

backup init also guards: file:// URLs + remote server = error, while cloud
URLs (DoltHub, S3, GCS) pass through since the remote server can reach them.

User stories: docs/REMOTE_SERVER_USER_STORIES.md (Backup section)
Add stories for: explicit output location requirement, DoltHub URL passthrough
for remote servers, and clearer error messaging guidance.
…red)

Tests verify that bd backup sync on a remote Dolt server returns a
helpful error suggesting bd export -o when no cloud backup URL is
configured, instead of letting the user hit confusing filesystem errors.
When connected to a remote Dolt server, bd backup sync now checks
whether a cloud backup destination (DoltHub, S3, GCS) is configured.
If only a filesystem path or no backup is configured, it returns a
clear error suggesting bd export -o for JSONL export instead of
letting the sync fail with a confusing server-side filesystem error.
…hable server (red)

Verifies that connection errors use the format "cannot connect to dolt
server at <host>:<port>" instead of raw driver errors or "Dolt server
unreachable" messages. Also verifies the error completes within a
reasonable timeout.
…(green)

Change connection error messages from "Dolt server unreachable at" to
"cannot connect to dolt server at <host>:<port>" for all three failure
paths: auto-start failed, auto-started but still unreachable, and no
auto-start. This gives users a clear, consistent message when the SQL
connection is down, matching the user story contract.

The DSN already has a 5s connect timeout via doltutil.ServerDSN, and
the fail-fast TCP dial uses 500ms, so connections don't hang.
…g (red)

Tests expect pushToRemote and pullFromRemote to wrap Dolt's raw SQL
"remote not found" error with a user-friendly message explaining that
no remotes are configured on the server.
…ge (green)

When DOLT_PUSH or DOLT_PULL fails because no remotes are configured on
the server, wrap the raw SQL error with a clear message: "no remotes
configured on the dolt server; configure a remote on the server first".
When beads is connected to a remote Dolt server, filesystem-dependent
doctor checks (Dolt Format, Remote Consistency, Btrfs NoCOW) should
return "skip" status with message "skipped: remote server mode" instead
of misleading errors about missing directories.

Also stubs checkBackupSyncRemoteGuard so the test package compiles
(pre-existing red test from bc72bff).
Add StatusSkip constant and IsRemoteServerMode() detection to the doctor
package. When the configured Dolt server host is not localhost, checks
that access the local .dolt/ directory now return "skip" status with
message "skipped: remote server mode" instead of misleading errors about
missing directories.

Skipped checks: Dolt Format, Remote Consistency, Btrfs NoCOW (dolt).
SQL-based checks (Dolt Locks, schema, etc.) still run normally since
they query the remote server. The printDiagnostics output shows skip
count in the summary header.
…d decisions

- Remove duplicate checkBackupSyncRemoteGuard stub added by doctor agent
  (real implementation at line 201, stub at line 489)
- Update user stories: resolve config conflict decision (remote host wins,
  CLI dir ignored with warning), fix backup export stories to match reality
  (bd export -o exists, auto-backup JSONL fallback works), expand general
  principle exceptions, remove connection timeout from out-of-scope
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.

2 participants