Skip to content

Generate @codama/visitors-core's identityVisitor and mergeVisitor from @codama/spec#1000

Open
lorisleiva wants to merge 1 commit into
05-12-regenerate_codama_nodes_constructors_from_codama_spec_from
05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_
Open

Generate @codama/visitors-core's identityVisitor and mergeVisitor from @codama/spec#1000
lorisleiva wants to merge 1 commit into
05-12-regenerate_codama_nodes_constructors_from_codama_spec_from
05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_

Conversation

@lorisleiva
Copy link
Copy Markdown
Member

Extends @codama-internal/spec-generators with a third generator that produces the identityVisitor and mergeVisitor of @codama/visitors-core from the encoded @codama/spec description. Both functions previously lived as ~1100 lines of hand-written if (keys.includes('xxxNode')) dispatch and were a known drift hazard whenever the spec gained a node kind. The mechanical walk now lives under packages/visitors-core/src/generated/; src/identityVisitor.ts survives as a thin wrapper layering six semantic transforms via extendVisitor (the empty-payload downgrades on enum struct/tuple variants, the empty-prefix/suffix bypass on hidden-prefix/suffix type nodes, the both-arms-absent null-collapse on conditionalValueNode, and the empty-dependsOn collapse on resolverValueNode); src/mergeVisitor.ts is gone — its export ships directly from the generated tree.

A new generated nodeTestPaths.ts plus a hand-written test/nodes/coverage.test.ts gate per-node fixture coverage: every spec-registered kind must have a matching fixture under test/nodes/ or the suite fails. Four previously-missing fixtures were added so the gate passes today.

…r` from `@codama/spec`

Extends `@codama-internal/spec-generators` with a third generator that produces the `identityVisitor` and `mergeVisitor` of `@codama/visitors-core` from the encoded `@codama/spec` description. Both functions previously lived as ~1100 lines of hand-written `if (keys.includes('xxxNode'))` dispatch and were a known drift hazard whenever the spec gained a node kind. The mechanical walk now lives under `packages/visitors-core/src/generated/`; `src/identityVisitor.ts` survives as a thin wrapper layering six semantic transforms via `extendVisitor` (the empty-payload downgrades on enum struct/tuple variants, the empty-prefix/suffix bypass on hidden-prefix/suffix type nodes, the both-arms-absent null-collapse on `conditionalValueNode`, and the empty-`dependsOn` collapse on `resolverValueNode`); `src/mergeVisitor.ts` is gone — its export ships directly from the generated tree.

A new generated `nodeTestPaths.ts` plus a hand-written `test/nodes/coverage.test.ts` gate per-node fixture coverage: every spec-registered kind must have a matching fixture under `test/nodes/` or the suite fails. Four previously-missing fixtures were added so the gate passes today.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

🦋 Changeset detected

Latest commit: 0e8f1ee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@codama/visitors-core Minor
@codama/cli Patch
@codama/dynamic-codecs Patch
@codama/dynamic-parsers Patch
@codama/renderers-core Patch
@codama/validators Minor
@codama/visitors Minor
codama Minor
@codama/dynamic-address-resolution Patch
@codama/dynamic-client Patch
@codama/nodes-from-anchor Patch
@codama/errors Minor
@codama/node-types Minor
@codama/nodes Minor
@codama/fragments Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Member Author

lorisleiva commented May 19, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@lorisleiva lorisleiva marked this pull request as ready for review May 19, 2026 12:41
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