Skip to content

Generate the frontend's wire types from nodespace-types and gate them for drift #3440

Closed

Description

@malibio

Overview

Generate the frontend's TypeScript wire types from nodespace-types with ts-rs, commit the output, and add a merge-gate stage that fails when the committed files drift from Rust (ADR-086 §8).

Problem Statement

  • Every wire type is hand-mirrored in TypeScript (packages/desktop-app/src/lib/types/). The AI-chat and schema interfaces have already drifted from Rust.
  • The only parity guard parses four promoted_fields lists.
  • Under ADR-086 every core type is fully typed, including nested shapes (query filters, play rules, schema fields), which is too much to mirror by hand.

Proposed Solution

  1. Add ts-rs to nodespace-types behind a cargo feature, so normal builds don't compile it. Derive TS on every wire type, respecting the existing serde attributes (rename_all, skip_serializing_if, tagged enums). Use #[ts(type)] overrides for custom-Serialize enums.
  2. Add bun run gen:types, which writes one file per type into packages/desktop-app/src/lib/types/generated/. The generated files are committed and never edited by hand.
  3. Generate TYPED_CORE_FIELDS and TYPED_CORE_DEFAULTS from the registry (the CoreNodeType issue).
  4. Replace hand-written TypeScript shapes with imports from generated/. Keep hand-written guards, default-filling converters, primitive aliases (PrimitiveNode<'header'>) and helpers.
  5. Add a merge-gate stage that regenerates and fails on any diff, following the SKILL.md drift check pattern.

Architecture Impact

Implements decisions/086-core-node-types-defined-once-typed-by-category.md §8 (nodespace-docs). components/creating-node-types.md and development/node-type-sequence.md already describe "regenerate TypeScript" as a step.

Acceptance Criteria

  • bun run gen:types writes the generated files; running it twice is a no-op
  • Every wire type in nodespace-types has a generated TypeScript file; the frontend imports them, and no hand-written interface restates a generated shape
  • TYPED_CORE_FIELDS / TYPED_CORE_DEFAULTS are generated; packages/desktop-app/src/lib/types/typed-core-fields.ts holds no hand-maintained field lists
  • The merge gate fails when a Rust wire-type change lands without regenerated TypeScript (test the stage with a fixture)
  • Default cargo builds don't compile ts-rs
  • bun run test:changed passes; bun run quality:fix clean

Technical Specifications

Reference Files

  • packages/nodespace-types/src/ (all wire types), packages/nodespace-types/Cargo.toml
  • packages/desktop-app/src/lib/types/ (node.ts, ai-chat-node.ts, typed-core-fields.ts, others)
  • scripts/test-gate.ts, scripts/gate-scope.ts (gate stages and scope)
  • The existing SKILL.md drift check, as the pattern to follow

Dependencies

Non-Goals

  • Changing any wire shape (that belongs to each type's own issue)

Activity

  1. malibio commented on Oct 1, 2026

    @malibio
    CollaboratorAuthor

    Baseline on main at 2760354 — Frontend: 299 test files passed

  2. self-assigned this
    on Oct 1, 2026
  3. malibio commented on Oct 1, 2026

    @malibio
    CollaboratorAuthor

    Correction: baseline on main at 2760354 — Frontend: 301 test files, 5558 tests passed

  4. added 3 commits that reference this issue on Oct 1, 2026
    fe73a70
    112063c
    515e0c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions