Repository navigation
Project core scaffold: schemas, time math, deterministic YAML, first CLI commands - #4
Conversation
…CLI commands TypeScript package (Node 24, pnpm, ESM, strict) with the first slice of project-core (project-core.md §1): - Zod v4 schemas for bloom.yaml, song, tempo/meter, arrangement, tracks, clips, and takes, each paired with the KeyOrder used for canonical emission (§3.6) - TempoMap/MeterMap: integer ticks at 960 PPQ, closed-form linear ramps, 1-based bar.beat.tick projection and parsing (§3.1) - Deterministic YAML: canonical key order, 2-space block style; fmt reorders the parsed document so comments survive programmatic edits - bloom init / song create / track create / check / fmt / status; check validates schemas, identity rules (track name = filename, §6), tempo and meter maps, clip/take references, and canonical formatting - 29 vitest tests; CI on macos-latest (typecheck + tests)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 5 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 3b1a56d. Configure here.
ninjudd
left a comment
There was a problem hiding this comment.
Reviewed at head 3b1a56d (local checkout matches the PR head). Verified locally on Node 24: pnpm typecheck clean, all 29 tests pass; CI is green. I also re-derived the ramp math — the closed forms in segmentSeconds/segmentTicksAt ((60/k)·ln((b0+kB)/b0) and its inverse) are correct, and the k=0 / equal-bpm / final-segment edges are all handled. Schemas match the §3 decisions, and comment preservation through fmt works as advertised.
Five findings, each verified with a runnable repro against this head — none block the happy path, but the first two are worth fixing before the next chunk builds on them:
- P2 —
fmtpicks the wrongKeyOrderby filename suffix, socheck/fmtdisagree forever on a track namedsong(or any name ending insong/tempo/arrangement). Inline comment with repro onsrc/commands/fmt.ts. - P2 — the take
position/position_samplesconsistency check promised by §3.1 ("the derived one is verified bybloom check, so they can never disagree") is not implemented; contradictory values passcheck. Inline onsrc/model/project.ts. - P3 — take identity rules unenforced:
id≠ filename andtrack≠ containingtakes/<track>/directory both passcheck. Inline onsrc/model/project.ts. - P3 — hand-written YAML anchors/aliases survive
canonicalTextunchanged and passcheck, contrary to §3.6 "no anchors/aliases". Inline onsrc/yaml/emit.ts. - P3 —
pnpm typechecknever sees the test files (tsconfig.jsonexcludessrc/**/*.test.ts, and vitest transpiles without typechecking), so a type error in a test can't fail CI. Inline ontsconfig.json.
Not merging per project convention — that's Justin's checkpoint.
- fmt: KeyOrder now travels on LoadedFile from the loader; the filename- suffix heuristic is gone, so a track named song/tempo/arrangement formats correctly (regression test asserts the exact output) - check: takes now verify the derived time representation against the tempo map per §3.1 (exact match for musical anchors, ±1 tick for absolute), and enforce id = filename and track = containing directory - check: asset references must be relative and resolve inside the project root; anchors and aliases in any project file are diagnostics per §3.6 - song create: tempo.yaml is written before song.yaml so the existence marker is written last and a partial failure is re-runnable - typecheck now covers test files (tsconfig.json is noEmit over all of src/; tsconfig.build.json excludes tests and emits); CI runs build, and prepare builds dist/ for installs 37 tests passing (8 new).
- fmt: KeyOrder now travels on LoadedFile from the loader; the filename- suffix heuristic is gone, so a track named song/tempo/arrangement formats correctly (regression test asserts the exact output) - check: takes now verify the derived time representation against the tempo map per §3.1 (exact match for musical anchors, ±1 tick for absolute), and enforce id = filename and track = containing directory - check: asset references must be relative and resolve inside the project root; anchors and aliases in any project file are diagnostics per §3.6 - song create: tempo.yaml is written before song.yaml so the existence marker is written last and a partial failure is re-runnable - typecheck now covers test files (tsconfig.json is noEmit over all of src/; tsconfig.build.json excludes tests and emits); CI runs build, and prepare builds dist/ for installs 37 tests passing (8 new).
b975671 to
5516e1f
Compare
ninjudd
left a comment
There was a problem hiding this comment.
Fresh review of 5516e1f (local checkout matches the PR head; single fix commit on top of 3b1a56d, history clean, dist/ untracked). Verified locally on Node 24: pnpm typecheck (now covering test files), pnpm build, and all 37 tests pass; CI is green; all 10 review threads re-fetched and isResolved: true.
I re-ran my original repro scripts against this head — every finding is genuinely fixed, not just tested around:
- fmt/check livelock: a shuffled
tracks/song.yamlnow formats withtrackOrder(namefirst) andcheckpasses afterward; a secondfmtis a no-op. Carrying theKeyOrderonLoadedFilealso letfmtandunformattedFilescollapse onto oneallFileswalk — nice reduction. - §3.1 take verification:
position_samples: 999999at 120 BPM/48 kHz now yieldsposition_samples 999999 disagrees with tempo map (position 960 ticks = 24000 samples)— diagnostic names both values as promised. - Take identity: both halves fire (
id … must match filename …andtrack "guitar" must match containing directory "vox"). - Anchors/aliases: an anchored node anywhere is a load diagnostic; agreed that flagging beats silent stripping in
fmt— collapsing aliased values is a human edit. - Absolute-anchor tolerance (untested branch — I exercised it manually): exact and off-by-1-tick pass, off-by-10 is flagged with the right message. Correct.
- Bugbot's three:
createSongre-runs cleanly after a simulated crash betweentempo.yamlandsong.yaml(regression test covers it); absolute and project-escaping asset paths are rejected;preparepopulatesdist/on install and CI builds.
Two non-blocking test-coverage notes, recorded here rather than as threads so they don't re-gate the merge — fine to fold into the next chunk:
- The test titled "flags id ≠ filename and track ≠ containing directory (§6)" only asserts the filename half; the
must match containing directorydiagnostic is emitted (verified) but has no assertion. - The
anchor: absolutebranch of the §3.1 check has no test — my manual run confirms it behaves, but a regression could land unnoticed. A three-case test (exact / ±1 / off-by-N) would pin it.
Nothing else found: checkAsset's containment logic, the hasAnchorsOrAliases visitor (including anchors on keys), and the tsconfig split all read correctly. Ready for Justin's merge.
…#5) Chunk 2 of [project-core](docs/projects/all/project-core.md) §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 #4: clip/take `asset` was a song-relative path, now an asset-name slug — flagged in #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). <!-- CURSOR_SUMMARY --> --- > [!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. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0c2c9f3. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->

