Repository navigation
bloom play through the daemon: position streaming, --from, bloom transport - #13
Conversation
…sport Playback.md 4.2: bloom play now loads each built artifact into bloom-audiod, blocks streaming musical position (bar.beat.tick derived CLI-side from the played label's song - the daemon only ever hears samples), and moves through the queue on the transport's stopped event. Ctrl-c stops the daemon from a second connection and winds down the queue. --from <bar[.beat[.tick]]> projects through the tempo map to locate(samples) before play; --device selects the output. The bloom transport family (status/locate/play/pause/stop) reaches the same daemon from anywhere - status shows state, musical position, file, device, and whether the daemon is resampling. afplay is demoted to a fallback that announces itself when the daemon binary is missing. BLOOM_AUDIOD_NULL=1 forces null-output spawns for CI and deviceless machines. 11 new tests: pure position math, queue order and position streaming, --from locate bounds, steering a blocking play from a second connection, and clear errors (multi-target --from, transport with no daemon). Verified live: bloom play //songs/creek/mix:bed --from 3.1.1 through real speakers, then bloom transport status.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default 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 40091d2. Configure here.
A ctrl-c landing while load/status were in flight set the flag and sent stop - which hit a stopped transport, and the imminent play() restarted it, playing the item out in full. Now interrupted is checked immediately before play() (skip), and re-checked after it with our own stop() - the handler's stop may have been processed first across connections, so we close the ordering race from this side. Regression test pins the exact window: an interrupt during onItem (post-load, pre-play) ends the queue with zero position events and a stopped transport.
ninjudd
left a comment
There was a problem hiding this comment.
Reviewed at head b78f9b5 (local checkout matches; note Bugbot's review covered 40091d2 — the interrupt-window fix commit after it is covered by this review and by its own regression test). Typecheck clean, all 136 tests pass with the daemon tests running against the real binary, CI green. One P3, found by execution; everything else verified clean.
Executed verification against this head (real CLI, null-output daemon):
- The full §3.6 loop works from the terminal:
bloom playon a 30 s asset, then from a second shellbloom transport status→playing 2.3.713 (0:03.4)with the file named,transport locate 5.1.1→ jumped to(0:08.0), then SIGINT on the blocking play → it exited promptly, transportstopped, daemon still alive and answering. The signal path — which the tests only reach via theinterruptedhook — behaves correctly end to end. --from 1.2.1on a 2 s file started half a second in and exited 0;transport locatepast the file's end surfaces the daemon'slocate out of rangecleanly;transport statuswith a stopped daemon shows the loaded file at1.1.1.- A 12-item queue plays in order — and produces the P3 below on stderr.
Verified by reading, no issues found:
- The Bugbot interrupt fix is genuinely airtight: I walked all three interleavings of the SIGINT handler's
stop()againstplay()(flag-set before the pre-check; between pre-check and play; after play) — the both-sides check plus the post-play stop covers each one, and the new test pins the nastiest window (interrupt duringonItem, after load, before play). - The stale-
stopped-event hazard between queue items can't fire: the daemon's per-connection write mutex means a late transition broadcast is always written before the nextplayresponse, so it lands whilewaitForStopisn't attached yet — and the 500 ms status poll independently covers the unobserved-transition case (a file shorter than one heartbeat tick never emits events at all). - Musical time stays CLI-side exactly as §3.6 promised: the daemon sees only
locate(samples), and both derivations (label pkg for play, artifact path for transport,.bloom/out/included) are unit-tested. --frommulti-target rejection happens before connecting; afplay fallback announces itself and refuses--from/--device;transportnever spawns;BLOOM_AUDIOD_NULLcomposes with the explicit option via??so tests keep their explicitnullOutput: true.
Merging is Justin's checkpoint. With the P3 fixed (or deferred — it's cosmetic), the phase's definition of done is met from my side: bloom build && bloom play through Core Audio, steerable from anywhere.
waitForStop leaked one once('close') listener per item - a twelve-item
queue (an easy assets:all) played correctly but tripped
MaxListenersExceededWarning. finish() now removes it alongside the event
listener. Regression test plays a 12-item queue under a process warning
listener and requires silence.

Chunk 2 of playback.md §4 — the handoff.
bloom build && bloom playnow auditions the mix through Core Audio viabloom-audiod, which is the phase's definition of done.What this adds
bloom playgoes through the daemon — loads each built artifact over the socket, blocks while streaming position (a TTY gets a live13.1.1 (0:32.5)line at 4 Hz), and advances the queue on the transport'sstoppedevent. Ctrl-c stops the daemon from a second connection and winds the queue down — the blocking client just sees the state change, which is the multi-client design doing its job.--from <bar[.beat[.tick]]>— musical time projected through the played label's song tempo map CLI-side; the daemon receiveslocate(samples)and never learns what a bar is (§3.6's boundary held). Single-target only, by validation.--device <name>— select the output for the daemon's lifetime.bloom transport status|locate|play|pause|stop— reaches the running daemon from anywhere;statusshows state, musical position (song derived from the loaded artifact's path), file, device, and a resampling note. Never spawns: transport on a dead daemon is a clear error.--from/--devicerefuse politely there.BLOOM_AUDIOD_NULL=1— forces null-output spawns so CI (and deviceless machines) run the full play path.Verified
--fromlower-bounds every observed position event, steering a blocking play from a second connection (status → locate → stop → the play returns), and both error paths.bloom play //songs/creek/mix:bed --from 3.1.1— cached build, pad from bar 3 through the speakers, natural end, thenbloom transport statusreportingstopped 1.1.1with file and device.Remaining for the phase: field README examples and the afplay retirement decision once this has soaked.
Note
Medium Risk
Changes the primary playback path and adds multi-client transport control; risk is bounded by afplay fallback, clear errors when the daemon is missing, and extensive integration tests against the real daemon.
Overview
bloom playnow auditions built artifacts throughbloom-audiodwhen the native binary exists: blocking queue playback, live position on a TTY, and Ctrl-C stopping transport via a second socket connection.--fromand--deviceare supported on that path; musical bar.beat.tick is converted to samples in the CLI (song tempo map) and the daemon only getslocate(samples). Without a built daemon,afplayremains a fallback and refuses those flags.Adds
bloom transportsubcommands (status,locate,play,pause,stop) that connect to an already-running daemon (no spawn).BLOOM_AUDIOD_NULL=1forces null-output when spawning for CI/deviceless runs. New tests cover position math, daemon queue/--from, and steering play from a second connection.Reviewed by Cursor Bugbot for commit 40091d2. Configure here.