Skip to content

Rename to bv-server; switch wire magics with legacy compatibility; record answering backend - #8

Merged
mrexodia merged 8 commits into
masterfrom
rename-bv-server
Nov 25, 2026
Merged

mrexodia merged 8 commits into
masterfrom
rename-bv-server

Conversation

@mrexodia

@mrexodia mrexodia commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Renames the project to bv-server. It's a bit-vector expression service (solve, optimize, simplify) for lifting-based binary analysis, and "smt-server" made people assume it was only an SMT solver front-end.

The two commits are easier to review separately:

  1. Rename smt-server to bv-server. Mechanical; behaviour and wire format unchanged. Crates bv-server / bv-wire / bv-smtlib (qfbvsmtrs keeps its name), Python bv_wire and bv_z3_server.py, C++ bv_wire (header, namespace, CMake package; smt_error → bv_error), env vars BV_SERVER_*, data dir ~/.bv-server.
  2. Switch wire magics with legacy compatibility; record answering backend. This is the actual logic.

Wire magics

New: BVSQ / BVSR / BV\0\0. Clients emit only these.

The server still accepts SMTQ requests from already-built clients and answers with SMTR (and SMT\0 inside simplify responses). Conversion happens at the dispatch boundary (bv_wire::raw::legacy), so the backends, the cache and the recordings only ever see current magics, and old and new clients share cache entries and recorded rows. The Python Z3 server does the same.

Recordings carry over

  • If ~/.bv-server/recordings.db is missing but ~/.smt-server/recordings.db exists, the server copies the old database in at startup. It uses a read-only VACUUM INTO followed by a no-clobber hard link, and the old file is never modified.
  • The schema is versioned with PRAGMA user_version and upgraded once at startup, before accepting connections. v0 rows are rewritten to the new magics and re-keyed; v2 adds the backend column.
  • SMT_SERVER_RECORD_DB is still honoured (with a warning). SMT_SERVER_ADDRESS and SMT_SERVER_TEXT_QFBVSMTRS_BUDGET_MS must be renamed.

Backend attribution

New nullable recordings.backend column: the race winner (z3 / binbit / qfbvsmtrs) or the simplifier (rumba). Wrapper backends fill it in via QueryResult::attributed_to, so it names the backend that actually answered. It's NULL for errors and existing rows. The first recording of a query wins, and the wire protocol is unchanged.

Testing

  • cargo test --workspace: 159 tests pass. The rename commit passes on its own (149 tests).
  • New tests: legacy request/response round-trips including simplify and cache sharing (tests/legacy_magic.rs), upgrading a real smt-server-schema database, importing the old default database without modifying it (including rows still in the WAL), legacy file-tree import, v1 → v2 upgrade, and attribution through the router and racing backends.
  • Python client, live-server and Z3-server tests pass; the C++ smoke and example tests pass against the server.
  • Manual end-to-end run against the binary: solves recorded as the race winner, simplifies as rumba, SMT-LIB text attributed too.

Heads-up

Open PRs #7 (CoBRA) and #3 (bitwuzla) will conflict, since everything moved from crates/smt-server to crates/bv-server. New backends constructing QueryResult should keep using the constructors; the new field defaults to None.

CI fixes (also broken on master)

