Skip to content

Project core scaffold: schemas, time math, deterministic YAML, first CLI commands - #4

Merged
ninjudd merged 2 commits into
mainfrom
feat/project-scaffold
Aug 5, 2026
Merged

ninjudd merged 2 commits into
mainfrom
feat/project-scaffold

Conversation

@ninjudd

@ninjudd ninjudd commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

First code PR — chunk 1 of project-core §1. Pure TypeScript, no audio code.

What's here

  • Package scaffold per §5: Node 24 (.nvmrc), pnpm, ESM-only, strict TypeScript (exactOptionalPropertyTypes, noUncheckedIndexedAccess), commander, zod v4, vitest. Single package at repo root.
  • Schemas (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 with slip separate from source_offset and effective read offset = source_offset − slip (§3.2), takes storing both time representations under a declared anchor (§3.1). Each schema is paired with the KeyOrder driving canonical emission.
  • Time math (src/time/tempo.ts): integer ticks at 960 PPQ; TempoMap with constant segments and closed-form linear ramps (ticks ↔ seconds ↔ samples); MeterMap projecting 1-based bar.beat.tick for display/CLI, with bar-boundary validation of meter changes (§3.1).
  • Deterministic YAML (src/yaml/emit.ts): canonical key order, 2-space block style, no aliases, trailing newline. fmt reorders the parsed document rather than re-emitting from data, so comments survive (§3.6) — covered by tests.
  • CLI: bloom init (project layout, .gitattributes with LFS patterns, git init + git lfs install best-effort), song create, track create, check (schemas, identity rules, tempo/meter validity, clip/take references, canonical formatting), fmt, status.
  • Tests: 29 across tempo math, emission/comment preservation, and an init → create → corrupt → check → fmt integration cycle. CI runs typecheck + tests on macos-latest.

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 create writes default 120 BPM 4/4 tempo.yaml; init defaults to 48 kHz (--sample-rate for 96k).
  • Clip asset is a song-relative path for now; it becomes a content-hash reference when the asset store lands.
  • git-lfs isn't installed on this machine — bloom init warns and proceeds; worth a brew install git-lfs before 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 + test on macOS).

Schemas (Zod v4) cover bloom.yaml, songs, tempo/meter, arrangement, tracks, clips, and takes, with slug identity, clip window/content (slip vs source_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), and MeterMap for bar.beat.tick display with bar-boundary meter changes.

Deterministic YAML canonicalizes key order via parsed documents so bloom fmt preserves comments; bloom check also enforces canonical formatting.

CLI commands: init (layout, .gitignore, LFS-oriented .gitattributes, optional git init / git lfs install), song create, track create, check, fmt, and status. 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.

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

@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 5 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 3b1a56d. Configure here.

Comment thread src/model/project.ts Resolved
Comment thread src/model/project.ts Resolved
Comment thread src/commands/create.ts Resolved
Comment thread src/model/project.ts Resolved
Comment thread package.json 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 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:

  1. P2 — fmt picks the wrong KeyOrder by filename suffix, so check/fmt disagree forever on a track named song (or any name ending in song/tempo/arrangement). Inline comment with repro on src/commands/fmt.ts.
  2. P2 — the take position/position_samples consistency check promised by §3.1 ("the derived one is verified by bloom check, so they can never disagree") is not implemented; contradictory values pass check. Inline on src/model/project.ts.
  3. P3 — take identity rules unenforced: id ≠ filename and track ≠ containing takes/<track>/ directory both pass check. Inline on src/model/project.ts.
  4. P3 — hand-written YAML anchors/aliases survive canonicalText unchanged and pass check, contrary to §3.6 "no anchors/aliases". Inline on src/yaml/emit.ts.
  5. P3 — pnpm typecheck never sees the test files (tsconfig.json excludes src/**/*.test.ts, and vitest transpiles without typechecking), so a type error in a test can't fail CI. Inline on tsconfig.json.

Not merging per project convention — that's Justin's checkpoint.

Comment thread src/commands/fmt.ts Resolved
Comment thread src/model/project.ts Resolved
Comment thread src/model/project.ts Resolved
Comment thread src/yaml/emit.ts Resolved
Comment thread tsconfig.json Resolved
ninjudd added a commit that referenced this pull request Aug 5, 2026
- 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).
@ninjudd
ninjudd force-pushed the feat/project-scaffold branch from b975671 to 5516e1f Compare August 5, 2026 05:06

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

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.yaml now formats with trackOrder (name first) and check passes afterward; a second fmt is a no-op. Carrying the KeyOrder on LoadedFile also let fmt and unformattedFiles collapse onto one allFiles walk — nice reduction.
  • §3.1 take verification: position_samples: 999999 at 120 BPM/48 kHz now yields position_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 … and track "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: createSong re-runs cleanly after a simulated crash between tempo.yaml and song.yaml (regression test covers it); absolute and project-escaping asset paths are rejected; prepare populates dist/ 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:

  1. The test titled "flags id ≠ filename and track ≠ containing directory (§6)" only asserts the filename half; the must match containing directory diagnostic is emitted (verified) but has no assertion.
  2. The anchor: absolute branch 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.

@ninjudd
ninjudd merged commit 384fc8e into main Aug 5, 2026
1 check passed
ninjudd added a commit that referenced this pull request Aug 5, 2026
…#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 -->
@ninjudd
ninjudd deleted the feat/project-scaffold 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