Skip to content

Null phases render as active stations on assembly line #36

Description

@williamthorsen

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.tsisPhaseActive() uses !== undefined checks to determine station activation
  • agent-state-resolver.tsPHASE_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 nullundefined 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions