Skip to content

Generate Godot send() kwarg map from Python on release#774

Open
bwhitman wants to merge 1 commit into
mainfrom
claude/godot-kwmap-sync
Open

Generate Godot send() kwarg map from Python on release#774
bwhitman wants to merge 1 commit into
mainfrom
claude/godot-kwmap-sync

Conversation

@bwhitman

Copy link
Copy Markdown
Collaborator

Problem

The send() kwarg → wire-code map was hand-duplicated in three places that had to be kept in sync manually:

  • amy/__init__.py _KW_MAP_LIST — the source of truth
  • godot/amy.gd _KW_MAP
  • a verbatim third copy embedded in setup_godot.sh

The Godot copies had silently drifted ~20 entries behind Python — missing bus (the reported gap), plus patch_string, the synth sub-params (pedal, synth_flags, oscs_per_voice, to_synth, grab_midi_notes, note_source, synth_delay), the sample params, midi_cc/midi_note_cmd/cv_trigger, sequencer_run, and the eg0/eg1 aliases — and carried a wrong type for volume (F instead of L).

JS doesn't have this problem: scripts/gen_amy_js_api.py already generates it from _KW_MAP_LIST, and #773 now rebuilds it on release.

Fix

Make Godot generated from the Python source, the same way JS is:

  • scripts/gen_amy_gd_api.py (new) rewrites the # BEGIN/END GENERATED region of godot/amy.gd from _KW_MAP_LIST, reusing the JS generator's parser so the two bindings can't disagree. Run via make godot-api.
  • release.yml runs make godot-api next to the web rebuild and folds godot/amy.gd into the tagged bump commit — so the released addon (built from godot/ at the tag) always matches the Python API.
  • c-cpp.yml gains a godot-api job that fails any PR where godot/amy.gd drifts from _KW_MAP_LIST, and validates the generated GDScript with gdparse (the addon build never parses amy.gd, so nothing else would catch a syntax error).

Also in here

  • Ordering fix: message() now sorts keys by _KW_PRIORITY like Python/JS, so patch_string is emitted last — required now that it's in the map, since it consumes to the end of the message.
  • De-dup setup_godot.sh: it now cps godot/amy.gd instead of embedding a copy. That third copy had drifted even further (also missing amy.gd's web-configure block), so this removes ~300 lines and a whole class of drift.

Verification

  • make godot-api is idempotent; godot/amy.gd now has all 63 params, with bus present and volume corrected to ["V", "L"].
  • gdparse godot/amy.gd passes (the lambda + typed loops are valid Godot 4 GDScript).
  • bash -n setup_godot.sh and YAML validation of both workflows pass.

Follows #773 (already merged) — both regenerate artifacts into the release bump commit.

🤖 Generated with Claude Code

The send() kwarg-to-wire map was hand-duplicated in three places: amy/__init__.py _KW_MAP_LIST (the source of truth), godot/amy.gd, and a verbatim copy embedded in setup_godot.sh. The Godot copies had silently drifted ~20 entries behind Python (missing bus, patch_string, the synth sub-params, the sample/midi/cv params and the eg0/eg1 aliases) and carried a wrong type for volume.

Generate the Godot map from the Python source the same way gen_amy_js_api.py does for the browser build: scripts/gen_amy_gd_api.py rewrites the BEGIN/END GENERATED region of godot/amy.gd from _KW_MAP_LIST (make godot-api), reusing the JS generator parser. release.yml runs it and folds godot/amy.gd into the tagged bump commit, so the released addon (built from godot/ at the tag) always matches. c-cpp.yml fails any PR where the map drifts or the GDScript stops parsing (gdparse).

Also sort message() keys by _KW_PRIORITY like Python and JS so patch_string is emitted last (required now that it is in the map), and stop embedding a second amy.gd in setup_godot.sh -- it now copies godot/amy.gd, which also fixes a separate drift where the embedded copy lacked the web-configure block.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant