Skip to content

Generator v2: emit Rust modules, IPC tokio scaffolding, tests, and ts-rs bindings #353

Closed as not planned

Description

@joelteply

airc-queue card

Coordinates work via the AIRC queue substrate (airc#562). Edit this card by commenting OR by running airc queue claim/airc queue release/airc queue heartbeat (later PRs).

{
  "kind": "airc-queue-card-v1",
  "id": "#353",
  "owner": "claude-tab-1",
  "status": "claimed",
  "evidence": "bulk-adopted from continuum unlabeled-open backlog (Joel directive 2026-05-14)",
  "next_action": "triage scope + assign or close stale"
}

Close this issue when the work is done (status=merged/abandoned).

Original issue body

Pre-adoption body

Problem

The CommandGenerator currently emits TypeScript only:

  • Shared types (*Types.ts)
  • Server/browser command implementations
  • README, package.json, test stubs

It does NOT generate:

  • Rust commands.rs (command name constants + schemas)
  • Rust ServiceModule scaffolding
  • IPC concurrent tokio patterns (the boilerplate every module needs)
  • Integration test scaffolding for Rust
  • ts-rs #[derive(TS)] type definitions for wire types
  • TypeScript IPC mixin (bindings/modules/*.ts)

Vision

A single command spec (JSON or TOML) generates the ENTIRE stack:

spec: grid.toml
  → Rust:
    - commands.rs (constants, schemas)
    - mod.rs (ServiceModule skeleton with handle_command dispatch)
    - types.rs (wire types with #[derive(TS, Serialize, Deserialize)])
    - tests.rs (unit test stubs for each command)
  → TypeScript:
    - shared/*Types.ts (params, results)
    - bindings/modules/grid.ts (IPC mixin)
    - server/*ServerCommand.ts
    - browser/*BrowserCommand.ts
  → Docs:
    - README.md with usage examples
    - Command schema for MCP tool discovery

Key patterns to codify

IPC tokio boilerplate

Every module has the same pattern:

  • pub struct MyState { ... } with Arc<DashMap> for concurrent state
  • pub struct MyModule { state: Arc<MyState> }
  • ServiceModule impl with config(), initialize(), handle_command(), as_any()
  • Match dispatch to handler functions

This is mechanical and should be generated.

ts-rs bindings

Wire types that cross the Rust↔TS boundary need #[derive(TS)] with export paths. The generator should place these in shared/generated/ with barrel exports.

Test generation

  • Unit tests for each command (call handler with mock params, verify JSON result shape)
  • Integration test stubs (TCP roundtrip for grid-like modules)
  • Test that schemas match constants (like grid's test_schemas_match_constants)

Scope

  • Extend CommandGenerator.ts or create RustModuleGenerator.ts
  • Define spec format that covers both TS and Rust concerns
  • Generate for new modules; optionally retrofit existing ones
  • This is the "generators as architectural compilers" vision from GENERATOR-OOP-PHILOSOPHY.md

Activity

  1. joelteply commented on Mar 26, 2026

    @joelteply
    ContributorAuthor

    Generator as enforcer, not just scaffolder (from Joel):

    The generator must:

    1. Validate specs — reject bad naming, missing params, wrong patterns before generating anything
    2. Fix bad commands — if an existing command violates conventions, the generator should be able to audit and repair it
    3. Produce only correct output — generated code uses the API cleanly, follows all conventions, compiles without warnings
    4. Emit constants — every command name is a generated constant, not a string literal
    5. Be the ONLY way to create commands — no hand-written commands that skip validation

    The generator is not a convenience tool. It is the quality gate. A command that exists means it passed the generator. A command that does not pass the generator does not exist.

    This means:

    • npx tsx generator/CommandGenerator.ts audit — scan all commands, report violations
    • npx tsx generator/CommandGenerator.ts fix <command> — repair a command to comply
    • npx tsx generator/CommandGenerator.ts validate <spec> — check before generating
    • Generated constants file is the canonical command registry
    • Build fails if any command references a name not in the constants file
  2. added
    airc-queue
    on May 14, 2026
  3. github-actions commented on Sep 8, 2026

    @github-actions

    This issue is stale because it has been open for 60 days with no activity. Please comment or update this issue to keep it active.

  4. github-actions commented on Oct 8, 2026

    @github-actions

    This issue was closed because it has been inactive for 30 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    airc-queuestale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions