Generate @codama/visitors-core's identityVisitor and mergeVisitor from @codama/spec#1000
Merged
lorisleiva merged 1 commit intoJun 11, 2026
Conversation
This was referenced May 19, 2026
🦋 Changeset detectedLatest commit: e9a89fe The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
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 |
Member
Author
8831793 to
3070d95
Compare
0e8f1ee to
1d45ad2
Compare
3070d95 to
9614dc6
Compare
1d45ad2 to
70df4fa
Compare
9614dc6 to
c116317
Compare
70df4fa to
d197456
Compare
c116317 to
f473e96
Compare
d197456 to
82a8a16
Compare
f473e96 to
f81f5e5
Compare
82a8a16 to
03e7196
Compare
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.
03e7196 to
e9a89fe
Compare
This was referenced Jun 11, 2026
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.

Extends
@codama-internal/spec-generatorswith a third generator that produces theidentityVisitorandmergeVisitorof@codama/visitors-corefrom the encoded@codama/specdescription. Both functions previously lived as ~1100 lines of hand-writtenif (keys.includes('xxxNode'))dispatch and were a known drift hazard whenever the spec gained a node kind. The mechanical walk now lives underpackages/visitors-core/src/generated/;src/identityVisitor.tssurvives as a thin wrapper layering six semantic transforms viaextendVisitor(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 onconditionalValueNode, and the empty-dependsOncollapse onresolverValueNode);src/mergeVisitor.tsis gone — its export ships directly from the generated tree.A new generated
nodeTestPaths.tsplus a hand-writtentest/nodes/coverage.test.tsgate per-node fixture coverage: every spec-registered kind must have a matching fixture undertest/nodes/or the suite fails. Four previously-missing fixtures were added so the gate passes today.