Repository navigation
Description
Summary
bm cloud sync --name X is currently hardcoded as a one-way local → cloud mirror (makes the cloud bucket identical to local). Underlying rclone sync supports a remote as either the source or the destination, so we can expose the reverse direction (one-way cloud → local) without changing transport.
Motivation
Today the only way to pull cloud state down to local is bm cloud bisync (two-way) or a snapshot restore. There's no one-way pull equivalent of the upload sync. Useful cases:
- Hydrating a fresh machine from cloud without establishing a bisync baseline
- Forcing local to match cloud after manual cloud edits (e.g., web UI, API)
- Recovery / re-mirror when local bisync state is corrupt and
--resyncis too risky - Symmetry with
bm cloud sync(upload) — abm cloud pull(download) reads naturally
Current state
project_sync() in src/basic_memory/cli/commands/cloud/rclone_commands.py:187 builds:
rclone sync <local_path> <remote_path> ...
…with source/dest hardcoded.
Proposed change
Add a direction option. Two reasonable shapes — pick one:
Option A — flag on existing command:
bm cloud sync --name research # default: local → cloud (unchanged)
bm cloud sync --name research --direction pull # cloud → localOption B — separate command (clearer intent, harder to misuse):
bm cloud sync --name research # local → cloud (unchanged)
bm cloud pull --name research # cloud → localEither way, the implementation in project_sync() swaps the source/dest args to rclone sync. Because rclone sync is destructive on the destination, the cloud → local direction will delete local files not present in the cloud — --dry-run must be the default suggestion in the docs and surfaced prominently in the command help.
Open questions
- Should
--direction pullbe gated behind a confirmation prompt (or require--force) given it can delete local files? - Does the existing bisync filter (
get_bmignore_filter_path()) compose correctly when the cloud side is source? (Likely yes, since filters apply to both sides — worth verifying.) - Interaction with per-project cloud routing and bisync state: pulling should probably not touch bisync metadata, but we should think through whether a subsequent
bisyncneeds--resyncafter a pull.
Test plan
- One-way cloud → local with a clean local dir matches cloud contents
- One-way cloud → local with extra local files deletes them (and
--dry-runreports it without doing so) -
.bmignorefilters apply correctly with cloud as source - Subsequent
bm cloud bisyncbehavior after a pull is documented and sane
Activity
claude commentedon May 26, 2026
Claude finished @phernandez's task in 1m 29s —— View job
Triage Analysis
Classification
Labels applied:
enhancement,cloudAnalysis
No duplicate issues found. This is a well-scoped feature request with clear motivation.
Current state (confirmed from source):
project_sync()inrclone_commands.py:222hardcodes:The CLI wrapper in
project_sync.py:92exposes this asbm cloud syncwith no direction option.Recommended approach: Option B (separate
bm cloud pullcommand)A separate command is preferable over a
--directionflag because:bm cloud sync(upload) vsbm cloud pull(download) maps cleanly to mental modelImplementation notes:
rclone_commands.py—project_sync(): Add adirection: Literal["push", "pull"] = "push"parameter. Whendirection == "pull", swap source/dest:Also note:
--local-no-preallocateis a local-filesystem flag — it should only be added when local is the destination (pull direction). Currently it's always added as source; confirm whether it's safe on source too or should be conditional.project_sync.py— newpullcommand: Mirrorsync_project_commandwith:"pull"when callingproject_sync()--dry-runsuggestion in the help text--forcerequirement) before proceeding, since pull deletes local files not present in cloud.bmignorefilters: Filters apply symmetrically in rclone — no changes needed. Theget_bmignore_filter_path()call can be reused as-is.Bisync interaction: Pull should NOT touch bisync state. If bisync has been initialized, a subsequent
bm cloud bisyncshould still work without--resync(since bisync detects actual file deltas), but this is worth verifying in tests.Open questions to resolve before implementation:
bm cloud pullrequire--forceor show an interactivey/Nprompt given it deletes local files? Recommend: interactive prompt by default,--forceto skip it in scripts.--local-no-preallocatesafe when local is the sync source (current push behavior) or only needed as destination? Worth checking rclone docs — it may be a no-op on source.Test plan from issue looks solid. Add a case for the confirmation prompt bypass (
--force) if that's implemented.phernandez commentedon May 26, 2026
Update: split into
push/pullwith Teams-safe semanticsIn light of Teams support (see #849, #851), the original "add
--direction pull" shape isn't quite right —rclone syncis destructive on the destination, which is the whole problem we're trying to avoid for shared workspaces. Revised proposal:bm cloud pull --name Xrclone sync remote: local/bm cloud push --name Xrclone copy local/ remote:bm cloud sync --name Xrclone sync local/ remote:bm cloud bisync --name Xrclone bisync …Why
pushusesrclone copy, notrclone syncIf a teammate added or edited a note since your last pull, a
local → cloudmirror (rclone sync) would delete their additions and overwrite their edits to make the cloud identical to your local. Last-writer-wins with collateral damage.rclone copyis additive — it uploads new/changed files but never deletes on the destination. Same-file edit conflicts still resolve as last-writer-wins (which is acceptable for a file-level CLI primitive); for conflict-aware edits, writes should go through the MCP/API path.Why keep
syncandbisyncat allFor Personal workspaces, the mirror semantics are useful and correct (one user, one source of truth). They just get gated to Personal-only per #849.
Implementation sketch
project_sync()in rclone_commands.py:187 becomes parameterized on:local→cloud|cloud→local)sync|copy)Then the four verbs (
sync,bisync,push,pull) are thin command wrappers that pick the right combination and apply the Teams gate.Open questions
pullalso have a--copyvariant (additive download, doesn't delete local files missing from cloud)? Useful for hydrating without risk.groksrc commentedon May 27, 2026
I think the push/pull split is the right short-term shape, and I would keep that separate from the longer-term "Team mirror sync" story.
For Teams, the thing we need to avoid is not rclone itself. It is letting one client's stale local tree become authoritative for shared cloud state.
pullis safe because the destructive side is only the caller's local directory;pushis Team-safe if it uses additive copy semantics.sync/bisyncshould remain Personal-only because they can delete or overwrite shared remote state.Even if files do not change fast enough for locking to matter, a sync baseline still matters because it distinguishes intentional deletes from stale clients that simply have not pulled a teammate's newer file yet.
For a real Team mirror workflow, I think we eventually need an app-owned reconciler instead of raw mirror semantics:
That gives us a path to Teams-safe mirror behavior without treating a local folder snapshot as the source of truth. It also keeps the current guard wording clean: Teams block mirror-style
sync/bisync, but can still support Team-safepull/push.phernandez commentedon May 27, 2026
claude confused what I was saying.
groksrc commentedon May 28, 2026
Follow-up after tightening the #849/#855 wording: I would make the short-term guard bisync-only, not sync/bisync.
That means:
bm cloud sync --name Xcan remain available for Team workspaces as the one-way/manual operation.bm cloud bisync --name Xandbm cloud bisync-reset Xstay Personal-only.bm cloud sync --name Xinstead."The longer-term three-way reconciler idea still applies, but specifically for a Team-safe bidirectional/mirror workflow. We would still want a per-client baseline/manifest and revision-aware comparison of baseline, local, and cloud state before letting a Team workspace do anything that behaves like continuous two-way sync.
groksrc commentedon May 28, 2026
Opened #862 to track the longer-term Team-safe bidirectional sync design using Tigris snapshots as the remote baseline.
I still think the short-term
push/pullsplit in this issue is the right primitive layer, while #862 covers the app-owned reconciler needed before Team workspaces get anything that behaves like true bidirectional local mirror sync.phernandez commentedon Jun 8, 2026
Decision: ship
push/pullas git-style, fail-safe primitivesAfter working through the Teams semantics, here's the finalized design we're implementing. Guiding principle: be clear, let the user decide, no surprises — nothing destructive happens without the user spelling out who wins.
Command surface
bm cloud pull --name Xcopy(cloud → local), new files onlybm cloud push --name Xcopy(local → cloud), new files onlybm cloud sync --name Xsync(local → cloud mirror)bm cloud bisync --name Xbisync(two-way)push/pullare Team-safe and ungated: pull's only destructive side is your own local, push is additive on cloud.syncbecomes Personal-only (it's a destructive local→cloud mirror that can delete a teammate's files); its guard message points Teams atpush/pull.Conflict handling: like
git pull/git pushA conflict is any file that exists on both sides and differs. By default the command aborts before transferring anything, lists the exact paths, and tells you the flag to resolve — exactly like
git pullrefusing to clobber local changes, orgit pushbeing rejected when the remote is ahead. One explicit knob:--on-conflict fail(default) — list conflicts, exit non-zero, transfer nothing.--on-conflict keep-local— local wins (pull: skip those files; push: overwrite cloud).--on-conflict keep-cloud— cloud wins (pull: overwrite local; push: skip those files).--on-conflict keep-both— keep yours, write the other side beside it asname.conflict-<date>.mdso nothing is lost.--dry-run/--verbosethroughout.No vague
--force, no interactive prompt to fat-finger. The flag value names what survives, so it reads the same in both directions.Honest limitations (surfaced in
--help+ command output, not buried)Because there is no sync baseline (the thing #862 adds):
Comparison is content-based (rclone
check); a large multipart-uploaded binary whose ETag isn't a plain MD5 may show as differing — acceptable for a notes vault.Scope boundary vs #862
This is the dumb-but-safe byte-transfer primitive. Real three-way merge — auto-resolving unambiguous cases, propagating deletes, distinguishing both-edited from stale — requires the per-client manifest + Tigris-snapshot baseline tracked in #862. Conflict-aware editing continues to flow through MCP/API. We're deliberately not building a partial manifest here; #862 owns the baseline.
Implementation shape
rclone_commands.py: extract a shared transfer builder; refactorproject_synconto it (no behavior change); addproject_diff(conflict detection viarclone check --combined),project_push,project_pull.project_sync.py: newpush/pullcommands with--on-conflict/--dry-run; add the Personal-only gate tosyncand reword the guard to namepush/pull.--helptext covers the Document cloud sync/bisync commands as Personal-workspace-only local mirror workflows #851 documentation ask in passing.feat(cli): add Team-safe cloud push/pull and gate sync to Personal wo…