{"record":{"id":"01b2ec6f7acbfe1b","repo":"Yeachan-Heo/oh-my-codex","slug":"sandbox-md-must-start-with-yaml-frontmatter-contai","errorCode":null,"errorMessage":"sandbox.md must start with YAML frontmatter containing evaluator.command and evaluator.format=json.","messagePattern":"sandbox\\.md must start with YAML frontmatter containing evaluator\\.command and evaluator\\.format=json\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/autoresearch/contracts.ts","lineNumber":85,"sourceCode":"export function slugifyMissionName(value: string): string {\n  return value\n    .toLowerCase()\n    .replace(/[^a-z0-9]+/g, '-')\n    .replace(/-+/g, '-')\n    .replace(/^-|-$/g, '')\n    .slice(0, 48) || 'mission';\n}\n\nfunction ensurePathInside(parentPath: string, childPath: string): void {\n  const rel = relative(parentPath, childPath);\n  if (rel === '' || (!rel.startsWith('..') && rel !== '..')) return;\n  throw contractError(MISSION_DIR_GIT_ERROR);\n}\n\nfunction extractFrontmatter(content: string): { frontmatter: string; body: string } {\n  const match = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n  if (!match) {\n    throw contractError(SANDBOX_FRONTMATTER_ERROR);\n  }\n  return {\n    frontmatter: match[1] || '',\n    body: (match[2] || '').trim(),\n  };\n}\n\nfunction parseSimpleYamlFrontmatter(frontmatter: string): Record<string, unknown> {\n  const result: Record<string, unknown> = {};\n  let currentSection: string | null = null;\n\n  for (const rawLine of frontmatter.split(/\\r?\\n/)) {\n    const line = rawLine.replace(/\\t/g, '  ');\n    const trimmed = line.trim();\n    if (!trimmed || trimmed.startsWith('#')) continue;\n\n    const sectionMatch = /^([A-Za-z0-9_-]+):\\s*$/.exec(trimmed);\n    if (sectionMatch) {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/autoresearch/contracts.ts#L67-L103","documentation":"extractFrontmatter throws SANDBOX_FRONTMATTER_ERROR when sandbox.md content does not begin with a valid YAML frontmatter block: a leading '---' line, content, a closing '---' line. The regex /^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/ requires the delimiters, so any deviation (missing fences, wrong characters, leading blank line/BOM) fails.","triggerScenarios":"parseSandboxContract receives sandbox.md content that does not start with '---\\n' or lacks a closing '---' line — e.g. the file starts with prose, has a BOM or blank line before the first fence, or uses '---' with trailing spaces.","commonSituations":"Hand-editing sandbox.md and deleting a fence; editors saving with a BOM; copying the file from docs that stripped the leading '---'; CRLF/whitespace issues around the fences.","solutions":["Ensure sandbox.md starts on line 1 with exactly '---', then YAML, then a closing '---' line.","Remove any BOM or blank lines before the first fence.","Avoid trailing whitespace after the fence lines.","Regenerate sandbox.md from a known-good template and re-apply changes."],"exampleFix":"# before (sandbox.md)\nThis is my sandbox.\n---\nevaluator:\n  command: ./run.sh\n  format: json\n---\n\n# after\n---\nevaluator:\n  command: ./run.sh\n  format: json\n---\n\nThis is my sandbox.","handlingStrategy":"validation","validationCode":"function hasValidFrontmatter(content: string): boolean {\n  return /^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?(\\n|$)/.test(content.charCodeAt(0) === 0xfeff ? content.slice(1) : content);\n}","typeGuard":"const isFrontmatterDoc = (s: string): boolean => /^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?(\\n|$)/.test(s);","tryCatchPattern":"try {\n  const parsed = parseSandboxContract(content);\n} catch (err) {\n  if ((err as Error).message.includes('must start with YAML frontmatter')) {\n    // rewrite file with leading --- fences or strip BOM\n  }\n  throw err;\n}","preventionTips":["Start sandbox.md with '---' on the very first line.","Save files as UTF-8 without BOM.","Lint sandbox.md in CI with a frontmatter checker."],"tags":["frontmatter","yaml","sandbox-md","parsing"],"backgroundTag":"yaml-frontmatter-missing","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}