Bug Description
When using the MCP server with ENGRAM_CLOUD_AUTOSYNC=1, cloud sync fails with:
engram: canonicalize cloud chunk: mutations[N]: session payload directory is required for upsert
Root Cause
The MCP server generates sync_mutations entries for session upserts that are missing the directory field in the JSON payload. Example of a problematic mutation payload:
{"id":"manual-save-ddata","project":"ddata","started_at":"2026-04-18 00:41:04"}
The directory field is absent entirely (not empty string, but missing). The cloud chunk canonicalizer requires this field for session upserts and fails hard with no fallback.
Repro Steps
- Configure engram MCP with
ENGRAM_CLOUD_AUTOSYNC=1 and a cloud endpoint
- Use
mem_save tool from the MCP multiple times in a session
- Run
engram sync --cloud --project <name>
- Observe:
mutations[N]: session payload directory is required for upsert
Workaround
Manually patch the affected rows before syncing:
UPDATE sync_mutations
SET payload = json_set(payload, '$.directory', '/path/to/project')
WHERE entity = 'session'
AND json_extract(payload, '$.directory') IS NULL;
Expected Behavior
Either:
- The MCP server should always include
directory in session mutation payloads
- OR the cloud sync canonicalizer should be tolerant of missing
directory and use a fallback from the sessions table
Environment
- engram client: v1.14.0 (Windows, scoop)
- engram server: v1.14.1 (Docker, self-hosted)
- OS: Windows 11 / PowerShell
- MCP tools profile: --tools=agent
Bug Description
When using the MCP server with
ENGRAM_CLOUD_AUTOSYNC=1, cloud sync fails with:Root Cause
The MCP server generates
sync_mutationsentries forsessionupserts that are missing thedirectoryfield in the JSON payload. Example of a problematic mutation payload:{"id":"manual-save-ddata","project":"ddata","started_at":"2026-04-18 00:41:04"}The
directoryfield is absent entirely (not empty string, but missing). The cloud chunk canonicalizer requires this field for session upserts and fails hard with no fallback.Repro Steps
ENGRAM_CLOUD_AUTOSYNC=1and a cloud endpointmem_savetool from the MCP multiple times in a sessionengram sync --cloud --project <name>mutations[N]: session payload directory is required for upsertWorkaround
Manually patch the affected rows before syncing:
Expected Behavior
Either:
directoryin session mutation payloadsdirectoryand use a fallback from thesessionstableEnvironment