{"record":{"id":"8eb19b8c44133e00","repo":"affaan-m/ECC","slug":"unsupported-memory-schema","errorCode":null,"errorMessage":"Unsupported memory schema.","messagePattern":"Unsupported memory schema\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault-format.js","lineNumber":176,"sourceCode":"  return normalized;\n}\n\nfunction normalizeMemory(memory) {\n  if (!memory || typeof memory !== 'object' || Array.isArray(memory)) {\n    throw new Error('memory must be an object.');\n  }\n\n  const targetHarnesses = uniqueStrings(memory.targetHarnesses, {\n    label: 'target harnesses',\n    limit: MAX_TARGETS,\n    validator: value => validateSlug(value, 'target harness'),\n  });\n  if (targetHarnesses.length === 0) {\n    throw new Error('target harnesses must contain at least one harness or \"all\".');\n  }\n\n  if (memory.schema !== MEMORY_SCHEMA_VERSION) {\n    throw new Error('Unsupported memory schema.');\n  }\n\n  return {\n    schema: memory.schema,\n    id: validateMemoryId(memory.id),\n    title: asNonEmptyString(memory.title, 'memory title', MAX_TITLE_CHARS),\n    kind: validateEnum(memory.kind, MEMORY_KINDS, 'memory kind'),\n    scope: validateEnum(memory.scope, MEMORY_SCOPES, 'memory scope'),\n    trust: validateEnum(memory.trust, MEMORY_TRUST_STATES, 'memory trust'),\n    status: validateEnum(memory.status, MEMORY_STATUSES, 'memory status'),\n    sourceHarness: validateSlug(memory.sourceHarness, 'source harness'),\n    targetHarnesses,\n    tags: uniqueStrings(memory.tags, {\n      label: 'tags',\n      limit: MAX_TAGS,\n      validator: value => validateSlug(value, 'tag'),\n    }),\n    links: uniqueStrings(memory.links, {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/memory-vault-format.js#L158-L194","documentation":"normalizeMemory enforces that memory.schema equals the current MEMORY_SCHEMA_VERSION constant. The memory vault format is versioned; documents written for an older (or newer, e.g. after a plugin upgrade) schema are refused rather than silently migrated or misinterpreted.","triggerScenarios":"Saving or parsing a memory whose schema field is missing, set to a different number (e.g. schema: 0 or 2), a string like '1' instead of the numeric version, or copied from an older ECC version before a schema bump.","commonSituations":"Upgrading the ECC plugin and loading old vault documents; hand-editing frontmatter and typo-ing the schema value; copying an example with an outdated schema number; JSON.stringify serializing the number as a string via a custom writer.","solutions":["Set schema to the library's MEMORY_SCHEMA_VERSION value (import the constant rather than hardcoding).","Re-save older memories through the current version's write path so they are re-serialized with the current schema.","If the schema was bumped by an ECC update, migrate the document (or regenerate it) rather than editing the number blindly.","Ensure the value is a number, not a string: schema: 1, not schema: \"1\"."],"exampleFix":"// before\nconst memory = { schema: \"1\", id: 'notes', title: 'Notes', targetHarnesses: ['all'] };\n\n// after\nimport { MEMORY_SCHEMA_VERSION } from './memory-vault-format.js';\nconst memory = { schema: MEMORY_SCHEMA_VERSION, id: 'notes', title: 'Notes', targetHarnesses: ['all'] };","handlingStrategy":"validation","validationCode":"import { MEMORY_SCHEMA_VERSION } from './memory-vault-format.js';\nif (doc.schema !== MEMORY_SCHEMA_VERSION) {\n  doc = migrateSchema(doc, doc.schema, MEMORY_SCHEMA_VERSION);\n}","typeGuard":"const hasCurrentSchema = (m) => m.schema === MEMORY_SCHEMA_VERSION;","tryCatchPattern":"try {\n  saveMemory(memory);\n} catch (err) {\n  if (err.message === 'Unsupported memory schema.') {\n    console.error('Document schema %j != current %d; re-save or migrate it.', memory.schema, MEMORY_SCHEMA_VERSION);\n  } else throw err;\n}","preventionTips":["Import MEMORY_SCHEMA_VERSION instead of hardcoding the number.","After ECC upgrades, re-save old vault documents to bump their schema.","Always write schema as a JSON number, never a quoted string."],"tags":["versioning","schema","memory-vault"],"backgroundTag":"schema-validation-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}