Skip to content

Add cloud-sync: optional R2 / S3 / Azure sync for memories and config#1330

Closed
ikarolaborda wants to merge 1 commit intooraios:mainfrom
ikarolaborda:feature/cloud-sync
Closed

Add cloud-sync: optional R2 / S3 / Azure sync for memories and config#1330
ikarolaborda wants to merge 1 commit intooraios:mainfrom
ikarolaborda:feature/cloud-sync

Conversation

@ikarolaborda
Copy link
Copy Markdown

Refs #1328. Supersedes #1329 (closed — same branch renamed).

Adds an experimental, opt-in cloud-sync feature so Serena's memories and configuration can be mirrored to a user-provided cloud bucket across machines. Additive union — no silent overwrites.

What it does

  • CLI group serena cloud-sync {configure, test, status, push, pull, fix-perms}.
  • Dashboard panel at /dashboard/cloud-sync.html with credential form, dry-run plan preview, and push/pull actions.
  • Providers: Cloudflare R2 and Amazon S3 via boto3 (the endpoint_url override also enables MinIO / Ceph RGW / SeaweedFS), and Azure Blob via azure-storage-blob (lazy-imported so R2/S3 users never load it).

How it's shaped

  • CloudStorageProvider ABC is the only seam; CloudSyncService receives the provider via constructor. A guard test (test_no_boto3_in_business_logic) fails if any SDK leaks into sync/diff/inventory/scope/hash_util/credentials/provider.
  • Conflict preservation by default: sha256 compare; mismatches leave both sides intact. On pull the remote is saved as <path>.cloud-<ts>; on push the remote is kept. --force-push / --force-pull are opt-in.
  • Credentials live only in ~/.serena/cloud-sync.env (chmod 0600, atomic write; a **** sentinel on re-save preserves existing secrets). Dashboard routes require a per-process local token and reject non-localhost callers.
  • Dry-run-first on both CLI and dashboard — destructive actions only run after the user sees the classified plan.

Scope (explicit MVP non-goals)

  • No delete propagation, no rename detection, no background scheduler.
  • 5 MiB per-object cap.
  • Hard-excludes credentials, logs, caches, symlinks, project.local.yml (opt-in only).

Tests

  • 24 unit tests via an in-memory FakeCloudProvider.
  • LocalStack and Azurite integration skeletons — auto-skip unless LOCALSTACK_ENDPOINT / AZURITE_ACCOUNT env is set.

Docs

Design rationale, data model, failure/idempotency contract, and acceptance criteria in docs/cloud-sync-feature-plan.md.

Ships an experimental feature to sync serena memories and configuration to
a cloud backend. Additive union semantics — never silently overwrites
divergent content.

- New CLI group: serena cloud-sync {configure, test, status, push, pull,
  fix-perms}.
- Dashboard panel at /dashboard/cloud-sync.html with credential form,
  dry-run plan preview, and push/pull actions.
- Providers: Cloudflare R2 and Amazon S3 via boto3 (endpoint_url override
  also enables MinIO / Ceph RGW / SeaweedFS), Azure Blob via
  azure-storage-blob (lazy-imported).
- CloudStorageProvider ABC as the only seam; CloudSyncService takes the
  provider via constructor (DIP). A guard test asserts business-logic
  modules import no SDKs.
- Conflict preservation: sha256 compare; conflicts leave both sides
  intact (remote saved as <path>.cloud-<ts> sibling on pull;
  --force-push / --force-pull opt-in).
- Credentials only in ~/.serena/cloud-sync.env (chmod 0600, atomic
  write, mask sentinel preserves existing secrets on re-save). Dashboard
  routes require a per-process local token and reject non-localhost
  callers.
- Dry-run-first on both CLI and dashboard.
- EXPERIMENTAL; user-triggered only. 5 MiB per-object cap.
- Tests: 24 unit tests with an in-memory FakeCloudProvider; LocalStack
  and Azurite integration skeletons (auto-skip when not configured).
- Full design doc at docs/cloud-sync-feature-plan.md.
@MischaPanch
Copy link
Copy Markdown
Contributor

Hi. Sry, 4150 loc of changes is the limit of PRs that we accept before prior discussion in an issue, so closing this.

Jokes aside, if this is a feature you're interested in, feel free to open an issue and start a discussion there

@MischaPanch
Copy link
Copy Markdown
Contributor

FYI @ikarolaborda in the past we have worked on https://github.com/oraios/accsr/ for syncing data between cloud and local, it was used in many production projects. Have a look if you're interested, supports all providers

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