Phase 3 (L39, ST13, ST9, ST10). - L39: deleted codegen/seed-midi-devices.ts. It regenerated — and therefore silently CLOBBERED — the hand-tuned device schemas it had originally created. Its purpose is served and git retains it. Confirmed nothing invokes it (the root package.json that once might have was deleted in Phase 1). - ST13: moved the provenance artifact out of the repo root. AUDIT CORRECTION: the finding's proposed destination, schemas/midi_devices/synth-midi-cc.sources.json, would have BROKEN codegen and CI — generate-midi-devices.ts treats every *.json directly under that directory as a device template and ajv-validates it, and the sources file has no device_id/midi/params, so the generator would exit non-zero. It went to schemas/midi_devices/sources/ instead. - ST9: schemas/schema.json's own description stated the direction of truth BACKWARDS. Rewritten: schemas are canonical, codegen emits C++ and TypeScript. (The audit cited params_notes.md; the real path is schemas/modes/params_notes.md.) - ST10: codegen/README.md rewritten against current reality — it described retired playground paths and a phantom temp dir. Descriptions are never emitted, so this is behaviour-inert; proven by regenerating all four generated directories byte-identically. |
||
|---|---|---|
| .. | ||
| tests | ||
| .gitignore | ||
| generate-midi-devices.ts | ||
| generate.ts | ||
| lib.ts | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
codegen — schemas → C++ + TypeScript
Bun scripts that turn the JSON schemas under schemas/ into generated code for both
targets. The per-file inventory lives in MAP.md (§ codegen/) — this README only
covers how to run it.
generate.ts— validatesschemas/modes/*.jsonagainstschemas/schema.json, emitsnisps/modes/generated/<mode>_schema.hpp(+schema_types.hpp) andmanifold/src/modes/generated/<mode>_schema.ts(+types.ts,index.ts).generate-midi-devices.ts— validatesschemas/midi_devices/*.jsonagainstschemas/midi_device.schema.json, emitsnisps/midi/generated/midi_devices.hppandmanifold/src/midi-devices/generated/{types,devices,index}.ts.
Both validate with ajv (Draft 2020-12), exit non-zero on failure, and are idempotent (re-running with unchanged schemas is byte-identical).
Run
cd codegen
bun install
bun run generate.ts # mode schemas
bun run generate-midi-devices.ts # MIDI device templates
Schema or codegen changes ship with the regenerated C++ and TypeScript in the same commit — CI re-runs both generators and fails on any diff.
Golden test
tests/golden_test.ts re-runs generate.ts against the live output dirs, diffs
paf_synth_schema.{hpp,ts} against the snapshots in tests/golden/, then re-runs to
prove idempotency:
bun run test
After an intentional emission change, refresh the goldens:
bun run generate.ts
cp ../nisps/modes/generated/paf_synth_schema.hpp tests/golden/
cp ../manifold/src/modes/generated/paf_synth_schema.ts tests/golden/
Adding a mode / device
Drop the new JSON into schemas/modes/ (or schemas/midi_devices/), run the matching
generator, and commit the JSON plus the regenerated outputs together.