Repository navigation
Watch cleanup: honest build statuses, one source path, teardown evidence - #38
Conversation
The no-thread footnotes from the #34/#35/#37 reviews, each small enough that none justified its own PR and all of them together justify one. `bloom build` said `cached` about assets and chosen variants, which were never built at all — nothing was executed and nothing came out of the cache. Outcomes now carry `committed`, the print says `source`, and the three status words pad to a common width so the labels line up. The committed file path was computed in three places by two spellings (`assetFilePath` and an inline join) and was drifting apart by construction; `sourceFilePath` is now the one place, covering assets and generation labels alike. `withClick` returned a Playable whose 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 where it would have bitten. It re-hashes instead. Quitting a watch with a takeover pending left the frozen `└` looking like it was about to happen, when ctrl-c means it never will; teardown now says `<hash> built, never sounded (stopped before the wrap)`. A seeded baseline could 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 ending in .yaml (Emacs's `.#track.yaml`, a dangling symlink while a buffer is unsaved) were loaded as project files, so merely opening a track under --watch ended the rebuild with ENOENT. Tests: the `.bloom/` watch exclusion had nothing pinning it — the new one settles the watcher first, since "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). Also the committed/rule outcome flags, the click re-hash, the dotfile, and the three teardown cases.
ninjudd
left a comment
There was a problem hiding this comment.
Reviewed at head 1bfeb2b. CI test is SUCCESS, Bugbot posted no threads, pnpm typecheck exits 0 and 271/271 pass locally. Six footnotes turned into one coherent PR is the right call, and most of it I verified working live. Two P2s inline — one is the new hold path saying the opposite of what happened, the other is the dotfile fix stopping one file short.
The hold fixes a real error — A/B measured. I widened the window it exists for (a 6 s delay before client.load, the only change, applied to both trees) and edited the source 2 s into the session so the watcher's outcome lands before the first load.
At 85b4440 (main):
reload failed: audiod reload: nothing loaded
playing //songs/creek/sounds:long-96k─5ce5a1b727a4
[1] 1.1 … [2] 3.4 (no pending marker, no swap, edit lost for the session)
At 1bfeb2b:
playing //songs/creek/sounds:long-96k┬5ce5a1b727a4
[1] 1.1 └631dcc9db642
played //songs/creek/sounds:long-96k─5ce5a1b727a4
playing //songs/creek/sounds:long-96k─631dcc9db642
The error is gone and the edit lands. What it lands as is the inline P2.
The status column, verified across every label kind (scratch project with an asset, a generative sound with two committed variants, and rules):
source //songs/creek/assets:longtone → …/songs/creek/audio/longtone.wav
source //songs/creek/sounds:gen1-1 → …/songs/creek/audio/gen1/1.wav
source //songs/creek/sounds:gen1 → …/songs/creek/audio/gen1/2.wav
cached //songs/creek/sounds:long-96k → …/.bloom/out/songs/creek/sounds/long-96k.wav
built //songs/creek/sounds:pad-96k → …/.bloom/out/songs/creek/sounds/pad-96k.wav
The audition labels (gen1-1, gen1-2) and the chosen label (gen1 → variant 2) all read source, the rule outputs keep cached/built, and the three words line up. cached for a file nothing produced really was a claim about a cache that was never consulted, and committed on the outcome rather than a third state of cached keeps the two questions separate.
Teardown, verified live in the honest case — edit mid-pass, ctrl-c before the wrap:
[1] 7.3 └631dcc9db642
631dcc9db642 built, never sounded (stopped before the wrap)
Also re-verified, no issue: the --from requeue route still transitions exactly once with the successor's hash (#37 P2 stays fixed under the new hold); sourceFilePath throwing for rule nodes is safe because its one reachable caller routes rules to built.get(...).outputPath first, and the message names the label; the withClick re-hash and its test assert the invariant in both directions.
Three footnotes, no threads:
quiet()inwatch.test.tshas no give-up: if FSEvents keeps chattering, it spins until vitest's 20 s file timeout and the failure reads as a hung suite rather than a noisy watcher. A bounded version (for (let i = 0; i < 20; i++), then return) fails the assertion instead, which says what actually happened.bloom buildprints absolute output paths (→ /private/tmp/.../wproj38/.bloom/out/...), not the relative ones in the PR description —project.rootis absolute, sowherealways is. The new alignment buys a tidy left column that a full absolute path then swamps;relative(process.cwd(), o.outputPath)would let it show. Pre-existing from #35, not this diff.sha256FileSyncreading the whole file into memory is fine here —withClickalready doesreadWavon the same file synchronously, so it adds no new class of cost, and the comment says why async would ripple.
Two P2s from the #38 review. The hold added in 1bfeb2b labelled the first pass with a hash the file no longer had. A rule target's materialized path is stable, so when the rebuild lands before the session's first load, the load opens the successor's bytes — the takeover already happened, by the file landing. The block still opened on the pre-session snapshot, the held outcome was queued as though it were still coming, and the new teardown line then said the version that was audible the whole time had never sounded. `openingHash` correlates by path at release, which is the same correlation later passes have had since #37 and the first pass never got. The takeover is still released: when it is already what plays, the queue renders as nothing pending and the daemon's confirmation keeps the block open, so a raced load still ends on the right bytes. A chosen-variant repoint moves the path instead, and there the old variant really is what loaded — the snapshot stands. Reproduced deliberately (a widened load window in a throwaway copy of the repo, playing in the field clone). Before: playing //songs/creek/mix:main┬fa105f281f9b [1] 1.1 └620a257d713d played //songs/creek/mix:main─fa105f281f9b playing //songs/creek/mix:main─620a257d713d 620a257d713d was what sounded. After: one block, `playing …─620a257d713d`, no phantom `played` for a pass that rendered zero samples, no `never sounded` claim. The dotfile fix also stopped one file short: takenSongNames reads every sounds/*.yaml for the name-collision pre-flight, so a dangling `.#hum.yaml` threw ENOENT out of the function whose comment promises it never crashes — `bloom import` exited 1 with a lock file present. Same one-line filter. Both fixes are A/B'd by their tests: the openingHash pair and the composite display test fail on the old behaviour with the reviewer's exact symptom, and the import test fails with their exact ENOENT. Also: quiet() in the watch tests now gives up after 6 s, so a watcher that never settles reports a failed assertion instead of reading as a hung suite (#38 review footnote).
ninjudd
left a comment
There was a problem hiding this comment.
Re-reviewed at head 1016331. Both P2s are fixed, and I re-ran the exact sessions that produced them. CI test is SUCCESS, pnpm typecheck exits 0, 276/276 locally, both threads resolved.
P2 (first-pass hash) — fixed, verified on both routes. Same harness as before: 6 s delay before client.load, edit at t=2 s so the rebuild lands first.
--from route, the one that produced the inversion — same session, block and daemon side by side:
playing //songs/creek/sounds:long-96k─631dcc9db642 <- the block
5ce5a1b727a4 <- on disk before play starts
--- during pass 1 ---
file: .bloom/out/songs/creek/sounds/long-96k.wav
631dcc9db642 <- what that file hashes to, mid-pass
The header now names the version that is sounding. No ┬, and ctrl-c mid-pass produces no never sounded line — the claim that was exactly backwards is simply absent.
Native route: one continuous block on 631dcc9db642 running [1] 1.1 → [2] 3.4, with the phantom played //…─5ce5a1b727a4 [1] 1.1 gone.
Extracting openingHash was the better call than my inline version. A three-case pure function — landed-at-this-path, path-moved (the choose repoint), nothing-held — is a proposition you can state, and the repoint case is the one that would quietly rot if it lived inside the onItem closure.
On still sending the takeover when the paths match: agreed, and your reason is better than the one I'd have given. The path comparison answers what does this path hold now, which is not quite what did this reader open — a load already in flight when renameSync swaps the inode keeps the old bytes, and nothing but a real reload gets it back. I verified the cost is nil in the common case: it renders as nothing pending, the confirmation keeps the block open, and it can't disturb --from, since the requeue route never has a reloadClient at all and so never touches the locate the reload's setPosition(0) would have undone.
P2 (takenSongNames) — fixed, and the pre-flight still pre-flights. With .#hum.yaml in place at this head:
import tone.wav --name tone-f → imported tone-f (…) exit 0
import tone.wav --name hum → "hum" is already a sound (or an audition label) … exit 1
That second line is the check I most wanted: the filter skips the debris without blinding the collision test the function exists for. Testing it through importAsset rather than takenSongNames directly is right — the ENOENT escaped through the command, so that is where the regression belongs.
Also re-verified, unchanged: the teardown line still fires in the honest case (mid-pass edit, ctrl-c before the wrap → 631dcc9db642 built, never sounded (stopped before the wrap)), so narrowing it did not silence it. And quiet()'s 6 s deadline throws with the event count in the message, which is the difference between a diagnosis and a timeout.
Nothing further from me. Two follow-ups stay on the list where you put them: bounding the beat scheduler's prints by the loop length, and printing build paths relative to the project root — the second is a print-format change and does deserve its own PR, which is also why my footnote about the absolute paths was a footnote.
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.
…#39) Same syntax as `build`; the result lands on `~/Desktop` as a numbered version. Captured against a clone of field (`--to` a scratch directory, rewritten here to `~/Desktop`): ``` $ bloom export creek exported //songs/creek/mix:main → ~/Desktop/creek-mix-main-v1.wav # nudge the keys fader $ bloom export creek exported //songs/creek/mix:main → ~/Desktop/creek-mix-main-v2.wav # export again, having changed nothing $ bloom export creek current //songs/creek/mix:main → ~/Desktop/creek-mix-main-v2.wav # put the fader back where it was $ bloom export creek reverted //songs/creek/mix:main → ~/Desktop/creek-mix-main-v1.wav (v2 is newer and different) ``` `--to <dir>` sends them elsewhere. ### Why Outputs live under their content hash and materialize at `.bloom/out/<label>.wav`. That is the right address for the engine and a useless one in a Finder window or an email attachment — this is the one command whose product is *a file you take somewhere else*. ### Decisions worth reviewing **Versioned, never overwritten.** Finishing something and putting it somewhere is how people mark a version, and the previous one is often the only copy of a decision later undone. Numbering is `max + 1` over what is already there — a gap means someone threw that version away, and minting a second `-v2` would disagree with them. Nothing in the destination is ever removed or overwritten, including files this command did not write (pinned by a test that puts a hand-bounced `creek-sounds-pad-normalized-v1.wav` in the way and checks it survives byte-for-byte). **Re-exporting is a no-op, against every version — not just the newest.** The `reverted` line above is the case that motivates it: export v1, change something, export v2, change it back. Those bytes are v1 again; filing them as v3 buries that, and a silent no-op would leave the newest file on disk not being what you just built. So the result names the version the bytes *are* and the version that is still newest. **The long name, always.** `creek-mix-main` rather than `creek-main`. The short form reads better until a song has a track and a sound of the same name — legal (the one-namespace rule covers sounds and assets, the `source:` namespace) and the natural thing to do when a track plays one sound — and then two different files want one name. Disambiguating only on collision produced a name you could not predict without knowing the rest of the project. **It exports what `play` would play**, through `resolvePlayables`, so the two commands cannot drift on which file a label means — and committed sources (assets, chosen variants) export straight from the song with no special case. **Only the labels the patterns match.** A build prints its dependencies because they are work it did; they are means, not products, and `bloom export creek` scattering fifteen files across a Desktop would be a bug that reads like a feature. **A missing destination is an error, not a `mkdir`.** `--to ~/Desktps` is a typo, and creating it would bury the mistake under something that looks like success. ### Cost Searching every version costs a hash per candidate, so size is checked first — a stat, not a read; a mix that differs audibly usually differs in length. Same-size candidates are still hashed (a fader move keeps the length), and a test pins that the filter cannot end the search early by putting a same-size, different-content v2 in front of the real match. ### Tests 18: the naming, the version scan (gaps, other labels, other extensions, near-miss filenames), `homeRelative` (including that `/Users/justinx` is not `~x`), and the behaviours above end to end against a real built project — each with an explicit `--to` so no test can write to a real Desktop. `pnpm typecheck` exit 0, 282/282. Branched off `main`, so it is independent of #38.
…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 -->
…ot (#42) The two deferred footnotes from #37 and #38, both small and unrelated to each other but sharing a theme: printing things that are not true. ### The readout announced beats the file never reaches Beat prints are scheduled ahead of the audio, so a loop shorter than a beat left the print for beat 2 permanently pending — unfired only because each fresh anchor cleared its timer. An anchor arriving >50 ms late let a phantom `1.2` through. That is what made a #37 test flake on CI, and it was filed as a flake before it was understood. The load response already carries the file's length, so the scheduler takes it and declines to schedule any beat at or past it. A wrap is unaffected: it re-anchors and the next pass announces its own first beat, which a sub-beat loop must keep doing. **Tested directly rather than by waiting.** The daemon test that observes this can only wait and hope — the phantom appeared under load, not on demand — so `beatScheduler` is exported and driven with fake timers: - a bounded scheduler emits only `1.1` for a 0.2 s file; - an unbounded one emits `1.2` (the old behaviour, kept as contrast); - beats *inside* the file still print; - a file exactly one beat long does not announce the beat at its end; - a wrap still produces the next pass's `1.1`; - targets with no tempo map keep their seconds fallback, unbounded. The #37 test's assertion that `1.1` is the *only* line it can produce is now true by construction rather than by luck. Its comment said so explicitly ("the honest fix... is a scheduler change for another PR"); this is that PR, and the comment is updated. One note while writing those tests: my first wrap test asserted two announcements from two anchors at the *same* sample, and failed. That was the test being wrong — two anchors at one position are the same beat, and #37's dedupe is deliberately on movement, not text. The test now models a real wrap (a position moving backwards). ### `bloom build` printed absolute paths Same prefix on every line, saying nothing, while pushing the part that differs off the edge of a terminal — which also swamped the status alignment #38 added: ``` cached //songs/creek/tracks:pad → .bloom/out/songs/creek/tracks/pad.wav source //shared/assets:water → shared/samples/water.wav cached //songs/creek/mix:main → .bloom/out/songs/creek/mix/main.wav ``` A path outside the root stays absolute rather than being spelled in `../..`: the one case where the prefix carries information. I checked whether anything parses this output before changing it — no test asserts it and CI does not read it. `pnpm typecheck` exit 0, 310/310, and the build output above is a live run against a clone of field. 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** > CLI display and beat-scheduler timing logic only; no auth, persistence, or daemon protocol changes beyond using existing load sample count. > > **Overview** > **Beat readout** no longer announces beats past the loaded file’s end. `playThroughDaemon` passes `loaded.samples` into `beatScheduler`, which skips scheduling any beat whose sample position is at or beyond that bound—fixing phantom lines (e.g. `1.2` on sub-beat loops) that were timing-dependent flakes (#37). Wraps still re-anchor; tempo-less targets keep the seconds fallback without bounding. > > **`bloom build`** prints output paths via `projectRelative(root, path)` so lines show paths from the project root (better terminal alignment with the status column, #38). Paths outside the root stay absolute. > > **Tests:** new `beat-scheduler.test.ts` with fake timers; `projectRelative` unit tests; daemon sub-beat loop test now asserts only `1.1` appears. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6fe2358. 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.
The no-thread footnotes from the #34/#35/#37 reviews. Each was too small
to justify its own PR; together they justify one.
bloom buildclaimed cache hits that never happenedAssets and chosen variants printed
cached— but nothing executed andnothing came out of the cache; they are committed files the build only
pointed at. Outcomes now carry
committed, the print sayssource, andthe three status words pad to a common width so the labels line up:
(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 (
assetFilePathand aninline
join), which were drifting apart by construction.sourceFilePathcovers assets and generation labels alike.withClickleft a hash describing a different fileThe returned Playable's
pathpointed at the clicked copy whilesha256still described the source.--clickand--watchdon'tcompose 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, whenctrl-c means it never will. Verified live under a pty in a scratch
clone:
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 isunsaved. It ends in
.yaml, so the loader read it and threw ENOENT,which under
--watchmeant merely opening a track file ended therebuild.
Tests
The
.bloom/watch exclusion had nothing pinning it. The new testsettles 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.watchfilenames were never the problem.) Plus the committed/ruleoutcome flags, the click re-hash, the dotfile, and three teardown cases.
pnpm typecheckexit 0, 271/271 green, andbloom buildre-run againstthe 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
statusand is ascheduler behavior change, not cleanup.
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 --watchreload timing, and fewer watch false failures.Build reporting:
BuildOutcomeaddscommittedfor assets and chosen variants (nothing was executed or cache-hit).bloom buildprintssourceinstead ofcachedfor those labels, with padded status columns viabuildStatus.Paths and hashes: Committed file paths are unified in
sourceFilePath(replaces duplicated asset/generation path logic).withClicknow setssha256from 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) untilonItemopens the block, thentakeoverruns—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 inwatch.md).Watch stability: YAML discovery skips dot-prefixed files (e.g. Emacs
.#…yaml). Tests addquiet(), assert.bloom/writes do not retrigger watch, and cover committed outcomes, click re-hash, and teardown cases.Reviewed by Cursor Bugbot for commit 1bfeb2b. Configure here.