Skip to content

fix(sync): don't enqueue cloud mutations when no cloud target is configured/enrolled #478

@IP-Mattos

Description

@IP-Mattos

Pre-flight Checklist

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

📝 Bug Description

mem_save (and every other write path) unconditionally enqueues cloud sync mutations — even when cloud is not configured, no cloud URL is set, and sync_enrolled_projects is empty. The mutations accumulate forever as dead letters in sync_mutations (with sync_state rows for cloud / cloud:{project} targets auto-created on every save).

On a machine that has never enrolled in cloud:

  • May 2026: 997 dead-letter mutations had accumulated
  • June 11: 3,131 more since the May cleanup

Empirically verified the targets are self-regenerating: deleted all cloud% rows from sync_state AND all rows from cloud_upgrade_state, then ran a single canary engram save — the cloud + cloud:{project} sync_state rows and 2 fresh mutations reappeared immediately. There is no local config file or env var involved (~/.engram contains only the DB; engram cloud status = not configured).

Side effects beyond disk noise:

  • engram doctor can flip to blocked on these dead letters (e.g. sync_mutation_required_fields when a queued payload is malformed) — alarming users about a sync pipeline they never opted into.
  • The queue's entity_key set fossilizes junk project names from the past (cloud:c:, cloud:\, typo'd names), which resurface in diagnostics.

🔄 Steps to Reproduce

  1. Fresh engram install, never run engram cloud enroll/config (engram cloud statusnot configured)
  2. engram save "test" "hello" --project foo
  3. Inspect: SELECT COUNT(*) FROM sync_mutations WHERE target_key LIKE 'cloud%'; and SELECT * FROM sync_state WHERE target_key LIKE 'cloud%';

✅ Expected Behavior

No cloud-targeted mutations are enqueued unless a cloud target is configured/enrolled. (Or at minimum: a retention cap / pruning for unenrolled targets, and doctor ignoring dead letters for targets that aren't configured.)

❌ Actual Behavior

Every save enqueues mutations toward a cloud target that doesn't exist; the queue grows without bound (~4k rows in ~5 weeks of normal use) and can put doctor into blocked.

Engram Version

engram 1.16.1 (also observed on 1.15.x)

Operating System

Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions