Skip to content

refactor(server): extract AudioEffectsMappingDB into lib/audio_effects_db.py (R3) - #831

Merged
byrongamatos merged 1 commit into
mainfrom
refactor/r3-audio-effects-db
Jul 10, 2026
Merged

refactor(server): extract AudioEffectsMappingDB into lib/audio_effects_db.py (R3)#831
byrongamatos merged 1 commit into
mainfrom
refactor/r3-audio-effects-db

Conversation

@byrongamatos

@byrongamatos byrongamatos commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Second step of R3, following #830. Move-only, backend-only, zero behaviour change.

What moves

AudioEffectsMappingDB (273 lines) — the core-owned song/tone → audio-effect-provider routing index — leaves server.py for lib/audio_effects_db.py. Its only dependency on the host file was CONFIG_DIR.

server.py: 9,705 → 9,433 lines (14,037 at the start of R3).

The one non-verbatim change

The same seam as #830: __init__ takes config_dir explicitly rather than reading the module-level CONFIG_DIR, so the new module performs no IO at import (Principle V).

audio_effect_mappings = AudioEffectsMappingDB(CONFIG_DIR)

The class body is byte-identical, and server.py reconstructs exactly from origin/main minus the cut range, plus the import-back and the call site. No import went dead.

What deliberately does not move

The audio_effect_mappings singleton stays in server.py. No route moves, no test changes, and none of the monkeypatch.setattr(server, …) targets is touched.

Verification

  • pyflakes: lib/audio_effects_db.py clean — zero undefined names, zero unused imports. server.py gains no new undefined name.
  • pytest2341 passed, 4 skipped (unchanged; no test needed retargeting).
  • npm run lint — 0 errors.
  • Boot smoke drives the extracted DB end-to-end rather than just importing it: POST /api/audio-effects/mappings creates a row, GET reads it back, and audio_effects.db is created under CONFIG_DIR — which is what actually proves the config_dir seam. All three migrated plugins (stems, studio, editor) still serve their src/ module graphs over the R0 route.
  • Codex preflight: 0 findings.

Register

docs/size-exemptions.md ratcheted: server.py → 9,433.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added persistent storage and routing for audio-effect mappings across providers.
    • Added support for listing, creating, updating, activating, and deleting mappings.
    • Added filtering by song, tone, filename, and provider.
  • Documentation

    • Updated changelog and project sizing documentation to reflect the audio-effects mapping improvements.

…s_db.py (R3)

Move-only, same shape as the MetadataDB extraction. The core-owned song/tone ->
audio-effect-provider routing index leaves server.py for a flat lib/ module.
The class body is byte-identical; server.py reconstructs exactly from
origin/main minus the cut range plus the import-back and the call site.

server.py: 9,705 -> 9,433 lines.

The only non-verbatim change is the constructor seam: `__init__` takes
`config_dir` instead of reading the module-level CONFIG_DIR, so the module does
no IO at import (Principle V). The `audio_effect_mappings` singleton stays in
server.py -- no route, no test, and none of the `monkeypatch.setattr(server, ...)`
targets move. No import went dead.

Verified: pyflakes clean on the new module; no new undefined name in server.py;
pytest 2341 passed; eslint 0 errors; boot smoke drives the extracted DB
end-to-end (POST a mapping -> GET reads it back -> audio_effects.db lands in
CONFIG_DIR, proving the config_dir seam) and all three migrated plugins still
serve their src/ module graphs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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: f6824017-0b5c-4060-a80b-4039b880309d

📥 Commits

Reviewing files that changed from the base of the PR and between 5812074 and 0302671.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • docs/size-exemptions.md
  • lib/audio_effects_db.py
  • server.py

📝 Walkthrough

Walkthrough

AudioEffectsMappingDB is moved from server.py into lib/audio_effects_db.py, where it owns config-scoped SQLite persistence and routing operations. server.py imports the class and initializes its singleton with CONFIG_DIR; related changelog and size documentation are updated.

Changes

Audio effects database extraction

Layer / File(s) Summary
Database module foundation
lib/audio_effects_db.py
Adds the SQLite schema, configuration-based database initialization, locking, input normalization, and active-state row decoding.
Mapping and activation operations
lib/audio_effects_db.py
Implements filtered listing, retrieval, upsert, deletion, activation, and active-mapping clearing.
Server wiring and documentation
server.py, CHANGELOG.md, docs/size-exemptions.md
Replaces the inline database implementation with the imported class and updates extraction and line-count documentation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 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 states the main refactor: moving AudioEffectsMappingDB from server.py into lib/audio_effects_db.py.
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 refactor/r3-audio-effects-db

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

@byrongamatos
byrongamatos merged commit 94a58b7 into main Jul 10, 2026
5 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