Repository navigation
[kyo-sql] add the SQLite backend, and make engine neutrality checkable - #1945
Merged
Merged
Conversation
## Problem kyo-sql only talked to servers. PostgreSQL and MySQL are both network drivers on kyo-net, so every program needed a database process running somewhere: no file-backed or in-memory database, nothing that runs in a browser or ships inside a single binary, and a container for any test that wanted real SQL. Adding an embedded engine was not just a third driver. PostgreSQL and MySQL are alike in every way the abstraction cares about, so core had been shaped around their similarities without anyone deciding to, and the conformance battery could not tell real agreement between engines from two engines that merely resemble each other. ## Solution **`kyo-sql-sqlite`** is an embedded SQLite driver over the C library through kyo-ffi. A database is a file path or `:memory:`, with no server. It cross-builds for JVM, JS, Native and Wasm; in a browser it runs on the WebAssembly build. **`kyo-sql-sqlite-driver`** is that driver's connection, pool plumbing, codecs, row reader, dialect and URL parsing, plus the binding trait as declarations only: no C, no FFI plugin, no engine. The split exists because on Scala Native an FFI module's C is compiled INTO the binary, so any module depending on an engine module links that engine in. A second engine speaking the same `sqlite3_*` API therefore cannot depend on `kyo-sql-sqlite` without carrying the vendored `sqlite3.c` too, at which point the calls bind to whichever linked first. Depending on declarations carries no C. **kyo-ffi gained a second JS transport.** A generated JS impl asks `NativeFacade` for its dispatch table: koffi over a real shared library on Node, or a registered WebAssembly provider where there is neither, which is every browser. The choice is made by asking whether koffi can be loaded, not by sniffing for a browser, and `-Dkyo.ffi.js.transport=wasm` forces the WASM path so it runs under the same driver suites as the native one. ### What this changed in core SQLite is the first engine that is not a server, and four things in kyo-sql had assumed one: - `SqlConfig.Address` was a host and a port. It is now sealed over `Network` and `Local`, so neither kind of backend can be handed the other's coordinate. - Core parsed the URL and then looked up the backend, so it defined what a database URL looks like. The scheme is now resolved first, and `Backend.parseUrl` hands each backend the raw URL to parse itself. - A defaulted column was rendered by substituting a cell, which needs a `DEFAULT` keyword. `Idiom.overrideFor` is now `private[kyo]`, so a flavor without one can drop the column from the insert list instead. - `supportsGroupingSets` implied rollup. MySQL has rollup and no grouping sets, SQLite has neither, so `supportsRollup` is its own flag. `SqlJsonArray` also moves from `kyo-sql-mysql` into core. MySQL and SQLite both lack an array type and both map the three array kinds onto `JSON`, so one wire means a value written by either is read by either. ### Conformance Every suite now runs against three engines. Telling a real divergence from an accident needed the descriptors to say what an engine can do, so they gained seventeen members: isolation levels honoured and defaulted to, advisory locks, concurrent write transactions, JSON key order, case folding past ASCII, and others. A leaf reads a capability, never an engine name, and capabilities are used in complementary pairs, so an engine that lacks a feature asserts what it does instead of being skipped. An engine that cannot deliver an isolation level has to refuse it rather than quietly substitute a weaker one, which is the lost-update bug this suite exists to catch. `SqlBackendNeutralitySourceTest` enforces that mechanically: it scans the shared conformance source and fails on an engine name in a body, with the banned list derived from the registered descriptors, so a new backend joins the check by existing. ## Notes **This is the first of two.** A Dolt backend, its embedded DoltLite counterpart, and a `FileSystem` stored in a version-controlled database follow separately. DoltLite is the second engine the driver split above exists for: it keeps the `sqlite3_*` API over different storage, so it reuses this driver's connection, codecs and row reader with its own library. Nothing here depends on that landing. **SQLite is compiled from a pinned C source** rather than linked against a host `libsqlite3`, since several conformance answers depend on the version: `RETURNING` since 3.35.0, the `RIGHT`/`FULL JOIN` floor at 3.39.0. A current macOS ships 3.43.2 against the 3.53.4 pinned here. The source is fetched and checksummed by `kyo-sql-sqlite/scripts/build-sqlite.sh`, and the staged tree is a gitignored build artifact. Nothing is staged per os-arch: it is one architecture-independent `.c`, and the FFI plugin already compiles per platform. **`SqliteVfs` is a `SqlConfig` extension** rather than a config field, because it means nothing to any other engine. It is how a browser gets persistence: the WebAssembly build has no filesystem, so the default VFS keeps a database in memory and loses it at reload. **What this engine refuses.** It has no advisory locks and no configurable isolation, and both are reported as typed refusals naming what was asked rather than silently downgraded. That is the shape engine-specific API takes here: what SQLite has over the others is an absence of things, so `SqliteClient` adds no methods. **Verification.** PostgreSQL and MySQL run in containers, SQLite embedded. The module cross-builds for JVM, JS, Native and Wasm.
fwbrasil
force-pushed
the
kyo-sql-sqlite-backend
branch
from
September 17, 2026 01:00
1f22938 to
f3e8ba8
Compare
kyo-sql-sqlite's ffiLibraries hard-errors when build/sqlite/staged holds no C source, rather than compiling a stub, so a cold checkout cannot evaluate the setting at all. The setup action staged BoringSSL and libaeron and nothing else, so every leg touching that module would have failed. No os-arch mapping, unlike the other two: SQLite is one architecture-independent .c that the FFI plugin compiles per platform, so one staged tree serves every runner. Verified by parking the staged tree and reproducing the failure, then running the step's own command from cold: it fetches and stages a byte-identical source.
scripts/build.sh has the same gap the CI setup action had: it stages BoringSSL and Aeron behind their own flags and nothing for SQLite, so a podman run over a clean snapshot hits the same hard error. STAGE_SQLITE=1, opt-in like the other two because only a command touching kyo-sql-sqlite needs it. Lighter than they are: curl and unzip, no compiler.
CI runs JVM and JS on windows-x64 and windows-arm64, and the new staging step runs there too. Git Bash on those images carries neither unzip nor shasum reliably, and neither sibling staging script checksums, so there was no precedent to inherit. Checksum falls back shasum, sha256sum, openssl; extraction falls back unzip, bsdtar (the tar Windows 10+ ships, which reads zip), 7z. A missing tool is refused by name rather than left to produce an empty digest, which would have read as a corrupt download. The openssl-plus-bsdtar combination, which is what Git Bash actually provides, is exercised and stages a byte-identical source.
… core SqlJsonArray moved from this module into kyo-sql so MySQL and SQLite could share one wire. The move landed but its deletions did not, so the old MysqlJsonArray and its test shipped alongside the new shared copy: dead code that compiles cleanly, being a different name in a different package, and is therefore invisible to the build.
Scala Native copies declared C sources beside its own generated ones and compiles them there, so includeDirs never reaches that compile: a header the sources include has to be bundled through cHeaders as well. It still built on macOS, whose SDK ships a sqlite3.h that satisfied the include while the vendored sqlite3.c was linked, which is the header and implementation coming from different versions. Linux has no system copy and failed outright with 'sqlite3.h file not found'. Linux Native in a container goes from failing to compile to 131 passing.
The generated impl now asks NativeFacade for its dispatch table by library id, instead of calling KoffiFacade with a path NativeLoader resolved. The goldens still pinned the old shape. Regenerated rather than hand-edited, and the diff is only that: the import line, and KoffiFacade.load(NativeLoader.jsResolve(id), fns) becoming NativeFacade.load(id, fns), the same two changes in all eleven.
Registering SQLite as a battery backend put its leaves on every platform, but this module's Node legs had neither the library path nor koffi: only kyo-sql-sqlite's own module set them. Every SQLite leaf panicked on a null facade, reading as nine unrelated failures rather than one missing engine. kyoSqliteFfiEnvMap now takes the library target and the koffi target separately, the split kyoDoltLiteFfiEnvMap already makes for the same reason: the module that builds the library and the module that runs against it are not the same here. kyo-sql-testsWasm and kyo-sql-testsJS go from 636 passing with 10 failures to 830 passing with none.
windows-arm64 builds this library with cl, which exports only what is declared, so the DLL loaded and koffi found none of its functions: every leaf touching the engine panicked on a null facade. windows-x64 uses MinGW, whose ld auto-exports, which is why only one arch failed. The shim's entry points now carry KYO_SQLITE_API and sqlite3.c is compiled with -DSQLITE_API=__declspec(dllexport) on Windows, since most bindings call a sqlite3_* symbol directly. Same pattern and same reason as kyo_net_api.h and kyo_aeron.h, which this omitted. A second Windows failure came with it: the VFS suite named 'unix', which SQLite calls 'win32' there. The name is the operating system's rather than the Scala platform's, so it is now read from one, the way SqliteTempDatabase already splits. All four platforms still pass locally, 524 leaves.
agreeAcrossBackends failed whenever its where matched nothing, which made one side of every complementary pair red on a platform that reaches a single engine: JS and Wasm reach only the embedded one, so the leaf for engines whose default forbids an anomaly had no backend to run against. forEachBackend already draws this line, and the two now agree: no backend AT ALL is missing infrastructure and stays red, while a filter matching none of the backends that are here is the ordinary shape of a complementary pair. Cancelled rather than passed, so the report says the leaf did not run and why. Passing it silently would hide a filter that matches nothing because it is wrong, which is what the strict check was protecting.
Blank-line runs left where the Dolt module blocks were removed, and an end marker scalafmt wants on the guard added beside it.
ffiLibraries is a SETTING, so the sys.error this declared failed project LOAD rather than its own compile. Three workflows broke on it and none of them build C: checks runs scalafmt and the README doctests, release-probe runs the packaging probe, and both only need the build to load. kyo-aeron sets the invariant, staging the same way and erroring nowhere in its setting. An unstaged tree now surfaces at ffiCompile, where cc names the file it cannot find, which is where aeron's missing archive reports too. The staging steps added for CI and the container runner are still needed: they are what makes compilation work, rather than what makes the build load. Verified by parking the staged tree: the build loads and scalafmtCheckAll passes, which is what the checks job runs.
release-probe uses release-setup, a different action from the one the build legs use, and it runs ffiCompileAll, which compiles every module's shim. Its own comment names this failure: a module added without its staging step passes publishLocal and kills every producer. No os-arch argument, unlike BoringSSL and libaeron beside it: SQLite is one architecture-independent source the plugin compiles per platform, so one staged tree serves whichever runner the probe lands on. Verified by running the probe's own commands, ffiCompileAll and ffiPackagingFormatCheckAll, which pass.
checks runs sbt doctest, which compiles every FFI module's C: it already repeats the liburing and libaeron staging for exactly that reason, since it does not use .github/actions/setup. The engine needed the same. Reproduced by parking the staged tree, which fails ffiCompile the way CI did, and confirmed by restoring it: doctest passes with no errors. No os-arch argument, unlike libaeron beside it, since SQLite is one architecture-independent source the plugin compiles per platform.
fwbrasil
added a commit
that referenced
this pull request
Sep 18, 2026
## Problem A kyo SQL client reads and writes, but the database's history is not something it can address. Committing a change, branching to try one, diffing two points in time, merging a branch back: all of that lives outside SQL, in whatever process happens to own the data. Dolt gives data the git model, and ships in two shapes that share no structure: a server speaking the MySQL wire, and an embedded SQLite fork with no server at all. Reaching either from kyo meant hand-rolling procedure calls against an untyped result set, and a caller that wanted to work against both had no type to name. ## Solution **`kyo-sql-dolt-api`** holds `DoltClient`, an abstract class carrying the version-control surface: `commit` and `add`, `log`, `status`, `diff`, branch creation and deletion, `merge` with typed conflicts and resolution, `reset`, `revert`, `cherryPick`, tags, and remotes with `push`, `fetch` and `pull`. Every operation answers a record rather than a row, so a caller reads `DoltCommit.parents` instead of decoding a column by name. **`kyo-sql-dolt`** drives the server over kyo-sql's existing MySQL wire, so it inherits pooling, codecs and transactions and adds only the version-control statements. **`kyo-sql-doltlite`** drives the embedded engine through kyo-ffi. It reuses `kyo-sql-sqlite-driver`'s connection, codecs and row reader against a different library, which is the second engine that driver split was made for. One file carries the branches, commits and merges, with no server. Each supplies a concrete subclass, so a caller names `DoltClient` and never the backend. **`kyo-system-dolt`** is what the model buys. A `FileSystem` whose files are rows in a versioned database, so a directory tree branches, merges and diffs like a repository, and it passes kyo-system's own conformance suites rather than a bespoke set. ### Conformance Both engines join kyo-sql's cross-engine battery, which now runs four backends through one surface rather than the two it shipped with. `SqlBackendNeutralitySourceTest` picks them up by existing, since its banned-name list is derived from the registered descriptors. ## Notes **This is the second of two**, following #1945. Nothing in that PR depended on this one landing. **`kyo-sql-dolt-api` is a separate module because of Scala Native.** An FFI module's C is compiled INTO the binary, so if `kyo-sql-doltlite` depended on `kyo-sql-dolt` to reach `DoltClient` it would link `sqlite3.c` as well, and the `sqlite3_*` calls could bind to either engine. Depending on declarations carries no C. **DoltLite stages a compiled library rather than source**, so staging is per os-arch, and upstream publishes no windows-arm64 build. The module declares itself absent there through `kyoSqlDoltLiteOsArchTargets`, and the release guard reads that declaration rather than failing the leg. **`ContainerPredef.Dolt` joins the other database fixtures in kyo-pod**, with one deliberate difference: its readiness probe waits for the entrypoint's own init marker instead of a `SELECT 1`. The image backgrounds the server and then runs its own initialisation queries against the same data directory, so a query probe reports ready while that is still in flight, and a client working in that window races those queries into an `exit 1` that takes the container down. **kyo-system's `FileSystem` conformance suites gained an `S >: Async` type parameter** so a backend carrying its own effects can reuse them. Behaviour is unchanged for the host filesystem.
fwbrasil
added a commit
that referenced
this pull request
Sep 18, 2026
## Problem A kyo SQL client reads and writes, but the database's history is not something it can address. Committing a change, branching to try one, diffing two points in time, merging a branch back: all of that lives outside SQL, in whatever process happens to own the data. Dolt gives data the git model, and ships in two shapes that share no structure: a server speaking the MySQL wire, and an embedded SQLite fork with no server at all. Reaching either from kyo meant hand-rolling procedure calls against an untyped result set, and a caller that wanted to work against both had no type to name. ## Solution **`kyo-sql-dolt-api`** holds `DoltClient`, an abstract class carrying the version-control surface: `commit` and `add`, `log`, `status`, `diff`, branch creation and deletion, `merge` with typed conflicts and resolution, `reset`, `revert`, `cherryPick`, tags, and remotes with `push`, `fetch` and `pull`. Every operation answers a record rather than a row, so a caller reads `DoltCommit.parents` instead of decoding a column by name. **`kyo-sql-dolt`** drives the server over kyo-sql's existing MySQL wire, so it inherits pooling, codecs and transactions and adds only the version-control statements. **`kyo-sql-doltlite`** drives the embedded engine through kyo-ffi. It reuses `kyo-sql-sqlite-driver`'s connection, codecs and row reader against a different library, which is the second engine that driver split was made for. One file carries the branches, commits and merges, with no server. Each supplies a concrete subclass, so a caller names `DoltClient` and never the backend. **`kyo-system-doltfs`** is what the model buys. A `FileSystem` whose files are rows in a versioned database, so a directory tree branches, merges and diffs like a repository, and it passes kyo-system's own conformance suites rather than a bespoke set. ### Conformance Both engines join kyo-sql's cross-engine battery, which now runs four backends through one surface rather than the two it shipped with. `SqlBackendNeutralitySourceTest` picks them up by existing, since its banned-name list is derived from the registered descriptors. ## Notes **This is the second of two**, following #1945. Nothing in that PR depended on this one landing. **`kyo-sql-dolt-api` is a separate module because of Scala Native.** An FFI module's C is compiled INTO the binary, so if `kyo-sql-doltlite` depended on `kyo-sql-dolt` to reach `DoltClient` it would link `sqlite3.c` as well, and the `sqlite3_*` calls could bind to either engine. Depending on declarations carries no C. **DoltLite stages a compiled library rather than source**, so staging is per os-arch, and upstream publishes no windows-arm64 build. The module declares itself absent there through `kyoSqlDoltLiteOsArchTargets`, and the release guard reads that declaration rather than failing the leg. **`ContainerPredef.Dolt` joins the other database fixtures in kyo-pod**, with one deliberate difference: its readiness probe waits for the entrypoint's own init marker instead of a `SELECT 1`. The image backgrounds the server and then runs its own initialisation queries against the same data directory, so a query probe reports ready while that is still in flight, and a client working in that window races those queries into an `exit 1` that takes the container down. **kyo-system's `FileSystem` conformance suites gained an `S >: Async` type parameter** so a backend carrying its own effects can reuse them. Behaviour is unchanged for the host filesystem.
|
god bless you for adding sqlite! that's exactly what i needed |
fwbrasil
added a commit
that referenced
this pull request
Sep 18, 2026
## Problem A kyo SQL client reads and writes, but the database's history is not something it can address. Committing a change, branching to try one, diffing two points in time, merging a branch back: all of that lives outside SQL, in whatever process happens to own the data. Dolt gives data the git model, and ships in two shapes that share no structure: a server speaking the MySQL wire, and an embedded SQLite fork with no server at all. Reaching either from kyo meant hand-rolling procedure calls against an untyped result set, and a caller that wanted to work against both had no type to name. ## Solution **`kyo-sql-dolt-api`** holds `DoltClient`, an abstract class carrying the version-control surface: `commit` and `add`, `log`, `status`, `diff`, branch creation and deletion, `merge` with typed conflicts and resolution, `reset`, `revert`, `cherryPick`, tags, and remotes with `push`, `fetch` and `pull`. Every operation answers a record rather than a row, so a caller reads `DoltCommit.parents` instead of decoding a column by name. **`kyo-sql-dolt`** drives the server over kyo-sql's existing MySQL wire, so it inherits pooling, codecs and transactions and adds only the version-control statements. **`kyo-sql-doltlite`** drives the embedded engine through kyo-ffi. It reuses `kyo-sql-sqlite-driver`'s connection, codecs and row reader against a different library, which is the second engine that driver split was made for. One file carries the branches, commits and merges, with no server. Each supplies a concrete subclass, so a caller names `DoltClient` and never the backend. **`kyo-system-doltfs`** is what the model buys. A `FileSystem` whose files are rows in a versioned database, so a directory tree branches, merges and diffs like a repository, and it passes kyo-system's own conformance suites rather than a bespoke set. ### Conformance Both engines join kyo-sql's cross-engine battery, which now runs four backends through one surface rather than the two it shipped with. `SqlBackendNeutralitySourceTest` picks them up by existing, since its banned-name list is derived from the registered descriptors. ## Notes **This is the second of two**, following #1945. Nothing in that PR depended on this one landing. **`kyo-sql-dolt-api` is a separate module because of Scala Native.** An FFI module's C is compiled INTO the binary, so if `kyo-sql-doltlite` depended on `kyo-sql-dolt` to reach `DoltClient` it would link `sqlite3.c` as well, and the `sqlite3_*` calls could bind to either engine. Depending on declarations carries no C. **DoltLite stages a compiled library rather than source**, so staging is per os-arch, and upstream publishes no windows-arm64 build. The module declares itself absent there through `kyoSqlDoltLiteOsArchTargets`, and the release guard reads that declaration rather than failing the leg. **`ContainerPredef.Dolt` joins the other database fixtures in kyo-pod**, with one deliberate difference: its readiness probe waits for the entrypoint's own init marker instead of a `SELECT 1`. The image backgrounds the server and then runs its own initialisation queries against the same data directory, so a query probe reports ready while that is still in flight, and a client working in that window races those queries into an `exit 1` that takes the container down. **kyo-system's `FileSystem` conformance suites gained an `S >: Async` type parameter** so a backend carrying its own effects can reuse them. Behaviour is unchanged for the host filesystem. **`scripts/browser-check.sh` is run by hand, not by CI.** It drives the published WebAssembly build in a real browser to check that the engine loads and that a database survives a reload through OPFS, which no automated leaf covers: that VFS exists only in a browser. It needs a Chrome and a network fetch of the pinned npm package, so it is not wired into sbt.
fwbrasil
added a commit
that referenced
this pull request
Sep 18, 2026
## Problem A kyo SQL client reads and writes, but the database's history is not something it can address. Committing a change, branching to try one, diffing two points in time, merging a branch back: all of that lives outside SQL, in whatever process happens to own the data. Dolt gives data the git model, and ships in two shapes that share no structure: a server speaking the MySQL wire, and an embedded SQLite fork with no server at all. Reaching either from kyo meant hand-rolling procedure calls against an untyped result set, and a caller that wanted to work against both had no type to name. ## Solution **`kyo-sql-dolt-api`** holds `Dolt`, an abstract class carrying the version-control surface: `commit` and `add`, `log`, `status`, `diff`, branch creation and deletion, `merge` with typed conflicts and resolution, `reset`, `revert`, `cherryPick`, tags, and remotes with `push`, `fetch` and `pull`. Every operation answers a record rather than a row, and those records are the companion's, so they read as the client's vocabulary: `Dolt.Commit`, `Dolt.Ref`, `Dolt.Merge`, `Dolt.Branch`, `Dolt.Diff`. A caller reads `Dolt.Commit.parents` instead of decoding a column by name. **`kyo-sql-dolt`** drives the server over kyo-sql's existing MySQL wire, so it inherits pooling, codecs and transactions and adds only the version-control statements. Its entry point is `DoltServer`. **`kyo-sql-doltlite`** drives the embedded engine through kyo-ffi. It reuses `kyo-sql-sqlite-driver`'s connection, codecs and row reader against a different library, which is the second engine that driver split was made for. One file carries the branches, commits and merges, with no server. Each supplies a concrete subclass, so a caller names `Dolt` and never the backend. **`kyo-system-doltfs`** is what the model buys. A `FileSystem` whose files are rows in a versioned database, so a directory tree branches, merges and diffs like a repository, and it passes kyo-system's own conformance suites rather than a bespoke set. ### Conformance Both engines join kyo-sql's cross-engine battery, which now runs four backends through one surface rather than the two it shipped with. `SqlBackendNeutralitySourceTest` picks them up by existing, since its banned-name list is derived from the registered descriptors. ## Notes **This is the second of two**, following #1945. Nothing in that PR depended on this one landing. **`kyo-sql-dolt-api` is a separate module because of Scala Native.** An FFI module's C is compiled INTO the binary, so if `kyo-sql-doltlite` depended on `kyo-sql-dolt` to reach `Dolt` it would link `sqlite3.c` as well, and the `sqlite3_*` calls could bind to either engine. Depending on declarations carries no C. **`Dolt.Ref` has cases `Branch`, `Tag` and `Commit`** that share a name with three records on the enclosing object, so `Ref.render` qualifies its own cases and a wildcard `import Dolt.*` makes those three ambiguous. The qualified paths do not, and the alternative was keeping fourteen prefixed names in the `kyo` package. **DoltLite stages a compiled library rather than source**, so staging is per os-arch, and upstream publishes no windows-arm64 build. The module declares itself absent there through `kyoSqlDoltLiteOsArchTargets`, and the release guard reads that declaration rather than failing the leg. **`ContainerPredef.Dolt` joins the other database fixtures in kyo-pod**, with one deliberate difference: its readiness probe waits for the entrypoint's own init marker instead of a `SELECT 1`. The image backgrounds the server and then runs its own initialisation queries against the same data directory, so a query probe reports ready while that is still in flight, and a client working in that window races those queries into an `exit 1` that takes the container down. **kyo-system's `FileSystem` conformance suites gained an `S >: Async` type parameter** so a backend carrying its own effects can reuse them. Behaviour is unchanged for the host filesystem. **`scripts/browser-check.sh` is run by hand, not by CI.** It drives the published WebAssembly build in a real browser to check that the engine loads and that a database survives a reload through OPFS, which no automated leaf covers: that VFS exists only in a browser. It needs a Chrome and a network fetch of the pinned npm package, so it is not wired into sbt.
fwbrasil
added a commit
that referenced
this pull request
Sep 18, 2026
## Problem A kyo SQL client reads and writes, but the database's history is not something it can address. Committing a change, branching to try one, diffing two points in time, merging a branch back: all of that lives outside SQL, in whatever process happens to own the data. Dolt gives data the git model, and ships in two shapes that share no structure: a server speaking the MySQL wire, and an embedded SQLite fork with no server at all. Reaching either from kyo meant hand-rolling procedure calls against an untyped result set, and a caller that wanted to work against both had no type to name. ## Solution **`kyo-sql-dolt-api`** holds `Dolt`, an abstract class carrying the version-control surface: `commit` and `add`, `log`, `status`, `diff`, branch creation and deletion, `merge` with typed conflicts and resolution, `reset`, `revert`, `cherryPick`, tags, and remotes with `push`, `fetch` and `pull`. Every operation answers a record rather than a row, and those records are the companion's, so they read as the client's vocabulary: `Dolt.Commit`, `Dolt.Ref`, `Dolt.Merge`, `Dolt.Branch`, `Dolt.Diff`. A caller reads `Dolt.Commit.parents` instead of decoding a column by name. **`kyo-sql-dolt`** drives the server over kyo-sql's existing MySQL wire, so it inherits pooling, codecs and transactions and adds only the version-control statements. Its entry point is `DoltServer`. **`kyo-sql-doltlite`** drives the embedded engine through kyo-ffi. It reuses `kyo-sql-sqlite-driver`'s connection, codecs and row reader against a different library, which is the second engine that driver split was made for. One file carries the branches, commits and merges, with no server. Each supplies a concrete subclass, so a caller names `Dolt` and never the backend. **`kyo-system-doltfs`** is what the model buys. A `FileSystem` whose files are rows in a versioned database, so a directory tree branches, merges and diffs like a repository, and it passes kyo-system's own conformance suites rather than a bespoke set. ### Conformance Both engines join kyo-sql's cross-engine battery, which now runs four backends through one surface rather than the two it shipped with. `SqlBackendNeutralitySourceTest` picks them up by existing, since its banned-name list is derived from the registered descriptors. ## Notes **This is the second of two**, following #1945. Nothing in that PR depended on this one landing. **`kyo-sql-dolt-api` is a separate module because of Scala Native.** An FFI module's C is compiled INTO the binary, so if `kyo-sql-doltlite` depended on `kyo-sql-dolt` to reach `Dolt` it would link `sqlite3.c` as well, and the `sqlite3_*` calls could bind to either engine. Depending on declarations carries no C. **`Dolt.Ref` has cases `Branch`, `Tag` and `Commit`** that share a name with three records on the enclosing object, so `Ref.render` qualifies its own cases and a wildcard `import Dolt.*` makes those three ambiguous. The qualified paths do not, and the alternative was keeping fourteen prefixed names in the `kyo` package. **DoltLite stages a compiled library rather than source**, so staging is per os-arch, and upstream publishes no windows-arm64 build. The module declares itself absent there through `kyoSqlDoltLiteOsArchTargets`, and the release guard reads that declaration rather than failing the leg. **`ContainerPredef.Dolt` joins the other database fixtures in kyo-pod**, with one deliberate difference: its readiness probe waits for the entrypoint's own init marker instead of a `SELECT 1`. The image backgrounds the server and then runs its own initialisation queries against the same data directory, so a query probe reports ready while that is still in flight, and a client working in that window races those queries into an `exit 1` that takes the container down. **kyo-system's `FileSystem` conformance suites gained an `S >: Async` type parameter** so a backend carrying its own effects can reuse them. Behaviour is unchanged for the host filesystem. **`scripts/browser-check.sh` is run by hand, not by CI.** It drives the published WebAssembly build in a real browser to check that the engine loads and that a database survives a reload through OPFS, which no automated leaf covers: that VFS exists only in a browser. It needs a Chrome and a network fetch of the pinned npm package, so it is not wired into sbt.
fwbrasil
added a commit
that referenced
this pull request
Sep 18, 2026
## Problem A kyo SQL client reads and writes, but the database's history is not something it can address. Committing a change, branching to try one, diffing two points in time, merging a branch back: all of that lives outside SQL, in whatever process happens to own the data. Dolt gives data the git model, and ships in two shapes that share no structure: a server speaking the MySQL wire, and an embedded SQLite fork with no server at all. Reaching either from kyo meant hand-rolling procedure calls against an untyped result set, and a caller that wanted to work against both had no type to name. ## Solution **`kyo-sql-dolt-api`** holds `Dolt`, an abstract class carrying the version-control surface: `commit` and `add`, `log`, `status`, `diff`, branch creation and deletion, `merge` with typed conflicts and resolution, `reset`, `revert`, `cherryPick`, tags, and remotes with `push`, `fetch` and `pull`. Every operation answers a record rather than a row, and those records are the companion's, so they read as the client's vocabulary: `Dolt.Commit`, `Dolt.Ref`, `Dolt.Merge`, `Dolt.Branch`, `Dolt.Diff`. A caller reads `Dolt.Commit.parents` instead of decoding a column by name. **`kyo-sql-dolt`** drives the server over kyo-sql's existing MySQL wire, so it inherits pooling, codecs and transactions and adds only the version-control statements. Its entry point is `DoltServer`. **`kyo-sql-doltlite`** drives the embedded engine through kyo-ffi. It reuses `kyo-sql-sqlite-driver`'s connection, codecs and row reader against a different library, which is the second engine that driver split was made for. One file carries the branches, commits and merges, with no server. Each supplies a concrete subclass, so a caller names `Dolt` and never the backend. **`kyo-system-doltfs`** is what the model buys. A `FileSystem` whose files are rows in a versioned database, so a directory tree branches, merges and diffs like a repository, and it passes kyo-system's own conformance suites rather than a bespoke set. ### Conformance Both engines join kyo-sql's cross-engine battery, which now runs four backends through one surface rather than the two it shipped with. `SqlBackendNeutralitySourceTest` picks them up by existing, since its banned-name list is derived from the registered descriptors. ## Notes **This is the second of two**, following #1945. Nothing in that PR depended on this one landing. **`kyo-sql-dolt-api` is a separate module because of Scala Native.** An FFI module's C is compiled INTO the binary, so if `kyo-sql-doltlite` depended on `kyo-sql-dolt` to reach `Dolt` it would link `sqlite3.c` as well, and the `sqlite3_*` calls could bind to either engine. Depending on declarations carries no C. **`Dolt.Ref` has cases `Branch`, `Tag` and `Commit`** that share a name with three records on the enclosing object, so `Ref.render` qualifies its own cases and a wildcard `import Dolt.*` makes those three ambiguous. The qualified paths do not, and the alternative was keeping fourteen prefixed names in the `kyo` package. **`kyo-system-doltfs` stores a file as one row, and slices it through hex.** Content is a `LONGBLOB` on `vfs_node`, the shape SQLAR uses, so the tree stays queryable and a commit's diff names one row per changed file. Splitting content into fixed-size rows would duplicate work the engine already does: measured on a 1 MiB value, flipping one byte and committing cost 12 KB, because Dolt content-addresses and shares structure inside a large blob across versions. Positioned access slices `hex(bytes)` rather than the bytes because this engine's byte-slicing functions are unusable on binary: `SUBSTRING`, `SUBSTR`, `MID`, `INSERT` and a `BINARY` cast all fail on a value that is not valid UTF-8, and `LEFT` and `RIGHT` succeed while silently replacing each such byte with U+FFFD. `concat` rather than `||`, which is logical OR on the server. **DoltLite stages a compiled library rather than source**, so staging is per os-arch, and upstream publishes no windows-arm64 build. The module declares itself absent there through `kyoSqlDoltLiteOsArchTargets`, and the release guard reads that declaration rather than failing the leg. **`ContainerPredef.Dolt` joins the other database fixtures in kyo-pod**, with one deliberate difference: its readiness probe waits for the entrypoint's own init marker instead of a `SELECT 1`. The image backgrounds the server and then runs its own initialisation queries against the same data directory, so a query probe reports ready while that is still in flight, and a client working in that window races those queries into an `exit 1` that takes the container down. **kyo-system's `FileSystem` conformance suites gained an `S >: Async` type parameter** so a backend carrying its own effects can reuse them. Behaviour is unchanged for the host filesystem. **`scripts/browser-check.sh` is run by hand, not by CI.** It drives the published WebAssembly build in a real browser to check that the engine loads and that a database survives a reload through OPFS, which no automated leaf covers: that VFS exists only in a browser. It needs a Chrome and a network fetch of the pinned npm package, so it is not wired into sbt.
fwbrasil
added a commit
that referenced
this pull request
Sep 19, 2026
…hem (#1956) ## Problem A kyo SQL client reads and writes, but the database's history is not something it can address. Committing a change, branching to try one, diffing two points in time, merging a branch back: all of that lives outside SQL, in whatever process happens to own the data. Dolt gives data the git model, and ships in two shapes that share no structure: a server speaking the MySQL wire, and an embedded SQLite fork with no server at all. Reaching either from kyo meant hand-rolling procedure calls against an untyped result set, and a caller that wanted to work against both had no type to name. ## Solution **`kyo-sql-dolt-api`** holds `Dolt`, an abstract class carrying the version-control surface: `commit` and `add`, `log`, `status`, `diff`, branch creation and deletion, `merge` with typed conflicts and resolution, `reset`, `revert`, `cherryPick`, tags, and remotes with `push`, `fetch` and `pull`. Every operation answers a record rather than a row, and those records are the companion's, so they read as the client's vocabulary: `Dolt.Commit`, `Dolt.Ref`, `Dolt.Merge`, `Dolt.Branch`, `Dolt.Diff`. A caller reads `Dolt.Commit.parents` instead of decoding a column by name. **`kyo-sql-dolt`** drives the server over kyo-sql's existing MySQL wire, so it inherits pooling, codecs and transactions and adds only the version-control statements. Its entry point is `DoltServer`. **`kyo-sql-doltlite`** drives the embedded engine through kyo-ffi. It reuses `kyo-sql-sqlite-driver`'s connection, codecs and row reader against a different library, which is the second engine that driver split was made for. One file carries the branches, commits and merges, with no server. Each supplies a concrete subclass, so a caller names `Dolt` and never the backend. **`kyo-system-doltfs`** is what the model buys. A `FileSystem` whose files are rows in a versioned database, so a directory tree branches, merges and diffs like a repository, and it passes kyo-system's own conformance suites rather than a bespoke set. ### Conformance Both engines join kyo-sql's cross-engine battery, which now runs four backends through one surface rather than the two it shipped with. `SqlBackendNeutralitySourceTest` picks them up by existing, since its banned-name list is derived from the registered descriptors. ## Notes **This is the second of two**, following #1945. Nothing in that PR depended on this one landing. **`kyo-sql-dolt-api` is a separate module because of Scala Native.** An FFI module's C is compiled INTO the binary, so if `kyo-sql-doltlite` depended on `kyo-sql-dolt` to reach `Dolt` it would link `sqlite3.c` as well, and the `sqlite3_*` calls could bind to either engine. Depending on declarations carries no C. **`Dolt.Ref` has cases `Branch`, `Tag` and `Commit`** that share a name with three records on the enclosing object, so `Ref.render` qualifies its own cases and a wildcard `import Dolt.*` makes those three ambiguous. The qualified paths do not, and the alternative was keeping fourteen prefixed names in the `kyo` package. **`kyo-system-doltfs` stores a file as one row, and slices it through hex.** Content is a `LONGBLOB` on `vfs_node`, the shape SQLAR uses, so the tree stays queryable and a commit's diff names one row per changed file. Splitting content into fixed-size rows would duplicate work the engine already does: measured on a 1 MiB value, flipping one byte and committing cost 12 KB, because Dolt content-addresses and shares structure inside a large blob across versions. Positioned access slices `hex(bytes)` rather than the bytes because this engine's byte-slicing functions are unusable on binary: `SUBSTRING`, `SUBSTR`, `MID`, `INSERT` and a `BINARY` cast all fail on a value that is not valid UTF-8, and `LEFT` and `RIGHT` succeed while silently replacing each such byte with U+FFFD. `concat` rather than `||`, which is logical OR on the server. **DoltLite stages a compiled library rather than source**, so staging is per os-arch, and upstream publishes no windows-arm64 build. The module declares itself absent there through `kyoSqlDoltLiteOsArchTargets`, and the release guard reads that declaration rather than failing the leg. **`ContainerPredef.Dolt` joins the other database fixtures in kyo-pod**, with one deliberate difference: its readiness probe waits for the entrypoint's own init marker instead of a `SELECT 1`. The image backgrounds the server and then runs its own initialisation queries against the same data directory, so a query probe reports ready while that is still in flight, and a client working in that window races those queries into an `exit 1` that takes the container down. **kyo-system's `FileSystem` conformance suites gained an `S >: Async` type parameter** so a backend carrying its own effects can reuse them. Behaviour is unchanged for the host filesystem. **`scripts/browser-check.sh` is run by hand, not by CI.** It drives the published WebAssembly build in a real browser to check that the engine loads and that a database survives a reload through OPFS, which no automated leaf covers: that VFS exists only in a browser. It needs a Chrome and a network fetch of the pinned npm package, so it is not wired into sbt. <!-- PRs require an approval from any of the core contributors, other than the PR author. CI on pull requests may require maintainer approval before it runs. To run CI yourself in the meantime, see "Running CI in Your Fork" in CONTRIBUTING.md. Include this header if applicable: Fixes #issue1, #issue2, ... -->
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.
Problem
kyo-sql only talked to servers. PostgreSQL and MySQL are both network drivers on kyo-net, so every program needed a database process running somewhere: no file-backed or in-memory database, nothing that runs in a browser or ships inside a single binary, and a container for any test that wanted real SQL.
Adding an embedded engine was not just a third driver. PostgreSQL and MySQL are alike in every way the abstraction cares about, so core had been shaped around their similarities without anyone deciding to, and the conformance battery could not tell real agreement between engines from two engines that merely resemble each other.
Solution
kyo-sql-sqliteis an embedded SQLite driver over the C library through kyo-ffi. A database is a file path or:memory:, with no server. It cross-builds for JVM, JS, Native and Wasm; in a browser it runs on the WebAssembly build.kyo-sql-sqlite-driveris that driver's connection, pool plumbing, codecs, row reader, dialect and URL parsing, plus the binding trait as declarations only: no C, no FFI plugin, no engine. The split exists because on Scala Native an FFI module's C is compiled INTO the binary, so any module depending on an engine module links that engine in. A second engine speaking the samesqlite3_*API therefore cannot depend onkyo-sql-sqlitewithout carrying the vendoredsqlite3.ctoo, at which point the calls bind to whichever linked first. Depending on declarations carries no C.kyo-ffi gained a second JS transport. A generated JS impl asks
NativeFacadefor its dispatch table: koffi over a real shared library on Node, or a registered WebAssembly provider where there is neither, which is every browser. The choice is made by asking whether koffi can be loaded, not by sniffing for a browser, and-Dkyo.ffi.js.transport=wasmforces the WASM path so it runs under the same driver suites as the native one.What this changed in core
SQLite is the first engine that is not a server, and four things in kyo-sql had assumed one:
SqlConfig.Addresswas a host and a port. It is now sealed overNetworkandLocal, so neither kind of backend can be handed the other's coordinate.Backend.parseUrlhands each backend the raw URL to parse itself.DEFAULTkeyword.Idiom.overrideForis nowprivate[kyo], so a flavor without one can drop the column from the insert list instead.supportsGroupingSetsimplied rollup. MySQL has rollup and no grouping sets, SQLite has neither, sosupportsRollupis its own flag.SqlJsonArrayalso moves fromkyo-sql-mysqlinto core. MySQL and SQLite both lack an array type and both map the three array kinds ontoJSON, so one wire means a value written by either is read by either.Conformance
Every suite now runs against three engines. Telling a real divergence from an accident needed the descriptors to say what an engine can do, so they gained seventeen members: isolation levels honoured and defaulted to, advisory locks, concurrent write transactions, JSON key order, case folding past ASCII, and others. A leaf reads a capability, never an engine name, and capabilities are used in complementary pairs, so an engine that lacks a feature asserts what it does instead of being skipped. An engine that cannot deliver an isolation level has to refuse it rather than quietly substitute a weaker one, which is the lost-update bug this suite exists to catch.
SqlBackendNeutralitySourceTestenforces that mechanically: it scans the shared conformance source and fails on an engine name in a body, with the banned list derived from the registered descriptors, so a new backend joins the check by existing.Notes
This is the first of two. A Dolt backend, its embedded DoltLite counterpart, and a
FileSystemstored in a version-controlled database follow separately. DoltLite is the second engine the driver split above exists for: it keeps thesqlite3_*API over different storage, so it reuses this driver's connection, codecs and row reader with its own library. Nothing here depends on that landing.SQLite is compiled from a pinned C source rather than linked against a host
libsqlite3, since several conformance answers depend on the version:RETURNINGsince 3.35.0, theRIGHT/FULL JOINfloor at 3.39.0. A current macOS ships 3.43.2 against the 3.53.4 pinned here. The source is fetched and checksummed bykyo-sql-sqlite/scripts/build-sqlite.sh, and the staged tree is a gitignored build artifact. Nothing is staged per os-arch: it is one architecture-independent.c, and the FFI plugin already compiles per platform.SqliteVfsis aSqlConfigextension rather than a config field, because it means nothing to any other engine. It is how a browser gets persistence: the WebAssembly build has no filesystem, so the default VFS keeps a database in memory and loses it at reload.What this engine refuses. It has no advisory locks and no configurable isolation, and both are reported as typed refusals naming what was asked rather than silently downgraded. That is the shape engine-specific API takes here: what SQLite has over the others is an absence of things, so
SqliteClientadds no methods.Verification. PostgreSQL and MySQL run in containers, SQLite embedded. The module cross-builds for JVM, JS, Native and Wasm.