Repository navigation
Closed
Description
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_fieldslists. - 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
- Add
ts-rstonodespace-typesbehind a cargo feature, so normal builds don't compile it. DeriveTSon every wire type, respecting the existing serde attributes (rename_all,skip_serializing_if, tagged enums). Use#[ts(type)]overrides for custom-Serializeenums. - Add
bun run gen:types, which writes one file per type intopackages/desktop-app/src/lib/types/generated/. The generated files are committed and never edited by hand. - Generate
TYPED_CORE_FIELDSandTYPED_CORE_DEFAULTSfrom the registry (theCoreNodeTypeissue). - Replace hand-written TypeScript shapes with imports from
generated/. Keep hand-written guards, default-filling converters, primitive aliases (PrimitiveNode<'header'>) and helpers. - Add a merge-gate stage that regenerates and fails on any diff, following the
SKILL.mddrift 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:typeswrites the generated files; running it twice is a no-op - Every wire type in
nodespace-typeshas a generated TypeScript file; the frontend imports them, and no hand-written interface restates a generated shape -
TYPED_CORE_FIELDS/TYPED_CORE_DEFAULTSare generated;packages/desktop-app/src/lib/types/typed-core-fields.tsholds 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:changedpasses;bun run quality:fixclean
Technical Specifications
Reference Files
packages/nodespace-types/src/(all wire types),packages/nodespace-types/Cargo.tomlpackages/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.mddrift check, as the pattern to follow
Dependencies
- Add the core node type registry, shared envelope, closed schemas and extends-aware rules #3439 (the registry and envelope that the generated types mirror)
Non-Goals
- Changing any wire shape (that belongs to each type's own issue)
Activity
malibio commentedon Oct 1, 2026
Baseline on main at 2760354 — Frontend: 299 test files passed
malibio commentedon Oct 1, 2026
Correction: baseline on main at 2760354 — Frontend: 301 test files, 5558 tests passed
Generate the frontend's wire types from nodespace-types and gate them…
Generate the frontend's wire types from nodespace-types and gate them…
Generate the frontend's wire types from nodespace-types and gate them…