Skip to content

Comments

Run kson-lib tests against Rust and Python bindings#327

Open
aochagavia wants to merge 4 commits intomainfrom
test-bindings
Open

Run kson-lib tests against Rust and Python bindings#327
aochagavia wants to merge 4 commits intomainfrom
test-bindings

Conversation

@aochagavia
Copy link
Collaborator

@aochagavia aochagavia commented Feb 21, 2026

See the individual commits (and their corresponding messages) for the implementation details. Note that the first one is merely a fix that I decided to pick up in this PR given it's so small.

Some remarks and questions:

  • Running these tests against the bindings already proved useful, because we found (and fixed) two bugs! Next steps are probably to grow the kson-lib test suite / migrate tests over from the core library.
  • @dmarcotte did the "KSON over HTTP" approach you suggested turn out like what you expected to see? We can iterate on the design if you think there is still room for improvement.
  • I'm wondering about the most effective way to help our future selves when the KSON API grows and the tests fail to compile. People will most likely be confused when adding functionality to Kson.kt breaks the tests (they break when the public API of lib-kson diverges from lib-kson-http). Also, people will not necessarily have an easy time updating the JSON schema (provided they remember at all) and the test HTTP servers provided by the bindings. I thought about leaving instructions in one of the readmes (including prompts that could fully automate the updates), but even that doesn't cut it IMO (there will still be confusion). Ideas appreciated!

We were accidentally converting the whole exception to a string, so the
final error was something along the lines of "IllegalArgumentException: <the actual error>".
This commit corrects that.
Since the `kson-lib` tests are written in Kotlin, we run them against
Python in an indirect way:

- We LLM-generated a JSON Schema based on the `kson-lib` API (with
  minimal manual tweaks).
- We LLM-generated a clone of `kson-lib`'s `Kson.kt` that internally
  sends POST requests to a server based on the JSON Schema (with minimal
  manual tweaks). We called it `kson-lib-http` and wrote a descriptive
  readme for it.
- We LLM-generated a Python server that receives requests and uses the
  bindings to handle them (with minimal manual tweaks).
- We created a `:lib-python:kson-lib-tests` project responsible for
  actually running the `kson-lib` tests against the Python server.

This setup is a bit convoluted, and I'm not sure I'd choose it for a
different project. However, next to it being useful for testing, it
doubles as an experiment to see how the KSON API could look like if we
were to expose it through a text-based API (currently JSON, in the
future... KSON!)
Here we follow the same approach used for testing the `lib-python`
bindings. There is some code duplication in `ServerExtension.kt`, but
I think we can tolerate that for now.

Here is what we did:

- We LLM-generated a Rust server that receives requests and uses the
  bindings to handle them (with minimal manual tweaks).
- We created a `:lib-rust:kson-lib-tests` project responsible for
  actually running the `kson-lib` tests against the Rust server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant