You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two independent cleanups to the JavaScript BiDi CDDL→schema generation pipeline; the generated schema/TS output is unchanged.
Schema generation accepts multiple --cddl files and concatenates their parsed definitions
Aligns schema projection's handling of extensible records with what cddl2ts already does
🔧 Implementation Notes
Should never have needed to access //py/private:merge_cddl from JS generation code
Top-level CDDL productions are position-independent (refs resolve by name), so parsing each spec separately and concatenating equals parsing one merged file — no merge tool required.
js_run_binary rejects external/cross-package srcs, so each spec is staged into the package with copy_file first (same pattern the dfns/spec_html steps already use).
The cddl parser emits an unbounded bound as Infinity; only the AST's JSON round-trip coerces it to null. The old m === null check silently relied on that coercion — the fix accepts either, covered by a regression test that projects an Infinity AST directly.
🤖 AI assistance
No substantial AI assistance used
AI assisted (complete below)
Tool(s): Claude Code
What was generated: the build-pipeline refactor and the projector fix + its regression test
I reviewed all AI output and can explain the change
💡 Additional Considerations
Groundwork for a planned follow-up PR adding support for vendor-specific CDDL extensions
Parse multiple BiDi CDDL specs and fix schema projection
✨ Enhancement🐞 Bug fix🧪 Tests🕐 10-20 Minutes
AI Description
• Parses multiple BiDi CDDL specifications directly, removing the Python merge dependency.
• Stages external specifications for Bazel-compatible JavaScript generation.
• Handles raw Infinity bounds during extensible-record projection, with regression coverage.
Diagram
graph TD
A["CDDL Specs"] --> B["Staged Copies"] --> C["CDDL Parser"] --> D["Combined AST"] --> E["Model Builder"] --> H["TypeScript Output"]
D --> F["Schema Projector"] --> G["Schema Output"]
E --> F
D --> H
Loading
High-Level Assessment
The current approach is appropriate because top-level CDDL references resolve by name, making independently parsed and concatenated definitions equivalent to merged source text. Retaining a separate Python merge action would preserve unnecessary cross-language and private-package coupling, while direct external inputs are incompatible with js_run_binary; package-local staging is therefore the simplest compatible design.
Files changed (5) +50 / -70
Enhancement (1) +8 / -4
generate_bidi.mjsAccept and combine multiple CDDL inputs+8/-4
Accept and combine multiple CDDL inputs
• Allows repeated --cddl arguments and concatenates definitions from independently parsed specifications into one AST. Updates validation and usage text for the multi-input interface.
project_bidi_schema.mjsRecognize Infinity as an unbounded occurrence+14/-9
Recognize Infinity as an unbounded occurrence
• Adds a shared unbounded-occurrence check accepting both parser-native Infinity and JSON-coerced null. Extensible maps and structural spreads no longer depend on an AST JSON round trip for correct projection.
generate_bidi.bzlReplace CDDL merge action with staged parser inputs+16/-55
Replace CDDL merge action with staged parser inputs
• Removes the custom CDDL merge rule and Python merge-tool dependency. Copies each specification into the package and passes repeated --cddl arguments to the JavaScript generator.
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
B-buildIncludes scripting, bazel and CI integrationsC-nodejsJavaScript Bindings
2 participants
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.
🔗 Related Issues
💥 What does this PR do?
Two independent cleanups to the JavaScript BiDi CDDL→schema generation pipeline; the generated schema/TS output is unchanged.
--cddlfiles and concatenates their parsed definitions🔧 Implementation Notes
//py/private:merge_cddlfrom JS generation codejs_run_binaryrejects external/cross-package srcs, so each spec is staged into the package withcopy_filefirst (same pattern the dfns/spec_html steps already use).Infinity; only the AST's JSON round-trip coerces it tonull. The oldm === nullcheck silently relied on that coercion — the fix accepts either, covered by a regression test that projects anInfinityAST directly.🤖 AI assistance
💡 Additional Considerations
🔄 Types of changes