Skip to content

feat: columnar-dbc Rust crates over a typed C API, with signature verification in Client.Install - #543

Closed
zeroshade wants to merge 13 commits into
mainfrom
feat/columnar-dbc-rust-crates
Closed

zeroshade wants to merge 13 commits into
mainfrom
feat/columnar-dbc-rust-crates

Conversation

@zeroshade

Copy link
Copy Markdown
Member

Summary

Adds columnar-dbc, a Rust crate that statically links dbc, built on a new typed C API (capi/). It also fixes a gap where library installs skipped signature verification.

Signature verification (security fix)

SignedByColumnar's deprecation note says Client.Install verifies signatures, but it didn't: only the CLI did. Library and npm-wasm installs accepted drivers whose library was modified after signing.

  • dbc.VerifyManifestSignature (moved from the CLI) is now shared by the library, install, and sync.
  • Client.Install verifies on a staged copy before touching the target location, so a failed reinstall never damages an existing install. dbc.AllowUnsigned() opts out, like --no-verify.
  • The opt-out is exposed everywhere: api.InstallOptions, DBC_INSTALL_ALLOW_UNSIGNED, Rust InstallOptions::allow_unsigned, npm install(name, location, { allowUnsigned }).
  • Behaviour change: unsigned drivers installed through the library or npm now fail unless the caller opts out.

Shared operation layer

internal/api holds search/resolve/install/uninstall/list once. The WASM bindings now use it, and install/uninstall/list accept an explicit directory or the user/system config level.

Typed C API (capi/, 13 functions)

  • ADBC-style key/value options to dbc_client_new; every operation returns one dbc_list (dbc_list_get/dbc_list_info with DBC_FIELD_* ids).
  • libdbc.h is generated by cgo from capi/exports.go; Rust bindings are generated from it by pinned bindgen 0.73.2 and drift-checked in CI.

Rust crates (rust/)

columnar-dbc (safe API), columnar-dbc-sys (bindings), and five columnar-dbc-sys-<platform> crates, each bundling a prebuilt libdbc.a.

Release

  • .goreleaser.yaml gains a capi c-archive build that cross-compiles all 5 targets with Zig 0.17.0 (glibc 2.28 / macOS 12 floors).
  • A build hook checks archive size and stages each archive; after hooks cargo package (snapshot) or cargo publish (release). ids: [dbc] filters keep the archives out of the CLI's packaging.
  • New rust_test matrix runs on the snapshot's archives on six native runners: Linux x64/arm64, macOS arm64/x64, Windows MSVC and GNU.
  • CI and releases now use the Go 1.27.3 toolchain (go.mod minimum unchanged).
  • Needs a CARGO_REGISTRY_TOKEN secret in the production environment (see RELEASE.md).

Windows

One Zig-built archive is intended for both x86_64-pc-windows-msvc and -gnu. It imports only kernel32 plus standard CRT symbols, and has no .drectve entries or MinGW/libgcc helpers. The GNU link was verified locally with an msvcrt mingw-w64 toolchain (mingw-w64 provides __acrt_iob_func). The MSVC link is verified by this PR's rust x86_64-pc-windows-msvc job; this is plan Task 6, still open.

Testing

  • Ran locally: go vet/go test ./... (with and without cgo), npm-wasm smoke/worker tests, a C smoke test against the generated header, Zig cross-builds for all 5 targets, Rust roundtrip + level tests (including a real user-level install), a bindgen drift check, actionlint, and a windows-gnu cross-link of the Rust tests.
  • Needs this PR's CI: the GoReleaser snapshot (Pro config) and the Windows/macOS rust_test jobs.

