Skip to content

A clip may play a track, and kit-punch becomes one - #100

Merged
ninjudd merged 3 commits into
mainfrom
tracks/fold-kit-punch
Aug 9, 2026
Merged

ninjudd merged 3 commits into
mainfrom
tracks/fold-kit-punch

Conversation

@ninjudd

@ninjudd ninjudd commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Chunk 6's first fold (nested-tracks.md §1.12, recorded in §17): the eq sound kit-punch becomes a track with one clip and one insert, and the mechanism it needed lands with it — a clip's source: may now be spelled track:<name>. That is the same string a placement already wires in sources and the label already uses (//songs/creek/track:drums), so the authored spelling and the wiring spelling are now one string and the graph layer needed no changes at all: refLabel has resolved track: refs since placements landed.

The spelling is deliberate rather than convenient. A bare slug keeps meaning the song's one namespace — assets and sounds — because tracks live deliberately outside it (a track and a sound may legally share a name today), and a bare slug that tried both would be a search path, which the one-spelling rule forbids (project-core.md §3.4). Whether a bare slug ever comes to mean a track is the finale's namespace-merge question, deliberately left open in §17 along with the check collision message and field import guard that merge will owe.

A clip that plays a track is checked exactly as a placement is: unknown, self, and midi each get the placement's message shape, the clip edge joins the containment-cycle walker, the clip's gain_db counts toward explain's level answer (clips carry no pan), and a loop still requires every — a track's length is as unknowable at plan time as any buildable's. It keeps the clip powers a placement lacks: source_offset, slip, loops. The trackRef helpers moved from stem.ts to labels.ts so the schema layer can share them without an import cycle.

The fold's proof is bit-identity, not key stability — kit-punch's own action key changes by construction (rule eq → rule stem). The track render hashes byte-for-byte identical to the sound render it replaces, and because action keys see content hashes and never spellings, drums kept its key (6cd170a1cbfe, cached) even though its YAML changed, and the whole song rebuilds from cache.

Also fixes a mis-addressed citation while touching the file: project-layout.md §4.3 cited the one-spelling rule as project-core.md §7, which is "Deferred within this phase"; the rule lives in §3.4's label-grammar record.

Testing

From the repo root:

pnpm build && pnpm typecheck && pnpm test

505 tests pass (12 new). Three of the new tests are mutation-proven: reverting the cycle-walker clip edges, the levels clip edges, or the unknown-track diagnostic each turns its test red.

cd examples/bloom
field check
field build creek/track:kit-punch
shasum -a 256 .field/out/songs/creek/sound/kit-punch.wav .field/out/songs/creek/track/kit-punch.wav

check says ok. The build brings //songs/creek/sound:kit-sc back cached and renders the new stem through the daemon — scsynth is not on my PATH, so the SC render couldn't have re-run; it didn't need to, because kit-sc's action key is untouched by this change. The two hashes are identical (d1ae4edb90b7…): the first file is the old eq sound's render (now orphaned in .field/out), the second is the fold's.

field explain creek/track:drums | grep '^action:'
field build creek/track:main

The first prints action: 6cd170a1cbfe (cached) — drums' YAML changed spelling, but action keys see content hashes, so the key must not move. This line is where wrong would show: if the fold changed the audio at all, drums would re-key and build creek/track:main would re-render instead of coming back with every line cached, which it does.

What wrong looks like at the model layer — the old bare spelling no longer resolves, because the sound is gone and bare slugs do not search tracks:

sed -i '' 's/track:kit-punch/kit-punch/' songs/creek/tracks/drums.yaml && field check
git checkout -- songs/creek/tracks/drums.yaml && field check

The first prints clip "kit-1-r2d8f" references unknown source "kit-punch"; the second restores and says ok. I also ran field check from a clean git archive HEAD examples/bloom export — ok, so nothing here depends on gitignored takes or caches (the bit-identity proof above does depend on this checkout's warm cache, since a fresh clone can't render kit-sc without scsynth).

State left behind: field build spawns an audiod daemon in examples/bloom (field quit stops it), and .field/out/songs/creek/track/kit-punch.wav now exists beside the orphaned sound/kit-punch.wav.


Note

Medium Risk
Touches core project validation, schema, and stem dependency wiring; risk is moderated by broad tests and bit-identical bloom renders, but wrong cycle or level handling could let bad graphs through or mis-report gain.

Overview
Chunk 6 (nested-tracks §17): clips can reference another track with source: track:<name> — the same string placements and labels already use — so an EQ wrapper can be a track instead of an eq sound.

Model & validation: clipSourceRef extends clip sources; check treats a clipped track like a placement (unknown/self/MIDI, containment cycles, loop.every when length is unknown at plan time). field explain level paths include clip gain_db on those edges (clips still have no pan).

Implementation: trackRef / trackRefName move to labels.ts (shared by schema, graph, levels, project). Stem planning already wired track: in sources; no graph-layer change beyond using the shared helpers.

Bloom: kit-punch becomes tracks/kit-punch.yaml (one clip on kit-sc, EQ insert); drums clips track:kit-punch; the old sounds/kit-punch.yaml is removed. Track render is bit-identical to the prior eq sound; upstream keys like drums stay cached when only spelling changes.

Docs and project-layout cite project-core §3.4 for the one-spelling rule (fixes a §7 mis-citation).

Reviewed by Cursor Bugbot for commit 0eff38e. Configure here.

Chunk 6's first fold (nested-tracks.md §1.12, recorded in §17): the eq
sound kit-punch is now a track with one clip and one insert, and the
mechanism it needed lands with it — a clip's source: may be spelled
track:<name>, the same string placements already wire in sources and
labels already use. Bare slugs keep meaning the song's one namespace;
no search path (project-core.md §3.4).

A clip playing a track is checked as a placement (unknown, self, midi),
joins the containment-cycle walker, counts toward explain's level
answer, and still requires loop.every. The graph needed nothing:
refLabel resolved track: refs already.

The fold's proof is bit-identity: the track render hashes identically
to the sound render it replaces, so drums kept its action key
(6cd170a1cbfe, cached) and the whole song rebuilds from cache.

Also fixes a mis-addressed citation: the one-spelling rule lives in
project-core.md §3.4, not §7 as project-layout.md §4.3 claimed.
@minjudd

minjudd commented Aug 9, 2026

Copy link
Copy Markdown

Starting review of 0eff38e.

minjudd
minjudd previously approved these changes Aug 9, 2026

@minjudd minjudd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving 0eff38e. Two things could have gone wrong quietly here — a new containment edge that the cycle walker does not follow, and a new path that explain's level walk does not see — and both are handled. I checked them by building the failures rather than by reading for them.

The cycle walker follows the clip edge, including across edge kinds. Pointing kit-punch's clip at phrase gives track containment cycle: phrase → drums → kit-punch → phrase — a loop that runs placement, placement, clip and closes. That is the one that would have hung rather than diagnosed. The locally decidable case keeps its own message (clip "self-a1b2c" clips this track inside itself), and the other two shapes fire as claimed: references unknown track "nope", and clips a midi track, which renders no audio. A malformed prefix is caught a layer earlier, at the schema: track: must name a track by its lowercase-slug at clips.0.source.

The level walk sees it. field explain creek/track:kit-punch reports track:bed 0.0 dB (via track:drums → track:phrase, 3 placements) and the same for main — the route passes through the clip edge into the placement edges above it and the placement count survives. pan: 0 on that hop is right rather than a placeholder: clipSchema has gain_db and no pan.

The wiring claim holds too. deps(creek/track:drums) is sound:kit-sc → track:kit-punch → track:drums, and drums's explain now shows input: //songs/creek/track:kit-punch — so the authored spelling and the wiring spelling really are one string, and the graph layer needed nothing.

Also checked: a clean git archive export of examples/bloom is 35 files and checks ok, so nothing here leans on caches or gitignored takes; the bare-spelling regression prints exactly clip "kit-1-r2d8f" references unknown source "kit-punch"; pnpm typecheck is clean; §17 is appended with §15 and §16 unmoved; and the citation repair is correct — project-core.md §3.4 is Label grammar (DECIDED), which is where the one-spelling rule lives, and §7 is indeed Deferred within this phase. Noting the mis-address in the text rather than silently repointing it is the right call for a record other files cite.

What I could not verify: the bit-identity of the two renders, which is the fold's actual proof. It needs the daemon and a warm cache holding kit-sc, and this machine has neither — the whole suite fails 58 tests here, all of them field-audiod is not built. The body says as much about its own dependence on your checkout's cache, which is the right way to state it. So the claim I am approving on that point is yours, verified in your environment, not mine; everything above it is mine.

No findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0eff38ec52

ℹ️ 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".

Comment thread src/model/project.ts Resolved
Comment thread src/generators/stem.ts Resolved
ninjudd added 2 commits August 9, 2026 10:57
Codex finding on #100: the clip branch checked only the child, so a
midi parent clipping track:inner passed check while buildGraph gave it
no stem — the edge would silently never render, and reaches() counted
it. The placement rule (only an audio track sums audio) now fires for
either spelling of a placement. Test proven failing first.
Codex finding on #100: raw-string sort let a fold reach the action key
through order — folding sound zebra into track:zebra beside buildable
wall flipped [wall, zebra] to [track:zebra, wall], permuting clip
indices and dep-hash order, re-keying a parent whose children are
byte-identical. Buildables now sort by trackRefName(ref) ?? ref, raw
ref breaking the legal sound/track same-name tie. Verified bloom's
whole cache survives: creek main rebuilds fully cached, drums stays
6cd170a1cbfe. Test proven failing first.
@minjudd

minjudd commented Aug 9, 2026

Copy link
Copy Markdown

Starting review of f6b4bcc.

@minjudd minjudd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving f6b4bcc. Both commits are real defects rather than polish, and I confirmed each by running the previous head beside this one.

The midi parent (d0f3e9a) was a hole I approved over. On 0eff38e, a type: midi track whose clip sources track:zebra gives ok; on f6b4bcc it gives a midi track cannot place tracks — only an audio track sums audio. I tested a midi child being clipped and missed the parent side entirely, so this one is yours, not the review's. The check reads the way it should now — placesTracks covers both spellings of the same act, rather than the clip case getting a rule of its own.

The sort (f6b4bcc) is the subtler one, and it reproduces. A track holding both a buildable sound wall and a placed track zebra:

0eff38e  sources [track:zebra, sound:wall]   clips input [0, 1]
f6b4bcc  sources [sound:wall, track:zebra]   clips input [1, 0]

Raw-string order puts track:zebra before wall because t sorts before w; the name underneath does not. So folding a sound into a track would have permuted its siblings' indices and re-keyed a parent whose children are byte-identical — the precise thing §17 says a fold must not do, and it would have shown up as a spurious rebuild rather than an error. The tie-break on the raw ref keeps the sound-and-track-sharing-a-name case deterministic.

Nothing in the example moves. All 13 tracks across creek and tall-grass have byte-identical input: lists and parameters on 0eff38e and f6b4bcc, so the sort change re-keys nothing that exists. The class it can move is a track mixing a buildable sound clip with a placed track, which bloom does not currently have — worth knowing rather than acting on, since the change is one-way for such a project and there is not one yet.

pnpm typecheck clean. The 23 failures in this subset are all field-audiod is not built, and the bit-identity claim from the last round is still the part I cannot check here.

No findings.

@ninjudd
ninjudd merged commit b3a6d68 into main Aug 9, 2026
1 check passed
@ninjudd
ninjudd deleted the tracks/fold-kit-punch branch August 9, 2026 18:20
ninjudd added a commit that referenced this pull request Aug 9, 2026
Chunk 6's design discussion landed somewhere better than where it
started. It opened as "fold sounds into tracks" with a `content:` block
sketched for leaves, detoured through #100's `source: track:<name>`
spelling, and closed on the observation that none of the intermediate
shapes were needed: a track file is a name, optional `time:`, optional
`inserts:`, and one `inputs:` list. Every entry places one thing —
`track:`, `audio:`, or an inline generator block (`supercollider:` /
`generative:`) — with the kind named by the entry's field and the
placement fields uniform across kinds.

§18 records the decisions and what each retires: `clips:` merges away
(the planner has sorted the two lists as one since placements existed —
the split was only ever spelled in YAML); the `content:` block never
ships ("the track is its content" is just "the track has one input");
value-prefix spellings die with §17's `source: track:x`, which lived
exactly one PR; `type:` leaves the track file (midi returns as an entry
kind when it's real, by decision 1's own no-kinds argument); ids on
entries answer §6's placement-identity question, with `id` required on
`generative` entries because takes attach to it; and the namespace
collision §17 called the finale's sleeping issue dissolves outright,
because kind-in-field means no bare namespace ever holds both bytes and
tracks.

The revised sequencing is in §18's tail: the format migration lands
alone and proves itself the way #100 did (every existing action key
survives — drums stays `6cd170a1cbfe`, creek rebuilds fully cached),
then `supercollider:` entries fold the three SC leaves, then
`generative:` entries retarget generate/choose and fold the last two,
with multi-rate's steps interleaved unchanged and the finale still
ending at `sounds/` empty and `sound:` forwarding.

