Skip to content

fix(editor): a drum edit no longer strips authored keys from drum-part manifest entries - #345

Merged
ChrisBeWithYou merged 1 commit into
mainfrom
drum-entry-key-preserve
Jul 22, 2026
Merged

ChrisBeWithYou merged 1 commit into
mainfrom
drum-entry-key-preserve

Conversation

@ChrisBeWithYou

@ChrisBeWithYou ChrisBeWithYou commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What

Closes a data-loss window opened by feedpak-spec 1.18.0 (spec #62, merged today): a type: "drums" arrangement entry can now carry a per-arrangement tones sound binding — but the editor's /save_song drum block rebuilds every drum-pointer entry from scratch as {id, name, type, drum_tab} on any drum-dirty save. Edit the drums in a pack whose entries carry tones (or any extension key), hit Save, and the binding silently vanished.

The fix

The rebuild now merges each entry onto its prior same-id entry through the existing _merge_manifest_entry — the exact unknown-key preservation rule the pitched pipeline has followed since the merge-not-rebuild save (#101). Semantics:

  • authored/additive keys (tones, extension keys) survive verbatim;
  • the editor-owned keys (id/name/type/drum_tab) always take the rebuilt value;
  • no predecessor (a new part, or an id that changed) → exactly the clean four-key entry, so single-drum packs stay byte-identical with pre-1.18.0 saves.

Extracted as module-level _drum_pointer_entry (used at both the primary-alias and extra-part sites), mirroring how the create-mode twin _create_build_drum_entries is pinned. Create mode builds fresh packs with no prior manifest — nothing to preserve, untouched. The absent-drum_parts branch already re-appends prior entries verbatim, so old clients were never the problem.

Spec cross-refs: 1.18.0 §5.2 entry tones; the §5.1 drum_tones/entry-tones precedence rule (top-level drum_tones was never at risk — the save merges the manifest top level rather than rebuilding it).

Tests

tests/test_drum_parts.py +3 (suite 14/14; the import fails on main where the helper doesn't exist):

  • tones + an extension key survive a rebuild while name/drum_tab take the new values; the prior entry object is never mutated
  • no predecessor → exactly the clean entry (byte-identical guarantee)
  • malformed predecessor contributes nothing rather than crashing the save

Full gates: pytest 381/0, npm run lint 0 errors, npm test 303/305 (the 2 failures pre-exist on main).

🤖 Generated with Claude Code

https://claude.ai/code/session_017xGPjDBF8NTwTK7VQvizix

Summary by CodeRabbit

  • Bug Fixes
    • Drum edits now preserve additional arrangement metadata and extension fields when saving.
    • Editor-managed drum fields continue to update correctly while unrelated authored keys remain intact.
    • Saving safely handles missing or malformed prior drum entries without errors.

…t manifest entries

The /save_song drum block rebuilds every type:"drums" pointer entry
from scratch as {id, name, type, drum_tab} whenever the client ships
drum_parts (any drum-dirty save). A pack whose drum entries carry
additive spec fields the editor doesn't author — feedpak-spec 1.18.0's
per-arrangement `tones` sound binding (spec #62), or any extension key
— lost them silently on the next drum edit + save.

The rebuild now merges each entry ONTO its prior same-id entry through
the same _merge_manifest_entry rule the pitched pipeline has followed
since the merge-not-rebuild save: authored/additive keys survive
verbatim, the editor-owned keys always take the rebuilt value, and a
part with no predecessor (or no id match after a rename) yields exactly
the clean four-key entry — so single-drum packs stay byte-identical.

Extracted as module-level _drum_pointer_entry for pytest, mirroring how
the create-mode twin (_create_build_drum_entries) is pinned. Create
mode itself builds fresh packs with no prior manifest, so it has
nothing to preserve and is untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xGPjDBF8NTwTK7VQvizix
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f168537-ae76-4bd0-9ffd-760e88959862

📥 Commits

Reviewing files that changed from the base of the PR and between f976f91 and 22ba8fe.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • routes.py
  • tests/test_drum_parts.py

📝 Walkthrough

Walkthrough

Drum arrangement pointer entries rebuilt during save now preserve prior additive keys while replacing editor-owned fields. The change adds a merge helper, integrates it into primary and extra drum pointer reconstruction, adds regression tests, and documents the fix.

Changes

Drum manifest preservation

Layer / File(s) Summary
Drum pointer merge helper
routes.py, tests/test_drum_parts.py
_drum_pointer_entry merges rebuilt core fields onto valid predecessors, falls back cleanly for missing or malformed predecessors, and is covered by regression tests.
Save rebuild integration
routes.py, CHANGELOG.md
The drum-parts save path matches prior pointer entries by ID and applies merged rebuilding to primary and extra drum pointers; the fix is documented.
Estimated code review effort: 2 (Simple) ~10 minutes

Possibly related PRs

Suggested reviewers: byrongamatos

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: preserving authored keys in drum-part manifest entries during drum edits.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch drum-entry-key-preserve

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ChrisBeWithYou
ChrisBeWithYou merged commit 0e3212a into main Jul 22, 2026
4 checks passed
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