affaan-m/ECC · error · Error

Memory document has no closing frontmatter marker.

Error message

Memory document ${sourcePath} has no closing frontmatter marker.

What it means

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.

Solutions

  1. Add the closing --- line after the frontmatter fields.
  2. Restore the document from git or the memory backup if it was truncated.
  3. Note CRLF and trailing-newline requirements: the closer must be preceded by a line break.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at scripts/lib/memory-vault-format.js:258 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/d50aa5cf088b5ca4. Report an issue: GitHub.

Appendix: source

Thrown at scripts/lib/memory-vault-format.js:258

  }
}

function parseMemoryDocument(source, sourcePath = '<memory>') {
  const openingMarker = typeof source === 'string'
    ? /^---\r?\n/.exec(source)
    : null;
  if (!openingMarker) {
    throw new Error(`Memory document ${sourcePath} must start with --- frontmatter.`);
  }
  if (Buffer.byteLength(source, 'utf8') > MAX_DOCUMENT_BYTES) {
    throw new Error(`Memory document ${sourcePath} is too large.`);
  }

  const frontmatterStart = openingMarker[0].length;
  const remainder = source.slice(frontmatterStart);
  const closingMarker = /\r?\n---(?=\r?\n|$)/.exec(remainder);
  if (!closingMarker) {
    throw new Error(`Memory document ${sourcePath} has no closing frontmatter marker.`);
  }

  const frontmatterSource = remainder.slice(0, closingMarker.index);
  const parsed = frontmatterSource.split(/\r?\n/).reduce((state, line) => {
    const next = parseFrontmatterLine(line, sourcePath, state.seen);
    return {
      values: { ...state.values, [next.objectKey]: next.value },
      seen: new Set([...state.seen, next.objectKey]),
    };
  }, { values: {}, seen: new Set() });

  const missing = FRONTMATTER_FIELDS
    .map(([, objectKey]) => objectKey)
    .filter(objectKey => !parsed.seen.has(objectKey));
  if (missing.length > 0) {
    throw new Error(`Memory document ${sourcePath} is missing fields: ${missing.join(', ')}.`);
  }

View on GitHub (pinned to 8321021c54)