{"record":{"id":"ab7db08a109fd151","repo":"Yeachan-Heo/oh-my-codex","slug":"invalid-autoresearch-goal-mission-at-reporelativ","errorCode":null,"errorMessage":"Invalid autoresearch-goal mission at ${repoRelative(cwd, path)}.","messagePattern":"Invalid autoresearch-goal mission at (.+?)\\.","errorType":"validation","errorClass":"AutoresearchGoalError","httpStatus":null,"severity":"error","filePath":"src/autoresearch/goal.ts","lineNumber":183,"sourceCode":"  await writeFile(autoresearchGoalRubricPath(cwd, slug), `${rubric}\\n`, 'utf-8');\n  await writeFile(autoresearchGoalLedgerPath(cwd, slug), '', 'utf-8');\n  await writeMission(cwd, mission);\n  await appendLedger(cwd, slug, { ts: now, event: 'workflow_created', slug, status: mission.status, message: `Autoresearch goal created: ${topic}` });\n  return mission;\n}\n\nexport async function readAutoresearchGoal(cwd: string, slug: string): Promise<AutoresearchGoalMission> {\n  const normalizedSlug = slugifyMissionName(slug);\n  const path = autoresearchGoalMissionPath(cwd, normalizedSlug);\n  let raw: string;\n  try {\n    raw = await readFile(path, 'utf-8');\n  } catch {\n    throw new AutoresearchGoalError(`No autoresearch-goal mission found at ${repoRelative(cwd, path)}. Run \\`omx autoresearch-goal create ...\\` first.`);\n  }\n  const parsed = JSON.parse(raw) as AutoresearchGoalMission;\n  if (parsed.schema_version !== 1 || parsed.workflow !== 'autoresearch-goal') {\n    throw new AutoresearchGoalError(`Invalid autoresearch-goal mission at ${repoRelative(cwd, path)}.`);\n  }\n  return parsed;\n}\n\nexport async function readAutoresearchGoalCompletion(cwd: string, slug: string): Promise<AutoresearchGoalCompletion | null> {\n  const path = autoresearchGoalCompletionPath(cwd, slugifyMissionName(slug));\n  if (!existsSync(path)) return null;\n  const parsed = JSON.parse(await readFile(path, 'utf-8')) as AutoresearchGoalCompletion;\n  return parsed;\n}\n\nexport async function recordAutoresearchGoalVerdict(\n  cwd: string,\n  options: RecordAutoresearchGoalVerdictOptions,\n): Promise<{ mission: AutoresearchGoalMission; completion: AutoresearchGoalCompletion }> {\n  const mission = await readAutoresearchGoal(cwd, options.slug);\n  if (mission.status === 'complete') {\n    throw new AutoresearchGoalError(`Autoresearch goal ${mission.slug} is already complete; create a new goal or explicitly reopen via a future workflow before recording more verdicts.`);","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/autoresearch/goal.ts#L165-L201","documentation":"The mission file was read successfully but failed the schema identity check: schema_version must be 1 and workflow must be 'autoresearch-goal'. The file at the mission path exists but is not a valid autoresearch-goal mission document.","triggerScenarios":"Hand-editing the mission JSON and changing schema_version or workflow, writing another workflow's mission file to the autoresearch-goal path, or a version mismatch after upgrading the tool to a new schema version.","commonSituations":"Manual edits to .omx mission files, files produced by a newer/older incompatible version of the tool, copy-pasting a mission file from a different workflow, or truncated/corrupted JSON that happens to still parse.","solutions":["Inspect the file at the printed path and verify schema_version === 1 and workflow === 'autoresearch-goal'","If the tool version changed, recreate the mission with `omx autoresearch-goal create` instead of reusing an old file","Restore the file from version control if it was hand-edited or corrupted","Never place other workflow mission files at the autoresearch-goal mission path"],"exampleFix":"// before\n// .omx/.../mission.json contains { \"schema_version\": 2, \"workflow\": \"other\" }\nawait completeAutoresearchGoal(repoRoot, 'fix-leak'); // throws: Invalid autoresearch-goal mission\n// after\n// .omx/.../mission.json contains { \"schema_version\": 1, \"workflow\": \"autoresearch-goal\", ... }\nawait completeAutoresearchGoal(repoRoot, 'fix-leak');","handlingStrategy":"type-guard","validationCode":"const raw = await readFile(missionPath, 'utf-8');\nconst doc = JSON.parse(raw);\nif (doc?.schema_version !== 1 || doc?.workflow !== 'autoresearch-goal') {\n  throw new Error('Mission file is not an autoresearch-goal v1 document; recreate it.');\n}","typeGuard":"function isAutoresearchGoalMission(v: unknown): v is AutoresearchGoalMission {\n  if (typeof v !== 'object' || v === null) return false;\n  const r = v as Record<string, unknown>;\n  return r.schema_version === 1 && r.workflow === 'autoresearch-goal' && typeof r.slug === 'string';\n}","tryCatchPattern":"try { await completeAutoresearchGoal(cwd, slug); }\ncatch (e) { if (e instanceof AutoresearchGoalError && e.message.startsWith('Invalid autoresearch-goal mission')) { /* recreate mission, do not retry blindly */ } else throw e; }","preventionTips":["Never hand-edit schema_version or workflow in .omx mission files","After upgrading the tool, recreate missions rather than reusing old-schema files","Commit .omx mission files so corruption is recoverable via git"],"tags":["autoresearch","schema","version-mismatch","json"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}