Repository navigation
feat(xhandler-wasm): generate the bindings' SUNAT answers from the schema - #613
Merged
Merged
Conversation
…hema
The answers of `parse` (CDR, fault, ticket, consult status) were untyped
`json!{}` in sender.rs and typed by hand in each binding, so a field added
in Rust, like the CDR's `document_description`, never reached Go, Python or
Java. They are now Rust types in answer.rs and part of the schema, and
codegen.py generates them into each binding's xsender package, like the
documents: a field is written down once, in Rust, and arrives with the next
release's sync PRs.
- answer.rs: the answers, typed; sender.rs builds them. The JSON doesn't
change: the conformance cases are byte for byte the same.
- codegen.py: two packages (xbuilder, xsender), externally tagged unions,
enum names from `x-enum-varnames`, the byte and uint16 formats, and
lenient answers that ignore fields a newer core adds.
- dist/models/<lang>/xsender/: the generated answers.
- docs/adrs/BINDINGS.md: the design and the rollout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 16, 2026
This was referenced Nov 16, 2026
Merged
Merged
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.
Why
A field added in Rust didn't reach the Go, Python and Java bindings. The SUNAT answers (CDR, fault, ticket, consult status) were untyped
json!{}insender.rsand were typed by hand in each binding. For example, #612 addeddocument_descriptionto the CDR, and none of the three bindings picked it up:What
The answers become part of the contract the bindings generate from, like the documents already are. A field is written down once, in Rust, and arrives in every binding with the next release's sync PRs.
xhandler-wasm/src/answer.rs: the answers as Rust types.sender.rsbuilds them, so it can't emit a field the schema lacks.examples/schema.rs: the schema root now includes the answers.codegen.py:xbuilder(documents) andxsender(answers)x-enum-varnames, and the byte and uint16 formatsdist/models/<lang>/xsender/: the generated answers. The existing paths don't change, so older binding Makefiles keep working.docs/adrs/BINDINGS.md: the design, the compatibility rules and the rollout.Verified
invokereturns, are byte for byte the same as on main. The JSON doesn't change.__str__).CDR.StatusCodeandFault.HTTPStatusbecome pointers.cargo fmt,cargo clippy(with and withoutschema) and the wasm build pass.Rollout (see the ADR)
document_description; Python's answers become lenient.dist/models/<lang>/xsender/and replaces its hand-written answers with the generated ones.Senior review
Two passes. The first found three should-fix items, all in the ADR:
It also listed codegen nits: package config in one place, the
__all__slot, a regex comment, and the shape ofsender.rs. All are applied. The second pass found nothing left.🤖 Generated with Claude Code