## Testing

Docs-only — no executable change; `pnpm typecheck` passes untouched.
What can be wrong in a plan file is its addresses, so check those: `grep
-n '^## ' docs/projects/all/nested-tracks.md` shows §18 appended after
§17 with nothing renumbered, and the citations inside §18 (§1.11, §6,
§16, §17, decision 1, multi-rate.md §4) each name sections whose
headings that grep — and `grep -n '^## '
docs/projects/all/multi-rate.md` — actually show. Before this change,
the intro paragraph still said the five leaves "wait on §6's
leaf-content question"; it now routes through §18, and a stale copy of
that sentence anywhere else would be the thing to catch — `grep -rn
'leaf-content' docs/` finds exactly two hits: the rewritten intro, and
§16's tail, which is a dated record that §18 explicitly revises and so
keeps its original wording.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Documentation-only change to the nested-tracks plan; no schema,
runtime, or test code is modified.
> 
> **Overview**
> Chunk 6’s **sounds fold** now has a settled target shape, captured as
**§18** in `nested-tracks.md`. A track file becomes a name, optional
`time:` / `inserts:`, and a single **`inputs:`** list where each entry’s
**field name** carries the kind: `track:`, `audio:`, or inline
`supercollider:` / `generative:` blocks, all sharing the same placement
fields (`at`, `duration`, `loop`, `gain_db`, `pan`, `id`, etc.).
> 
> The section records what that **retires or supersedes**: merging
`clips:` into `inputs:` (planner already treated them as one list),
dropping the sketched `content:` leaf block, rejecting §17’s `source:
track:x` value-prefix spelling, removing `type:` from track files,
resolving §6 placement identity via optional/required `id` on entries,
and dissolving §17’s namespace-collision finale work because
kind-in-field separates ledgers.
> 
> The **intro paragraph** is updated so chunk 6 no longer says five
leaves “wait on §6’s leaf-content question”; it now routes through §18,
with normalize sounds still blocked on `multi-rate.md`. **Sequencing**
is revised: format migration alone (with bloom rewrite and cache-key
proof like #100) → `supercollider:` leaf folds → `generative:` folds →
multi-rate steps → finale emptying `sounds/`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f8b6abc. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
ninjudd added a commit that referenced this pull request Aug 9, 2026
nested-tracks.md §18's first step, the format alone: `clips:` and
`inputs:` merge into one `inputs:` list whose entries name what they
play by field — `track:`, `audio:`, or `sound:`. The `sound:` field is
§18's transition made explicit: it exists exactly as long as `sounds/`
does, so `audio:` never quietly accepts a name that renders — that would
rebuild the bytes-versus-definitions ambiguity kind-in-field exists to
remove. Placement fields are uniform across kinds, every entry may carry
an `id:` (automation's handle, §18 decision 3, with per-track uniqueness
checked), `position:` becomes `at:`, and `type:` retires — every track
is audio, and midi returns as an entry kind when it is real. Old
spellings forward the way `mixes/` did: `clips:`, `type:`, `position:`,
and `source:` each get a message naming the move, not an
unrecognized-key shrug.

The planner needed almost nothing, which is the evidence the format was
the thing lying: `planTrack` has sorted the two lists into one placement
plan since placements existed, so this PR mostly deletes the second
spelling (net −153 lines). Validation becomes one entry loop with
per-kind resolution — `audio:` refuses a sound's name pointing at
`sound:`, and vice versa — and the containment-cycle walker, `explain`'s
level answer, and the loop rules (`every` required on renders-later
sources) all speak entries. Diagnostics on a bad reference stay
non-fatal to time resolution, matching how clip sources always behaved.

One real behavior note: tall-grass's `guitar` was the only `type: midi`
track in bloom; it becomes an ordinary empty track that renders silence
and that nothing places. `field track create` loses its `--type` flag,
and scaffolded tracks are written as `name` + `inputs: []`.

Generator entries (`supercollider:`, `generative:`) are deliberately
absent — they are §18's next two steps, and this PR is the flag day they
land on top of.

Review fixes folded in: loop repetitions carry the entry's pan (uniform
fields made a panned loop expressible, and expansion must equal the
hand-tiled equivalent — pan included), an unchosen generative sound is
one diagnostic rather than a false "unknown" stacked on the choose
message, the generative example in project-model.md says `sound:`, and
the comment that claimed checkSource's messages were shared with the
entry path now says the sites are separate on purpose.

