beads/internal/storage/versioncontrolops
Julian Knutsen 4e4ebdb443
feat(backup): proxied auto-backup on managed-local, serialized with bd backup sync (#6879)
* feat(backup): run opted-in auto-backup on a managed-local proxied server

#6584 routed the five `bd backup` verbs over the proxied provider on
managed-local, and #6694 made `bd backup status` admit the remaining gap:
the proxied arm of PersistentPostRunE never called runPostRunAutoBackup,
so backup.enabled=true was inert on every proxied workspace. Close it.

The proxied arm now calls the auto-backup hook before it closes the
provider, under the direct arm's maintenance gate (strict --readonly,
`bd serve`, a migration freeze) plus previews. maybeAutoBackup picks a
backend for the command: the direct store as before, or the proxied
provider's RunNonTx seam, which `bd backup sync` already uses.

The proxied backend is honored exactly where `bd backup sync` is: the
"backup sync" capability row's rule for this workspace's topology, so
managed-local only. Auto-backup registers a server-side backup remote,
which on a server bd does not own is global to every client; an implicit
trigger must not get further than the explicit verb. It never opens a
provider of its own: a command that opened none (`bd dolt stop`) or
closed it (restore) backs nothing up rather than relaunching the server.
The default stays OFF, as on every server-mode workspace.

The register/sync-to-a-local-dir sequence that DoltStore and
EmbeddedDoltStore each carried a copy of moves to
versioncontrolops.BackupToDir (and HEAD lookup to CurrentCommit), so the
proxied backend reuses it instead of adding a third copy.

Tests: TestManagedLocalProxiedAutoBackup (default off, opt-in writes a
restorable backup, change detection, `bd dolt stop` stays quiescent,
restore round trip with issue-set equality; fails against origin/main);
TestManagedLocalProxiedBackupRestoreRefusedWhileAttached pins the restore
design (refused while another bd client holds the workspace, serving
child untouched, succeeds once it detaches); unit tests for the backend
locality gate, the post-run wiring, the status note and BackupToDir.
Both managed-local tests, and the existing round trip, are added to the
proxied-local smoke lane's compiled-in list.

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

* fix(backup): serialize auto-backup and bd backup sync with a workspace backup lock

Review follow-up on #6879. Auto-backup and an explicit bd backup sync
both run under the command's SHARED workspace gate, so nothing stopped
them overlapping, and auto-backup's remove -> add -> sync on one fixed
remote name races a concurrent copy of itself.

A per-workspace flock (.beads/backup.lock, already gitignored by
*.lock) now serializes them in every mode. Auto-backup takes it
non-blocking and skips when held (the throttle is left alone, so a
later command retries). bd backup sync waits up to exclusiveGateWait -
the bound restore's exclusive gate acquisition uses - then fails with
"another backup is running for this workspace" before touching the
store. Restore needs no part in it: its exclusive workspace gate
already excludes every command that could hold the lock.

Tests: lock semantics (refusal while held, bounded wait, release),
auto-backup skipping while held and running once released, and sync
failing loudly without reaching the store.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 02:45:58 -07:00
..
automerge.go fix(automerge): settled merges must mint a row_lock distinct from both parents (absorbed from #4682) (#5245) 2026-08-02 06:21:35 -07:00
automerge_test.go fix(automerge): settled merges must mint a row_lock distinct from both parents (absorbed from #4682) (#5245) 2026-08-02 06:21:35 -07:00
backup.go feat(backup): proxied auto-backup on managed-local, serialized with bd backup sync (#6879) 2026-09-28 02:45:58 -07:00
backup_test.go feat(backup): proxied auto-backup on managed-local, serialized with bd backup sync (#6879) 2026-09-28 02:45:58 -07:00
blocked_recompute.go feat(recompute-blocked): port to proxied-server mode + cross-mode cascade parity suite (bd-04vav) (#5363) 2026-08-05 12:11:53 -07:00
branches.go /{cmd,internal}: wip sync and data EmbeddedDoltStore methods 2026-03-24 12:01:16 -07:00
BUILD.bazel test(bazel): fully green //..., tag taxonomy + docker lane, sharding, test sandbox ceiling (#6871) 2026-09-27 20:19:38 -07:00
clone.go feat(storage): carry the git data ref of a git-backed Dolt remote (#6521) 2026-09-27 15:56:18 -07:00
clone_test.go feat(storage): carry the git data ref of a git-backed Dolt remote (#6521) 2026-09-27 15:56:18 -07:00
commit.go fix(schema): widen issue_versions.change_at to DATETIME(6) before any store accumulates real history (#6675) 2026-09-27 01:21:20 -07:00
commit_empty_test.go fix(storage): skip empty Dolt commit when nothing is staged (re-port of #4288) (#5403) 2026-08-07 10:32:31 -07:00
compact.go fix(gc): prune remote-tracking refs before post-squash GC (bd-agctw) 2026-07-18 07:26:17 -07:00
conflicts.go fix(automerge): tell a no-op merge write from a vanished row (wy-o8swn) 2026-07-25 04:50:05 -07:00
conflicts_test.go fix(automerge): tell a no-op merge write from a vanished row (wy-o8swn) 2026-07-25 04:50:05 -07:00
db.go /{cmd,internal}: wip sync and data EmbeddedDoltStore methods 2026-03-24 12:01:16 -07:00
envguards.go fix(dolt): scrub stderr-directed git tracing before git-remote transfers (#5323) 2026-08-10 05:25:15 -07:00
fastforward.go fix(schema): stop the smart gate auto-migrating a data-behind clone (#6575) (#6658) 2026-09-21 02:49:05 -07:00
fastforward_test.go feat(gate): non-destructive fast-forward adopt detection (adopt-ff, #4551 follow-up 2) (#4586) 2026-07-07 05:58:28 -07:00
flatten.go fix(gc): prune remote-tracking refs before post-squash GC (bd-agctw) 2026-07-18 07:26:17 -07:00
gc.go fix(gc): flatten/compact run full GC after the rewrite; bd gc --full; low-reclaim hint (#5907) (#6057) 2026-08-29 05:19:06 +00:00
gc_test.go fix(gc): flatten/compact run full GC after the rewrite; bd gc --full; low-reclaim hint (#5907) (#6057) 2026-08-29 05:19:06 +00:00
mergesettle.go fix(dolt): harden Pull() merge-landed post-condition per multi-model review (#5983) 2026-08-24 04:16:19 -07:00
remoterefs.go fix(gc): prune remote-tracking refs before post-squash GC (bd-agctw) 2026-07-18 07:26:17 -07:00
remotes.go feat(storage): carry the git data ref of a git-backed Dolt remote (#6521) 2026-09-27 15:56:18 -07:00
remotes_githooks_test.go fix(dolt): disable git hooks on the in-process push path too (#4272) (#5186) 2026-07-31 09:42:50 -07:00
remotes_gittrace_test.go fix(dolt): scrub stderr-directed git tracing before git-remote transfers (#5323) 2026-08-10 05:25:15 -07:00
remotes_test.go feat(storage): carry the git data ref of a git-backed Dolt remote (#6521) 2026-09-27 15:56:18 -07:00
version_control.go fix(compact): replay cherry-picks in commit_order, not commit date (#6644) 2026-09-27 02:06:57 -07:00