Skip to content

Export grows --rate and --bit-depth; loop-cd retires - #108

Merged
ninjudd merged 2 commits into
mainfrom
export/rate-and-depth
Aug 10, 2026
Merged

ninjudd merged 2 commits into
mainfrom
export/rate-and-depth

Conversation

@ninjudd

@ninjudd ninjudd commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

multi-rate.md step 2, decision 1 as recorded: delivery rate and bit depth are export parameters. field export --rate 44100 --bit-depth 16 converts on the way out through the daemon's normalize op — the identical op a normalize sound drove, never a node in the song. A flag left off defaults to the source's own value where it has one — a float source (everything Field renders) has no integer depth of its own, so --rate alone on a stem refuses and asks for --bit-depth rather than silently changing the encoding; conversion always writes integer PCM at the chosen depth, exactly as normalize always has; and the effective pair joins the export name after a dot (tall-grass-sound-seven-eight-loop.44100-16-v1.wav) — a character no label can carry, so a converted family never versions an unconverted one, nor a label that happens to end in digits — v1 at 48 k and v2 at 44.1 k of "the same thing" would be different things. Converted bytes are staged in a scratch directory and versioned from there, the committed-source drift guard runs on the original bytes so conversion cannot launder a tampered asset, and unchanged-detection compares the delivered bytes, which the resampler's determinism makes meaningful.

loop-cd retires into that invocation. Before deleting it I ran the definition-of-done proof on bloom itself: field build tall-grass/sound:loop-cd, then field export tall-grass/sound:seven-eight-loop --rate 44100 --bit-depth 16, and cmp reported the two files bit-identical. A CD deliverable is an invocation, not a sound — and with loop-cd gone, seven-eight-loop's fold into a leaf track is unblocked, which is the next PR (it belongs to nested-tracks chunk 6, so it ships separately). The flag values are bounded by the same sets the normalize schema accepts, since they drive the same op.

Testing

