Skip to content

feat(sync): add opt-in automatic multi-machine sync on top of existing chunk sync #187

@evelioapc

Description

@evelioapc

📋 Pre-flight Checks

  • I have searched existing issues and this is not a duplicate
  • I understand this issue needs status:approved before a PR can be opened

🔍 Problem Description

Engram already has the right primitive for multi-machine usage: engram sync exports/imports compressed chunks that are safe to move between machines.

That works, but it is still manual:

  1. Save memory on machine A
  2. Run engram sync
  3. Commit/push or otherwise transfer the sync artifacts
  4. Pull on machine B
  5. Run engram sync --import

For users who switch between two or more computers during the day, this friction is high enough that memory becomes stale in practice.

Important constraints:

  • Syncing the live SQLite file through OneDrive/Dropbox/etc. is unsafe
  • The current chunk-based sync model is correct, but the UX is incomplete for real multi-PC workflows

💡 Proposed Solution

Add an opt-in automatic sync layer on top of the existing chunk-based sync model.

Design goals:

  • Keep SQLite local as the source of truth
  • Keep the existing chunk export/import format
  • Add background/scheduled auto-sync
  • Make the transport pluggable so Git can be supported first, with Cloud as a future option

Proposed UX:

Configure a sync profile once:
engram sync init git --repo ~/engram-sync

Then start Engram normally:
engram mcp

Behavior:

  • on startup: pull/import remote changes if available
  • after local writes: debounce, export chunks, commit, push
  • periodically: pull/import in the background
  • on shutdown: final sync attempt

Suggested commands:

  • engram sync init git --repo <path-or-url>
  • engram sync enable
  • engram sync disable
  • engram sync status
  • engram sync run-once
  • engram sync doctor

Implementation outline:

  • add a sync config file under ENGRAM_DATA_DIR
  • add sync orchestration on top of existing export/import logic
  • add Git transport hooks for pull, add/commit, and push
  • never block writes if sync fails
  • never sync the live SQLite database file directly

📦 Affected Area

Sync (multi-instance)

🔄 Alternatives Considered

  1. Sync the SQLite file with Dropbox/OneDrive
    Rejected because it is unsafe with concurrent machine usage and risks corruption/conflicts.

  2. Require PostgreSQL/shared DB for multi-machine use
    Rejected for this issue because it is too heavy for solo users with multiple machines and overlaps with separate shared-memory/team proposals.

  3. Keep manual sync only
    Rejected because it technically works, but the UX friction is high enough that many users will not keep memory in sync across devices.

📎 Additional Context

Related:

Why this matters:

Engram is already very close to solving the same-memory-on-every-machine problem.

The missing piece is not a new storage engine. It is a safe, opt-in automation layer built on top of the sync model that already exists.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions