{"record":{"id":"ad5a99af443cbdfa","repo":"Yeachan-Heo/oh-my-codex","slug":"final-code-review-must-use-an-independent-architec","errorCode":null,"errorMessage":"Final code-review must use an independent architect subagent; self-review or default/authoring-lane review cannot approve the ultragoal gate.","messagePattern":"Final code-review must use an independent architect subagent; self-review or default/authoring-lane review cannot approve the ultragoal gate\\.","errorType":"validation","errorClass":"UltragoalError","httpStatus":null,"severity":"error","filePath":"src/ultragoal/artifacts.ts","lineNumber":1744,"sourceCode":"  assertNonEmpty(review.evidence, 'codeReview.evidence');\n  const independentReview = (review as Partial<UltragoalQualityGate['codeReview']>).independentReview;\n  if (!independentReview || typeof independentReview !== 'object') {\n    throw new UltragoalError('Final code-review independent review unavailable: codeReview.independentReview must include completed code-reviewer and architect subagent evidence; use record-review-blockers instead of self-approving.');\n  }\n  const codeReviewer = independentReview.codeReviewer;\n  if (!codeReviewer || typeof codeReviewer !== 'object') {\n    throw new UltragoalError('Final code-review independent review unavailable: missing codeReview.independentReview.codeReviewer evidence from the code-reviewer subagent.');\n  }\n  if (codeReviewer.agentRole !== 'code-reviewer') {\n    throw new UltragoalError('Final code-review must use an independent code-reviewer subagent; self-review or default/authoring-lane review cannot approve the ultragoal gate.');\n  }\n  assertNonEmpty(codeReviewer.evidence, 'codeReview.independentReview.codeReviewer.evidence');\n  const architect = independentReview.architect;\n  if (!architect || typeof architect !== 'object') {\n    throw new UltragoalError('Final code-review independent review unavailable: missing codeReview.independentReview.architect evidence from the architect subagent.');\n  }\n  if (architect.agentRole !== 'architect') {\n    throw new UltragoalError('Final code-review must use an independent architect subagent; self-review or default/authoring-lane review cannot approve the ultragoal gate.');\n  }\n  assertNonEmpty(architect.evidence, 'codeReview.independentReview.architect.evidence');\n  validateArchitectureInvariantGate(gate, requiredInvariants);\n  return gate as UltragoalQualityGate;\n}\n\nexport async function startNextUltragoal(cwd: string, options: StartNextOptions = {}): Promise<{ plan: UltragoalPlan; goal: UltragoalItem | null; resumed: boolean; done: boolean }> {\n  return withUltragoalMutationLock(cwd, async () => {\n  const plan = await readUltragoalPlanUnderLock(cwd);\n  const now = iso(options.now);\n  if (plan.aggregateCompletion?.status === 'complete') return { plan, goal: null, resumed: false, done: true };\n  const existing = plan.goals.find((goal) => goal.status === 'in_progress' && isScheduleEligibleGoal(goal));\n  if (existing) {\n    await appendLedger(cwd, { ts: now, event: 'goal_resumed', goalId: existing.id, status: existing.status, message: 'Resuming active ultragoal' });\n    return { plan, goal: existing, resumed: true, done: false };\n  }\n\n  let next = plan.goals.find((goal) => goal.status === 'pending' && isScheduleEligible(goal));","sourceCodeStart":1726,"sourceCodeEnd":1762,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/ultragoal/artifacts.ts#L1726-L1762","documentation":"During final ultragoal quality-gate validation, the codeReview.independentReview.architect evidence exists but its agentRole is not 'architect'. The gate requires that the final code review be performed by an independent architect subagent; a self-review or a review performed by the default/authoring lane cannot approve the ultragoal gate.","triggerScenarios":"Calling checkpointUltragoal/completion with --quality-gate-json whose codeReview.independentReview.architect object is present but has agentRole !== 'architect' (e.g. 'default', 'coder', 'authoring-lane', or missing role) while the goal is a final gate candidate under strict mode.","commonSituations":"Teams wiring up the quality gate JSON by hand or via a script that fills in the reviewing agent's own role; pipelines where the architect subagent wasn't spawned and someone pasted reviewer evidence from the main agent; schema changes to the gate format that renamed agentRole.","solutions":["Re-run the final code review using an independent architect subagent and set independentReview.architect.agentRole to exactly 'architect' with non-empty evidence","Check the quality-gate JSON producer: ensure it records the architect subagent's role, not the authoring agent's role","Verify codeReviewer evidence and other required gate sections are also non-empty before resubmitting"],"exampleFix":"// before\n\"independentReview\": { \"codeReviewer\": {\"agentRole\": \"general\", \"evidence\": [\"...\"]}, \"architect\": {\"agentRole\": \"general\", \"evidence\": [\"reviewed diff\"]} }\n// after\n\"independentReview\": { \"codeReviewer\": {\"agentRole\": \"code-reviewer\", \"evidence\": [\"...\"]}, \"architect\": {\"agentRole\": \"architect\", \"evidence\": [\"architect subagent review notes\"]} }","handlingStrategy":"validation","validationCode":"const ok = gate?.codeReview?.independentReview?.architect?.agentRole === 'architect'\n  && (gate.codeReview.independentReview.architect.evidence ?? []).length > 0;\nif (!ok) throw new Error('quality gate lacks independent architect review');","typeGuard":"const isArchitectReview = (g: unknown): g is { agentRole: 'architect'; evidence: string[] } =>\n  typeof g === 'object' && g !== null && (g as any).agentRole === 'architect' && Array.isArray((g as any).evidence);","tryCatchPattern":"catch (e) { if (e instanceof UltragoalError && /independent architect subagent/.test(e.message)) { rerunReviewWithArchitectSubagent(); } else throw e; }","preventionTips":["Always spawn a dedicated architect subagent for final code review","Validate the quality-gate JSON against its schema before submitting completion"],"tags":["ultragoal","quality-gate","code-review","architect","validation"],"backgroundTag":"quality-gate-validation-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}