Yeachan-Heo/oh-my-codex · error · AutoresearchGoalError

Invalid autoresearch-goal mission at ${repoRelative(cwd, pat

Error message

Invalid autoresearch-goal mission at ${repoRelative(cwd, path)}.

What it means

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.

Source

Thrown at src/autoresearch/goal.ts:183

  await writeFile(autoresearchGoalRubricPath(cwd, slug), `${rubric}\n`, 'utf-8');
  await writeFile(autoresearchGoalLedgerPath(cwd, slug), '', 'utf-8');
  await writeMission(cwd, mission);
  await appendLedger(cwd, slug, { ts: now, event: 'workflow_created', slug, status: mission.status, message: `Autoresearch goal created: ${topic}` });
  return mission;
}

export async function readAutoresearchGoal(cwd: string, slug: string): Promise<AutoresearchGoalMission> {
  const normalizedSlug = slugifyMissionName(slug);
  const path = autoresearchGoalMissionPath(cwd, normalizedSlug);
  let raw: string;
  try {
    raw = await readFile(path, 'utf-8');
  } catch {
    throw new AutoresearchGoalError(`No autoresearch-goal mission found at ${repoRelative(cwd, path)}. Run \`omx autoresearch-goal create ...\` first.`);
  }
  const parsed = JSON.parse(raw) as AutoresearchGoalMission;
  if (parsed.schema_version !== 1 || parsed.workflow !== 'autoresearch-goal') {
    throw new AutoresearchGoalError(`Invalid autoresearch-goal mission at ${repoRelative(cwd, path)}.`);
  }
  return parsed;
}

export async function readAutoresearchGoalCompletion(cwd: string, slug: string): Promise<AutoresearchGoalCompletion | null> {
  const path = autoresearchGoalCompletionPath(cwd, slugifyMissionName(slug));
  if (!existsSync(path)) return null;
  const parsed = JSON.parse(await readFile(path, 'utf-8')) as AutoresearchGoalCompletion;
  return parsed;
}

export async function recordAutoresearchGoalVerdict(
  cwd: string,
  options: RecordAutoresearchGoalVerdictOptions,
): Promise<{ mission: AutoresearchGoalMission; completion: AutoresearchGoalCompletion }> {
  const mission = await readAutoresearchGoal(cwd, options.slug);
  if (mission.status === 'complete') {
    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.`);

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Inspect the file at the printed path and verify schema_version === 1 and workflow === 'autoresearch-goal'
  2. If the tool version changed, recreate the mission with `omx autoresearch-goal create` instead of reusing an old file
  3. Restore the file from version control if it was hand-edited or corrupted
  4. Never place other workflow mission files at the autoresearch-goal mission path

Example fix

// before
// .omx/.../mission.json contains { "schema_version": 2, "workflow": "other" }
await completeAutoresearchGoal(repoRoot, 'fix-leak'); // throws: Invalid autoresearch-goal mission
// after
// .omx/.../mission.json contains { "schema_version": 1, "workflow": "autoresearch-goal", ... }
await completeAutoresearchGoal(repoRoot, 'fix-leak');
Defensive patterns

Strategy: type-guard

Validate before calling

const raw = await readFile(missionPath, 'utf-8');
const doc = JSON.parse(raw);
if (doc?.schema_version !== 1 || doc?.workflow !== 'autoresearch-goal') {
  throw new Error('Mission file is not an autoresearch-goal v1 document; recreate it.');
}

Type guard

function isAutoresearchGoalMission(v: unknown): v is AutoresearchGoalMission {
  if (typeof v !== 'object' || v === null) return false;
  const r = v as Record<string, unknown>;
  return r.schema_version === 1 && r.workflow === 'autoresearch-goal' && typeof r.slug === 'string';
}

Try / catch

try { await completeAutoresearchGoal(cwd, slug); }
catch (e) { if (e instanceof AutoresearchGoalError && e.message.startsWith('Invalid autoresearch-goal mission')) { /* recreate mission, do not retry blindly */ } else throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/ab7db08a109fd151. Report an issue: GitHub.