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

formatCodexGoalReconciliation(reconciliation)

Error message

formatCodexGoalReconciliation(reconciliation)

What it means

completeAutoresearchGoal reconciles the supplied Codex goal snapshot (options.codexGoal, parsed by parseCodexGoalSnapshot) against the mission and throws with the formatted reconciliation report when reconciliation.ok is false. It enforces that a snapshot is present and the mission is complete, with all snapshot fields matching the mission.

Source

Thrown at src/autoresearch/goal.ts:243

    status: mission.status,
    evidence,
    artifact_path: options.artifactPath,
  });
  return { mission, completion };
}

export async function completeAutoresearchGoal(cwd: string, slug: string, options: CompleteAutoresearchGoalOptions = {}): Promise<{ mission: AutoresearchGoalMission; completion: AutoresearchGoalCompletion }> {
  const mission = await readAutoresearchGoal(cwd, slug);
  const completion = await readAutoresearchGoalCompletion(cwd, mission.slug);
  if (!completion || !completion.passed || completion.verdict !== 'pass') {
    throw new AutoresearchGoalError(`Autoresearch goal ${mission.slug} cannot complete until professor-critic validation records verdict=pass in ${mission.completion_path}.`);
  }
  const reconciliation = reconcileAutoresearchCodexGoalSnapshot(
    options.codexGoal === undefined ? null : parseCodexGoalSnapshot(options.codexGoal),
    mission,
    { requireSnapshot: true, requireComplete: true },
  );
  if (!reconciliation.ok) throw new AutoresearchGoalError(formatCodexGoalReconciliation(reconciliation));
  const completedAt = iso(options.now);
  mission.status = 'complete';
  mission.updated_at = completedAt;
  mission.completed_at = completedAt;
  await writeMission(cwd, mission);
  await appendLedger(cwd, mission.slug, {
    ts: completedAt,
    event: 'goal_completed',
    slug: mission.slug,
    status: mission.status,
    evidence: completion.evidence,
    artifact_path: completion.artifact_path,
  });
  return { mission, completion };
}

export function buildAutoresearchGoalObjective(mission: Pick<AutoresearchGoalMission, 'topic' | 'rubric' | 'slug'>): string {
  return [

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Pass options.codexGoal with the current Codex goal snapshot string when calling completeAutoresearchGoal
  2. Read the formatted message from formatCodexGoalReconciliation — it lists exactly which fields mismatch; fix those fields and retry
  3. Regenerate the snapshot from the live Codex goal state so it reflects the completed mission
  4. If the snapshot is malformed, check parseCodexGoalSnapshot's expected input format before passing it

Example fix

// before
await completeAutoresearchGoal(repoRoot, 'fix-leak'); // throws: snapshot required / mismatch
// after
await completeAutoresearchGoal(repoRoot, 'fix-leak', { codexGoal: currentCodexGoalSnapshotJson });
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'node:fs';
if (!existsSync(join(repoRoot, '.omx', 'autoresearch-goal', `${slugifyMissionName(slug)}.json`))) {
  throw new Error('Mission missing; snapshot reconciliation would fail.');
}

Type guard

function isReconcilable(r: { ok: boolean; mismatches?: string[] }): boolean { return r.ok; }

Try / catch

try { await completeAutoresearchGoal(cwd, slug, { codexGoal }); }
catch (e) { if (e instanceof AutoresearchGoalError) console.error(e.message /* the reconciliation report lists mismatches */); throw e; }

Prevention

When it happens

Trigger: Calling completeAutoresearchGoal without options.codexGoal (requireSnapshot: true), passing a malformed/stale Codex goal snapshot, or a snapshot whose fields (goal, status, metrics) diverge from the mission state at completion time.

Common situations: Upgrading to a version that made the snapshot mandatory, passing a snapshot captured before the final verdict, JSON drift between the Codex output and the mission record, or omitting the snapshot entirely in older automation scripts.

Related errors


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