## Testing

From the repo root:

```
pnpm build && pnpm typecheck && pnpm test
```

510 tests pass, every fixture migrated to the new format. The
exactly-one-kind rule is mutation-proven: disabling the schema's arity
check turns its test red.

```
cd examples/bloom
field check
field explain creek/track:drums | grep '^action:'
field build creek/track:main
field build tall-grass/track:main
```

`check` says `ok` on the fully migrated example. Drums prints `action:
6cd170a1cbfe (cached)` — the same key it has carried since before #100 —
and both songs come back **entirely cached** (creek: 10 cached + 2
source, tall-grass: 4 cached). This is the PR's core claim made
falsifiable: entry spelling is wiring, the resolved placement plan is
byte-identical, so a format flag day re-renders nothing. If any resolved
field had drifted — an offset defaulting differently, the sort order
moving — these commands are where it would show, as `built` lines and a
moved drums key.

What wrong looks like — the forwarding messages on an old-format file:

```
printf 'name: drums\ntype: audio\nclips:\n  - id: k\n    source: kit-punch\n    position: [1]\n' > songs/creek/tracks/drums.yaml && field check
git checkout -- songs/creek/tracks/drums.yaml && field check
```

The first prints two migration messages ("every track is audio — delete
type:…" and "clips: merged into inputs: — move each clip there, renaming
position: to at: and source: to audio:/sound:/track:…"), plus a cascade
from phrase losing sight of drums; the second restores and says `ok`.

I also ran `field check` and `field arrangement creek` from a clean `git
archive HEAD examples/bloom` export — `ok`, and the structure prints as
before — so nothing depends on this checkout's caches. `scsynth` is not
on my PATH; nothing here needed it, because no SC action key moved and
the cached renders satisfied every build.

State left behind: an `audiod` daemon in `examples/bloom` (`field quit`
stops it), and `.field/out/songs/tall-grass/` now exists from the first
tall-grass build in this checkout.
ninjudd added a commit that referenced this pull request Aug 9, 2026
nested-tracks.md §18 step 2, option A as decided: an entry may hold an
inline `supercollider:` block — the sound schema's authored fields
(program, seed, duration, channels), written where they play — and every
generator entry mints its own node, `//songs/<song>/gen:<name>`,
uniformly, whether it is a leaf's sole content or windowed among
siblings. The node is named by the owning track, or `<track>-<id>` when
the entry carries an id; two un-id'd generators in one track collide and
the diagnostic says to add ids. project-core.md §3.4 carries the dated
amendment adding the `gen:` package to the label grammar. One small
schema loosening rode along: `at:` defaults to 0, so a leaf reads as
bare content (`- supercollider: {...}` and nothing else) — the shape
approved in the design discussion.

`kit-sc` and `pad-sc` fold into leaf tracks, and the fold's central
claim held exactly: **their SuperCollider renders were cache hits under
the old sound keys** — `name` and `type` never reach an action key, and
the entry's parameters are the sound schema's verbatim, so `gen:kit-sc`
picked up `sound:kit-sc`'s cached render without scsynth ever running
(it is not on my PATH; nothing needed it). This is mutation-proven:
leaking one extra field into the minted spec turns the
fold-is-a-cache-hit test red.

One honest wrinkle the build surfaced, worth knowing at review: scsynth
writes 24-bit WAVs and the wrapper stems write float32, so
`track:kit-sc`'s bytes differ from `gen:kit-sc`'s while its samples do
not. The direct consumers (`kit-punch`, `pad`) therefore re-keyed once
and re-rendered — byte-identically: `kit-punch` came out
`d1ae4edb90b7…`, the exact hash it has carried since #100, and
everything downstream (`drums`, `phrase`, `main`) never moved. The
one-time price is two cheap daemon renders, not an SC render.

`seven-eight-loop` deliberately does not fold: `loop-cd` (a normalize
*sound*) sources it, and a sound's `source:` cannot see a track — a
dependency §18's sequencing list glossed over. It retires together with
`loop-cd` at multi-rate step 2; the plan intro now records that.

## Testing

From the repo root:

```
pnpm build && pnpm typecheck && pnpm test
```

517 tests pass (7 new: the `deps()` shape option A promised,
`<track>-<id>` naming, the two-generators-need-ids diagnostic and its
two review-found neighbours — a duplicate id stays one message, a
cross-track name clash names both files — program-path validation
through the entry, and fold-is-a-cache-hit via a counting runner — that
last one is the PR's core claim and is the mutation-proven one).

```
cd examples/bloom
field check
field build creek/track:main
field build creek/track:main
```

`check` says `ok`. The first build prints `cached` for
`//songs/creek/gen:kit-sc` and `//songs/creek/gen:pad-sc` — the folded
renders hitting their old sound keys, which is where wrong would show: a
`built` line on a `gen:` node means the key moved and scsynth would be
required (it would hang here, since it is not installed). On a checkout
with a warm pre-fold cache the wrapper stems and their two direct
consumers build once (`track:kit-sc`, `track:pad-sc`, `kit-punch`,
`pad`) while `drums`, `phrase`, and `main` stay cached — the downstream
cache surviving is the proof the re-render was byte-identical, and
`shasum -a 256 .field/out/songs/creek/track/kit-punch.wav` still prints
`d1ae4edb90b7…`. The second build is entirely cached.

```
field query 'deps(//songs/creek/track:kit-punch)'
```

prints the three-line shape from the design discussion: `gen:kit-sc`,
`track:kit-sc`, `track:kit-punch`.

I also ran `field check` from a clean `git archive HEAD examples/bloom`
export — `ok`. State left behind: an `audiod` daemon in `examples/bloom`
(`field quit` stops it), and `.field/out/songs/creek/gen/` now exists.
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.

2 participants