CI hadn't run since August, and the toolchain moved on in the meantime. master currently fails at clippy too.

  • c70d7f9: Rust 1.100 clippy. Fixed the new chunks_exact_to_as_chunks lint in bv-smtlib, and replaced the now-deprecated AtomicUsize::fetch_update with a compare_exchange_weak loop. (Its suggested replacement, try_update, doesn't exist on older toolchains.)
  • fd51ac5: newer Cargo writes build-script output to build/<pkg>/<hash>/out instead of build/<pkg>-<hash>/out. The live-server test and the C++ CI step looked for the z3 DLL only in the old layout, so on Windows the server exited with STATUS_DLL_NOT_FOUND. Both now search both layouts.
  • b7e2eda: when the server fails to start, the live-server test now reports which z3 directories it searched.

The project is a bit-vector expression service: it solves, optimizes and
simplifies QF_BV expressions. "smt-server" made people think it was only an
SMT solver front-end.

Mechanical rename only; behaviour and the wire format are unchanged:

- crates: smt-server -> bv-server, smt-wire -> bv-wire,
  smt-qfbv-smtlib -> bv-smtlib (qfbvsmtrs keeps its name)
- Python: smt_wire -> bv_wire (examples use `import bv_wire as bv`),
  smt_z3_server.py -> bv_z3_server.py
- C++: header, namespace and CMake package smt_wire -> bv_wire,
  base exception smt_error -> bv_error
- environment variables SMT_SERVER_* -> BV_SERVER_*
- default data directory ~/.smt-server -> ~/.bv-server
- docs/smt-wire-protocol.md -> docs/bv-wire-protocol.md
New magics: BVSQ (request), BVSR (response), BV\0\0 (expression buffer).
Clients emit only these.

Legacy compatibility (bv_wire::raw::legacy):
- The server accepts SMTQ requests: it upgrades the request and embedded
  expression magics, dispatches normally, and downgrades the response (and
  the expression magic in a HAS_EXPR simplify block) back to SMTR/SMT\0, so
  already-built clients keep working. The Python Z3 server does the same.
- The cache and recordings only ever see current magics, so legacy and
  current clients share cache entries and recorded rows.

Recordings:
- If ~/.bv-server/recordings.db does not exist but ~/.smt-server/recordings.db
  does, copy it into place on startup (read-only VACUUM INTO + no-clobber
  hard link); the old file is never modified.
- Versioned upgrade via PRAGMA user_version, run once at startup before
  accepting connections: v0 (smt-server) rows are rewritten to the new
  magics and re-keyed; v2 adds a nullable `backend` column.
- migrate-recordings accepts legacy-magic file trees and defaults to
  ~/.smt-server/requests again.
- SMT_SERVER_RECORD_DB is still honoured (with a deprecation warning) when
  BV_SERVER_RECORD_DB is unset.

Backend attribution:
- QueryResult gains `backend`, filled in by wrapper backends (router, pool,
  racing) via `attributed_to`, so it names the leaf that answered: the race
  winner (z3/binbit/qfbvsmtrs) or the simplifier (rumba).
- Recorded in the new `backend` column for binary and SMT-LIB text requests;
  NULL for errors and pre-existing rows. First recording wins.

Docs: README "Upgrading from smt-server" section and new project
description; protocol doc documents the legacy magics.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T22:29:09.294281Z 468c2a2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

CI runs clippy with -D warnings on the latest stable, which added two
diagnostics in existing code:

- clippy::chunks_exact_to_as_chunks in bv-smtlib's annotation parsing:
  use `as_chunks::<2>()` and destructure the keyword/value pair.
- `AtomicUsize::fetch_update` is deprecated in favour of `try_update`, which
  older toolchains lack; use an equivalent compare_exchange_weak loop.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c70d7f9ad5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/bv-server/src/server.rs Resolved
…s to start

On Windows the server exits with STATUS_DLL_NOT_FOUND and an empty stderr,
which says nothing about where the test looked for libz3.dll.
Newer Cargo puts build-script output in target/debug/build/<pkg>/<hash>/out
instead of target/debug/build/<pkg>-<hash>/out. The live-server test and the
C++ CI step only globbed the old layout, so on Windows (the one platform
where z3 is a DLL that must be on PATH) they found nothing and the server
exited with STATUS_DLL_NOT_FOUND. Match both layouts.
handle_connection replaced an over-limit response with a BVSR error after
dispatch had already downgraded it, so SMTQ clients got a frame they could
not parse.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4516e5afbb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python/bv_z3_server.py Resolved
…clients

Same bug as the Rust server: the size-limit replacement used BVSR. Also run
the legacy-magic tests from the script's main(), which had skipped them.
@mrexodia
mrexodia merged commit 3bdd448 into master Nov 25, 2026
6 checks passed
@mrexodia
mrexodia deleted the rename-bv-server branch November 25, 2026 11:35
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