Repository navigation
Build graph: labels, action cache, build/query/explain, normalize rule - #6
Conversation
The final project-core chunk. Targets derive from the project model by
convention (§3.4): assets.yaml entries are //songs/<song>/assets:<name>,
and a new songs/<song>/targets.yaml declares rule targets as
//songs/<song>/targets:<name>. Label grammar supports //pkg:name,
//pkg:all, and //pkg/... wildcards, absolute-only.
The action cache implements §3.5: outputs in .bloom/cache/cas/<sha256>,
an action index keyed by the hash of canonical JSON {rule, rule_version,
input hashes, parameters, project sample rate}, and the action entry
written last so a crash window re-runs rather than corrupts. Outputs
materialize under .bloom/out/<pkg>/<name>.wav for human ears.
First real rule: normalize (afconvert, sample-rate/bit-depth conversion),
with the runner injectable for tests. bloom build expands patterns and
builds in dependency order; bloom query handles patterns and deps();
bloom explain shows rule, inputs, parameters, action key, and cache
status. Also lands §7's deferred normalized-form requirement for asset
file paths.
64 tests passing (13 new). The §4 definition-of-done flow verified end to
end: build, cache hit on rebuild, rebuild on parameter change, honest
query/explain.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b08f138. Configure here.
ninjudd
left a comment
There was a problem hiding this comment.
Reviewed at head b08f138 (local checkout matches). Typecheck clean, all 64 tests pass on Node 24 including the real-afconvert integration test; CI's test job is green. The architecture is faithful to the settled decisions: labels derive from the model with no BUILD files (§3.4), the action key is canonical JSON of exactly the §3.5 tuple, the CAS write goes through tmp+rename with the action entry last (the #5 lesson applied), the runner injection makes cache behavior properly testable, and canonicalJson is genuinely deterministic. §7's normalization requirement landing here closes that thread, and the docs status update is accurate.
Four findings, each confirmed by executing a repro against this head — one P2 and three P3s, inline:
- P2 — the action cache can be silently poisoned: build keys actions by the declared input hash but feeds the rule the actual file bytes. A transient tamper before first build leaves a permanently wrong cache entry that survives restoring the file —
checkgoes green,buildreportscached,explainvouches for it. Inline onsrc/graph/build.ts. - P3 — a corrupt action entry (e.g. a crash mid-
writeFileSync, which is not atomic) crashes every subsequent build with a JSON parse error instead of re-running. Inline onsrc/graph/build.ts. - P3 — the everything-pattern spelling is inverted:
//...errors while///...works (and the test enshrines the latter). Inline onsrc/labels.ts. - P3 — an asset or target named
allpassescheckbut is shadowed by the:allwildcard: unaddressable individually, silently swept into package expansion. Inline onsrc/model/project.ts.
With the P2 fixed this completes the phase's §4 definition of done honestly — the whole point of explain is that its answers can be trusted, which is exactly what finding 1 breaks. Merging is Justin's checkpoint as always.
- build now verifies consumed input bytes against their declaration (size, then hash) before executing a rule, refusing with a pointer to bloom check on mismatch — the action key is the declared hash, so executing on disagreeing bytes would cache a poisoned output under the clean key - a corrupt action entry (crash mid-write) is a cache miss that removes itself and re-runs, not a wedged cache; entries are now written tmp+rename so they appear atomically - //... is the everything pattern; ///... is now an invalid package - "all" is reserved wherever a name becomes addressable: schema-level (assets, targets, tracks) plus early rejection in import and track create 67 tests passing (3 new, 2 extended).
ninjudd
left a comment
There was a problem hiding this comment.
Verified e4973d3 (local checkout matches; typecheck clean, all 67 tests pass on Node 24; CI test job green on this head; all 5 threads resolved). I re-ran every repro from the review against this head:
- Cache poisoning: closed in both variants — a different-size tamper is refused with the size message, a same-size tamper with the sha256 message, the counting runner stays at 0 executions (nothing poisoned), and the clean rebuild after restore produces the right bytes. Verifying only consumed inputs, only on the execute path, is exactly the right cost placement.
- Corrupt action entry: now a self-repairing miss — the truncated entry is removed, the rule re-runs once, and the rewritten entry serves a hit on the next build.
writeAction's tmp+rename makes the commit-message claim true this time. //...: works as the everything pattern;///...is now an invalid package, and the test asserts the correct spelling.allreserved: rejected at all three layers —import --name all,track create all, and a hand-writtenname: allin assets.yaml gets a schema diagnostic with the path. Owning the constant in the label-grammar module is the right dependency direction.
Nothing further from my side. With this, project-core's §4 definition of done stands honestly end to end — PR #6 and the phase are ready for Justin's merge.

Chunk 3 of 3 for project-core — the phase's §4 definition of done now runs end to end:
(afinfo confirms the materialized output really is 96 kHz / 24-bit.)
Design, per the settled decisions
tracks/drums.yaml→//songs/creek/tracks:drums) take their directory as package; collection files (assets.yaml, newtargets.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..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 Asset store: assets.yaml, bloom import, content verification in check #5 applied from the start). Cache hits require CAS presence, so a wiped CAS re-runs cleanly.normalizevia afconvert,rule_version: 1, runner injectable so tests count executions.validatenow requires assetfilepaths in normalized form, closing the./audio/x.wavspelling class entirely.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//creekrejection), 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 testandbloom preparefrom the brief remain out of scope for project-core, as does building anything audible beyond format conversion — that's mix-assembly after sc-render. With this PR, sc-render only has to add a build rule.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:namegrammar with//pkg:alland//pkg/...wildcards; assets andtargets.yamlentries become graph nodes with asset→rule edges.bloom build,bloom query(patterns ordeps(...)), andbloom explainrefuse invalid projects (same gate asbloom 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.yamlschema (discriminatednormalizetargets) plus validation for duplicate names and asset references.Validation — Asset
filepaths must be POSIX-normalized (closes deferred §7 tightening from #5).Reviewed by Cursor Bugbot for commit b08f138. Configure here.