Changes:
- Limited Windows support in `columnar-dbc-sys` to `x86_64-pc-windows-gnu`, using `target_env = "gnu"` in `Cargo.toml`, `src/lib.rs` and `build.rs`. The Windows archive is built with `zig cc -target x86_64-windows-gnu`, so it depends on the MinGW C runtime and can't be linked reliably by MSVC. MSVC targets now get the existing "no prebuilt dbc library for this target" build error instead of unresolved symbols at link time.
- `rust/platforms/windows-x64/build.rs` now fails with a clear message on non-GNU targets. After the archive, it links `kernel32` (the only DLL the Go runtime imports directly; other Windows DLLs are loaded at runtime) and the MinGW runtime libraries `mingwex`, `mingw32` and `msvcrt`.
- Changed the Windows row in the README's supported-targets table, which said "see below" but had nothing below it, to `x86_64-pc-windows-gnu` with a note that MSVC isn't supported.
Verification: Go build and `go test ./...` pass. `cargo test -p columnar-dbc -p columnar-dbc-sys` passes on Linux, and the Windows `build.rs` compiles. No Windows toolchain is available here, so the actual Windows link is untested.
I removed the MSVC Windows row from the Rust release test matrix, which leaves `x86_64-pc-windows-gnu` as the only Windows target there. No other part of `.github/` mentions `windows-msvc`. The Go build passes and the workflow YAML is valid. I didn't run the Go test suite because this change only touches workflow YAML, and the Rust release CI itself wasn't run here.
Changes:
- Removed the `x86_64-pc-windows-msvc` row from the `rust_test` matrix in `.github/workflows/release.yml`, since `columnar-dbc-sys` no longer supports that target and the release CI would fail on it
@zeroshade zeroshade closed this Oct 28, 2026
zeroshade added a commit that referenced this pull request Nov 4, 2026
- `.goreleaser.yaml` gains a `capi` c-archive build that cross-compiles
all 5 targets with Zig 0.17.0 (glibc 2.28 / macOS 12 floors).
- `scripts/stage_capi.py` checks size and stages each archive;
`scripts/publish_crates.py` runs `cargo package` (snapshot) or `cargo
publish` (on `v*` tag pushes, from the `production_deploy` GoReleaser
run). Publishing skips crate versions already on crates.io, so
re-running a partially published release finishes the rest. `ids: [dbc]`
filters keep the archives out of the CLI packaging.
- New `rust_test` job runs on the snapshot's archives on six native
runners (Linux x64/arm64, macOS arm64/x64, Windows MSVC and GNU), with a
30-minute timeout.
- Needs a `CARGO_REGISTRY_TOKEN` secret in the `production` environment
(see RELEASE.md).

Stacked on #548. Supersedes #543.

### libdbc-dev / libdbc-devel
- A new `capi-shared` build (linux amd64/arm64, SONAME `libdbc.so`).
- Two nfpm entries: deb `libdbc-dev` (`/usr/lib/<triplet>`) and rpm
`libdbc-devel` (`/usr/lib64`). Each ships `libdbc.a`, `libdbc.so`,
`/usr/include/libdbc.h` and `pkgconfig/dbc.pc`.
- `scripts/stage_devel.py` stages the `.so` and `.pc` files.
- nfpm takes only the c-archive build's artifacts, because both builds
emit `libdbc.h` and GoReleaser doesn't deduplicate.
- The packages ship in `release`, `blobs`, and Cloudsmith
(`columnar/dbc`, alongside the CLI packages; stable releases only).

New CI job `devel packages` (amd64 + arm64):
- installs the snapshot `.deb`;
- runs the Rust tests with the default build (pkg-config, statically
linked, checked with `ldd`), with `DBC_DYNAMIC`, and with
`DBC_SYS_LIB_DIR` (`scripts/test_devel_rust.sh`);
- installs the `.rpm` in a Fedora container, runs the same Rust tests
against it, and compiles and runs a C smoke program, statically and
dynamically.



### Docs
- `docs/getting_started/installation.md` gains a "Linux Package
Repositories (deb/rpm)" section: adding the Cloudsmith `columnar/dbc`
apt/dnf repo (setup script or manual config), installing `dbc` /
`libdbc-dev` / `libdbc-devel`, or installing a file from GitHub
Releases. Linked from the README.
- The `columnar-dbc` / `columnar-dbc-sys` rustdoc and crate README
explain installing the dev package from the repo or from GitHub
Releases, with links to the repo, releases, and install docs.


### macOS / Windows static libdbc-dev
- New `libdbc-dev` archive from the `capi` build:
`libdbc-dev_<v>_darwin_{amd64,arm64}.tar.gz` and
`libdbc-dev_<v>_windows_amd64.zip` with `libdbc.a` (`libdbc.lib` on
Windows), `libdbc.h`, `LICENSE`, and a relocatable `dbc.pc`
(`prefix=${pcfiledir}`). Attached to the release and the bucket.
- `libdbc` Homebrew formula via GoReleaser `brews` →
`columnar-tech/homebrew-tap` (`brew install columnar-tech/tap/libdbc`).
`brews` is deprecated in favor of casks, but casks can't install into
`lib/`/`include/`, so a formula is the only option for a library.
- Windows zip → Cloudsmith raw package `libdbc-dev-windows-x64` via a
`cloudsmith-raw` custom publisher (`scripts/publish_cloudsmith_raw.py`);
the `cloudsmiths` pipe only handles deb/rpm/apk. Stable releases only.
- `DBC_SYS_LIB_DIR` accepts `libdbc.lib` on Windows. winget is now
restricted to the CLI archives (it otherwise skips with "multiple
archives for the same platform").
- New CI job `devel archive`: on macOS arm64/x64 installs the snapshot
formula from a local tap, runs `brew test`, and runs the Rust suite with
the default pkg-config build; on Windows MSVC/GNU runs the Rust suite
against the unpacked zip with `DBC_SYS_LIB_DIR`.

This branch was previously deployed

1 inactive deployment
snapshot — a656d789 Deployed Oct 28, 2026 by zeroshade via snapshot #1048
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