Phase Type Definitions
Workflow phases (spec, exec, qa, etc.) are defined once in a canonical Zod schema. All modules that need the Phase type import from this single source.
Prerequisites
Section titled “Prerequisites”- Zod — already a project dependency (
import { z } from "zod")
Where Phase Is Defined
Section titled “Where Phase Is Defined”The canonical definition lives in src/lib/workflow/types.ts:
export const PhaseSchema = z.enum([ "spec", "security-review", "exec", "testgen", "test", "verify", "qa", "loop", "merger",]);
export type Phase = z.infer<typeof PhaseSchema>;Two other files re-export it (they do not define their own copy):
| File | Re-exports | Also exports |
|---|---|---|
state-schema.ts | PhaseSchema, Phase | WORKFLOW_PHASES (derived from PhaseSchema.options) |
run-log-schema.ts | PhaseSchema, Phase | — |
Adding a New Phase
Section titled “Adding a New Phase”- Add the phase string to the
z.enum([...])array insrc/lib/workflow/types.ts - Add prompt entries in
src/lib/workflow/phase-executor.ts(PHASE_PROMPTSandAIDER_PHASE_PROMPTS) - Run
npm run build— TypeScript will flag anyRecord<Phase, ...>maps missing the new entry - Run
npx vitest run src/lib/workflow/phase-types.test.tsto verify schema identity
No changes needed in state-schema.ts or run-log-schema.ts — they derive from the canonical source automatically.
Verdict Types
Section titled “Verdict Types”Merge-check verdict types follow the same pattern in src/lib/merge-check/types.ts:
export const CHECK_VERDICTS = ["PASS", "WARN", "FAIL"] as const;export const CheckVerdictSchema = z.enum(CHECK_VERDICTS);export type CheckVerdict = z.infer<typeof CheckVerdictSchema>;What to Expect
Section titled “What to Expect”PhaseSchema.optionsreturns the readonly tuple of all phase stringsPhaseSchema.safeParse(value)validates a string at runtimeWORKFLOW_PHASESinstate-schema.tsisPhaseSchema.options(same object, not a copy)
Troubleshooting
Section titled “Troubleshooting”Build error: “Property ‘newPhase’ is missing in type”
Section titled “Build error: “Property ‘newPhase’ is missing in type””Symptoms: After adding a phase, npm run build fails on Record<Phase, string> maps.
Solution: Add the new phase to every Record<Phase, ...> in the codebase. The two known locations are PHASE_PROMPTS and AIDER_PHASE_PROMPTS in phase-executor.ts.
Test failure: “expected X toBe Y”
Section titled “Test failure: “expected X toBe Y””Symptoms: phase-types.test.ts fails with identity check errors.
Solution: A file is defining its own PhaseSchema instead of importing from types.ts. Check for independent z.enum definitions containing "spec" and replace with an import.
Generated for Issue #401 on 2026-03-25