Skip to content

feat(core): consume keys.json — song-level key/scale track (loader + WS) - #528

Merged
byrongamatos merged 1 commit into
mainfrom
feat/core-keys-json
Jun 20, 2026
Merged

feat(core): consume keys.json — song-level key/scale track (loader + WS)#528
byrongamatos merged 1 commit into
mainfrom
feat/core-keys-json

Conversation

@byrongamatos

Copy link
Copy Markdown
Contributor

The feedpak spec defines keys.json — a song-level, instrument-independent key/scale-change track (§7.7) — but core never loaded it. This adds it, mirroring the song_timeline / drum_tab side-file pattern. (Unblocks scale-degree sd in the teaching-marks FEP.)

Change

  • lib/sloppak.pyLoadedSloppak gains a keys field; a permissive loader reads the manifest keys: key, path-safety-checks it (no escape), and stores a sanitized {version, events:[{t, key, scale?}]}:
    • finite non-bool t (bad-t events dropped, not rewritten to 0), non-empty string key, optional string scale, sorted;
    • int-only version (a float/NaN version can't abort the load);
    • missing / unreadable / malformed → None, never fatal.
  • server.py — streams a keys highway-WS message when present + a has_keys song_info flag so a consumer can light up a key/scale display.

Renderer/HUD surfacing is a thin follow-up; this lands the data plumbing so the highway, plugins, and the upcoming sd annotation can read the active key/mode from the WS.

Review

Codex-reviewed (2 rounds — hardened version-int coercion + bad-t drop); final pass clean.

Tests

+7 loader cases (happy path, absent/permissive variants, sanitize/sort, non-int-version no-abort).

PYTHONPATH=lib python -m pytest tests/ -k "sloppak or load" -q
# 150+ passed

Closes #525. Part of #334.

🤖 Generated with Claude Code

The feedpak spec defines keys.json (instrument-independent key/scale-change
track, §7.7) but core never loaded it. Add it, mirroring the song_timeline /
drum_tab side-file pattern:

- lib/sloppak.py: LoadedSloppak gains a `keys` field; a permissive loader reads
  the manifest `keys:` key, path-safety-checks it, and stores a SANITIZED
  {version, events:[{t, key, scale?}]} — finite non-bool t (bad-t events dropped,
  not rewritten to 0), non-empty string key, optional string scale, sorted.
  Missing / unreadable / malformed -> None, never fatal. int-only version
  (a float/NaN version can't abort the load).
- server.py: stream a `keys` highway-WS message when present + a `has_keys`
  song_info flag so a consumer can light up a key/scale display.

Renderer/HUD surfacing is a thin follow-up; this lands the data plumbing so
the highway, plugins, and the upcoming scale-degree (`sd`) annotation can read
the active key/mode from the WS.

Codex-reviewed (2 rounds: version-int-coercion + bad-t-drop hardening); clean.
+7 loader tests (happy path, absent/permissive variants, sanitize/sort,
non-int-version no-abort). 150 sloppak/load tests pass.

Closes #525. Part of #334.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos merged commit e64378d into main Jun 20, 2026
0 of 3 checks passed
@byrongamatos
byrongamatos deleted the feat/core-keys-json branch June 20, 2026 19:23
byrongamatos added a commit that referenced this pull request Jun 22, 2026
…cycle (#568)

Addresses Codex review of #526/#528:
- midi-input discover(): one provider's enumerate() rejection no longer aborts
  the whole discovery — other providers (e.g. a native/desktop MIDI provider)
  are still queried; denial is only reported when NO provider enumerates.
- Home tour now waits for a 'v3:dashboard-rendered' event (dashboard.js emits
  it after the #v3-home innerHTML swap) before attaching Shepherd, instead of a
  single animation frame that could latch onto pre-render nodes the async
  dashboard render then replaces.
- "Play it now" onboarding now arms the tour (armPendingFirstRun) to run the
  first time the user returns to v3-home, instead of silently never showing it.

Co-authored-by: Claude Opus 4.8 (1M context) <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.

feat(core): consume keys.json — song-level key/scale track (loader + WS + display)

1 participant