Skip to content

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

Merged
lorisleiva merged 1 commit into
mainfrom
05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_
Jun 11, 2026
Merged

Generate @codama/visitors-core's identityVisitor and mergeVisitor from @codama/spec#1000
lorisleiva merged 1 commit into
mainfrom
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.

@changeset-bot

changeset-bot Bot commented May 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e9a89fe

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

This PR includes changesets to release 16 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/dynamic-instructions 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

@lorisleiva lorisleiva marked this pull request as ready for review May 19, 2026 12:41
@lorisleiva lorisleiva force-pushed the 05-12-regenerate_codama_nodes_constructors_from_codama_spec_ branch from 8831793 to 3070d95 Compare May 21, 2026 13:52
@lorisleiva lorisleiva force-pushed the 05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_ branch from 0e8f1ee to 1d45ad2 Compare May 21, 2026 13:52
@lorisleiva lorisleiva force-pushed the 05-12-regenerate_codama_nodes_constructors_from_codama_spec_ branch from 3070d95 to 9614dc6 Compare June 2, 2026 12:34
@lorisleiva lorisleiva force-pushed the 05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_ branch from 1d45ad2 to 70df4fa Compare June 2, 2026 12:34
@lorisleiva lorisleiva force-pushed the 05-12-regenerate_codama_nodes_constructors_from_codama_spec_ branch from 9614dc6 to c116317 Compare June 3, 2026 08:34
@lorisleiva lorisleiva force-pushed the 05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_ branch from 70df4fa to d197456 Compare June 3, 2026 08:34
@lorisleiva lorisleiva force-pushed the 05-12-regenerate_codama_nodes_constructors_from_codama_spec_ branch from c116317 to f473e96 Compare June 11, 2026 10:19
@lorisleiva lorisleiva force-pushed the 05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_ branch from d197456 to 82a8a16 Compare June 11, 2026 10:19
@lorisleiva lorisleiva force-pushed the 05-12-regenerate_codama_nodes_constructors_from_codama_spec_ branch from f473e96 to f81f5e5 Compare June 11, 2026 10:35
@lorisleiva lorisleiva force-pushed the 05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_ branch from 82a8a16 to 03e7196 Compare June 11, 2026 10:35
Base automatically changed from 05-12-regenerate_codama_nodes_constructors_from_codama_spec_ to main June 11, 2026 10:46
…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.
@lorisleiva lorisleiva force-pushed the 05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_ branch from 03e7196 to e9a89fe Compare June 11, 2026 10:48
@lorisleiva lorisleiva merged commit b1f6a75 into main Jun 11, 2026
5 checks passed
@lorisleiva lorisleiva deleted the 05-14-generate_codama_visitors-core_s_identityvisitor_and_mergevisitor_from_codama_spec_ branch June 11, 2026 10:54
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