Repository navigation
Add the ctypes Python binding over the core C ABI - #1
Merged
Merged
Conversation
The ukiryu package loads the ukiryu-ffi library with ctypes (UKIRYU_CDYLIB, then the packaged library, then the system loader, with every rejected candidate reported) and sends one JSON wire request per operation. Typed dataclasses cover tool resolve, build and execute, type, definition and profile validation, version extraction and ranges, exit-code meanings and shell formatting. Symbols, exact times, regexps, ordered maps, Floats and integers of any size cross without loss. The core is pinned as the ukiryu-rs submodule at the wire ABI commit 4827c94. CI builds that library on Linux, macOS and Windows and runs the tests, including the shared conformance corpus through the public API with pinned per-operation row counts, and records engine provenance.
Add lint_string, safe_load, load_model and model_to_yaml over the core's new lint and yaml wire operations, dispatch the lint.string, yaml.load, yaml.model_load and yaml.lutaml_roundtrip rows (215), and raise the dispatched total to 14139. The core submodule moves to f820559, the head of ukiryu/ukiryu-rs#82, which adds those operations on top of #66.
The corpus test reads migrated.json, projection.json and emitter.json from the core checkout and judges the 27 lint and yaml rows they list by the same rules as the core: traced migrated expectations with frozen error detail, the Lutaml declared-field projection, and pinned Yeptris bytes plus canonical equality for the emitter rows. A new test checks the rules are traced, pinned and cover exactly those rows. UkiryuError gains detail, the structured facts the core attaches to some failures (category and stage for YAML reader errors). Pin ukiryu-rs to e6c4100 (#82), which adds the rule files and the safe_load error detail.
The pinned core now carries Yeptris 0.6.72 and the syntax_message adapter from ukiryu-rs#72, so the three schema rows match their frozen Psych messages. Its rule files drop the yaml-reader migrations the engine now matches, which leaves 25 R2 rows over the lint and yaml ops, and its .gitattributes keeps the emitter goldens byte-exact on Windows.
suleman-uzair
marked this pull request as ready for review
November 17, 2026 14:24
ukiryu-rs#82 merged as 1831ec9; move the submodule from its branch head 2ec6eea to the merge commit on main. Corpus data is unchanged between the two.
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.
This PR adds the
ukiryuPython binding as purectypesover the core's C ABI (ukiryu_abi_version,ukiryu_json,ukiryu_free). Each operation is one JSON wire request; all behaviour stays in the Rust core.Refs ukiryu/ukiryu#25 (part of ukiryu/ukiryu#29). Packaging, wheels and installed-wheel tests are a separate change.
Core pin
The
ukiryu-rssubmodule is pinned to1831ec960f5c992ab6ed28dc28a9ee08410458ebon ukiryu-rsmain, the merge commit of ukiryu/ukiryu-rs#82 (thelintandyamlwire operations and the R2 rule files, on top of #66 wire ABI and #72's Yeptris 0.6.72 pin and syntax-message adapter). It is not a released crate.Changes
_ffi.py: loads the library fromUKIRYU_CDYLIB, then the packagedukiryu/lib/, then the system loader. An explicit or present candidate that fails is an error, never a silent fallback;LibraryLoadErrorlists every candidate and the reason. Replies are copied and released withukiryu_freeexactly once; the ABI version must be 1.api.py/models.py:Register,Tool(resolve,build,execute,exit_code_meaning),Shell, and the validate / schema / version functions, returning frozen dataclasses. Unknown or missing reply fields raiseProtocolError.executerequiresenvandtimeout; failures raiseUkiryuErrorwith the source class, message and the run's result.values.py: exact wire values: integers of any size, Floats (RubyFloat#to_stext),Symbol,Time(seconds, nanos, UTC offset),Regexp, orderedMap, and bytes.tests/: value codec, loader order and ownership, typed API, realexecuteruns, and the conformance corpus through the public API (manifest digests checked, 14139 rows across 17 ops pinned;resolve.shell_detectandcli.runare declared with counts and reasons).lint_string,safe_load,load_modelandmodel_to_yamlrun the lint and yaml rows.ci.yml: builds the pinned core on Ubuntu, macOS and Windows with Python 3.9 and 3.13, runs the tests, and uploads engine provenance (submodule commit,Cargo.lockand library digests, core version). No publish step.Corpus rules
The 25 lint and yaml rows that root ruling R2 covers are judged by the core's own rule files (
migrated.json,projection.json,emitter.jsoninukiryu-rs/ukiryu/tests/conformance, from ukiryu/ukiryu-rs#49) with the same rules as the core: traced migrated expectations with frozen error detail, the Lutaml declared-field projection, and pinned Yeptris bytes plus canonical equality. A separate test checks those rules are traced, pinned and cover exactly these 25 rows.UkiryuErrorgainsdetailfor the structured facts the core attaches. The rule files' schema and shell detection migrations are not applied here.Earlier runs failed on three schema rows (
profiles-ghostscript-10-0,profiles-inkscape-1-0,synthetic.invalid-yaml) whose YAML error message differed from Psych's, and on Windows the emitter goldens were checked out with CRLF. The new pin fixes both: Yeptris 0.6.72 with the adapter gives Psych's message, and the core's.gitattributeskeeps the goldens byte-exact. The core also dropped the two yaml-reader migrations its engine now matches, so R2 covers 25 rows instead of 27.