{"record":{"id":"d50aa5cf088b5ca4","repo":"affaan-m/ECC","slug":"memory-document-sourcepath-has-no-closing-front","errorCode":null,"errorMessage":"Memory document ${sourcePath} has no closing frontmatter marker.","messagePattern":"Memory document (.+?) has no closing frontmatter marker\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault-format.js","lineNumber":258,"sourceCode":"  }\n}\n\nfunction parseMemoryDocument(source, sourcePath = '<memory>') {\n  const openingMarker = typeof source === 'string'\n    ? /^---\\r?\\n/.exec(source)\n    : null;\n  if (!openingMarker) {\n    throw new Error(`Memory document ${sourcePath} must start with --- frontmatter.`);\n  }\n  if (Buffer.byteLength(source, 'utf8') > MAX_DOCUMENT_BYTES) {\n    throw new Error(`Memory document ${sourcePath} is too large.`);\n  }\n\n  const frontmatterStart = openingMarker[0].length;\n  const remainder = source.slice(frontmatterStart);\n  const closingMarker = /\\r?\\n---(?=\\r?\\n|$)/.exec(remainder);\n  if (!closingMarker) {\n    throw new Error(`Memory document ${sourcePath} has no closing frontmatter marker.`);\n  }\n\n  const frontmatterSource = remainder.slice(0, closingMarker.index);\n  const parsed = frontmatterSource.split(/\\r?\\n/).reduce((state, line) => {\n    const next = parseFrontmatterLine(line, sourcePath, state.seen);\n    return {\n      values: { ...state.values, [next.objectKey]: next.value },\n      seen: new Set([...state.seen, next.objectKey]),\n    };\n  }, { values: {}, seen: new Set() });\n\n  const missing = FRONTMATTER_FIELDS\n    .map(([, objectKey]) => objectKey)\n    .filter(objectKey => !parsed.seen.has(objectKey));\n  if (missing.length > 0) {\n    throw new Error(`Memory document ${sourcePath} is missing fields: ${missing.join(', ')}.`);\n  }\n","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/memory-vault-format.js#L240-L276","documentation":"parseMemoryDocument throws when a memory document has an opening --- frontmatter marker but no closing --- line, i.e. truncated or corrupted frontmatter. The faulting input is the document text at sourcePath; parsing cannot delimit the frontmatter block.","triggerScenarios":"Thrown at scripts/lib/memory-vault-format.js:258 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the closing --- line after the frontmatter fields.","Restore the document from git or the memory backup if it was truncated.","Note CRLF and trailing-newline requirements: the closer must be preceded by a line break."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}