Repository navigation
Let a track carry its own rate; the edge converts - #112
Conversation
multi-rate.md step 3: rate: on tracks (decision 3), resample nodes minted at mismatched placements (decision 4), vocal-48k retired (decision 6), and the normalize sound type behind a tombstone.
|
Starting review of 63fef92. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 63fef92. Configure here.
source_offset and slip address the source's samples (project-core.md $3.2); a converted clip reads the resampled file at the track rate, so the effective read offset scales by the same ratio the conversion applies. Found by Bugbot on #112.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63fef92c22
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
minjudd
left a comment
There was a problem hiding this comment.
Reviewed 63fef92. The graph half of this is verifiable without a daemon, and it holds everywhere I pushed on it. Two findings, both one-liners; the first is about the record rather than the code.
The re-key is exactly the rename and nothing else. The cleanest witness is a node this PR does not otherwise touch — same program hash, same parameters string, key moved:
main //songs/tall-grass/gen:seven-eight-loop parameters {"seed":7801,"duration":3.182,"channels":2} action d61bda15904e
head //songs/tall-grass/gen:seven-eight-loop parameters {"seed":7801,"duration":3.182,"channels":2} action 1a79cb86ba64
So the one full re-render is bought by the key field alone, exactly as §3 prices it, and no plan moved underneath it.
The edge mints, shares, and is visible. With a 24 kHz take under lead-take, deps(//songs/creek/track:lead-vocal) is sound:lead-take → convert:lead-take-48000 → track:lead-vocal, the convert node explains as type: resample v1 with parameters: {"sample_rate":48000}, and lead-vocal's stem carries one input for both clips — one node per (source, rate), as claimed.
A declared rate behaves at both boundaries. Giving keys rate: 44100:
keys' own plan duration 441000 samples, where the 48 kHz version says 480000
into keys //songs/creek/convert:track-still-water-keys-44100
out of keys //songs/creek/convert:track-keys-48000
Four bars at 96 bpm is ten seconds either way — the tempo map really is projecting ticks at the track's own rate rather than the song's. The kind survives in the node name (track-still-water-keys), so the sound-and-track-sharing-a-name case cannot collapse two sources into one node.
The refusals all fire, and each names the fix: the normalize tombstone (type: normalize has retired (multi-rate.md §2) — … delete this sound and reference its source directly), the output track's rate: (the song's output renders at the project rate — sample_rate in project.yaml is that choice), and the rate-boundary loop, which names both rates: loops a 24000 Hz source on a 48000 Hz track — set loop.every: the edge conversion changes its length, which is unknown before it builds. That last one is the case the plain "a track's length is unknown" message would have hidden.
578 tests, 470 pass, 41 skip, 67 fail — main is 562/458/63, so the 16 new tests split 12 passing here and 4 needing the daemon, and every failure in the run is the single field-audiod is not built string. pnpm typecheck clean, field check on bloom ok with vocal-48k gone. The daemon half — the resample op, plan version 7, the real renders and the bit-exact 1:1 passthrough — I could not run and am not vouching for; those are yours.
On the §5 note you flagged: discharging the declared-rate and 44.1 kHz-asset clauses by rates.test.ts rather than by bloom reads right to me. Bloom is a song, and putting a 96 kHz track in it to satisfy a checklist would be the example lying about what it is.
|
Starting review of 3f98171. |
minjudd
left a comment
There was a problem hiding this comment.
Reviewed 3f98171. The new commit is a real bug and a clean fix; the verdict is unchanged only because the two findings from 63fef92 are untouched by it — nothing in this push is at fault.
The scaling is right, and I checked it against a real conversion rather than the arithmetic. Giving lead-vocal's first clip source_offset: 24000 — one second into the 24 kHz take:
converted source "read_offset":48000 ← one second of the 48 kHz file the stem actually reads
same-rate source "read_offset":24000 ← keys placing a 48 kHz track, unscaled
no offset "read_offset":0
Before this commit the plan carried the raw 24000 into a 48 kHz file — half a second in where a second was written — with nothing to say so. Silently wrong audio from a field that reads as absolute, which is the worst shape a bug can have here. Good find by Bugbot.
The default parameter is the right seam. Every same-rate caller keeps its exact previous behaviour, and I went looking for the one place readOffset changes more than an output value: the no-every branch, where it sets the tiling interval and can raise loop without 'every' needs source content after its read offset. That path cannot be reached with a stale offset, because check demands loop.every across a rate boundary first — and it fires alone, one message rather than two, which I confirmed by looping a 24 kHz source on the 48 kHz track and reading the whole diagnostic list.
580 tests, 472 pass, 41 skip, 67 fail — main is 562/458/63, so the 18 new tests are 14 passing here and 4 needing the daemon, all one error string. rates.test.ts is 14 of 15, the miss being the real-render case. pnpm typecheck clean.
Still open from the previous head, both one-liners and neither touched here: the now.md line deleted on merge day, against the file's own header and its three neighbours; and rate: refusing with Invalid input at rate, which Codex flagged independently on the same line. Their threads carry the detail.
musicalContext takes the rate of the file the daemon is streaming — the load response's for play, the artifact header's for transport — so --from and locate seek the right moment on a rate: track. Found by Codex on #112.
The sampleRate union's refusal now says what a rate may be; rate: on a track is the field a person types to opt into multi-rate. Found by minjudd on #112.
now.md lists what is live, not what has landed; the neighbours' precedent says a phase no session has exercised stays. Found by minjudd on #112.
|
Starting review of b923805. |
minjudd
left a comment
There was a problem hiding this comment.
Approving b923805. Both findings are fixed, and the commit that came with them is the more valuable of the three.
play and transport speaking the played file's rate is a hole I did not find. A 44.1 kHz stem played through the daemon would have had its --from locate and its beat readout computed against the project's 48 kHz — bar 2 seeking to sample 96000 of a file where bar 2 is 88200, a systematic eighth-note-ish error that only shows up by ear. Making musicalContext take the rate as a required parameter is the right shape: the omission becomes a type error at every call site instead of a silent default, which is why transport and click had to answer for themselves too. And the fix needs no protocol change — the daemon has been reporting sample_rate on the load response all along (protocol.ts:40, asserted in client.test.ts:71); it was simply unused.
The click exemption checks out rather than being waved through: beatGrid computes ticksToSamples(t) / ctx.tempo.sampleRate * sampleRate, so the context's rate cancels through seconds against the clicked file's own header, and any rate really does serve. playedRate falling back to the project's on an unreadable header keeps a vanished file from taking the status line down, which is the right failure for a readout.
The rate refusal now names the set, at both fields the union reaches:
songs/creek/tracks/bed.yaml: must be one of 44100, 48000, 88200, 96000, 176400, 192000 at rate
field.yaml: must be one of 44100, 48000, 88200, 96000, 176400, 192000 at sample_rate
The test asserting the sentence rather than merely that "rate" appears is what keeps it from decaying back.
The now.md line is better than the one it replaces: it names the three PRs, says what it is waiting for, and gives the reason — every action key moved, the plan version bumped, conversions appear at edges nobody typed. That is a line a reader can act on rather than a placeholder.
581 tests, 472 pass, 42 skip, 67 fail — main is 562/458/41/63. The new play-daemon case is skipIf-gated rather than failing, which is why skips moved and failures did not, and every failure in the run is the one field-audiod is not built string. pnpm typecheck clean, bloom check ok.
The daemon half stays yours throughout: the resample op, plan version 7, the real renders, and now the playback rate on live audio.
No findings.
The last sound folds (nested-tracks.md §18 step 3, the shape still-water-keys set): `lead-take` is now a leaf track whose one input is the generative request, and `lead-vocal` places `track: lead-take` at bars 5 and 9 where its clips said `sound: lead-take`. The gen node keeps the name — the entry carries no id, so the node is the owning track's name — which is why `audio/lead-take/` never moves and the takes file only flips its attachment key. The 24 kHz take converts at the leaf's own edge (multi-rate.md decision 4), and what the old sound indirection was for survives the fold: `field choose lead-take` repoints the gen node and both placements follow, with the track files untouched. The fold is byte-identical: `lead-vocal` re-renders (its wiring changed from the conversion ref to the track ref) to exactly the bytes it produced before the fold — `cmp` clean against the pre-fold artifact — so `main` never re-keys. The conversion itself was not even re-run: `convert:gen-lead-take-48000` is an action-cache hit from `convert:lead-take-48000`'s render, because the node name is wiring and the key never sees it. A/B take flipping stays fully cached in both directions. With that, bloom has no `sounds/` directory left and `rg 'sound:' examples/` finds only history in the README's prose. What remains of chunk 6 — recorded in the plan's status — is retiring the machinery bloom no longer exercises: the `sound:` entry field, the `sound:` label and takes key, and the `sounds/` loader, behind the migration diagnostics the format owes departing spellings. That is the next PR, and it is deliberately not this one: this diff is the example moving, and the retirement diff is schema surgery that deserves its own review. ## Testing One local migration first: if you have generated takes for `lead-take`, `field check` will say `songs/creek/audio/lead-take/variants.yaml: these takes attach to the gen node "lead-take" now — rename sound: to gen: (nested-tracks.md §18)` — a one-line edit to that git-ignored file, and the diagnostic tells you exactly it. Then, in `examples/bloom` (needs `pnpm build` so the `field` on your PATH is current; spawns an `audiod` daemon — `field quit` stops it): ``` field check field query 'deps(//songs/creek/track:lead-vocal)' field build //songs/creek/track:lead-vocal field choose lead-take --song creek --variant 2 field build //songs/creek/track:lead-vocal field choose lead-take --song creek --variant 3 field build //songs/creek/track:lead-vocal ``` `check` says ok; the deps run in a straight line `gen:lead-take → convert:gen-lead-take-48000 → track:lead-take → track:lead-vocal`; the first build re-renders `lead-take` and `lead-vocal` (new labels, converted content unchanged), and a following `field build //songs/...` shows `main` cached — the fold moved no bytes, which is the claim that would fail loudest if the leaf stem were not a clean pass-through. The choose round-trip re-renders on the way to variant 2 and is entirely `cached` on the way back to 3, and `git status` stays clean throughout — neither command touches a tracked file. 581 tests pass unchanged from #112; the fold adds none because it changes no code, which is itself the point: the machinery landed in #105–#112, and this PR is bloom catching up to it. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Example and documentation only; no schema or CLI changes in this diff, so production risk is limited to readers following outdated `sound:` paths in local clones. > > **Overview** > **Moves creek’s last sound into the nested-tracks model:** `lead-take` is now a leaf track (`tracks/lead-take.yaml`) whose sole input is a `generative:` block (text, delivery knobs), and `sounds/lead-take.yaml` is removed so bloom has no `sounds/` left. > > **`lead-vocal` wires through the track, not a sound:** both verse and build placements use `track: lead-take` instead of `sound: lead-take`. The 24 kHz take still resamples at the leaf edge to 48 kHz; `field choose lead-take` repoints the `gen:` node so both placements follow without touching tracked YAML. > > **Docs and the bloom README** are aligned with `gen:` labels, track-based placements, and chunk 6 status (sound machinery retirement deferred to a follow-up PR). **No application code changes** — behavior was already in prior nested-tracks / multi-rate work; this diff is the example catching up. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit acc96ae. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->

multi-rate.md step 3, the plan's last: decisions 3, 4, and 6 as recorded. A track may declare
rate:, defaulting to the project's — the same inheritance shape astime:, from the song and never from the placing parent, because a track renders once. Where a source arrives at a placement at another rate — a 24 kHz generated take, a 44.1 kHz import, a child tracked elsewhere — the graph mints//songs/<song>/convert:<name>-<rate>between it and the stem: content-addressed, one node per (source, rate) however many placements consume it, visible inexplainanddeps()like any rule (track:andgen:refs keep their kind in the name, so a track and a sound legally sharing a name cannot mint one node for two sources). The stem generator's "add a normalize sound at 48000" refusal retires with the refusal itself: a diagnostic that knows the one right answer now applies it.The conversion is a new daemon op,
resample, which amends §3's "plan.cpp needs nothing" claim (recorded in the plan): it cannot ride the normalize op, because normalize always quantizes to integer PCM — a delivery choice — and an internal stem legitimately exceeds 0 dBFS in float before its edge gain applies, so int conversion would clip it.resampleis rate and nothing else, float32 out, no dither, driving the same polyphase resampler (render-pipeline.md §2.9 still has exactly one). RENDER_PLAN_VERSION moves to 7. The resampler's property oracle moved with the change — normalize-properties.test.ts became src/audio/convert-properties.test.ts, driving the ops directly — and grew three resample properties: the float format tag, bit-exact 1:1 passthrough, and no clipping above 0 dBFS, which is the reason the op exists.Everything downstream follows the rate. Entry generators render at their owner's rate; a track's tempo map projects ticks at its own rate (bar 2 at 44.1 kHz is 88200 samples, not 96000); playback speaks the played file's rate too —
--from,transport locate, and the beat readout project through the loaded file's own header rather than the manifest, and a converted clip's read offset scales by the conversion's ratio sosource_offsetkeeps addressing the source's samples; and the action key'sproject_sample_ratefield renames tosample_rate, carrying the node's effective rate — the priced-in §3 cost, one full re-render, the same trade project-layout.md §4.4's sc-render → supercollider change made. The song's output track refuses arate:of its own (the output is the song, and the song's rate is project.yaml's — a field with one correct value should not exist), and a loop tiling at the source's length across a rate boundary demandsloop.every, because the conversion changes that length and the converted count exists only after it renders.With the edge automatic,
type: normalizehas no remaining legitimate use — anything it could say restates either export or the edge — so the sound type retires behind a tombstone that tells an old file the move rather than "invalid type". Andvocal-48k, the last authored conversion, retires with it: creek'slead-vocalclipslead-takedirectly, and what the wrapper was for survives it — choosing a different take still moves both clips, because they reference the sound, not a variant. That leaveslead-takethe last sound insounds/, unblocked to fold as a generative leaf (nested-tracks chunk 6's finale, next PR).One definition-of-done note flagged rather than buried: §5's "bloom keeps a 44.1 kHz asset" and "a track declared at a non-project rate" clauses are discharged by rates.test.ts rather than by bloom, and the plan now records why — placing a mismatched asset or declaring a 96 kHz track in bloom is a musical decision about what the example should sound like, not a mechanical one. Say the word if you'd rather bloom carry one and I'll add it.
Testing
From the repo root,
pnpm build:native && pnpm build, thenpnpm typecheck && pnpm test— 581 tests pass (19 new: 15 in src/graph/rates.test.ts covering therate:bounds, the output-track refusal, tempo-at-rate projection, conversion minting/sharing/explaining, the header fallback for a ledger without WAV facts, real rendering through the edge, re-keying on arate:edit, the loop.every demand, and read-offset scaling through the conversion; 3 resample properties in src/audio/convert-properties.test.ts). The conversion tests are mutation-proven: disabling the minting in buildGraph turns 9 of the 15 red, and forcing the transport back to the manifest rate turns the daemon locate test red at sample 24000. The native rebuild is load-bearing — a stale field-audiod refuses the new plans with "render plan version 6 but this field-audiod speaks 7", which is also the failure you would see if you skippnpm build:native.By hand, in
examples/bloom(spawns anaudioddaemon —field quitstops it; creek ships takeless, solead-takeneeds takes generated — any checkout that has played creek already has them):checksays ok with vocal-48k gone; the deps list shows//songs/creek/convert:lead-take-48000between the sound and the stem;explainshowstype: resample v1withparameters: {"sample_rate":48000}. What wrong used to look like: before this change, placing a 24 kHz take without the wrapper failed the build with "input is 24000 Hz but the project is 48000 Hz — Field never resamples implicitly (add a normalize sound at 48000, or re-import at that rate)" — the diagnostic this PR deletes. A fullfield build //songs/...re-renders everything once (the priced-in re-key) and then rebuilds entirely cached.