Skip to content

feat: composes/includes primitive — build specs from building blocks (HAR-1174) - #4

Merged
zhiganov merged 2 commits into
mainfrom
composes-primitive
Jun 20, 2026
Merged

feat: composes/includes primitive — build specs from building blocks (HAR-1174)#4
zhiganov merged 2 commits into
mainfrom
composes-primitive

Conversation

@zhiganov

Copy link
Copy Markdown
Contributor

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> is id or id@version.
  • uses: <ref> (stage level, optional): a stage runs one of the composed sub-methods; the id must be listed in composes.

Checks

  • Format (validateSpec): ref well-formed, no self-compose, no duplicates, every stage uses is in composes.
  • Cross-spec (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).
  • Index: a consumer carries composes; each building block carries used_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 via REGISTRY_ROOT: a bad compose fails validate (exit 1), the fix passes.

Not in this PR

  • The runtime adapter (expanding a composed spec into a runnable template) is deferred, as noted in FORMAT.
  • No existing spec uses it yet; it unblocks decomposing the MosaicLab deliberation chain (HAR-1173) into ORID / clustering / 5L building blocks.

🤖 Generated with Claude Code

zhiganov and others added 2 commits June 20, 2026 11:30
…(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>
@zhiganov
zhiganov merged commit 5e2c928 into main Jun 20, 2026
1 check passed
@zhiganov
zhiganov deleted the composes-primitive branch June 20, 2026 09:49
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