From the repo root, pnpm build && pnpm typecheck && pnpm test — 562 tests pass (5 new, real daemon, no stub runner: the delivered header says what the flags asked, the export is bit-identical to a normalize sound's render of the same source at the same parameters, and converted/plain families version independently with deterministic current detection, a float source refusing --rate alone, and a .wave asset converting by content). The conversion is mutation-proven: replacing the daemon call with a plain copy turns the two content tests red while the naming test stays green.

By hand, in examples/bloom (needs pnpm build; spawns an audiod daemon — field quit stops it):

field check
EXPORT_DIR=$(mktemp -d)
field export tall-grass/sound:seven-eight-loop --rate 44100 --bit-depth 16 --to "$EXPORT_DIR"

prints exported //songs/tall-grass/sound:seven-eight-loop → …/tall-grass-sound-seven-eight-loop.44100-16-v1.wav, and the file is a 44.1 kHz 16-bit integer PCM WAV. The bit-identity claim against loop-cd cannot be re-run on this head because this head deletes the sound — I ran it immediately before the deletion (cmp clean against field build tall-grass/sound:loop-cd's output), and the test is bit-identical to the normalize sound it retires reconstructs the same comparison from scratch on every run, which is the durable form of the proof. What wrong would look like: an export whose header still says 48000, or bytes that differ from a normalize render of the same source — either fails the suite. field check stays ok after the deletion because nothing referenced loop-cd; that nothing did is why it could retire without a forwarding diagnostic.

multi-rate step 2 (decision 1): delivery rate and bit depth are export
parameters, converted on the way out by the daemon's normalize op —
never a node in the song. A flag left off defaults to the source's own
value; conversion writes integer PCM at the chosen depth; the
effective pair joins the export name so a converted family never
versions an unconverted one. Proven bit-identical to loop-cd's render
on bloom before that sound retired — a CD deliverable is an
invocation, not a sound.
@minjudd

minjudd commented Aug 9, 2026

Copy link
Copy Markdown

Starting review of 3618dc6.

@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.

Reviewed 3618dc6. The shape is right — delivery formatting is an invocation, the conversion runs on the way out, and the effective pair joining the name is what keeps a converted family from versioning an unconverted one. The finding is about what "the source's own value" means for the sources Field itself renders.

What I could check here, and what I could not. The three new tests are real-daemon tests, and this machine has no field-audiod: 61 failures against main's 58, the delta being exactly those three, each field-audiod is not built. So the header-says-what-the-flags-asked claim, the bit-identity against loop-cd, and the deterministic current detection across families are yours, verified in your environment — I did not re-run them and am not implying otherwise. The bit-identity proof being reconstructed by a test on every run, rather than resting on the cmp you ran before deleting the sound, is the right durable form.

The refusals that do not need the daemon all fire, and refuse before anything lands. --rate 12345 → rate must be one of 44100, 48000, 88200, 96000, 176400, 192000; a non-WAV source with conversion → cannot convert //songs/creek/asset:notwav: .aiff is not a WAV; an 8-bit source with --rate alone → //songs/creek/asset:eight is 8-bit — pass --bit-depth 16, 24, or 32. The destination directory is empty after each, so the reject-the-request-not-the-item invariant survives the restructuring.

EXPORT_RATES really is the normalize schema's set — the six literals in schema/common.ts's sampleRate union — so the flags cannot promise a value the op refuses. Staging in a scratch dir and versioning from there is sound: writeVersion copies into a dot-file inside the destination before linking, so nothing depends on the scratch path outliving the call, and the drift guard hashing the original bytes before conversion is the right order — conversion cannot launder a tampered asset.

One small thing, no action needed: ExportResult.from now points into the scratch directory for a converted export, and that directory is gone by the time the caller sees it. Nothing in src/ reads the field, so it costs nothing today.

And one asymmetry worth knowing rather than fixing: export decides WAV-ness by extension, so a WAV named .aiff refuses conversion — the opposite of the sniffing #107 just landed for import. The failure direction is benign here (a refusal, not wrong bytes), which is why I am not filing it.

Docs match: build-graph.md states the rule, multi-rate's status line adds step 2 with step 3 still unstarted, and nested-tracks records that seven-eight-loop's fold is unblocked.

Comment thread src/commands/export.ts Resolved

@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: 3618dc6f0c

ℹ️ 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/commands/export.ts Resolved
Comment thread src/commands/export.ts Resolved
Comment thread src/commands/export.ts Resolved
…rom paths

Four review findings on the flags. --rate alone on a float source —
everything Field renders — silently delivered int32 while promising
the source's own value; it now refuses and asks for --bit-depth,
because int32 is the same width in a different encoding, not a
default. The format suffix joins the name after a dot, a character no
label can carry, so a converted family can never collide with a label
ending in digits. ExportResult.from names the source artifact rather
than a scratch path the call deletes. And convertibility sniffs the
RIFF/WAVE signature (hasWavSignature moves to audio/wav.ts, shared
with import), so a .wave asset the ledger fully supports is as
deliverable as a .wav.
@minjudd

minjudd commented Aug 9, 2026

Copy link
Copy Markdown

Starting review of c3b0166.

@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 c3b0166. The refusal is the right half of the choice I offered — a default that guesses would have been wrong for one class of source or the other — and the message says why rather than only what:

$ field export creek/asset:float --rate 44100 --to "$E"
//songs/creek/asset:float is 32-bit float — conversion writes integer PCM, so pass --bit-depth 16, 24, or 32

That is against a real float32 asset (written with writeWavFloat32, imported, ledger reading 32-bit), and it fires before any daemon call, so it is one of the paths I could exercise here rather than read. The non-float odd-depth case keeps its own message, and the help text and build-graph.md both now say a float source must choose.

The dot separator closes a collision I missed. asset:pad-44100-16 exported plain and asset:pad exported at 44100/16 would have produced the same base under a hyphen — two labels versioning each other, which is precisely what the dedupe check exists to prevent and which that check could not see, because the collision is between a converted name and a plain one. SLUG_PATTERN is /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, so a dot cannot come from a label, and existingVersions already regex-escapes the base, so widening the version scan is not a side effect.

Export sniffs content now too, which is what #107's precedent asked for: a WAV the ledger holds as .wave gets past the not-a-WAV refusal and on to the daemon — here that is where it stops, for the usual reason, but the refusal it used to hit is gone. Import and export share one probe in wav.ts rather than two copies, which is the shape that keeps them agreeing.

from names the source artifact and the test asserts it is still a file after the call, so the field means something after the scratch directory is swept.

562 tests, 458 pass, 41 skip, 63 fail — main is 58, and the delta is exactly the five delivery-formatting tests, every one field-audiod is not built. So the same three claims as last round stay yours: the delivered header, the bit-identity against loop-cd, and cross-family current detection. pnpm typecheck clean.

No findings.

@ninjudd
ninjudd merged commit a1d714e into main Aug 10, 2026
1 check passed
@ninjudd
ninjudd deleted the export/rate-and-depth branch August 10, 2026 00:16
ninjudd added a commit that referenced this pull request Aug 10, 2026
The last supercollider sound becomes a leaf track whose one entry is the
program — the fold that loop-cd's retirement (#108, multi-rate step 2)
unblocked, and the third run of the pattern kit-sc and pad-sc set in
#103. `drums` changes one word (`sound:` → `track:`), the recipe file
moves from `sounds/` to `tracks/` keeping its comment, and the README's
play line follows to the `track:` spelling. tall-grass's `sounds/`
directory is now empty; creek's holds the last two, both blocked on
multi-rate step 3 (`vocal-48k` retires when a track carries its own
rate, and `lead-take` folds with it).

The cache story is amended decision 6 exactly, proven a third time:
`gen:seven-eight-loop` was a cache hit under the old sound's action key
— `name` and `type` never reach a key, the entry's parameters are the
sound schema's verbatim, and scsynth never ran (it is not installed
here; nothing needed it). `drums` re-keyed once, its input moving from
the raw render to the wrapper stem, and re-rendered byte-identically to
its pre-fold hash (`f25b9e091be2…`), so `main` never re-keyed and prints
`cached`.

