Repository navigation
Give every audio item a directory - #104
Conversation
field import now writes audio/<name>/<name>.<ext> instead of a flat file, so derived forms (resampled versions, when multi-rate needs them) have a home beside their original. The generative half of audio/ already lived this way; project-layout.md §4.11 records the rule. Ledgers resolve assets through their file field, so rows written before the rule keep working as declared.
|
Starting review of 09c3583. |
minjudd
left a comment
There was a problem hiding this comment.
Reviewed 09c3583. The code change is small and correct, and both claims it rests on hold when tested. The finding is about why the rule exists rather than what it does — worth settling before this becomes the record another chunk builds on.
Your by-hand steps run verbatim, from mktemp -d through check, and print exactly what you say: imported water (audio/water/water.wav, 19244 bytes), with find showing the file inside songs/creek/audio/water/. The compat claim holds too — a flat audio/legacy.wav declared by hand in the ledger still checks ok, so an old ledger really is read as declared.
The risk that would have been invisible is LFS, and it is fine. Nesting a file one level deeper is exactly the kind of change that falls out of a tracking pattern silently, and a new import committed as a plain git blob would not surface until somebody cloned the repo. init writes extension globs — *.wav filter=lfs … — which gitattributes matches at any depth, so audio/water/water.wav is tracked exactly as audio/water.wav was.
Nothing scans audio/, which is the other way a layout change goes wrong. Assets reach the model only through the ledger, and the loader's readdirSync calls are songs/, sounds/, and takes/ — so a directory where a file used to be cannot produce a spurious orphan or dangling diagnostic.
The guards cover the sharp edge this creates. An imported item's directory and a generative item's directory are now the same shape, so audio/keys/ could in principle be claimed twice — but takenSongNames blocks importing a name any sounds/*.yaml already holds, before the copy, and the same pre-flight runs on generate. Re-importing a name errors (asset "water" already declared), and a second import of the same bytes under a new name lands in its own directory, as it should.
Also checked: bloom really has no imported audio (no assets.yaml, only .gitkeep under audio/), so no migration is owed; every test change is a mechanical path update with no assertion weakened; no doc anywhere still shows a flat import path; §4.11 is appended with §1–§3 unrenumbered; and §1.4's audio/<target>/<variant>.wav really is the precedent the new item claims. 517 tests, 418 pass, 41 skip, 58 fail — the same 58 as main, all field-audiod is not built. pnpm typecheck clean.
The derived-form argument promised a committed home to resampled versions, which multi-rate.md §2.4 (DECIDED) already rules out — a rate conversion is a content-addressed graph node in the cache, never a file under audio/. The rule stands on its other leg: one shape for both halves of audio/, migration cheapest now. The derived-form point survives as explicitly hypothetical, citing §2.4 for why today's one candidate is not it.
Every ledger in the suite is written by importAsset and wears the new item-directory shape, so the promise that old flat paths keep working was true only by nobody having written a rule that assumes otherwise. A hand-written flat row beside real bytes now asserts check stays ok.
|
Starting review of 8b6c724. |
minjudd
left a comment
There was a problem hiding this comment.
Approving 8b6c724. Both findings are fixed, and the test is the stronger of the two fixes.
The rewritten §4.11 does better than dropping the claim. It keeps the derived-form case, marks it hypothetical, and then names the reason today's candidate is not one — a conversion node, content-addressed and never committed (§2.4), which is also how the vocal-48k wrapper retires (§2.6). Both citations check out. That is more useful than silence: the next person to wonder whether a resampled file belongs under audio/ now finds the answer and the record that decided it, instead of finding the question open. The rejected alternative is re-argued on the two legs that actually hold, and import.ts no longer carries the retired reason.
The test is load-bearing, which I checked by breaking it. Repointing the ledger row at audio/legacy/legacy.wav while the bytes stay flat turns it red — so check really resolves the declared path rather than passing the assertion vacuously, and a future rule that derived the path from the item name would be caught here. The comment says exactly why the test exists, which is what keeps someone from "simplifying" it later into another importAsset ledger like its neighbours.
518 tests, 419 pass, 41 skip, 58 fail — the same 58 as main, one distinct error string across the run. pnpm typecheck clean.
No findings.
nested-tracks.md §18 step 3: a track entry may hold an inline `generative:` block — the sound schema's request fields verbatim (prompt or text, plus conditioning), written where they play. The entry mints a `gen:` node under step 2's naming rule, but nothing in the build may run it: the node resolves to the chosen take, every take auditions as `gen:<name>-<n>`, and a request with no takes fails resolution naming the `field generate` that fills it. Decision 3 amended as designed on concrete files: the required id fell. Takes key on the gen node's name — the owning track's, or `<track>-<id>` — so run-recorded state lives in `audio/<name>/variants.yaml` with a `gen:` first key (`sound:` stays for the transitional sounds), and the common leaf fold moves no files: `still-water-keys` folded and its audio directory never moved, only the file's first key renamed, a move the check diagnostic tells a pre-fold file to make. `field generate` and `field choose` resolve gen node names, so the sole-entry leaf reads as `field generate still-water-keys --song creek` — the exact command the file's comment has always shown. The track file never changes when audio is generated or chosen — the design constraint stated in the leaf-content discussion, asserted at the byte level by a test. It is also why a voice entry authors `voice_ref_sha256` up front (the schema already pairs it with `voice_ref`): the run verifies the snapshot against it and refuses a drifted voice, instead of writing the hash back the way the sound path fills its recipe. Namespace guards grew to match: a generative entry may not mint a name a sound or an asset holds (both claim `audio/<name>/`, which imports also land in since #104), check says so, and the import pre-flight now reads generative entry names from tracks/ so the collision is an upfront refusal rather than a check-red project after the copy. The gen-name collision check covers both generator kinds, so an un-id'd generative and an un-id'd supercollider in one track collide with the give-each-an-id message. The fold's cache story is the amended decision 6 exactly, with a better ending than kit-punch's: `keys` re-keyed once (its input moved from the raw take to the wrapper stem) and re-rendered byte-identically — `be389af6d73b…`, the hash it had before the fold — so `phrase` and `main` never re-keyed at all and print `cached`. `lead-take` deliberately does not fold: `vocal-48k` (a normalize sound) sources it and a sound cannot see a track; it waits for multi-rate step 3, recorded in the plan intro beside seven-eight-loop's identical deferral. ## Testing From the repo root: ``` pnpm build && pnpm typecheck && pnpm test ``` 549 tests pass (31 new: entry-takes loading and its diagnostics, the graph shape and never-runs proof, generate/choose end-to-end against the stub worker including the track-file-untouched byte assertion, the namespace guards, and the review round's pins — tampered takes and drifted voice references flagged by check, fmt coverage for takes files on both sides, the orphaned-takes-directory scan, and generate/choose refusing an asset-owned name and a mis-attached takes file). ``` cd examples/bloom field check field build creek/track:main field query 'deps(//songs/creek/track:keys)' ``` `check` says `ok`. The build prints `source //songs/creek/gen:still-water-keys → songs/creek/audio/still-water-keys/1.wav` — a `built` line on that gen node is what wrong looks like, because it would mean the build ran a deliberate generation. `deps` prints the three-line leaf shape: `gen:still-water-keys`, `track:still-water-keys`, `track:keys`. On a warm pre-fold cache, `track:still-water-keys` and `track:keys` build once and `phrase`/`main` stay `cached` — the downstream cache surviving is the proof keys re-rendered byte-identically (`shasum -a 256 .field/out/songs/creek/track/keys.wav` still prints `be389af6d73b…`). Without my cache the same claim is checkable via `field explain`: keys' `parameters` are byte-identical across the fold, so only the input hash moved. ``` field choose still-water-keys --song creek --variant 2 field build creek/track:main field choose still-water-keys --song creek --variant 1 ``` `choose` prints the gen spelling (`//songs/creek/gen:still-water-keys now plays it; every placement follows` — before this PR it claimed a `sound:` label and said `source:`, a spelling #102 retired). The first build after switching takes rebuilds exactly the keys chain — different take, different bytes, so `still-water-keys`, `keys`, `phrase`, `main` rebuild and nothing else does — and both renders then live in the action cache, so flipping between takes after that is entirely `cached`: variant A/B-ing is a one-line diff each way and zero renders once both have been heard. I also verified the fresh-clone story from a `git archive` export (no takes — audio/ is git-ignored): `field check` says `ok`, and `field build creek` refuses with `//songs/creek/sound:lead-take has no takes yet — field generate lead-take --song creek --seed <n>`, which is the message the README now quotes (it used to quote still-water-keys' — the fold changed which request the build reaches first). Generating on this machine is stub-tested only; no model workers are installed here. State left behind: an `audiod` daemon in `examples/bloom` (`field quit` stops it).
multi-rate.md step 1, decision 5 as recorded: `field import` gains the first content validation it has ever had. It reads the WAV header before any write, records `sample_rate`, `bit_depth`, `channels`, and `frames` in the ledger row — stored derived values in project-core.md §3.1's sense — and `check` verifies the recorded facts against the file it already hashes, so a hand-edited row that lies about its rate goes red. A rate that differs from the project's must be acknowledged: `--allow-mismatch` in scripts, a y/N prompt interactively, and the refusal happens before the copy, naming the flag. Refusing outright stays rejected, per the decision — with decision 4, a mismatched asset is a conversion cost, not an error, and the warning exists so nobody pays it unknowingly. The WAV signature is sniffed by content, so the extension neither gates the safeguard nor fools it; a file whose header will not parse (or declares an impossible rate) records nothing and reports why — import has always been willing to carry bytes it does not understand, and several test fixtures rely on exactly that, so unparseable stays legal rather than becoming a new refusal. The fields are optional in the schema, so every ledger written before this rule stays valid; old rows simply carry no facts (the same forward-compat stance as #104's path rule). The normalize property tests import off-rate sources deliberately — the resampler is the thing under test — so their fixtures now acknowledge the mismatch, which reads as documentation of what they do. The multi-rate status line moves to In progress with step 1 done, and the Multi-rate line moves from next.md to now.md. ## Testing From the repo root, `pnpm build && pnpm typecheck && pnpm test` — 557 tests pass (8 new: facts recorded and check-verified, mismatch refused before any write then acknowledged both ways, junk .wav recording nothing, a hand-edited `sample_rate` going check-red, and a partial row — the facts stripped down to a subset — refused by the schema so the verification gate cannot be dodged, a real WAV named `.wave` sniffed by content so the acknowledgement cannot be bypassed by filename, and a header declaring a zero sample rate recorded as nothing instead of as a row check rejects). The recording and the verification are both mutation-proven: neutralizing either turns its test red. By hand, in a throwaway project (needs `pnpm build` so the `field` on your PATH is current): ``` cd "$(mktemp -d)" field init --name demo field song create creek python3 -c "import struct,wave; w=wave.open('water.wav','wb'); w.setnchannels(2); w.setsampwidth(2); w.setframerate(48000); w.writeframes(struct.pack('<9600h', *[0]*9600)); w.close()" python3 -c "import struct,wave; w=wave.open('tape.wav','wb'); w.setnchannels(2); w.setsampwidth(2); w.setframerate(44100); w.writeframes(struct.pack('<8820h', *[0]*8820)); w.close()" field import water.wav --song creek field import tape.wav --song creek < /dev/null field import tape.wav --song creek --allow-mismatch cat songs/creek/assets.yaml field check ``` The first import prints `imported water (audio/water/water.wav, 19244 bytes, 48000 Hz 16-bit 2ch, 4800 frames)` — before this change the parenthetical stopped at the byte count and the ledger row at `bytes:`, which is where wrong would show. The second exits 1 with `tape.wav is 44100 Hz against the project's 48000 — placements will pay a conversion (multi-rate.md §2.4); import it anyway with --allow-mismatch` and leaves no file and no row behind. The third succeeds and records `sample_rate: 44100`. `check` says `ok`; edit `sample_rate: 44100` to another value by hand and it says `asset "tape" records sample_rate ... but the file says 44100`. Run interactively (a real terminal, no `< /dev/null`) and the second import asks `import anyway? [y/N]` instead of exiting. State left behind: just the throwaway directory.
Every audio item under
audio/is now a directory named for the item:field import water.wavwritesaudio/water/water.wavand pins that path in the ledger, where it used to write a flataudio/water.wav. The generative half ofaudio/already lived this way —audio/still-water-keys/holds takes andvariants.yaml— so this makes the imported half match: one shape for both halves, and the migration is cheapest now, before any project accumulates imports. If a derived form of an item is ever committed, the directory is where it belongs — though today's one candidate is not one: a resampled placement is a conversion node, content-addressed in the cache and never committed (multi-rate.md §2.4). project-layout.md §4.11 records the rule with the rejected alternative.The change is confined to what
field importwrites. Everything that consumes an asset resolves it through the ledger'sfilefield, so anassets.yamlwritten before this rule keeps working exactly as declared — the rule governs new imports, not whatcheckaccepts, and a test pins that promise with a hand-written flat-path ledger row. No bloom song has imported audio, so the example needs no migration.This is the first slice of nested-tracks §18 step 3, split out per the design discussion: the
generative:entry chunk builds on audio-item directories being settled (takes will key on the gen node's name, directory per item), so the layout rule lands first on its own.Testing
From the repo root,
pnpm build && pnpm typecheck && pnpm test— 518 tests pass. The layout is pinned byrecords forward-slash file pathsand its neighbours insrc/model/project.test.ts, which now expectaudio/first/first.wav; revertingsrc/commands/import.tsturns them red. The compat promise is pinned byreads a flat pre-rule ledger path as declared, which hand-writes a flatfile: audio/legacy.wavrow beside real bytes and assertscheckstays ok.To see it by hand, in a throwaway project (needs
pnpm buildso thefieldon your PATH is current):importprintsimported water (audio/water/water.wav, 19244 bytes)andfindshows the file insidesongs/creek/audio/water/— before this change both saidaudio/water.wav, which is where wrong would show.checksaysok. State left behind: just the throwaway directory.