You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand this issue needs status:approved before a PR can be opened
📝 Bug Description
This is the product-repair slice split out from umbrella issue #299, per maintainer feedback to separate product repair behavior from wrapper/script hardening.
Legacy local SQLite databases can contain frozen sync_mutations.payload snapshots that violate current cloud canonicalization requirements. Current engram cloud upgrade doctor / repair does not give users a complete local-only repair path for the observed required-field blockers.
Observed blocker classes:
session payloads with missing or empty directory.
sessions.directory='' rows that should be backfilled before repairing corresponding mutation payloads.
legacy/project-consolidation cases where sync_mutations.project no longer matches the canonical current project name, leaving repair inference incomplete unless aliases or project mappings are considered.
old mutations with project='' / directory='' that need to be reported or canonicalized before project filtering hides them from project-scoped sync diagnostics.
🔄 Steps to Reproduce
Start from a legacy Engram database with pending sync_mutations rows captured before current cloud-required payload fields existed.
Include one or more rows such as:
entity='session' with payload.directory='' or missing.
local sessions.directory='' for the same project/session.
entity='observation' with payload.type='' or missing required content/title/scope fields.
sync_mutations.project='' for old imported/projectless mutations.
Run engram cloud upgrade doctor --project <project> and/or engram sync --cloud --project <project>.
Observe blocked sync requiring manual SQL rather than a complete dry-run/apply repair report.
✅ Expected Behavior
Product code should provide an explicit, local-first repair/diagnostic path that:
dry-runs by default and supports an explicit --apply mode before mutating SQLite;
backfills sessions.directory when an inferable canonical directory exists;
updates frozen sync_mutations.payload snapshots for repairable required fields, including session.directory and observation required fields;
reports unfixable rows with seq/entity/op/project/entity_key and the exact missing/empty field;
handles project rename/consolidation cases through explicit alias/mapping input or clear manual guidance;
Suggested product shape from #299 discussion: a local SQLite repair command such as engram cloud repair backfill-directory --project <name> [--dry-run|--apply], potentially generalized to cloud repair legacy-mutations, plus improved cloud upgrade doctor reporting.
This issue intentionally excludes operator Bash/PowerShell wrapper behavior; that is split into a separate child issue.
📋 Pre-flight Checks
status:approvedbefore a PR can be opened📝 Bug Description
This is the product-repair slice split out from umbrella issue #299, per maintainer feedback to separate product repair behavior from wrapper/script hardening.
Legacy local SQLite databases can contain frozen
sync_mutations.payloadsnapshots that violate current cloud canonicalization requirements. Currentengram cloud upgrade doctor/ repair does not give users a complete local-only repair path for the observed required-field blockers.Observed blocker classes:
sessionpayloads with missing or emptydirectory.sessions.directory=''rows that should be backfilled before repairing corresponding mutation payloads.observationpayloads with required fields missing or empty, observed astype=''in the WSL/Beta repair andcontentmissing/empty in the macOS confirmation comment on Cloud sync legacy repair misses empty project/type mutations and autosync can fail silently #299.sync_mutations.projectno longer matches the canonical current project name, leaving repair inference incomplete unless aliases or project mappings are considered.project=''/directory=''that need to be reported or canonicalized before project filtering hides them from project-scoped sync diagnostics.🔄 Steps to Reproduce
sync_mutationsrows captured before current cloud-required payload fields existed.entity='session'withpayload.directory=''or missing.sessions.directory=''for the same project/session.entity='observation'withpayload.type=''or missing required content/title/scope fields.sync_mutations.project=''for old imported/projectless mutations.engram cloud upgrade doctor --project <project>and/orengram sync --cloud --project <project>.✅ Expected Behavior
Product code should provide an explicit, local-first repair/diagnostic path that:
--applymode before mutating SQLite;sessions.directorywhen an inferable canonical directory exists;sync_mutations.payloadsnapshots for repairable required fields, includingsession.directoryand observation required fields;project='') legacy mutations instead of letting project-scoped sync hide them;last_acked_seq, never deletes mutations silently, and never auto-repairs during autosync.❌ Actual Behavior
Real repairs required manual SQLite edits:
engramsessions withdirectory='', 5 oldproject=''/directory=''mutations, and one observation withtype=''.project=''/directory=''mutations blocking scheduled sync foropencodeandengram.sync_mutation_required_fieldsblockers reduced to 9 via manual SQLite repair; 558 were sessions missingdirectory, and 2 observations were missingcontent.Operating System
Windows (WSL)
Engram Version
1.15.x / Beta cloud sync environments
Agent / Client
OpenCode
📋 Relevant Logs
# macOS confirmation from #299 sync_mutation_required_fields blocked findings: 560 entity=session, missing_fields=[directory]: 558 entity=observation, missing_fields=[content]: 2 blocked findings after manual SQL repair: 9💡 Additional Context
Parent umbrella: #299.
Related but distinct issues:
engram sync --cloud, closed.cloud_mutationscausing pull FK failures.Suggested product shape from #299 discussion: a local SQLite repair command such as
engram cloud repair backfill-directory --project <name> [--dry-run|--apply], potentially generalized tocloud repair legacy-mutations, plus improvedcloud upgrade doctorreporting.This issue intentionally excludes operator Bash/PowerShell wrapper behavior; that is split into a separate child issue.