[js] Add binding-neutral BiDi schema with cddl2ts-gated fidelity#17700
[js] Add binding-neutral BiDi schema with cddl2ts-gated fidelity#17700titusfortner wants to merge 7 commits into
Conversation
PR Summary by QodoAdd binding-neutral BiDi schema generator with cddl2ts fidelity gate Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
14 rules 1.
|
5a7fca3 to
5ae00f7
Compare
|
Code review by qodo was updated up to the latest commit 5ae00f7 |
|
Code review by qodo was updated up to the latest commit 421fc38 |
There was a problem hiding this comment.
Pull request overview
Adds a binding-neutral WebDriver BiDi schema artifact (commands/events/types) generated from shared CDDL AST/model data, plus Bazel wiring and tests that gate schema fidelity against cddl2ts to prevent silent field/type loss across bindings.
Changes:
- Introduces a BiDi AST normalizer and schema projector that emit a flat schema with referential-integrity + completeness validation.
- Extends the Bazel BiDi generation pipeline to produce a shared
*_schema.jsonartifact with cross-binding visibility. - Adds mocha tests, including a differential “oracle” check comparing the generated schema to
cddl2tsoutput.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| javascript/selenium-webdriver/project_bidi_schema.mjs | Projects normalized AST + model into a flat schema and validates it (integrity + completeness). |
| javascript/selenium-webdriver/project_bidi_schema_test.mjs | Unit tests for schema projection and validation helpers. |
| javascript/selenium-webdriver/private/generate_bidi.bzl | Adds schema-generation step to the Bazel BiDi pipeline and exposes schema to other bindings. |
| javascript/selenium-webdriver/normalize_bidi_ast.mjs | Normalizes raw CDDL AST into canonical forms (hoisted enums/records, flattened unions/composition). |
| javascript/selenium-webdriver/normalize_bidi_ast_test.mjs | Unit tests for AST normalizer transforms. |
| javascript/selenium-webdriver/BUILD.bazel | Adds project_bidi_schema_script and a mocha test target for schema tooling + fidelity gate. |
| javascript/selenium-webdriver/bidi_schema_diff_test.mjs | Differential test comparing generated schema to cddl2ts as an oracle. |
|
Code review by qodo was updated up to the latest commit 7c315df |
|
Shouldn't this be a draft until #17657 gets a 👍? |
|
@diemol #17657 is merged. Do you mean #17701? |
|
Yes, sorry. I meant that one. Thank you for clarifying. From that point of view, then we could move forward on this one. |
|
Working with this code to generate Ruby code surfaced several real projector type-loss bugs (LocalValue date/regexp arms, js-int/js-uint ranges, the ConsoleLogEntry composition drop) which are now fixed and gated at build time |
|
Code review by qodo was updated up to the latest commit 439dacd |
|
Code review by qodo was updated up to the latest commit 8bc4569 |
|
Pushed |
|
Code review by qodo was updated up to the latest commit 72a51dd |
72a51dd to
09f7fa7
Compare
|
Code review by qodo was updated up to the latest commit 09f7fa7 |
09f7fa7 to
a87d7b9
Compare
|
Code review by qodo was updated up to the latest commit a87d7b9 |
|
Code review by qodo was updated up to the latest commit eb5ef4f |
|
I think this is the right direction. Building a Java CDDL generator off of this is much better. Looks good to me. Once the bot comments are addressed, let's merge it. |
…es, alias-aware structural selectors, correlated/nullable gates
|
I did file an upstream bug as well: webdriverio/cddl#64 |
|
Code review by qodo was updated up to the latest commit 3154ca5 |
…ver dropped command/event params
|
Code review by qodo was updated up to the latest commit 8396f65 |
…nc schema vocabulary doc
|
Code review by qodo was updated up to the latest commit 1bf04e6 |
🔗 Related Issues
Builds on #17657 (shared BiDi CDDL ast/model artifacts).
💥 What does this PR do?
Generates a single, binding-neutral BiDi schema (commands + events + types) from the shared CDDL artifacts, so the non-JS bindings can create client generators that consume one explicit, normalized artifact instead of each re-deriving the native CDDL shapes from the raw AST.
That re-derivation is where the bindings currently diverge and silently drop data — inline string-literal enums, variant-union params, composed-in base-type fields, optional/nullable fields. The schema normalizes all of these once (hoists inline enums to named types, canonicalizes variant unions into self-contained records, flattens group composition, preserves wire names and nullability verbatim) and the generation step fails the build if anything is dropped or dangling.
It lands the artifact and its fidelity gate only; no binding consumes it yet.
🔧 Implementation Notes
(A | B) & commonintersection form, because the non-TS bindings can't express TS-style intersections cleanly. This duplicates common fields across variants but keeps each variant complete and the discriminator-conditional rule structural.{ synthetic: true, owner, label }—owneris the type the construct was lifted out of,labelthe member name within it — so a binding can keep the flat name or nest it (Owner::Label) without parsing the synthetic def name. Generation fails the build if a syntheticownerdoesn't resolve.bidi-ast.json/bidi-model.jsonare made package-private (dropping the cross-binding visibility added in [js] Expose BiDi CDDL ast and model as shared artifacts #17657), since the schema folds in the model and supersedes both for bindings. They remain internal inputs to the schema and to the existing JS generation. Nothing consumed the old visibility yet, so this changes a not-yet-used contract.🤖 AI assistance
💡 Additional Considerations
javascript/selenium-webdrivertojavascript/bidi-support, the additional wiring seemed out of scope for this PR🔄 Types of changes