feat: composes/includes primitive — build specs from building blocks (HAR-1174) - #4
Merged
Conversation
…(HAR-1174) Adds composition to the method-spec format (v0.2): a spec may declare `composes: [id|id@version, ...]` and a stage may declare `uses: <ref>` to build on other specs as reusable blocks. - validateSpec: ref format, no self-compose, no duplicates, every stage `uses` is listed in `composes`. - composition.mjs: cross-spec existence, version-pin warnings, cycle detection (DFS); wired into the validate + build-index runners. - index: a consumer carries `composes`, each building block carries `used_by`. - FORMAT.md updated; 15 new tests (37 total); runner smoked via REGISTRY_ROOT. No existing spec composes yet; this unblocks decomposing the MosaicLab deliberation chain (HAR-1173) into ORID / clustering / 5L blocks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The vitest suite tested the tooling (validator, index-builder, composition checker) but CI only ran validate/check/guard against spec content, so a regression in the tooling logic could ship green. Gate the tests too. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements the composes/includes primitive (HAR-1174): the format feature that lets a method spec be built from other specs as reusable building blocks. Takes the format to v0.2.
How it works
composes: [<ref>, ...](spec level): building-block specs this one is built from; each<ref>isidorid@version.uses: <ref>(stage level, optional): a stage runs one of the composed sub-methods; the id must be listed incomposes.Checks
validateSpec): ref well-formed, no self-compose, no duplicates, every stageusesis incomposes.composition.mjs, wired into the validate + build-index runners): every composed id exists; a version-pin mismatch is a warning; the composition graph must be acyclic (a cycle is an error and the build refuses).composes; each building block carriesused_by(who composes it), so the catalog shows what builds on what.Tests
New
composition.test.mjs(parseRef + validateComposition: missing ref, cycle, version warning) plus added cases to the validate + buildIndex suites. 37/37 pass. Smoked the runner end-to-end viaREGISTRY_ROOT: a bad compose failsvalidate(exit 1), the fix passes.Not in this PR
🤖 Generated with Claude Code