Repository navigation
feat(api): Generate* wrappers and consistency runners for the remaining nine bindings - #385
Merged
Merged
Conversation
spec.proto declares ListMethod under BuiltinService, but every other RPC is registered under KclService regardless. Dart's listMethod() was the one place that followed neither: it called KclService.ListMethod, which the dispatcher does not know. The call did not raise — the dispatcher logs `unknown method name`, panics on a Rust background thread and returns an empty payload, which protobuf decodes into a default-valued message. So listMethod() silently reported "this core implements nothing" while printing a panic to stderr. Route it to BuiltinService.ListMethod, which is what the other 14 bindings already do. That silent failure is why the Dart and Julia tests wrapped the assertion in "if the list is non-empty". Both cores return the full 28-name table (verified against go/lib/darwin-arm64/libkcl.dylib and the vendored libkcl.jll), so the guard only ever hid a real regression. Assert the table unconditionally now; an empty result means the wrapper picked the wrong service name again, which is exactly what these pin down. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Peefy <xpf6677@163.com>
… 6 RPCs The checked-in descriptor table was stale relative to spec.proto, so any message added since it was written was simply absent — the Generate* Args/Result pairs among them. A caller reaching for one got a nil index rather than an error. Regenerated in full and added `make proto` so it does not drift again. `hack/generate_pb.lua` emits the bare descriptor blob, so the target re-prepends `hack/schema_header.lua` afterwards; the header is what documents where the file came from and how to rebuild it. Worth knowing before touching this file: the generator is not deterministic across runs — it emits messages in a different order each time — so a diff here is only meaningful if the header still matches. Also adds `make test`, which was missing. Signed-off-by: Peefy <xpf6677@163.com>
…ng bindings Brings the nine bindings #383 did not cover — c, cpp, dart, julia, lua, ruby, swift, wasm, zig — to the same shape as go/python/java/.NET/node: the five Generate* RPCs behind typed wrappers, and a runner over the shared goldens in tests/consistency/cases.json. Wrappers follow the dispatch contract the existing calls already use: encode the args, invoke libkcl.call, decode the reply, surface an `ERROR:`-prefixed payload as the language's own error type. Kotlin additionally gets FormatTestReport, which its DSL wrappers had no coverage for at all. The consistency runners drive the same 13 cases. The seven new_core cases skip on runtimes that predate them through the existing listMethod probe, so this lands green everywhere: 13 run dart, julia, zig prebuilt 28-RPC core 6 run c, cpp, lua, ruby, pinned kcl-api revs / stale kcl.wasm swift, wasm swift was separately verified at 13/13 by relinking against a core built from a newer kcl-api, so its skips are the pin and not the wrapper. Also fills the last two gaps against the reference shape: the facade (dart) and the plugin layer (ruby, wasm). Signed-off-by: Peefy <xpf6677@163.com>
…en changes Two gaps in the pipeline. hack/ast_diff.rb compares what each binding's AST decoder actually produces against a single golden, and reports disagreement across bindings. It had never run in CI, so a decoder could drift and nothing would notice until someone noticed. New ast-diff-test.yaml runs it on a ten-binding matrix; on the current tree it is 10 agreed, 0 disagreed, 0 vacuous. The other gap: every binding's workflow filtered pull requests on its own directory, so a change to tests/consistency/ or testdata/ast/ — the goldens the runners and the differ both read — would not trigger any of them. All fifteen now include tests/consistency/** in their path filters. The dart job needs the prebuilt core on its library path. Resolving it from go/lib/<platform>/ rather than checking it out separately, since that is where the repo already vendors it; the directory is linux-amd64, following the Go embed dirs rather than the Rust/NuGet target names. Signed-off-by: Peefy <xpf6677@163.com>
MethodArgs.parse documents `@raise [ArgumentError] when a payload is not JSON of the expected shape`, and handles the wrong-shape half of that by naming the offending payload. The malformed half fell straight through to JSON.parse, so it raised JSON::ParserError instead — a different type than the one documented — and surfaced the underlying parser's wording rather than anything a plugin author can act on: unexpected token 'not' at line 1 column 1 for a payload of `not json`, which neither echoes the payload nor says whether the positional or the keyword argument was at fault. Route both payloads through one helper so a parse failure is reported the same way a shape failure is. Signed-off-by: Peefy <xpf6677@163.com>
Peefy
force-pushed
the
feat/generate-rpc-parity-and-consistency
branch
from
October 5, 2026 06:00
e35812b to
4932199
Compare
… cores Five of these were found by CI on the platforms I could not test locally, and two of them contradict a comment the first commit got wrong. **The assumption that was wrong.** 8c9fceb rebuilt only darwin-arm64 and said so: "Other platforms keep skipping new-core cases until their prebuilt runtimes are refreshed." That is still true — the linux-amd64 runtime this repo ships does not implement BuiltinService.ListMethod at all. Asking it prints thread '<unnamed>' panicked at .../capi.rs:229:14: unknown method name : BuiltinService.ListMethod and returns an empty table. So the dart/julia/zig guards asserting a non-empty table passed on my machine and failed on every Linux leg. Each now asserts the one thing that holds whatever the core is — that the table never names KclService.ListMethod, which is what a regression to the wrong service would produce — and checks the rest only when there is a table to inspect. The residual gap is inherent: on a core with no ListMethod at all there is nothing in the reply to distinguish "too old" from "misrouted". **A lua test that had never run.** generate_openapi asserted `components.schemas.AppConfig`, but the runtime qualifies schema names with their package, so the key is `AppConfig___main__`. It passed locally because my rock predates the RPC and the case pends; CI builds from source and actually executed it. Match the prefix instead — the exact key is the core's naming policy, not this fixture's business. **ast-diff-test.yaml setup, four ways.** All four only ever ran on my machine: `maturin develop` with no virtualenv, `setup-swift` on a Linux runner (the limitation swift-test.yaml already documents), `setup-zig` with no version, and gh-actions-lua defaulting to 5.5 against a rockspec that requires < 5.5. Each now mirrors the working per-binding workflow; swift gets its own runner. Signed-off-by: Peefy <xpf6677@163.com>
The swift leg moved to macos-latest so setup-swift could provision it, but "Install protobuf" is unconditional and the runner has no apt: sudo: apt-get: command not found Guard it to Linux. Nothing on the swift leg needs protoc — the dump driver compiles the AST sources standalone with swiftc — and the Linux bindings that do are covered by this step or by arduino/setup-protoc. Signed-off-by: Peefy <xpf6677@163.com>
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.
Follow-up to #383, which covered go/python/java/.NET/node. This does the
other nine — c, cpp, dart, julia, lua, ruby, swift, wasm, zig — bringing
each to the same shape: the five
Generate*RPCs behind typed wrappers,and a runner over the shared goldens in
tests/consistency/cases.json.What it does
Wrappers. Each follows the dispatch contract the existing calls
already use: encode the args, invoke
libkcl.call, decode the reply,surface an
ERROR:-prefixed payload as the language's own error type.Kotlin additionally gets
FormatTestReport, which its DSL wrappers hadno coverage for at all.
Consistency runners. All nine drive the same 13 cases; the seven
new_coreones skip on a core that predates them, through the existinglistMethodprobe.How many of the 13 actually run
Worth being precise about, because the number is a property of the
core, not of the wrapper — and it varies by runner:
da01314or later842b02b), ruby (931e6a9), swiftkcl.wasmThe same binding therefore gets different coverage on different runners,
which is worth knowing before reading a 6/13 as a wrapper gap. swift was
separately verified at 13/13 by relinking against a newer core, so its
skips are the pin and not the wrapper.
Also fills the last two shape gaps: the facade (dart) and the plugin
layer (ruby, wasm).
Four bugs found along the way
dart dispatched
listMethodto the wrong service.spec.protodeclares that one RPC under
BuiltinService; the wrapper usedKclService.ListMethod. The dispatcher loggedunknown method name,panicked on a Rust background thread, and returned an empty payload,
which protobuf happily decoded into a default-valued message. It failed
silently, and several bindings had tests that tolerated that emptiness
and so could never have caught it.
The prebuilt cores disagree about whether
ListMethodexists at all.#383 rebuilt only darwin-arm64 and said so. On Linux the vendored runtime
does not implement the RPC:
So the dart/julia/zig guards asserting a non-empty table passed on my
machine and failed on every Linux leg. Each now asserts the one thing
that holds whatever the core is — that the table never names
KclService.ListMethod— and checks the rest only when there is a tableto inspect. The residual gap is inherent: on a core with no
ListMethodthere is nothing in the reply to tell "too old" from "misrouted".
lua's
schema.luahad drifted to 20 messages and 6 RPCs. Everymessage added since was simply absent, and a caller reaching for one got
a nil index rather than an error. Regenerated, with
make prototo keepit from drifting again.
ruby's
MethodArgs.parsedocuments@raise [ArgumentError]but letJSON::ParserErrorthrough, surfacing the parser's own wording —unexpected token 'not' at line 1 column 1for a payload ofnot json,which echoes none of the payload and does not say which of the two was at
fault.
A fifth turned up only in CI: lua's
generate_openapiassertedcomponents.schemas.AppConfig, but the runtime qualifies schema nameswith their package, so the key is
AppConfig___main__. It passed locallyonly because my rock predates the RPC and the case pends; CI builds from
source and actually executed it.
CI
hack/ast_diff.rbcompares what each binding's AST decoder actuallyproduces against a single golden and reports disagreement across
bindings. It had never run in CI. New
ast-diff-test.yamlruns it on aten-binding matrix — all ten green, and 10 agreed, 0 disagreed, 0
vacuous.
Every binding's workflow also filtered pull requests on its own
directory, so a change to
tests/consistency/ortestdata/ast/— thegoldens the runners and the differ both read — would not trigger any of
them. All fifteen now include
tests/consistency/**.Getting the new workflow green took four fixes that only a real runner
would have surfaced:
maturin developwith no virtualenv,setup-swifton Linux (a limitationswift-test.yamlalreadydocuments, so swift gets its own runner),
setup-zigwith no version,and gh-actions-lua defaulting to 5.5 against a rockspec requiring
< 5.5.Verification
Every binding, from the CI logs for this branch:
dotnet was not run locally — it is not installed here — but its
workflow and its AST-diff leg both pass in CI.
Non-vacuity was proven rather than assumed: tampering a manifest golden
makes the c and ruby runners fail, and the manifests restore
byte-identically afterwards.
License Compliancereportserror, but identically onmain— FOSSAfinds the same 3 issues on both, so this PR adds none.
Reviewer notes
lua/hack/schema_header.lua+make proto:hack/generate_pb.luaisnot deterministic across runs, so a diff in
schema.luais onlymeaningful if the header still matches.
fix(dart,julia),fix(lua)andfix(ruby)are pure bugfixes and reviewable independently of the feature work.
🤖 Generated with Claude Code