# TODO.md — near-term actionable slice

The immediate, ordered tasks to execute the first step of `PLAN.md`: Milestone 0
(transition) → Milestone 1 (`bank_model`) → Milestone 2 (`peaks`). Everything past
M2 lives in `PLAN.md`, not here. Verify REAPER API names/flags against
`vendor/reaper-sdk/sdk/reaper_plugin_functions.h` before use.

## Now — Milestone 0: transition scaffold

1. Delete the MPE modules: `src/mpe_model.{h,cpp}`, `src/mpe_view.{h,cpp}`,
   `tests/test_mpe_model.cpp`.
2. CMakeLists.txt — rename `project(reaper_mpeview …)` and the MODULE target to
   `reaper_reasampler`; update `OUTPUT_NAME`, `PREFIX ""`, and the WIN32/APPLE/
   Linux SUFFIX blocks to the new target name.
3. CMakeLists.txt — replace the `mpe_model` static lib with a `bank_model` static
   lib (`src/bank_model.cpp`, `PUBLIC src` includes); replace `mpe_model_tests`
   with `bank_model_tests` (`tests/test_bank_model.cpp`), keep `add_test` / CTest.
4. `src/main.cpp` — remove `#include "mpe_view.h"` and every `MpeView_*` call
   (`MpeView_Toggle`, `MpeView_IsOpen`, `MpeView_OnTimer`, `MpeView_Cleanup`).
   Leave a minimal, loadable extension entry that resolves API pointers and logs
   to console; keep the `command_id`/`gaccel`/`hookcommand` registration pattern
   as a commented seam for the future action family.
5. `src/main.cpp` — replace the `CEREBELLUM_MPEVIEW_TOGGLE` action string with the
   chosen sampler action-id prefix (record the prefix in a comment; it is
   forever-stable once shipped).
6. Confirm the tree still configures and builds:
   `cmake -B build -S .` → `cmake --build build` → `ctest --test-dir build`.
   (bank_model tests may be a single placeholder assertion at this point.)
7. README.md — retarget the layout / "where to build next" sections to the
   sampler module set so the first implementer is not misled by MPE prose.

## Next — Milestone 1: bank_model + JSON round-trip (pure, no REAPER)

8. `src/bank_model.h` — define `Sample` with the full field set from CONTEXT.md
   §Data model (id, name, relative path, source mode, source range project-time +
   PPQ, track GUID(s), wet/dry, channels, SR, length sec + beats, capture tempo,
   optional key, peak/RMS/LUFS, clip flag, tier, content hash, provenance, ts).
9. `src/bank_model.h/.cpp` — `BankIndex`: ordered, keyed by id; `add` / `remove` /
   `query`.
10. Dedup: content-hash lookup so an add with an existing hash collapses.
11. Tiers: `scratch` | `archive`, tier-move, tier filtering; scratch auto-prunable.
12. JSON serialize/deserialize to/from `std::string` (self-contained; no external
    JSON dep unless one is already vendored — check first).
13. Enforce **relative-paths-only** at the model boundary (reject/normalize
    absolute paths on add).
14. `tests/test_bank_model.cpp` — assert: full-field round-trip lossless; dedup
    collapses equal-hash adds; tier move + filter correct; absolute-path rejected;
    empty-index and malformed-JSON edge cases.

## Then — Milestone 2: peaks (pure, no REAPER)

15. `src/peaks.h/.cpp` — min/max bin computation from interleaved PCM for a target
    bin count; per-channel (no silent fold). Add `peaks.cpp` to the `bank_model`
    lib (or a sibling pure lib) so tests link it.
16. `tests/test_peaks.cpp` (+ CTest entry) — assert: full-scale sine envelope ≈
    ±amplitude per bin; ramp envelope monotonic; silence/DC → zero envelope;
    short-buffer and non-divisible-length (remainder bin) edge cases.

## Definition of done for this slice
- `ctest --test-dir build` green with `bank_model_tests` and `peaks` tests present.
- No `mpe`/`Mpe`/`MPE` symbols remain in `src/` or `tests/`.
- The extension target builds under the new name and loads in REAPER (console log
  on load); it registers no half-wired actions.
