coleam00/Archon · error · Error
Workflow run '${runId}' references codebase '${codebaseId}',
Error message
Workflow run '${runId}' references codebase '${codebaseId}', but that codebase no longer exists.
Cannot safely discover workflows from the run worktree because project workflow files may be missing.
Re-register the project or restore the codebase row, then retry. What it means
Before discovering workflows from a run's worktree, commands like resume/approve/reject/respond load the run's codebase row. If the row is gone (dangling foreign reference), the CLI refuses to proceed because project workflow files may no longer be discoverable.
Source
Thrown at packages/cli/src/commands/workflow.ts:4181
// Precheck failures follow each mode's error contract: --json emits the
// standard { ok: false } line; human mode throws like the inline path.
if (json) {
await printJsonWriteError(runId, action, error);
return;
}
throw error;
}
}
async function resolveDiscoveryCwdForCodebase(
runId: string,
codebaseId: string,
action: 'resume' | 'approve' | 'reject' | 'respond'
): Promise<string> {
try {
const codebase = await codebaseDb.getCodebase(codebaseId);
if (!codebase) {
throw new Error(
`Workflow run '${runId}' references codebase '${codebaseId}', but that codebase no longer exists.\n` +
'Cannot safely discover workflows from the run worktree because project workflow files may be missing.\n' +
'Re-register the project or restore the codebase row, then retry.'
);
}
return codebase.default_cwd;
} catch (error) {
const err = error as Error;
if (err.message.includes('references codebase')) {
throw err;
}
getLog().error(
{ err, errorType: err.constructor.name, runId, codebaseId },
`cli.workflow_${action}_codebase_lookup_failed`
);
throw new Error(
`Failed to load codebase '${codebaseId}' for workflow run '${runId}': ${err.message}\n` +
'Cannot safely discover workflows from the run worktree because project workflow files may be missing.\n' +View on GitHub (pinned to 0773b97458)
Solutions
- Re-register the project (`archon project register` from the checkout) so a codebase row exists again, then retry the action.
- If re-registration creates a new id, restore the original codebase row (or update the run's codebase_id) in the database.
- If the runs are stale, drop the orphaned run rows instead of acting on them.
Example fix
// before archon workflow approve ab12 # codebase row deleted // after cd ~/projects/my-app && archon project register && archon workflow approve ab12
Defensive patterns
Strategy: validation
Validate before calling
const run = await getRun(runId, { json: true }); const cb = await db.getCodebase(run.codebaseId); if (!cb) throw new Error('codebase row missing; re-register project first'); Type guard
function codebaseExists(c: Codebase | null | undefined): c is Codebase { return c != null && typeof c.default_cwd === 'string'; } Try / catch
try { await approve(runId); } catch (e) { if (String(e.message).includes('no longer exists')) { await exec('archon project register'); await approve(runId); } else throw e; } Prevention
- Re-register (not delete) projects you intend to keep acting on; cascade or clean run rows when a project is truly removed.
- Avoid manual DB pruning of the codebases table while runs reference it.
- Restore codebase rows when restoring partial database backups.
When it happens
Trigger: Invoking `workflow resume/approve/reject/respond <runId>` where runs.codebase_id points to a codebases row deleted via re-registration cleanup or manual DB pruning.
Common situations: Re-registering or deleting a project while old runs still reference it; pruning the database without cascading run rows; restoring a partial DB backup.
Related errors
- Failed to get workflow run: ${err.message}
- Failed to load codebase '${codebaseId}' for workflow run '${
- Cannot create worktree: database lookup failed. Error: ${res
- Cannot create worktree: repository registration failed. Erro
- Cannot execute run '${detachedPreCreatedRun.id}': it belongs
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/6ed586aad266a57d.
Report an issue: GitHub.