Repository navigation
Watch chunk 2: play --loop --watch, atomic materialize, docs - #35
Conversation
The watch plan's second chunk (watch.md §4.2): play --loop --watch composes the watch-build loop with blocking playback. On the native loop, a moved output hash queues a daemon reload (takeover at the wrap, printed when it actually sounds); a --from region loop takes the requeue path and just repoints what the next pass loads (§2). Requires --loop and exactly one label (§1.4); --click is refused for now (the click bakes into a temp file a swap would drop). The scripted §3 walk against field surfaced a real bug: materialize copied into the stable out path in place, truncating under the daemon's open reader — the very file the loop was playing. It now lands by copy-to-temp + rename, so the playing pass keeps its inode until the swap (§1.6), with a test pinning the fresh-inode behavior. Walk results (null output, every edit reverted): clip move ↻, fader ↻, .scd edit re-rendered and swapped at the wrap, broken YAML printed diagnostics while the loop kept playing, the fix recovered silently (identical content, all cache hits), fmt was a no-op, and choose against the running watch A/B-ed variants live — the final revert swapped back to the exact original mix hash. Ctrl-c ended cleanly. Docs: build-graph.md gains the watch section under caching; playback.md's follow-ups record the reload op; watch.md status → implemented; the now.md line retires.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 92f944b. Configure here.
ninjudd
left a comment
There was a problem hiding this comment.
Reviewed at head 92f944bb — in place this time, since the checkout is already on it and clean. 244/244 pass, typecheck clean, tree still clean afterwards.
One P2 and one P3, inline. The P2 is that the feature works for the label kind the walk exercised and is silently blind to the one decision 5 calls the best demo — and this PR promotes that promise into a root doc. The headline path itself is solid: I ran it and it works.
Verified by execution — on a scratch project with the null-output daemon:
play --loop --watchon a rule label swaps, end to end:playing //songs/creek/sounds:pad-96k→ editsample_rate→↻ //songs/creek/sounds:pad-96k e85908974779 at the next wrap→↻ swapped at the wrap. Both lines, in order, at the wrap. That's the DoD's shape (a mix is the same node kind), and it's genuinely good.--fromtakes the requeue path and says so:↻ … next pass, then the pass boundary reloads. No native reload attempted, matching §2.- Atomic materialize is real: the output's inode moved across a rebuild (
220019865→220019882), so a reader holding the old pass keeps its bytes. No.tmp-<pid>residue left in.bloom/out/after any of my runs. - All three guards fire with their messages:
--watchwithout--loop, and with two labels, both give--watch needs --loop and exactly one label (got N) — watch.md §1.4;--watch --clickgives--watch does not compose with --click yet. - The phase-tagged errors close the #34 footnote properly —
load failed:for a loader crash,build failed:for a build one, and the test pins the phase rather than just the message.
Verified by reading, no issue found:
- The version guard is the
load+loopprecedent applied correctly, and it's rightly skipped on the requeue path, which never callsreload. waitForStopgrowing anonReloadedarm is additive; the event reaches the play's connection because the daemon broadcasts, while the reload is requested on a second connection — the right split, and the miniature test mirrors it.say()clearing the position line before every message keeps the TTY readout from being scribbled over.- SIGINT now aborts the watch as well as stopping the transport, and the
finallyaborts + awaitswatchDone, so ctrl-c can't leave a watcher behind. materialize's tmp file lands inside.bloom/, so the write that used to truncate under the daemon also can't self-trigger the watcher.
Two footnotes, no threads:
watchDoneis an unawaited promise for the whole life of the play — it only gets a handler in thefinally. IfwatchBuildever rejects before then (fs.watchthrowing at setup is the realistic candidate), that's an unhandled rejection: #34's P2 one level up. I could not demonstrate it and I'm not claiming it's reachable today; a.catchat creation routing tosay('watch failed: …')closes the shape for one line.- An edit landing in the window before the play's first
loadwould answerreload failed: nothing loaded. It needs an edit inside the first few hundred ms, so it's cosmetic — worth knowing only because the message reads as a bug in the swap rather than a race at startup.
CI: there is no workflow run for feat/watch-play at all — not a failure, an absence (Bugbot completed NEUTRAL, but the test job never ran on this head). #34 needed a nudge commit for the same reason. Worth a green run before merging, since this PR changes materialize for every build, not just watched ones.
P2 (+ Bugbot dup): play --loop --watch was silently blind to chosen-variant and asset labels — outputPath only existed on rule outcomes, so the hook returned early for exactly the label whose repoint is decision 5's demo. Committed outcomes (assets, generation labels) now name their file path, so every outcome is a playable path and both the reload and currentPath mechanisms reach it. Proven live on field: choose against a running watch prints the queued reload and swaps at the wrap, both directions. Bugbot (teardown): an abort landing mid-build now suppresses the report — edit-then-ctrl-c inside a render no longer fires reload into a closed socket; the racing in-flight reload's failure print is also suppressed once the session is ending. Deterministic test stalls a rebuild in the runner, aborts, releases, and asserts nothing reported. Bugbot (first-outcome premise, the real residual): play --watch now seeds the watch baseline with what the daemon started looping (Playable carries sha256), so an edit landing between the play's own build and the watcher's first pass is reported and swapped, not absorbed. A seed only speaks for the labels it names — dependencies baseline silently on the first build. P3: watch mode returns to now.md (shipped, held by §5's open status-visibility question, per the Project core precedent), and watch.md §1.1's promise is marked kept — playback.md §5 records the reload op.
ninjudd
left a comment
There was a problem hiding this comment.
Re-reviewed at head 8e80a02, in place. Both fixes are real and I verified each one live, including an A/B against the pre-fix commit. One new finding, inline, and it blocks: pnpm typecheck fails on this head, so CI cannot go green as pushed. Everything else is clean.
P2 — fixed at the root, and it works. bloom choose gen1 --song creek --variant 2 against a running bloom play creek/sounds:gen1 --loop --watch now prints ↻ //songs/creek/sounds:gen1 5aefb2a387ff at the next wrap (variant 2's hash) and then ↻ swapped at the wrap. Giving committed outcomes their file path was the right of the three options: one hook now serves all three node kinds, currentPath becomes meaningful for the requeue path, and nothing special-cases a repoint.
Teardown race — fixed, and the A/B is decisive. Same script, same timing (long say render, ctrl-c 0.4 s after the edit, three attempts each), run against both heads:
- pre-fix
92f944b: 3/3 printed↻ … at the next wrapafter ctrl-c — a reload queued once the session had ended. That's the other face of the bug I first hit asreload failed: Cannot call write after a stream was destroyed: whether you get a stray error or a late swap just depends on whether the socket close wins the race. - post-fix
8e80a02: 3/3 end atplaying …with nothing after it.
The abort check between the build completing and the report firing is the fix that matters; the aborted-guarded error message is a sensible second layer.
Baseline seeding — verified by reading, not by racing (the window is sub-second and I won't claim a repro I didn't get). The logic is right: seeded labels compare on the first build, unseeded dependencies stay silent until a full baseline exists, and bloom build --watch behaves exactly as before because its map starts empty. Quiet starts stay quiet in practice — no spurious first-build ↻ in any of my seven runs, which is what the seed being item.sha256 predicts.
Docs — all three verified. playback.md's reload note really is in §5 (Follow-ups, and the note sits inside it — grepped, not assumed); the now.md line is back with the Project core precedent named; §1.1 reads in past tense with the promise marked kept.
Three footnotes, no threads:
bloom buildnow prints→ <path>for committed labels —cached //songs/creek/sounds:gen1 → …/songs/creek/audio/gen1/2.wav. The arrow used to mean "materialized under.bloom/"; it now also points at source files the build didn't produce. Informative either way, but it's a user-visible change that fell out of the fix rather than being chosen — worth a deliberate yes or no.- The committed paths are now computed twice:
buildNode's two new branches, andinputPathsat build.ts:250-251, with the same two expressions. If they ever drift, the daemon plays a different file than the graph consumes. Since every outcome now names a path,inputPathscould collapse tobuilt.get(…)!.outputPath!for all three kinds and the duplication would go away. - The seeding makes my earlier "reload before the first load" footnote marginally more reachable — the first build can now report, and it races
playThroughDaemon's connect-and-load (which may include a daemon spawn). It still needs an edit inside that window, so it stays cosmetic; noting it only because the suppression checksaborted, not "nothing loaded yet".
CI: still zero runs on feat/watch-play — the second nudge commit didn't produce one either. Given the finding above, that absence is now load-bearing: the branch has never had its typecheck step executed.
Making sha256 required on Playable broke the one call site that builds one by hand — invisible to all three usual signals (vitest doesn't typecheck, pnpm build excludes test files, and CI never ran during the Actions outage). Fixed at the call site; the field stays required, since the seed existing is what closes the absorbed-first- build window.
ninjudd
left a comment
There was a problem hiding this comment.
Confirmed at head 6897e40, in place: pnpm typecheck exits 0 over the whole project, tests included, alongside 248/248. The fix is at the call site with the field left required, which is the version I'd argue for. All six threads resolved, each carrying its fix. No new findings — nothing blocking from me beyond the CI run you're already waiting on.
One footnote for the cleanup PR you've already got queued — it joins the other two rather than being worth its own round:
withClick returns { ...item, path }, so a click-wrapped Playable keeps the source's sha256 while its path points at the rendered click file in .bloom/tmp/. That makes the field's stated invariant — "content hash of what path holds" — false for exactly that one path through the code, and the new test comment ("withClick carries it through untouched") is describing the thing that breaks it. It's harmless today only because --watch refuses --click two files away; the refusal message says "yet," and when it lifts, a watch would swap in the un-clicked artifact and drop the click — the same failure the refusal already exists to prevent, arriving by a second route. Cheapest resolutions: recompute the hash in withClick, or note the exception on the field so the next reader isn't relying on a guard in cli.ts to keep a type honest.
…nce (#38) The no-thread footnotes from the #34/#35/#37 reviews. Each was too small to justify its own PR; together they justify one. ### `bloom build` claimed cache hits that never happened Assets and chosen variants printed `cached` — but nothing executed and nothing came out of the cache; they are committed files the build only pointed at. Outcomes now carry `committed`, the print says `source`, and the three status words pad to a common width so the labels line up: ``` cached //songs/creek/tracks:drums → /Users/justin/…/field/.bloom/out/songs/creek/tracks/drums.wav source //songs/creek/sounds:still-water-keys → /Users/justin/…/field/songs/creek/audio/still-water-keys/1.wav built //songs/creek/mix:main → /Users/justin/…/field/.bloom/out/songs/creek/mix/main.wav ``` (Paths are absolute and elided here for width — that is pre-existing behaviour from #35, and it does swamp the alignment this buys. Printing them relative to the project root is a follow-up, not something to change quietly inside a cleanup PR.) ### One spelling for the committed path It was computed in three places by two spellings (`assetFilePath` and an inline `join`), which were drifting apart by construction. `sourceFilePath` covers assets and generation labels alike. ### `withClick` left a hash describing a different file The returned Playable's `path` pointed at the clicked copy while `sha256` still described the source. `--click` and `--watch` don't compose today, so nothing was wrong yet — but watch seeds its baseline from that field, so the next composition is exactly where it would have bitten. It re-hashes. ### Quitting before the wrap now leaves evidence A pending takeover froze as a `└` that reads as *about to happen*, when ctrl-c means it never will. Verified live under a pty in a scratch clone: ``` [1] 7.3 └51a757a22efb 51a757a22efb built, never sounded (stopped before the wrap) ``` ### The seeded-baseline window A seeded baseline can report drift before the play's own first load, and a reload with nothing to take over from errors. The takeover is held until the first load opens the block, then released. ### Editor dotfiles are not project files Emacs writes `.#track.yaml` — a dangling symlink — while a buffer is unsaved. It ends in `.yaml`, so the loader read it and threw ENOENT, which under `--watch` meant merely *opening* a track file ended the rebuild. ### Tests The `.bloom/` watch exclusion had nothing pinning it. The new test settles the watcher before probing, because "nothing happened because of what I just did" is only measurable from a quiet baseline — the fixture's own writes can still be in FSEvents' pipeline when the baseline lands, and an absolute event count blames the probe for them. (That is what the first draft of this test did, and it failed; the `fs.watch` filenames were never the problem.) Plus the committed/rule outcome flags, the click re-hash, the dotfile, and three teardown cases. `pnpm typecheck` exit 0, 271/271 green, and `bloom build` re-run against the field clone for the status column. Deliberately **not** here: bounding the beat scheduler's prints by the loop length (#37 review). It needs the loop length from `status` and is a scheduler behavior change, not cleanup. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Localized CLI/watch/build and loader filtering changes with broad test coverage; no auth, persistence, or protocol changes beyond existing reload behavior. > > **Overview** > This PR bundles small **watch/build UX fixes** from #34/#35/#37 review footnotes: clearer build output, safer `play --watch` reload timing, and fewer watch false failures. > > **Build reporting:** `BuildOutcome` adds **`committed`** for assets and chosen variants (nothing was executed or cache-hit). `bloom build` prints **`source`** instead of **`cached`** for those labels, with padded status columns via **`buildStatus`**. > > **Paths and hashes:** Committed file paths are unified in **`sourceFilePath`** (replaces duplicated asset/generation path logic). **`withClick`** now sets **`sha256`** from the clicked temp WAV (**`sha256FileSync`**) so path and hash stay aligned for watch baselines. > > **`play --watch`:** Rebuilds that arrive before the first daemon load are **held** (`heldForStart`) until **`onItem`** opens the block, then **`takeover`** runs—avoiding reload errors when nothing is looping yet. > > **TTY teardown:** **`LoopDisplay.end()`** prints that a pending hash **built but never sounded** if you ctrl-c before the wrap (docs updated in **`watch.md`**). > > **Watch stability:** YAML discovery skips **dot-prefixed** files (e.g. Emacs **`.#…yaml`**). Tests add **`quiet()`**, assert **`.bloom/`** writes do not retrigger watch, and cover committed outcomes, click re-hash, and teardown cases. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1bfeb2b. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Three findings from the #39 review, all reproduced before fixing. **A file differing only in case was silently destroyed.** The version scan matched case-sensitively while APFS resolves case-insensitively, so someone's `Creek-Mix-Main-v1.wav` was invisible to the scan and then became our bytes *under their filename* — a directory listing does not even change. Confirmed on this machine: copyFileSync onto the lowercase name left one file, holding our content, still called theirs. Writes now go to a temp name in the destination and `link` into place. `link` fails EEXIST rather than truncating, including on a name that differs only in case, and the next version number is taken. The scan is also case-insensitive now — not for safety, which the link already gives, but for truthfulness: their v5 must count as 5, or our next export writes a "v1" that is newer in time than a v5 sitting beside it. **The same change makes a version complete or absent.** An interrupted copy left a truncated `-vN.wav`, and since nothing is ever overwritten that file was permanent: forever "newest and different", so every later matching export would report `reverted`. Now an interrupt leaves debris under a dotted `.part-<pid>` name that no scan matches. **A drifted committed source exported as `current`.** For assets and chosen variants the recorded hash is the *declared* one, which the build deliberately trusts and only verifies when consuming the file as an input. So a bounce written over pad.wav without re-importing compared equal to the previous export, and the command said `current` while the exported file was different audio from the project's. Export now hashes what it is about to copy and refuses when a committed source disagrees with its declaration — the guard build applies to inputs, on the command whose product leaves the machine. Playable gained `committed` to say which items carry a declared hash; typecheck caught the one hand-built Playable in click.test.ts, as it did in #35. Each fix has a test that fails without it, checked by reverting them one at a time. The case test alone did not isolate the scan (the link guard also saves the file), so there is a second test for the numbering. Docs: the paragraph said bytes are compared against the newest version when the code compares every version, and never mentioned `reverted`. Rewritten, including the two new guarantees. A citation I had drafted for project-core.md §3.5 turned out to be the cache-key decision, not the tamper guard, so it is described rather than cited.
One conflict, in the hand-built Playables in click.test.ts. #38 taught withClick to re-hash, dropping the stale "carries it through untouched" comment; this branch made `committed` required. The resolution takes both, and adds the field to the re-hashes test #38 introduced — which the merge would otherwise have left as a type error the branch's own CI never saw, because a conflicting PR has no merge ref to build. That call site has now needed the same edit three times (#35, this PR, this merge). A test Playable factory would end it; noted for a follow-up rather than smuggled in here.
…it (#40) Hand-built `Playable` literals in tests have broken three times running, each time in a way the usual signals missed: - `sha256` in #35 — invisible to vitest (which does not typecheck) and to `pnpm build` (which excludes tests), so every signal was green. - `committed` in #39. - Again merging #38 into #39: the re-hashes test #38 added needed the field too, a type error neither branch's own CI could see, because a conflicting pull request has no merge ref to build. `playable({ path })` fills every required field. The two call sites in `click.test.ts` use it. ### The property, verified rather than assumed I added a temporary required field to `Playable` and checked who breaks: ``` before updating the factory: src/commands/play.ts, src/testing/playable.ts after updating only the factory: src/commands/play.ts ``` `play.ts` is real code and has to change anyway. No test file does. ### Two small decisions `path` has no default. A Playable's job is to name a file, and defaulting it would turn a missing fixture into an ENOENT somewhere far away instead of a compile error at the call site. The helper lives in `src/testing/` and is excluded from `tsconfig.build.json`, so it does not ship in `dist`. `*.test.ts` was the only exclusion before; a helper that is not itself a test needed its own. `pnpm typecheck` exit 0, 301/301. Built in a git worktree off `main`, so the shared checkout — whose `dist` the global `bloom` symlinks into — was never switched or rebuilt. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only helper and test refactors; no production runtime behavior changes. > > **Overview** > Adds **`playable()`** in `src/testing/playable.ts` so tests can build a full **`Playable`** with defaults for `label`, `pkg`, `sha256`, and `committed`, while **`path` stays required** at the call site. > > **`click.test.ts`** now uses `playable({ path: src })` (and overrides `sha256` in the re-hash test) instead of hand-written literals. > > **`tsconfig.build.json`** excludes **`src/testing/**`** so the helper is not emitted to **`dist`** alongside test files. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f3a353e. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
It said chunk 2 'is on the PR that carries this status line', which stopped being true when #35 merged and has been describing an unopenable PR through #37, #38 and the #44 rename. Now it names #35 and the amendments, verified against the file's history and against the commit that introduced the flag rather than from memory. And it ends by enumerating what is outstanding, which sets the expectation that the enumeration is complete. §6 records a known, audible, deliberately-deferred defect in the shipped feature and the line did not mention it, so someone reading only the top concluded the single loose end was a design question about status visibility. Both are named now, with the audible one first, because a reader deciding whether to trust --watch cares about that one and not the other.

Second and final chunk of the watch plan (watch.md §4.2), on top of #34.
play --loop --watch
Composes the watch-build loop with blocking playback (§1.4): the same pattern is watch-built beside the play; when the played label's output hash moves, the native loop queues a daemon reload —
↻ <label> <shortHash> at the next wrapwhen queued,↻ swapped at the wrapwhen the takeover actually sounds (the daemon'sreloadedbroadcast, surfaced through a newonReloadedplay hook). A--fromregion loop takes the requeue path instead: no wrap to swap at, so the freshest artifact is consulted at every pass load (currentPathon PlayOptions, per §2's last bullet). Requires--loopand exactly one label;--clickis refused for now — the click bakes into a CLI-side temp file a swap would silently drop. Version-guarded against pre-0.4 daemons following theload+loopprecedent. Watch errors print with their phase (load failed:/build failed:/watch failed:) — closing the #34 review footnote about loader crashes reading as build failures.Atomic materialize (a real bug the walk found)
materializecopied into the stable.bloom/out/...path in place — truncating the very file the daemon streams while looping, violating §1.6's "the old mix keeps looping". It now lands by copy-to-temp + rename so the playing pass keeps its inode until the swap, with a test pinning the fresh-inode behavior.The §3 definition-of-done walk, run against field
Scripted with the null-output daemon, every edit reverted, tree clean after:
↻ mix:mainqueued↻(latest-wins replaced the queued takeover).scdedit → real re-render,↻, then↻ swapped at the wrapbloom fmt→ "already canonical", nothing rebuilt, nothing swappedbloom choose still-water-keys --variant 2from another shell →↻— live variant A/B inside the loopThe audible version is one command away:
bloom play creek --loop --watch.Tests (244 passing) and docs
New:
onReloadedsurfaced through a native-loop play (the watch composition in miniature, real daemon);currentPathrepointing a requeue pass; materialize-by-rename. Docs: build-graph.md gains the watch section under caching; playback.md's follow-ups record the reload op; watch.md status → implemented with only thestatus-visibility question left open; the now.md watch line retires.Note
Medium Risk
Changes live playback and build output materialization (all cached builds get rename-based writes); behavior is well-tested with the daemon but affects the critical edit-while-listening path.
Overview
Completes watch mode chunk 2:
bloom play <patterns> --loop --watchrunswatchBuildbeside blocking playback. When the single looped label’s output hash moves, a native loop queuesreloadat the wrap (↻ swapped at the wrapviaonReloaded);--fromregion loops usecurrentPathso each pass loads the freshest file.--watchrequires--loop, one label, daemon ≥0.4, and refuses--clickfor now.Fixes a watch bug:
materializenow copy-to-temp + rename instead of copying in-place, so a looping daemon reader is not truncated under an open path (inode test added).Watch/CLI errors report
load/build/watchphase instead of generic “build failed”. Docs mark watch implemented;now.mddrops the watch line.Reviewed by Cursor Bugbot for commit 92f944b. Configure here.