Skip to content

bloom play through the daemon: position streaming, --from, bloom transport - #13

Merged
ninjudd merged 3 commits into
mainfrom
feat/play-daemon
Aug 5, 2026
Merged

ninjudd merged 3 commits into
mainfrom
feat/play-daemon

Conversation

@ninjudd

@ninjudd ninjudd commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Chunk 2 of playback.md §4 — the handoff. bloom build && bloom play now auditions the mix through Core Audio via bloom-audiod, which is the phase's definition of done.

What this adds

  • bloom play goes through the daemon — loads each built artifact over the socket, blocks while streaming position (a TTY gets a live 13.1.1 (0:32.5) line at 4 Hz), and advances the queue on the transport's stopped event. 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 receives locate(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; status shows 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.
  • afplay demoted to fallback — used only when the binary isn't built, announcing itself on stderr; --from/--device refuse politely there.
  • BLOOM_AUDIOD_NULL=1 — forces null-output spawns so CI (and deviceless machines) run the full play path.

Verified

  • 135 tests pass (11 new): pure position math (label/path → song, bar.beat.tick ↔ samples), queue order + position streaming against the real daemon, --from lower-bounds every observed position event, steering a blocking play from a second connection (status → locate → stop → the play returns), and both error paths.
  • Live on real hardware: bloom play //songs/creek/mix:bed --from 3.1.1 — cached build, pad from bar 3 through the speakers, natural end, then bloom transport status reporting stopped 1.1.1 with 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 play now auditions built artifacts through bloom-audiod when the native binary exists: blocking queue playback, live position on a TTY, and Ctrl-C stopping transport via a second socket connection. --from and --device are supported on that path; musical bar.beat.tick is converted to samples in the CLI (song tempo map) and the daemon only gets locate(samples). Without a built daemon, afplay remains a fallback and refuses those flags.

Adds bloom transport subcommands (status, locate, play, pause, stop) that connect to an already-running daemon (no spawn). BLOOM_AUDIOD_NULL=1 forces 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.

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

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

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

Comment thread src/commands/play.ts Resolved
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 ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 play on a 30 s asset, then from a second shell bloom 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, transport stopped, daemon still alive and answering. The signal path — which the tests only reach via the interrupted hook — behaves correctly end to end.
  • --from 1.2.1 on a 2 s file started half a second in and exited 0; transport locate past the file's end surfaces the daemon's locate out of range cleanly; transport status with a stopped daemon shows the loaded file at 1.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() against play() (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 during onItem, 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 next play response, so it lands while waitForStop isn'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.
  • --from multi-target rejection happens before connecting; afplay fallback announces itself and refuses --from/--device; transport never spawns; BLOOM_AUDIOD_NULL composes with the explicit option via ?? so tests keep their explicit nullOutput: 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.

Comment thread src/commands/play.ts Resolved
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.
@ninjudd
ninjudd merged commit ef1e81f into main Aug 5, 2026
1 check passed
@ninjudd
ninjudd deleted the feat/play-daemon branch September 28, 2026 04:11
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.

1 participant