Repository navigation
Asset store: assets.yaml, bloom import, content verification in check - #5
Conversation
Each song's assets.yaml binds a readable asset name to its file, sha256, and size. Clips and takes now reference assets by name — human-edited files stay readable while the hash carries content identity. The sha256 equals the Git LFS OID for the same bytes (verified end to end against git lfs ls-files), so manifest, pointer, and future build cache share one identifier per project-core.md §3.5. - bloom import <file> --song <s> [--name <slug>]: copies into audio/, hashes, and appends to assets.yaml via the document API so comments survive - bloom check verifies asset content against recorded hashes (async pass, separate from loadProject so fmt/status stay cheap), plus reference validity and relative/inside-project file paths - init and song create write .gitkeep so empty structure survives clone 43 tests passing (6 new).
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 0c2c9f3. Configure here.
ninjudd
left a comment
There was a problem hiding this comment.
Reviewed at head 0c2c9f3 (local checkout matches). Verified on Node 24: typecheck clean, all 43 tests pass, CI green. The design point flagged for review — asset-by-name with the hash in assets.yaml — is right, and consistent with §6's philosophy: references stay readable and greppable, content identity lives in one place, and sha256 = LFS OID holds by construction (LFS OIDs are SHA-256 of content). The async split keeping hashing out of loadProject so fmt/status stay cheap is also the right shape.
Five findings, each confirmed by executing a repro against this head — one P2 (a crash) and four P3s. Inline comments on the relevant lines:
- P2 —
bloom checkcrashes with an unhandledEISDIRwhen an assetfilepoints at a directory; the same skip-condition gap also makes it hash files outside the project on escaping paths. Inline onsrc/model/project.ts. - P3 —
bloom importisn't re-runnable after a partial failure: the copied file is the guard and it's written first — the exact patterncreateSongwas just fixed for. Inline onsrc/commands/import.ts. - P3 — importing into an
assets.yamlthat reads{}corrupts it:addIncreates a map underassetsinstead of a sequence, import reports success, and the file then fails check. Inline onsrc/commands/import.ts. - P3 — the recorded
bytesfield is never verified by check; a hand-edit to it passes silently. Inline onsrc/schema/schemas.ts. - P3, pre-existing from #4, surfaced while testing this PR — §3.6 declares block style canonical, but flow-style YAML passes
checkuntouched:canonicalTextpreserves parsed flow flags, so key order is enforced and style is not. E.g.clips: [{id: intro-abc12, asset: x, position: 0, duration: 960}]round-trips as "canonical". Recording it here rather than as a thread since the fix lives insrc/yaml/emit.ts, outside this diff — clearingflowon maps/seqs duringorderNodewould enforce it (and would also have contained finding 3's flow-styled output). Fine to take as a follow-up chunk instead of in this PR.
Not merging per convention — Justin's checkpoint.
- resolveAssetFile is now the single source of truth for asset-path rules
(relative, inside root, exists, regular file); validate diagnoses with
it and verifyAssetHashes reads only what it accepts — directories get a
diagnostic instead of an EISDIR crash, and escaping paths are never
opened or hashed
- verifyAssetHashes checks recorded bytes before hashing, so truncation
and hand-edits get a clear size diagnostic
- import: the assets.yaml declaration is the existence marker (written
last); an on-disk file without a declaration is treated as the orphan
of a failed import and overwritten. A non-sequence assets value ({} or
null) is replaced with a sequence before addIn instead of corrupting
the file. Recorded paths always use forward slashes
- canonicalization now clears flow flags on non-empty collections, so
flow-style YAML formats to block style per §3.6 (empty collections keep
inline [] rendering) — the pre-existing gap noted in review, taken here
since the fix is small
- check CLI action wraps the await so any residual error is a message,
not an unhandled rejection
50 tests passing (7 new).
|
Finding 5 from the review body (flow style passing check, pre-existing from #4) is also fixed in 616e455 rather than deferred — |
ninjudd
left a comment
There was a problem hiding this comment.
Re-review of 616e455 (local checkout matches the head; typecheck clean, all 50 tests pass on Node 24, CI green, all 7 threads re-fetched and resolved). I re-ran every repro from the previous round against this head:
- EISDIR / escaping paths:
file: audionow yieldsasset "oops" file is not a regular file: audio, and an escaping path that exists gets exactly one diagnostic with no hash — the out-of-tree file is never opened. TheresolveAssetFilehelper is the right shape and the "can't drift" property is structural now. - Partial import: my exact crash-window repro now re-runs successfully and checks clean.
{}corruption: import now writes a proper block sequence and check passes.bytes: tampering yieldsasset "sized" is 11 bytes on disk but 999999 recorded, and the size-before-hash ordering gives truncation a clear message.- Flow style (re-verified cleanly this time — my earlier F repro was confounded because a coexisting diagnostic suppresses the
unformattedlist): a flow-styletempo.yamlwith no other problems is flagged unformatted,fmtconverts it to block, check then passes, and empty collections keep inline[]. Good call taking it in this PR.
One new finding — a regression introduced by the partial-import fix (P2, inline on src/commands/import.ts): the orphan test is by name, but an orphan is defined by its file. A declared entry whose file doesn't follow the name convention (legal per schema, passes check) gets its bytes silently overwritten by a later import that derives the same destination filename. Confirmed by execution — import reported success while destroying a declared asset's working-tree bytes. One-line fix; details and repro in the thread.
Everything else from the fix commit reads correctly: the CLI check catch, forward-slash recorded paths, and the size-first verification order. After the orphan-test fix this is mergeable from my side — merging is Justin's checkpoint as always.
The overwrite path for crash-window orphans now requires that no declared entry references the destination file — a declared asset whose file doesn't follow the name convention (legal, and one hand-rename away) can no longer be silently clobbered by a later import deriving the same filename. Reviewer's repro carried as a test: the second import errors, the original bytes survive, and check stays green.
ninjudd
left a comment
There was a problem hiding this comment.
Verified 50615a2 (local checkout matches; typecheck clean, all 51 tests pass on Node 24; CI green on this head; all threads resolved). The orphan-axis fix works: my original clobber repro is now blocked with audio/kick.wav already belongs to a declared asset in "opener", the original bytes survive, and the carried test asserts exactly that.
One residual gap, found while probing the fix's boundaries (P3 — the common case is closed, but the uncommon spelling reproduces the P2 outcome): the guard compares unnormalized strings, and check accepts non-normalized file spellings, so ./audio/kick.wav evades it. Confirmed by execution; inline comment with the repro and a one-line resolved-path fix. Small enough to fold into this PR or take as a follow-up — either way it shouldn't hold up the merge decision, which is Justin's.
resolveAssetFile accepts any relative spelling that resolves inside the project, so the declared-file guard must match by the same rules — ./audio/kick.wav no longer evades it. Reviewer's evasion repro carried as a test.
ninjudd
left a comment
There was a problem hiding this comment.
Verified the final head 49ddbca (local checkout matches): typecheck clean, all 52 tests pass on Node 24, CI green, all 9 threads resolved. Re-ran my ./-prefix evasion repro against this head — the resolved-path guard blocks it (audio/kick.wav already belongs to a declared asset) and the original bytes survive; the carried test asserts the same. The §7 deferral note is a good close-out: the normalization decision now lives in the plan (appended as a new section, so no references break) instead of a review thread, tied to the build-graph chunk where path→label normalization gets settled anyway. Nothing further from my side — PR #5 is ready for Justin's merge.
#6) Chunk 3 of 3 for [project-core](docs/projects/all/project-core.md) — the phase's §4 definition of done now runs end to end: ``` bloom init && bloom song create opener bloom import hello.wav --song opener --name hello # declare a normalize target in songs/opener/targets.yaml bloom build //songs/opener/targets:hello-96k # built → .bloom/out/…/hello-96k.wav bloom build //songs/opener/targets:hello-96k # cached (action-cache hit, nothing executed) bloom query 'deps(//songs/opener/targets:hello-96k)' bloom explain //songs/opener/targets:hello-96k # rule, inputs, action key, cache status ``` (afinfo confirms the materialized output really is 96 kHz / 24-bit.) ## Design, per the settled decisions - **Labels (§3.4)**: targets derive from the model by convention — entity files (`tracks/drums.yaml` → `//songs/creek/tracks:drums`) take their directory as package; collection files (`assets.yaml`, new `targets.yaml`) take dir + stem, so entries become `//songs/creek/assets:pad` / `//songs/creek/targets:pad-96k`. Grammar: `//pkg:name`, `//pkg:all`, `//pkg/...`, absolute-only. No BUILD files. - **Action cache (§3.5)**: CAS at `.bloom/cache/cas/<sha256>`, action index keyed by sha256 of canonical JSON `{rule, rule_version, inputs, parameters, project_sample_rate}`. The action entry is written last (crash window re-runs, never corrupts — the lesson from #5 applied from the start). Cache hits require CAS presence, so a wiped CAS re-runs cleanly. - **First rule**: `normalize` via afconvert, `rule_version: 1`, runner injectable so tests count executions. - **§7 deferral lands**: `validate` now requires asset `file` paths in normalized form, closing the `./audio/x.wav` spelling class entirely. - Rule targets declared in `songs/<song>/targets.yaml` — the seed of the future mix file, not a BUILD file: it declares *renders*, structure stays derived. ## Tests 64 passing (13 new): label grammar (incl. `//songs//creek` rejection), cache-hit/param-change/rebuild against a counting runner, wildcard expansion, invalid-project refusal, unmatched patterns, deps ordering, explain before/after build, and one real-afconvert integration test (CI is macos-latest, so afconvert exists there). ## Scope note `bloom test` and `bloom prepare` from the brief remain out of scope for project-core, as does building anything audible beyond format conversion — that's [mix-assembly](docs/projects/all/mix-assembly.md) after [sc-render](docs/projects/all/sc-render.md). With this PR, sc-render only has to add a build rule. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > New build pipeline writes cache artifacts and shells out to afconvert on macOS; invalid projects are blocked before build, but cache/CAS correctness affects reproducibility of outputs. > > **Overview** > Completes **project-core** chunk 3: a real dependency graph with caching and CLI surface, so later phases only add rules—not a build system. > > **Labels & graph** — `//pkg:name` grammar with `//pkg:all` and `//pkg/...` wildcards; assets and `targets.yaml` entries become graph nodes with asset→rule edges. **`bloom build`**, **`bloom query`** (patterns or `deps(...)`), and **`bloom explain`** refuse invalid projects (same gate as `bloom check`). > > **Action cache** — Outputs in `.bloom/cache/cas/<sha256>`; keys from canonical JSON of rule version, input hashes, parameters, and project sample rate. Hits materialize to `.bloom/out/...`; action index written last so partial crashes re-run safely. > > **Normalize rule** — First executable rule via `afconvert`, with injectable runner for tests. **`targets.yaml`** schema (discriminated `normalize` targets) plus validation for duplicate names and asset references. > > **Validation** — Asset `file` paths must be POSIX-normalized (closes deferred §7 tightening from #5). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b08f138. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->

Chunk 2 of project-core §1 (follows #4).
Design point worth reviewing
Clips and takes reference assets by name, not by hash or path: each song's
assets.yamlbindsname → file + sha256 + bytes. This keeps human-edited files readable (the §6 philosophy applied to asset references) while the hash carries content identity. The sha256 equals the Git LFS OID — verified end to end:bloom importrecorded60cb6bc7…for a test WAV andgit lfs ls-filesshows the same OID on the staged pointer. Manifest, LFS pointer, and the upcoming build cache share one identifier (§3.5).What's here
bloom import <file> --song <s> [--name <slug>]— copies into the song'saudio/, streams a sha256, appends toassets.yamlvia the yaml document API (comments in assets.yaml survive imports — tested)bloom checknow also verifies asset content against recorded hashes, as an async pass separate fromloadProjectsofmt/statusdon't pay for it; reference checks (clip/take → declared asset name) and file-path safety (relative, inside the project) moved toassets.yamlvalidationinit/song createwrite.gitkeep(the fix from the field session)assetwas a song-relative path, now an asset-name slug — flagged in Project core scaffold: schemas, time math, deterministic YAML, first CLI commands #4's PR body as coming with this chunkNotes
checkis O(asset bytes); fine at sample-project scale. If it gets slow, a mtime/size-keyed hash cache under.bloom/is the planned fix — deferred until it hurts.Note
Medium Risk
Changes referential integrity for clips/takes (breaking for projects that still use path-based asset fields) and adds content hashing on every check, which is correct but could become slow on large libraries without a future cache.
Overview
Adds the project-core asset store: per-song
assets.yamlmaps slug names tofile, sha256, and bytes, with SHA-256 aligned to Git LFS OIDs for a single content identity across manifest, LFS, and future cache.bloom importcopies audio intosongs/<song>/audio/, hashes the file, and appends toassets.yamlvia the YAML document API so comments survive re-imports. Clip and takeassetfields now reference those names (not paths), with validation for declared names, relative paths, and project-boundary safety.bloom checkis async and runsverifyAssetHashes(byte-level SHA-256 vs recorded hash) in addition to schema/reference checks;fmt/statusstill avoid full-file reads.initandsong createadd.gitkeepfiles so emptyshared/and songtracks//audio/directories survive clone. Docs inproject-model.mdandproject-core.mddescribe the name→hash model.Reviewed by Cursor Bugbot for commit 0c2c9f3. Configure here.