First code PR — chunk 1 of project-core §1. Pure TypeScript, no audio code.
What's here
.nvmrc), pnpm, ESM-only, strict TypeScript (exactOptionalPropertyTypes,noUncheckedIndexedAccess), commander, zod v4, vitest. Single package at repo root.src/schema/schemas.ts):bloom.yaml, song, tempo+meter, arrangement, track, clip, take — every §3 decision encoded: slug identity (§3.3/§6), clip window/content withslipseparate fromsource_offsetand effective read offset =source_offset − slip(§3.2), takes storing both time representations under a declaredanchor(§3.1). Each schema is paired with theKeyOrderdriving canonical emission.src/time/tempo.ts): integer ticks at 960 PPQ;TempoMapwith constant segments and closed-form linear ramps (ticks ↔ seconds ↔ samples);MeterMapprojecting 1-basedbar.beat.tickfor display/CLI, with bar-boundary validation of meter changes (§3.1).src/yaml/emit.ts): canonical key order, 2-space block style, no aliases, trailing newline.fmtreorders the parsed document rather than re-emitting from data, so comments survive (§3.6) — covered by tests.bloom init(project layout, .gitattributes with LFS patterns, git init +git lfs installbest-effort),song create,track create,check(schemas, identity rules, tempo/meter validity, clip/take references, canonical formatting),fmt,status.Not in this PR (next two chunks)
Content-addressed asset store +
bloom import, then the build graph (labels, hashing, cache,build/query/explain) with the copy/normalize rules.Notes for review
song createwrites default 120 BPM 4/4tempo.yaml;initdefaults to 48 kHz (--sample-ratefor 96k).assetis a song-relative path for now; it becomes a content-hash reference when the asset store lands.bloom initwarns and proceeds; worth abrew install git-lfsbefore real audio.Note
Medium Risk
Large foundational addition (schemas, validation, tempo math, and CLI surface) that will anchor later build and asset work; risk is mainly breadth and correctness of timeline/YAML semantics rather than production runtime impact.
Overview
Introduces the first Bloom TypeScript package and CLI: Node 24, pnpm, strict ESM TypeScript, Vitest, and GitHub Actions CI (
typecheck+teston macOS).Schemas (Zod v4) cover
bloom.yaml, songs, tempo/meter, arrangement, tracks, clips, and takes, with slug identity, clip window/content (slipvssource_offset), and musical/absolute anchors as designed in project-core.Time math adds 960 PPQ tick timelines,
TempoMap(constant tempo + linear ramps, ticks↔seconds↔samples), andMeterMapforbar.beat.tickdisplay with bar-boundary meter changes.Deterministic YAML canonicalizes key order via parsed documents so
bloom fmtpreserves comments;bloom checkalso enforces canonical formatting.CLI commands:
init(layout,.gitignore, LFS-oriented.gitattributes, optionalgit init/git lfs install),song create,track create,check,fmt, andstatus. Project loading validates schemas, identity rules, tempo/meter, and clip/take asset paths.Docs update project-core status to in progress for this chunk. Not included: content-addressed asset store,
bloom import, and the build graph (build/query/explain).Reviewed by Cursor Bugbot for commit 3b1a56d. Configure here.