Skip to content

Unified generator architecture: specs → Rust traits → TS commands - #300

Merged
joelteply merged 1 commit into
mainfrom
feature/unified-generator-architecture
Mar 12, 2026
Merged

joelteply merged 1 commit into
mainfrom
feature/unified-generator-architecture

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

  • Architecture design for the unified generator that produces the complete Rust+TS vertical from a single JSON spec
  • ManagedService trait: health(), pressure_response(), shed_load(), heal(), shutdown() — every resource-owning module must implement
  • Generator adapters: RustIPC, ServerOnly, BrowserOnly, FullStack, TraitOnly
  • CommandSpec v2: Complex types, union types, nested interfaces, Rust config, imports
  • Reverse engineer mode: Read existing hand-written commands → produce specs (critical for migrating 266 commands)
  • Audit mode: Scan all 312 commands, report conformance
  • Enforcement: Precommit check — new command dirs must have generator spec
  • Three implementation phases: A (generator redesign), B (Rust ManagedService), C (full vertical)

Why this matters

Yesterday's 35GB memory leak happened because TypeScript made a resource decision that Rust should have gated. With ManagedService, adapter loading checks health() and pressure_response() before touching GPU memory. The trait is compile-time enforced — you can't forget it.

Broader impact

Generators as architectural compilers for AI-assisted development. The insight: the right abstraction for AI coding isn't "generate code" — it's "generate specs, compile to code." 15x token reduction, zero drift, institutional knowledge baked into the compiler.

Test plan

  • Design document review — no code changes yet
  • Phase A: Generator redesign (next PR)
  • Phase B: Rust ManagedService trait
  • Phase C: Full vertical generation

Design doc for the architectural compiler that generates the complete
stack from a single JSON spec — Rust ManagedService traits, ts-rs wire
types, IPC mixins, and TypeScript commands.

Key concepts:
- ManagedService trait: health(), pressure_response(), shed_load(), heal()
- Generator adapters: RustIPC, ServerOnly, BrowserOnly, FullStack, TraitOnly
- Reverse engineer mode: read existing commands, produce specs
- Audit mode: scan all commands, report conformance
- Enforcement: precommit check for new commands without specs
- CommandSpec v2: complex types, imports, Rust config, adapter selection

Three phases: A (generator redesign), B (Rust traits), C (full vertical)
Copilot AI review requested due to automatic review settings March 12, 2026 15:15
@joelteply
joelteply merged commit 02a04e0 into main Mar 12, 2026
3 of 4 checks passed
@joelteply
joelteply deleted the feature/unified-generator-architecture branch March 12, 2026 15:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a design document describing a proposed unified generator architecture that compiles a single JSON spec (CommandSpec v2) into a complete Rust + TypeScript “vertical”, including Rust trait contracts (e.g., ManagedService) and TS command layers, with planned reverse-engineering/audit/enforcement workflows to migrate existing commands and prevent drift.

Changes:

  • Introduces the unified generator architecture design (vision, adapters, phases, success metrics).
  • Specifies a proposed ManagedService contract and related cross-cutting traits for resource-owning Rust modules.
  • Defines a v2 command spec shape and planned generator modes (reverse/audit) + enforcement hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +129 to +133
generator/enforce.ts:
- Scan commands/ for directories without matching spec in generator/specs/
- FAIL if any new (untracked by git) command dir has no spec
- WARN if existing command dir has no spec (migration in progress)
```

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within the doc, the enforcement script is named generator/enforce.ts, but later the proposed post-redesign layout places this under generator/enforce/PrecommitCheck.ts. Consider standardizing on one path/name (and preferably prefixing with src/ if these paths are meant from repo root) to avoid confusion during implementation.

Copilot uses AI. Check for mistakes.
Comment on lines +96 to +99
# Read existing hand-written command, generate spec from it
npx tsx generator/CommandGenerator.ts --reverse commands/sentinel/run

# Output: generator/specs/sentinel-run.json (inferred from code)

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI example uses --reverse, but the current src/generator/CommandGenerator.ts CLI only supports --template, --test, or <spec-file.json> (no --reverse). To avoid misleading readers, mark this as a Phase A planned flag (or reference the new script that will be added) and clarify the expected working directory (these generator/... paths only resolve when run from src/).

Suggested change
# Read existing hand-written command, generate spec from it
npx tsx generator/CommandGenerator.ts --reverse commands/sentinel/run
# Output: generator/specs/sentinel-run.json (inferred from code)
# Phase A (planned) flag — not yet supported by the current CommandGenerator.ts CLI
# Run from the src/ directory so generator/... paths resolve correctly
# Read existing hand-written command, generate spec from it
npx tsx generator/CommandGenerator.ts --reverse commands/sentinel/run
# Output (planned): generator/specs/sentinel-run.json (inferred from code)

Copilot uses AI. Check for mistakes.
Comment on lines +105 to +111
### Audit Mode

```bash
# Scan all commands, report conformance
npx tsx generator/CommandGenerator.ts --audit

# Output:

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example shows npx tsx generator/CommandGenerator.ts --audit, but the current src/generator/CommandGenerator.ts CLI doesn't implement an --audit flag. If this is part of Phase A, label it as planned/future behavior (or point to the intended audit entrypoint) so current users don’t try to run a non-existent command.

Suggested change
### Audit Mode
```bash
# Scan all commands, report conformance
npx tsx generator/CommandGenerator.ts --audit
# Output:
### Audit Mode (planned)
```bash
# Planned Phase A behavior — current CommandGenerator CLI does not yet support --audit
# Intended: scan all commands and report conformance
npx tsx generator/CommandGenerator.ts --audit
# Output (planned):

Copilot uses AI. Check for mistakes.

```bash
# Precommit check: new command dirs must have generator spec
# Added to .husky/pre-commit or equivalent

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section references adding the enforcement hook to .husky/pre-commit, but this repo currently uses a committed .githooks/pre-commit hook instead. Updating the doc to reference .githooks/pre-commit (or the repo’s actual hook installation mechanism) will keep the instructions actionable.

Suggested change
# Added to .husky/pre-commit or equivalent
# Added to .githooks/pre-commit (or your repo's hook mechanism)

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Aug 3, 2026
* docs(serving): gather consume-arm BUILT + first live A/B measured — 4.0x decode, zero bytes/token (#314 / fork #23)

Updates the Cut-2 map with what actually landed on the fork (a3effefe4):
the consume-arm as-built (per-backend repr seam via get_proc_address, table
pool sub-pooled by cur_copy, gather-epoch eviction fence semantics), the
first live A/B (OLMoE on M5 Metal: copy 12.23 t/s @ 465 MiB/token vs gather
49.09 t/s @ 0 bytes — 4.0x, 100% hit, temp-0 coherence both arms), and the
three serving-config traps (CPU repack silently disables the path; decode
min-batch default; device-engagement verification) — the last learned via a
watchdog kernel panic, documented so nobody pays that tuition twice.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(serving): Grid Expert Share build plan — the GridFetcher arc (#180/#300 convergence)

Plans grid-shared expert serving on the proven Cut-2 substrate: depot-not-fork
architecture (llama.cpp's entire grid surface = one localhost URL; all grid
intelligence in a continuum-core expert_depot module), five slices from
manifest instrument through the two-machine partial-artifact proof to the
flagship cross-node measure, with the learned guardrails baked in (disk tier
governed on day one, content-hash verify, never-block-serving, headroom rule,
fail-loud engagement).

Composes only existing seams: ExpertFetcher adapters, ExpertId keying, the
fenced ResidencyCache, plan-file actuators, airc control plane, pager
predictor. No parallel systems.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants