Skip to content

Asset store: assets.yaml, bloom import, content verification in check - #5

Merged
ninjudd merged 5 commits into
mainfrom
feat/asset-store
Aug 5, 2026
Merged

ninjudd merged 5 commits into
mainfrom
feat/asset-store

Conversation

@ninjudd

@ninjudd ninjudd commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

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.yaml binds name → 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 import recorded 60cb6bc7… for a test WAV and git lfs ls-files shows 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's audio/, streams a sha256, appends to assets.yaml via the yaml document API (comments in assets.yaml survive imports — tested)
  • bloom check now also verifies asset content against recorded hashes, as an async pass separate from loadProject so fmt/status don't pay for it; reference checks (clip/take → declared asset name) and file-path safety (relative, inside the project) moved to assets.yaml validation
  • init/song create write .gitkeep (the fix from the field session)
  • Schema change from Project core scaffold: schemas, time math, deterministic YAML, first CLI commands #4: clip/take asset was 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 chunk

Notes

  • Hashing on every check is 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.
  • 43 tests passing (6 new: import round-trip, name derivation, duplicate rejection, comment preservation, tamper detection, undeclared-reference diagnostics).

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.yaml maps slug names to file, sha256, and bytes, with SHA-256 aligned to Git LFS OIDs for a single content identity across manifest, LFS, and future cache.

bloom import copies audio into songs/<song>/audio/, hashes the file, and appends to assets.yaml via the YAML document API so comments survive re-imports. Clip and take asset fields now reference those names (not paths), with validation for declared names, relative paths, and project-boundary safety.

bloom check is async and runs verifyAssetHashes (byte-level SHA-256 vs recorded hash) in addition to schema/reference checks; fmt/status still avoid full-file reads.

init and song create add .gitkeep files so empty shared/ and song tracks//audio/ directories survive clone. Docs in project-model.md and project-core.md describe the name→hash model.

Reviewed by Cursor Bugbot for commit 0c2c9f3. Configure here.

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

@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 high effort and found 3 potential issues.

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 0c2c9f3. Configure here.

Comment thread src/model/project.ts Resolved
Comment thread src/commands/import.ts Resolved
Comment thread src/commands/import.ts Resolved

@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 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:

  1. P2 — bloom check crashes with an unhandled EISDIR when an asset file points at a directory; the same skip-condition gap also makes it hash files outside the project on escaping paths. Inline on src/model/project.ts.
  2. P3 — bloom import isn't re-runnable after a partial failure: the copied file is the guard and it's written first — the exact pattern createSong was just fixed for. Inline on src/commands/import.ts.
  3. P3 — importing into an assets.yaml that reads {} corrupts it: addIn creates a map under assets instead of a sequence, import reports success, and the file then fails check. Inline on src/commands/import.ts.
  4. P3 — the recorded bytes field is never verified by check; a hand-edit to it passes silently. Inline on src/schema/schemas.ts.
  5. P3, pre-existing from #4, surfaced while testing this PR — §3.6 declares block style canonical, but flow-style YAML passes check untouched: canonicalText preserves 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 in src/yaml/emit.ts, outside this diff — clearing flow on maps/seqs during orderNode would 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.

Comment thread src/model/project.ts Resolved
Comment thread src/commands/import.ts Resolved
Comment thread src/commands/import.ts Resolved
Comment thread src/schema/schemas.ts Resolved
- 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).
@ninjudd

ninjudd commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Finding 5 from the review body (flow style passing check, pre-existing from #4) is also fixed in 616e455 rather than deferred — canonicalizeDocument now clears flow flags on non-empty collections, so clips: [{...}] formats to block style and check flags it until it does. Empty collections keep their inline [] rendering. Two emit tests cover both directions.

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

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: audio now yields asset "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. The resolveAssetFile helper 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 yields asset "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 unformatted list): a flow-style tempo.yaml with no other problems is flagged unformatted, fmt converts 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.

Comment thread src/commands/import.ts Resolved
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 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.

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.

Comment thread src/commands/import.ts Resolved
ninjudd added 2 commits August 4, 2026 22:41
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 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.

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.

@ninjudd
ninjudd merged commit 9ad79de into main Aug 5, 2026
1 check passed
ninjudd added a commit that referenced this pull request Aug 5, 2026
#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 -->
@ninjudd
ninjudd deleted the feat/asset-store branch September 28, 2026 04:10
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