Skip to content

feat(types,core): migrate to explicit type field discrimination #344

@perasperaactual

Description

@perasperaactual

Context

See ROADMAP.md section 'Grammar Hardening'.

Problem

The content renderer currently uses Object.entries(item)[0] to discriminate content types. This pattern:

  • Relies on JS object insertion order (not guaranteed)
  • Prevents TypeScript discriminated unions
  • Produces poor error messages

Solution

Migrate to an explicit type field on every content item. This is a breaking change that:

  • Enables proper discriminated union narrowing
  • Produces clearer validation errors
  • Requires updates to all YAML files, tests, and content types

Acceptance Criteria

  • Update Zod schemas to use z.object({ type: z.literal('...'), ... }) pattern
  • Update content renderer to use item.type switch
  • Update all content type TypeScript discriminated unions
  • Migrate all YAML content files to use explicit type field
  • Update unit tests
  • Update E2E tests
  • Regenerate JSON schemas
  • Update AGENTS.md tables

Timeline

This is a breaking change - coordinate with next major version bump.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:nextCommitted — starting soon

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions