Description
After CODY-34 relaxed the status-adapter validator to accept null phase entries (representing skipped phases), a type mismatch causes skipped phases to render as active stations on the Factory assembly line.
The Phases interface defines each phase as SomePhase | undefined, but JSON data uses null for skipped phases. Since the validator now passes null through without coercing it, client-side code that checks phases.architecture !== undefined treats null as present (because null !== undefined is true).
Affected code paths:
run-to-scene.ts — isPhaseActive() uses !== undefined checks to determine station activation
agent-state-resolver.ts — PHASE_STATUS_ACCESSORS use optional chaining (?.), which safely returns undefined for null (no crashes, but the station still lights up because isPhaseActive already flagged it as active)
Impact: Skipped phases appear as active stations in the visualization. No crashes — optional chaining protects against null dereferencing — but the visual state is incorrect.
Root cause: null (JSON's "absent") vs undefined (TypeScript's "absent") mismatch. The fix needs to either normalize at the boundary (coerce null → undefined in the adapter) or update the type + client checks to handle both.
Acceptance criteria
Must have
- Skipped phases (
null in run-index.json) do not render as active stations on the assembly line
- Existing phases with valid data continue to render correctly
- Tests cover the null-phase rendering path
Should have
- The
Phases type accurately reflects the runtime values (either by normalizing nulls to undefined in the adapter, or by updating the type to include | null)
Nice to have
- A consistent convention across the codebase for how "absent" values from JSON are handled at the adapter boundary
Description
After CODY-34 relaxed the status-adapter validator to accept
nullphase entries (representing skipped phases), a type mismatch causes skipped phases to render as active stations on the Factory assembly line.The
Phasesinterface defines each phase asSomePhase | undefined, but JSON data usesnullfor skipped phases. Since the validator now passesnullthrough without coercing it, client-side code that checksphases.architecture !== undefinedtreatsnullas present (becausenull !== undefinedistrue).Affected code paths:
run-to-scene.ts—isPhaseActive()uses!== undefinedchecks to determine station activationagent-state-resolver.ts—PHASE_STATUS_ACCESSORSuse optional chaining (?.), which safely returnsundefinedfornull(no crashes, but the station still lights up becauseisPhaseActivealready flagged it as active)Impact: Skipped phases appear as active stations in the visualization. No crashes — optional chaining protects against null dereferencing — but the visual state is incorrect.
Root cause:
null(JSON's "absent") vsundefined(TypeScript's "absent") mismatch. The fix needs to either normalize at the boundary (coercenull→undefinedin the adapter) or update the type + client checks to handle both.Acceptance criteria
Must have
nullin run-index.json) do not render as active stations on the assembly lineShould have
Phasestype accurately reflects the runtime values (either by normalizing nulls to undefined in the adapter, or by updating the type to include| null)Nice to have