## Testing

From the repo root, `pnpm build && pnpm typecheck && pnpm test` — 562
tests pass, unchanged from the base: the fold is example-and-docs only,
exercising machinery #103 landed and tested.

In `examples/bloom` (spawns an `audiod` daemon; `field quit` stops it):

```
field check
field build tall-grass
field build tall-grass
field query 'deps(//songs/tall-grass/track:drums)'
```

`check` says `ok`. On a warm pre-fold cache the first build prints
`cached` for `//songs/tall-grass/gen:seven-eight-loop` — the folded
render hitting its old sound key, which is where wrong would show: a
`built` line there means the key moved and scsynth would be required (it
would fail here, since it is not installed). `track:seven-eight-loop`
and `track:drums` build once while `track:main` stays `cached` — the
downstream cache surviving is the proof drums re-rendered
byte-identically, and `shasum -a 256
.field/out/songs/tall-grass/track/drums.wav` still prints
`f25b9e091be2…`. The second build is entirely cached. `deps` prints the
three-line leaf shape: `gen:seven-eight-loop`, `track:seven-eight-loop`,
`track:drums`. `field fmt` says `already canonical`.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Example YAML and documentation only; no runtime or schema code
changes, with cache behavior validated by existing build machinery.
> 
> **Overview**
> **`seven-eight-loop` becomes a leaf track** in the nested-tracks §18
pattern (`kit-sc` / `pad-sc`): the SuperCollider recipe moves from
`sounds/` to `tracks/seven-eight-loop.yaml` as a single `supercollider:`
input instead of `type: supercollider` on a sound.
> 
> **`drums` now places the track**, swapping `sound: seven-eight-loop`
for `track: seven-eight-loop`. The bloom README `field play` example
uses the `track:` spelling.
> 
> **Plan docs** record that this fold (unblocked after `loop-cd`
retirement / multi-rate step 2) has landed; tall-grass `sounds/` is
empty aside from creek’s remaining sounds blocked on multi-rate step 3.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
66a15f1. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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