docs(plan): add Phase Q pre-restructure functional+DSP audit wave (Q-W0)

This commit is contained in:
2026-07-27 14:29:56 -04:00
parent fcca987454
commit bbfb033819
3 changed files with 260 additions and 13 deletions
+76 -2
View File
@@ -3204,6 +3204,13 @@ compat event.
> bar), the reorg being the means. Product framing, the Vital-grounded target shape, the
> grep-verified SOLID audit (the evidence base), and the fork record (Q-1..Q-6):
> `docs/product/code-organization.md`. When a point lands, doc-keeper moves it to `COMPLETED.md`.
>
> **Phase Q opens with a pre-restructure audit (Q-W0 — added 2026-07-27).** Before any structural
> point (Q-W1+), Phase Q runs a **functional + DSP quality audit** that produces a written, triaged
> findings report — a functional-correctness/algorithm-quality complement to the SOLID/naming audit
> below. **Q-W1 is gated on Q-W0's triage being complete and Daniel signing off on each finding's
> disposition** (fix-now vs. document-and-defer). Spec: §"The pre-restructure audit wave (Q-W0)"
> below.
## What it is
@@ -3219,6 +3226,66 @@ architecture *changes*; it becomes *visible*. This is why the phase can be zero-
CTest-green throughout: the seams already exist in the link graph; Phase Q draws them where a
reader sees them.
## The pre-restructure audit wave (Q-W0)
Phase Q **opens** with `Q-W0` — a thorough **static/functional audit** that runs before any
structural point (Q-W1+) moves a single file. It is the *functional-correctness and
algorithm-quality* complement to the grep-verified SOLID audit (§"The evidence base" in
`docs/product/code-organization.md` §2) and naming audit (§2b): those ground *where responsibilities
live* and *what things are called*; Q-W0 grounds *does the code do the right thing, and does it do it
well.* It exists because the structural reorg is the wrong moment to discover a bad algorithm — a
reinvented wheel or a numerically-fragile DSP path should be eliminated or consciously documented
**before** it is relocated, re-namespaced, and split, not carried forward untouched into a tidier
tree. Bringing the code "into the realm of something I can stand to look at" is not only a matter of
shape; it is also a matter of the code being *functionally sound*.
**Audit scope — the named surfaces:**
1. **DSP / audio, close eye on pitch.** Assess *algorithm quality* — correctness, artifacts,
numerical robustness, interpolation quality, and reinvented-wheel-vs.-established-technique — on:
- `src/vst/pitch_shift` — the hand-rolled OLA pitch-preserve engine: window/overlap choice, phase
coherence, transient and formant behavior, buffer-edge handling. **The highest-priority DSP
surface** (Daniel: "a close eye on the Pitch stuff").
- `sampler_core` — repitch ratio math, interpolation order/quality, loop-point-aware sustain
crossfade, and voice-stealing correctness (clicks/discontinuities on steal).
- `peaks` — envelope min/max binning correctness.
- `wav_trim` — the realtime-tail decay-scan threshold + truncate plan.
- the capture / tail paths — any DSP-adjacent arithmetic in capture range/tail handling.
2. **Architecture smells.** Duplicate code, reinvented wheels, poor abstractions, and leaky
pure/shell boundaries (a `core/` file reaching a REAPER/host type; geometry or algorithm math
sitting untestable in a shell instead of a pure module). This overlaps the SOLID audit's territory
but targets the *functional* smell, not the responsibility-placement smell — Q-W0 reports what
§2/§2b did not.
3. **Env-coupled-constant domain-modeling smells (explicit category).** ANY value stored in a
frame / rate / DPI / tick-coupled domain that should instead be stored **rate-free and resolved at
the point of use** is a domain-modeling smell — *store rate-free, resolve at use*, **not** "rescale
by the rate." This is grounded in the load-bearing invariant that wall-clock times are stored as
rate-free **SECONDS** resolved against the live project rate (`sample_map`), with **NO hardcoded
sample rates in `src/`** (Daniel's standing ruling). There was a prior incident on exactly this —
envelope times stored in the frame domain — which is why it is a first-class audit category, not a
footnote. Sweep at least: envelope times, loop points, fade lengths, tail lengths, and any UI
geometry constant that silently bakes in a DPI or rate.
**Deliverable + acceptance:** a **written findings report** exists covering the named surfaces;
**every finding is triaged** into *eliminate-before-restructure* (fix-now) or *document-and-defer*
(with a one-line rationale so the deferral is a decision, not an omission). Fix-now findings are
remediated **in Q-W0**, or folded into the downstream wave that already opens the file (recorded per
finding) — they are **not** silently deferred into the structural waves. Any behavior-changing
remediation lands with the module's CTest executable green, and where a DSP path changes audibly, a
stated before/after listening or null check. **The gate to begin Q-W1 is: triage complete and Daniel
signed off on every disposition.**
**Relationship to the structural waves:** Q-W0's findings may **add or reshape** downstream
Q-W1..Q-W6 points (e.g. an algorithm rewrite that changes a module's shape, or a domain-modeling fix
that changes a payload). Those reshapes are folded in before Q-W1 begins. Q-W0 is thus both the entry
point and a scoping input to the rest of the phase.
**Report home (fork — Daniel's call):** whether the findings report lives as a committed doc under
`docs/product/` (e.g. `code-quality-audit.md`, alongside the SOLID/naming audit that already lives in
`docs/product/code-organization.md`) or as a tracked issue list is Daniel's call — see the fork note
in `docs/product/code-organization.md` §2c. The recommendation is a committed doc: it sits beside the
existing audit, travels with the tree, and each finding's disposition is reviewable in one place.
## The quality bar — Vital (read from its actual `src/` tree)
Vital (`github.com/mtytel/vital`) groups its synth by **subsystem** — `common/` `synthesis/`
@@ -3232,7 +3299,8 @@ below). Vital is GPLv3; the borrowed artifact is the **structural pattern**, not
## Settled decisions (Q-1 settled; Q-2..Q-6 recommended — see `docs/product/code-organization.md` §6)
- **Q-1 — namespace letter. SETTLED: `Q` (Quality).** Point-id family `Q1..Qn`, wave prefixes
`Q-W1..Q-W6`. `O` (Organization) was set aside: the glyph reads ambiguously against zero in
`Q-W0` (the pre-restructure audit) then `Q-W1..Q-W6` (the structural reorg). `O` (Organization)
was set aside: the glyph reads ambiguously against zero in
point ids, and "Organization" undersells a phase measured against a *quality* bar.
- **Q-2 — JSON extraction in scope + first. REC: yes.** The 4× duplicated `Parser` is the largest
DRY+SRP violation and is entirely off the hot paths — the ideal safe, high-leverage opener
@@ -3412,6 +3480,11 @@ Big-bang is rejected — the CMake per-module static-lib + per-module test-execu
file move + namespace change **mechanically verifiable** (`ctest --test-dir build` green or not, at
every commit), a property only an *incremental* reorg uses. Risk-ordered:
- **Q-W0** — **pre-restructure functional + DSP quality audit** (entry point; see §"The
pre-restructure audit wave (Q-W0)"). Produces a written, triaged findings report; runs **first**
and **gates Q-W1** — no structural point begins until the triage closes and Daniel signs off on
every disposition. Fix-now findings are remediated here or folded into the wave that opens the
file; the report may add/reshape downstream Q-W1..Q-W6 points before they start.
- **Q-W1** — safe opener: `core/json` extract (delete 4 `Parser`s) + impose the directory/
namespace layout on the 30 clean pure libs + clean shells (pure relocation, no logic change).
All later waves assume this layout. **Carries the naming collision fixes + the model-class
@@ -3458,6 +3531,7 @@ every commit), a property only an *incremental* reorg uses. Risk-ordered:
- **No big-bang commit.** Every wave is independently landable and CTest-green; reject a change set
that cannot be verified at each step.
- **Do not begin before the GATE.** Re-confirm the tree is quiescent (Phase S + L + D2 merged/closed;
M9 abandoned) before any Q point.
M9 abandoned) before any Q point. **And do not begin any structural point (Q-W1+) before the Q-W0
sub-gate:** the audit's triage is complete and Daniel has signed off on every finding's disposition.
- **Verify** the CMake `src/` path updates and the SWELL/LICE surfaces still resolve after
relocation, as the existing build already requires.