Skip to content

Enforce generator usage: prevent manual module creation without spec #356

Closed

Description

@joelteply

Problem

Nothing stops a developer (human or AI) from manually creating a ServiceModule with hand-written files, magic strings, and no IPC mixin. The generator exists but is optional. This leads to:

  • Inconsistent module structure
  • Missing IPC mixins (command exists in Rust but not accessible via jtag)
  • Missing health checks
  • Missing ts-rs bindings
  • Magic strings instead of generated constants

Proposed enforcement

Pre-commit/CI check

  • Scan modules/ for new directories
  • Verify each module has a corresponding spec in generator/specs/
  • Fail if a module exists without a spec (manual creation detected)

Generator-first workflow

  1. Create spec: generator/specs/grid.json (or .toml)
  2. Run generator: npx tsx generator/RustModuleGenerator.ts generator/specs/grid.json
  3. Generator creates: Rust skeleton, TS mixin, TS commands, ts-rs types, health endpoint
  4. Developer fills in the business logic (handle_command implementations)
  5. CI verifies spec↔module consistency

What to enforce

  • Every modules/{name}/ directory has a generator/specs/{name}.json
  • Every module's commands.rs constants match the spec
  • Every module has a health endpoint
  • Every wire type has #[derive(TS)]
  • IPC mixin exists in bindings/modules/{name}.ts

Escape hatch

  • #[generator(skip)] attribute or "generator_managed": false in spec for exceptional cases
  • But these get flagged in PR review

Why

Generators are architectural compilers (GENERATOR-OOP-PHILOSOPHY.md). If the generator is optional, it's not a compiler — it's a suggestion. Enforcement makes the architecture self-sustaining.

Activity

  1. joelteply commented on Mar 25, 2026

    @joelteply
    ContributorAuthor

    Merged into #353 (Generator v2). Enforcement comes after the generator can actually produce complete modules. #353 is the prerequisite.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions