Browse Source

feat: 2.15.0 - client and server release independently

- GetServerInfo: version, commit and feature names
  (service/src/server_capabilities.hpp). Client: serverInfo() (nullopt for
  a pre-2.15.0 server, throws on an outage, cached 60 s), serverSupports(),
  Client::Capability, and requireCapability() refusing with reason
  server_unsupported before a request an older server would misread.
- Every call carries sbdb-client-version metadata.
- The server links the generated proto code directly instead of the client
  library; its package no longer pins libsmartbotic-db-client (= VERSION).
  build.sh --only client|server publishes one side.
- packaging/compat.sh <version>: this tree vs a released version, both
  directions. Green against 2.14.0 and 2.13.1. Its first run found that the
  CLI package never declared liblmdb0/libssl3t64 and could not start without
  the server package installed; fixed.
- CLI server-info.

Tests: test_server_info (current 35, down 1, old 9 via compat.sh). Reverted
alone: no version header 1 fails, outage reported as an old server 1 fails.
fszontagh 1 tháng trước cách đây
mục cha
commit
94dc6a7535

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
CLAUDE.md


+ 1 - 1
VERSION

@@ -1 +1 @@
-2.14.0
+2.15.0

+ 17 - 0
cli/main.cpp

@@ -76,6 +76,7 @@ void printUsage() {
               << "  " << C_CYAN << "lock" << C_RESET << "                                 Lock database (read-only)\n"
               << "  " << C_CYAN << "lock" << C_RESET << "                                 Lock database (read-only)\n"
               << "  " << C_CYAN << "unlock" << C_RESET << "                               Unlock database (accept writes)\n"
               << "  " << C_CYAN << "unlock" << C_RESET << "                               Unlock database (accept writes)\n"
               << "  " << C_CYAN << "status" << C_RESET << "                               Show read-only + recovery status\n"
               << "  " << C_CYAN << "status" << C_RESET << "                               Show read-only + recovery status\n"
+              << "  " << C_CYAN << "server-info" << C_RESET << "                          Server version, commit and feature names (2.15.0+)\n"
               << C_BOLD << "  Access policy (v2.7.0+)" << C_RESET << "\n"
               << C_BOLD << "  Access policy (v2.7.0+)" << C_RESET << "\n"
               << "  " << C_CYAN << "security" << C_RESET << " [project]                   Show whether a project enforces policy\n"
               << "  " << C_CYAN << "security" << C_RESET << " [project]                   Show whether a project enforces policy\n"
               << "  " << C_CYAN << "indexes" << C_RESET << " <collection>"
               << "  " << C_CYAN << "indexes" << C_RESET << " <collection>"
@@ -498,6 +499,22 @@ bool execCommand(smartbotic::database::Client& client,
                  // for `relations` means "every project" rather than "default".
                  // for `relations` means "every project" rather than "default".
                  const std::string& explicitProject) {
                  const std::string& explicitProject) {
     try {
     try {
+        if (cmd == "server-info") {
+            const auto si = client.serverInfo(true);
+            if (!si) {
+                std::cout << "server predates 2.15.0 (no GetServerInfo); this client is "
+                          << smartbotic::database::clientLibraryVersion() << "\n";
+                return true;
+            }
+            std::cout << "server:   " << si->version << " (commit " << si->commit << ")\n"
+                      << "client:   " << smartbotic::database::clientLibraryVersion()
+                      << " (the server saw '" << si->clientVersionSeen << "')\n"
+                      << "features:";
+            for (const auto& c : si->capabilities) std::cout << " " << c;
+            std::cout << "\n";
+            return true;
+        }
+
         if (cmd == "collections") {
         if (cmd == "collections") {
             auto collections = client.listCollections();
             auto collections = client.listCollections();
             std::cout << C_BOLD << "Collections:" << C_RESET << "\n";
             std::cout << C_BOLD << "Collections:" << C_RESET << "\n";

+ 64 - 0
client/include/smartbotic/database/client.hpp

@@ -300,6 +300,70 @@ public:
      */
      */
     bool connect();
     bool connect();
 
 
+    // ===== Server info and capabilities (v2.15.0) =====
+
+    /**
+     * Feature names a server reports (GetServerInfo). Gate a feature on its
+     * NAME, never on a version number: a patched or backported server reports
+     * exactly what it supports. Names are never reused; a feature whose meaning
+     * changes gets a new name. Kept identical to the server's list
+     * (service/src/server_capabilities.hpp).
+     */
+    struct Capability {
+        static constexpr const char* kProjects = "projects";
+        static constexpr const char* kAccessPolicy = "access_policy";
+        static constexpr const char* kQueryProjection = "query_projection";
+        static constexpr const char* kFileTtl = "file_ttl";
+        static constexpr const char* kDocumentTtlUpdate = "document_ttl_update";
+        static constexpr const char* kSecondaryIndexes = "secondary_indexes";
+        static constexpr const char* kIndexValues = "index_values";
+        static constexpr const char* kRelations = "relations";
+        static constexpr const char* kUniqueIndexes = "unique_indexes";
+        static constexpr const char* kErrorDetail = "error_detail";
+        static constexpr const char* kPatchIfVersion = "patch_if_version";
+        static constexpr const char* kIncrement = "increment";
+        static constexpr const char* kCompositeUnique = "composite_unique";
+        static constexpr const char* kBatchDeleteIds = "batch_delete_ids";
+        static constexpr const char* kEventActor = "event_actor";
+        static constexpr const char* kVectorReadback = "vector_readback";
+        static constexpr const char* kExportCollection = "export_collection";
+        static constexpr const char* kWriteSizeGuard = "write_size_guard";
+        static constexpr const char* kFilteredSimilarity = "filtered_similarity";
+        static constexpr const char* kServerInfo = "server_info";
+        static constexpr const char* kClientVersionHeader = "client_version_header";
+    };
+
+    struct ServerInfo {
+        std::string version;                    // e.g. "2.15.0"
+        std::string commit;                     // short git commit, or "unknown"
+        std::vector<std::string> capabilities;  // see Capability
+        std::string clientVersionSeen;          // this library's version, as the server received it
+    };
+
+    /**
+     * v2.15.0 - what the server is and which features it has.
+     *
+     * nullopt means the server predates 2.15.0 (it has no GetServerInfo): it
+     * supports none of the features introduced in 2.15.0 or later, and may or
+     * may not have earlier ones. Throws Client::Error when the server cannot be
+     * asked (unreachable, denied) - an outage is not "an old server".
+     *
+     * Cached for 60 s per Client, so a server upgraded or rolled back behind a
+     * long-lived client is noticed; `refresh` asks now.
+     */
+    [[nodiscard]] std::optional<ServerInfo> serverInfo(bool refresh = false);
+
+    /**
+     * v2.15.0 - true when the server reports `capability`. False for a server
+     * that predates 2.15.0. Throws like serverInfo() when it cannot be asked.
+     *
+     * Every client method that needs a feature introduced in 2.15.0 or later
+     * checks this itself and throws Client::FailedPrecondition, reason
+     * `server_unsupported`, BEFORE sending - an old server would otherwise
+     * ignore what it does not understand and answer something that looks right.
+     */
+    [[nodiscard]] bool serverSupports(const std::string& capability);
+
     /**
     /**
      * The channel's last known state: false after a failed connection attempt
      * The channel's last known state: false after a failed connection attempt
      * or disconnect(). Not a live probe - an idle channel to a server that has
      * or disconnect(). Not a live probe - an idle channel to a server that has

+ 94 - 0
client/src/client.cpp

@@ -59,6 +59,10 @@ Client::ErrorCode toErrorCode(grpc::StatusCode code) {
 // `service DatabaseService` in database.proto). Empty when absent.
 // `service DatabaseService` in database.proto). Empty when absent.
 constexpr const char* kErrorDetailKey = "sbdb-error-detail-bin";
 constexpr const char* kErrorDetailKey = "sbdb-error-detail-bin";
 
 
+#ifndef SMARTBOTIC_DB_VERSION_STRING
+#define SMARTBOTIC_DB_VERSION_STRING "unknown"
+#endif
+
 std::string trailerDetail(const grpc::ClientContext& context) {
 std::string trailerDetail(const grpc::ClientContext& context) {
     const auto& md = context.GetServerTrailingMetadata();
     const auto& md = context.GetServerTrailingMetadata();
     auto it = md.find(kErrorDetailKey);
     auto it = md.find(kErrorDetailKey);
@@ -1200,6 +1204,17 @@ public:
         const std::string& collection, const std::vector<float>& queryVector,
         const std::string& collection, const std::vector<float>& queryVector,
         uint32_t topK, float minScore,
         uint32_t topK, float minScore,
         const std::vector<Client::Filter>& filters = {}) {
         const std::vector<Client::Filter>& filters = {}) {
+        // v2.15.0 - a server that answers GetServerInfo and lacks the feature
+        // is refused before sending. A pre-2.15.0 server cannot say, so for it
+        // the response's filters_applied (below) remains the guard.
+        if (!filters.empty()) {
+            const auto si = serverInfo(false);
+            if (si && std::find(si->capabilities.begin(), si->capabilities.end(),
+                                Client::Capability::kFilteredSimilarity) ==
+                          si->capabilities.end()) {
+                requireCapability(Client::Capability::kFilteredSimilarity, "similaritySearch");
+            }
+        }
         smartbotic::databasepb::SimilaritySearchRequest request;
         smartbotic::databasepb::SimilaritySearchRequest request;
         request.set_collection(qualify(collection));
         request.set_collection(qualify(collection));
         for (float v : queryVector) {
         for (float v : queryVector) {
@@ -2944,12 +2959,83 @@ private:
     // v2.4 — attach the bearer-token authorization metadata if configured.
     // v2.4 — attach the bearer-token authorization metadata if configured.
     // Use this on contexts that set their own deadline (streams,
     // Use this on contexts that set their own deadline (streams,
     // long-running ops) so the auth metadata still lands.
     // long-running ops) so the auth metadata still lands.
+    //
+    // v2.15.0 - every call also carries this library's version, so a server can
+    // keep an old behaviour for an old client if a meaning ever has to change.
+    // Every context passes through here (setDeadline, setWriteDeadline, the
+    // streams), which is why the header is attached here and not elsewhere.
     void attachAuth(grpc::ClientContext& context) {
     void attachAuth(grpc::ClientContext& context) {
+        context.AddMetadata("sbdb-client-version", SMARTBOTIC_DB_VERSION_STRING);
         if (!config_.auth_token.empty()) {
         if (!config_.auth_token.empty()) {
             context.AddMetadata("authorization", "Bearer " + config_.auth_token);
             context.AddMetadata("authorization", "Bearer " + config_.auth_token);
         }
         }
     }
     }
 
 
+public:
+    // ===== Server info and capabilities (v2.15.0) =====
+
+    std::optional<Client::ServerInfo> serverInfo(bool refresh) {
+        {
+            std::lock_guard<std::mutex> lk(infoMu_);
+            if (!refresh && infoFetched_ &&
+                std::chrono::steady_clock::now() - infoAt_ < std::chrono::seconds(60)) {
+                return info_;
+            }
+        }
+        smartbotic::databasepb::GetServerInfoRequest request;
+        smartbotic::databasepb::GetServerInfoResponse response;
+        grpc::ClientContext context;
+        setDeadline(context);
+        auto status = stub_->GetServerInfo(&context, request, &response);
+        std::optional<Client::ServerInfo> got;
+        if (status.ok()) {
+            Client::ServerInfo si;
+            si.version = response.version();
+            si.commit = response.commit();
+            si.capabilities.assign(response.capabilities().begin(), response.capabilities().end());
+            si.clientVersionSeen = response.client_version();
+            got = std::move(si);
+        } else if (status.error_code() != grpc::StatusCode::UNIMPLEMENTED) {
+            // An outage is not "an old server": answering nullopt here would
+            // make every 2.15.0+ feature look unsupported during a blip.
+            throwStatus(status, "serverInfo: " + status.error_message(), trailerDetail(context));
+        }
+        // UNIMPLEMENTED: a pre-2.15.0 server. Cached like an answer.
+        std::lock_guard<std::mutex> lk(infoMu_);
+        info_ = got;
+        infoFetched_ = true;
+        infoAt_ = std::chrono::steady_clock::now();
+        return got;
+    }
+
+    bool serverSupports(const std::string& capability) {
+        const auto si = serverInfo(false);
+        if (!si) return false;
+        return std::find(si->capabilities.begin(), si->capabilities.end(), capability) !=
+               si->capabilities.end();
+    }
+
+    // For client methods that need a feature introduced in 2.15.0 or later:
+    // refuse BEFORE sending, because an old server ignores what it does not
+    // understand and answers something that looks right.
+    void requireCapability(const char* capability, const char* what) {
+        if (serverSupports(capability)) return;
+        const auto si = serverInfo(false);
+        const std::string msg = std::string(what) + ": the server does not support '" +
+                                capability + "' (server " +
+                                (si ? si->version : std::string("older than 2.15.0")) + ")";
+        spdlog::error("Client::{}", msg);
+        throw DetailedFailedPrecondition(
+            msg, makeDetail(Client::ErrorCode::FailedPrecondition, msg,
+                            R"({"reason":"server_unsupported"})"));
+    }
+
+private:
+    std::mutex infoMu_;
+    bool infoFetched_ = false;
+    std::optional<Client::ServerInfo> info_;
+    std::chrono::steady_clock::time_point infoAt_{};
+
     Config config_;
     Config config_;
     std::shared_ptr<grpc::Channel> channel_;
     std::shared_ptr<grpc::Channel> channel_;
     std::unique_ptr<smartbotic::databasepb::DatabaseService::Stub> stub_;
     std::unique_ptr<smartbotic::databasepb::DatabaseService::Stub> stub_;
@@ -3472,6 +3558,14 @@ Client::FileListResult Client::listFiles(const std::string& file_type,
 #define SMARTBOTIC_DB_GIT_COMMIT_STRING "unknown"
 #define SMARTBOTIC_DB_GIT_COMMIT_STRING "unknown"
 #endif
 #endif
 
 
+std::optional<Client::ServerInfo> Client::serverInfo(bool refresh) {
+    return impl_->serverInfo(refresh);
+}
+
+bool Client::serverSupports(const std::string& capability) {
+    return impl_->serverSupports(capability);
+}
+
 std::string clientLibraryVersion() { return SMARTBOTIC_DB_VERSION_STRING; }
 std::string clientLibraryVersion() { return SMARTBOTIC_DB_VERSION_STRING; }
 std::string clientLibraryCommit() { return SMARTBOTIC_DB_GIT_COMMIT_STRING; }
 std::string clientLibraryCommit() { return SMARTBOTIC_DB_GIT_COMMIT_STRING; }
 
 

+ 5 - 3
docs/ROADMAP.md

@@ -1,6 +1,6 @@
 # Smartbotic Database - Status and Roadmap
 # Smartbotic Database - Status and Roadmap
 
 
-**Released version: 2.14.0** (see `VERSION`). Last reviewed: 2026-10-09.
+**Released version: 2.15.0** (see `VERSION`). Last reviewed: 2026-10-09.
 
 
 > 2.11.5 was prepared but never released on its own: its work (event actors,
 > 2.11.5 was prepared but never released on its own: its work (event actors,
 > `removeAs()`) ships inside 2.12.0. There is no 2.11.5 package.
 > `removeAs()`) ships inside 2.12.0. There is no 2.11.5 package.
@@ -56,12 +56,14 @@ Consequences of that substitution, which trip up readers:
 
 
 ## Shipped
 ## Shipped
 
 
-Every item below is in the installed product as of 2.14.0. `CLAUDE.md` has the
+Every item below is in the installed product as of 2.15.0. `CLAUDE.md` has the
 detail and the failure modes.
 detail and the failure modes.
 
 
 - JSON document store: collections, version history, field-level encryption, TTL
 - JSON document store: collections, version history, field-level encryption, TTL
 - LMDB storage substrate, one env per project, dual-write mirror from MemoryStore
 - LMDB storage substrate, one env per project, dual-write mirror from MemoryStore
 - Multi-project namespaces (`<project>:<collection>`)
 - Multi-project namespaces (`<project>:<collection>`)
+- Independent client and server releases: `GetServerInfo` capability
+  negotiation, decoupled packages, `build.sh --only`, `packaging/compat.sh` (2.15.0)
 - Vector storage with SIMD cosine similarity search; filtered search, exact
 - Vector storage with SIMD cosine similarity search; filtered search, exact
   top-K among rows matching `find()`'s filters (2.14.0)
   top-K among rows matching `find()`'s filters (2.14.0)
 - Views (read-only projections with baked-in filters)
 - Views (read-only projections with baked-in filters)
@@ -464,7 +466,7 @@ joins; see 5c), which does not fit in 10 s. The container is now run with
   ones hold nothing, but because their collections were never written, their
   ones hold nothing, but because their collections were never written, their
   sub-db never persists and every boot logs `rebuilt ... over 0 row(s)`. Two
   sub-db never persists and every boot logs `rebuilt ... over 0 row(s)`. Two
   small gaps behind it: the CLI accepted an argument starting with `--` as a
   small gaps behind it: the CLI accepted an argument starting with `--` as a
-  field name (fixed on main after 2.14.0: `index-create` refuses it, unreleased),
+  field name (fixed in 2.15.0: `index-create` refuses it),
   and a collection name may contain a space (open). Cleanup (`index-drop` of
   and a collection name may contain a space (open). Cleanup (`index-drop` of
   both) was handed to the smartbotic session on 2026-10-09 at the owner's
   both) was handed to the smartbotic session on 2026-10-09 at the owner's
   request.
   request.

+ 39 - 0
docs/integration-guide.md

@@ -175,6 +175,45 @@ if (!db.connect()) {
 }
 }
 ```
 ```
 
 
+### Mixed versions: what the server supports (2.15.0+)
+
+From 2.15.0 the client library and the server are released independently: a
+host may run a newer client against an older server, or the reverse. The client
+can ask the server what it is:
+
+```cpp
+using Cap = smartbotic::database::Client::Capability;
+if (auto si = db.serverInfo()) {
+    // si->version, si->commit, si->capabilities
+}
+if (db.serverSupports(Cap::kFilteredSimilarity)) { /* ... */ }
+```
+
+- **Gate on feature NAMES (`Client::Capability`), not version numbers.** A
+  patched or backported server reports exactly what it has.
+- `serverInfo()` is **nullopt for a server older than 2.15.0** (it has no
+  `GetServerInfo`): such a server has none of the features introduced in 2.15.0
+  or later. It **throws** when the server cannot be asked - an outage is not "an
+  old server". The answer is cached for 60 s per `Client`; `serverInfo(true)`
+  asks now.
+- **The library checks for you.** A client method that needs a feature
+  introduced in 2.15.0 or later checks the server first and throws
+  `Client::FailedPrecondition`, reason `server_unsupported`, instead of sending
+  a request an older server would misread. Features from before 2.15.0 keep
+  their own guards (for example `similaritySearch` with filters:
+  `filters_unsupported`).
+- Every call carries the library's version in the `sbdb-client-version`
+  metadata, so a server can keep an old behaviour for an old client if a meaning
+  ever has to change. The server is additive-only otherwise: new fields and new
+  RPCs, never a changed meaning without a new feature name.
+- `smartbotic-db-cli server-info` prints the same answer.
+
+**Packaging:** `smartbotic-database` (server) and `libsmartbotic-db-client`
+(+ `-dev`, `smartbotic-db-cli`) no longer depend on each other, so upgrading one
+side leaves the other's installed version alone. Up to 2.14.0 the server package
+pinned the client library to its exact version, so on a host running the server
+the two always moved together.
+
 ### Document Operations
 ### Document Operations
 
 
 ```cpp
 ```cpp

+ 28 - 0
packaging/build.sh

@@ -47,6 +47,7 @@ NO_CACHE=0
 DO_REPO=0
 DO_REPO=0
 SUITE=""
 SUITE=""
 DO_SYNC=0
 DO_SYNC=0
+ONLY=all
 
 
 # ---------------------------------------------------------------------------
 # ---------------------------------------------------------------------------
 # Colored logging
 # Colored logging
@@ -77,6 +78,12 @@ Options:
   --repo               Add packages to local APT repository
   --repo               Add packages to local APT repository
   --suite NAME         Distribution suite (e.g., trixie)
   --suite NAME         Distribution suite (e.g., trixie)
   --sync               Add to repo and upload to repository.smartbotics.ai
   --sync               Add to repo and upload to repository.smartbotics.ai
+  --only SIDE          Package/publish only one side (default: all):
+                         client = libsmartbotic-db-client, -dev, smartbotic-db-cli
+                         server = smartbotic-database
+                       The two sides have no package dependency on each other
+                       (2.15.0+), so a client-only or server-only release leaves
+                       the other side's installed version alone.
 
 
 Environment variables:
 Environment variables:
   BUILD_JOBS           Parallel build jobs (default: nproc)
   BUILD_JOBS           Parallel build jobs (default: nproc)
@@ -105,6 +112,7 @@ while [[ $# -gt 0 ]]; do
         --repo)         DO_REPO=1; shift ;;
         --repo)         DO_REPO=1; shift ;;
         --suite)        SUITE="$2"; shift 2 ;;
         --suite)        SUITE="$2"; shift 2 ;;
         --sync)         DO_SYNC=1; shift ;;
         --sync)         DO_SYNC=1; shift ;;
+        --only)         ONLY="$2"; shift 2 ;;
         -h|--help)      usage ;;
         -h|--help)      usage ;;
         *)
         *)
             log_error "Unknown option: $1"
             log_error "Unknown option: $1"
@@ -129,6 +137,11 @@ if [[ $NO_PACKAGE -eq 1 && $INSTALL_AFTER -eq 1 ]]; then
     exit 1
     exit 1
 fi
 fi
 
 
+case "$ONLY" in
+    all|client|server) ;;
+    *) log_error "--only takes client, server or all (got '$ONLY')"; exit 1 ;;
+esac
+
 if [[ $DO_SYNC -eq 1 && $DO_REPO -eq 0 ]]; then
 if [[ $DO_SYNC -eq 1 && $DO_REPO -eq 0 ]]; then
     DO_REPO=1
     DO_REPO=1
 fi
 fi
@@ -361,6 +374,21 @@ fi
 shopt -s nullglob
 shopt -s nullglob
 BUILT_DEBS=("$OUTPUT_DIR"/*_"${VERSION}-${DEB_REVISION}"_*.deb)
 BUILT_DEBS=("$OUTPUT_DIR"/*_"${VERSION}-${DEB_REVISION}"_*.deb)
 shopt -u nullglob
 shopt -u nullglob
+# --only: a one-sided release publishes only that side's packages. The build
+# still produces all four (one CMake tree), the other side's are just not
+# staged.
+if [[ "$ONLY" != "all" ]]; then
+    SELECTED=()
+    for deb in "${BUILT_DEBS[@]}"; do
+        name="$(basename "$deb")"
+        if [[ "$name" == smartbotic-database_* ]]; then
+            [[ "$ONLY" == "server" ]] && SELECTED+=("$deb")
+        else
+            [[ "$ONLY" == "client" ]] && SELECTED+=("$deb")
+        fi
+    done
+    BUILT_DEBS=("${SELECTED[@]}")
+fi
 if [[ ${#BUILT_DEBS[@]} -eq 0 ]]; then
 if [[ ${#BUILT_DEBS[@]} -eq 0 ]]; then
     log_error "No ${VERSION}-${DEB_REVISION} .deb files found in $OUTPUT_DIR"
     log_error "No ${VERSION}-${DEB_REVISION} .deb files found in $OUTPUT_DIR"
     exit 1
     exit 1

+ 130 - 0
packaging/compat.sh

@@ -0,0 +1,130 @@
+#!/usr/bin/env bash
+#
+# packaging/compat.sh - mixed-version check against a RELEASED version, both ways.
+#
+#   packaging/compat.sh <old-version>        e.g. packaging/compat.sh 2.14.0
+#
+#   1. this tree's CLIENT against the released <old-version> SERVER
+#      (tests/load_test/test_server_info.cpp, phase `old`, plus `server-info`
+#      from this tree's CLI);
+#   2. the released <old-version> CLIENT (its CLI and library, from the .debs)
+#      against this tree's SERVER.
+#
+# Run it before every one-sided release (packaging/build.sh --only client|server):
+# the side you do not release stays at its old version on every host, so this
+# is the combination those hosts will actually run.
+#
+# Needs: docker, a built tree (packaging/dev.sh build), and the released .debs
+# in a smartbotics-deb-repo checkout ($DEB_REPO_DIR, default: next to this one).
+# Everything runs in throwaway containers on their own network namespaces.
+
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
+OLD="${1:?usage: packaging/compat.sh <old-version>}"
+DEB_REPO_DIR="${DEB_REPO_DIR:-$(dirname "$ROOT")/smartbotics-deb-repo}"
+POOL="$DEB_REPO_DIR/repo/pool/trixie/main"
+DEV_IMAGE="${BASE_IMAGE_NAME:-smartbotic-db-build-base:debian13}"
+REV="${DEB_REVISION:-1}"
+
+for p in smartbotic-database libsmartbotic-db-client smartbotic-db-cli; do
+    [[ -f "$POOL/${p}_${OLD}-${REV}_amd64.deb" ]] || {
+        echo "missing $POOL/${p}_${OLD}-${REV}_amd64.deb"; exit 1; }
+done
+[[ -x "$ROOT/build/service/smartbotic-database" ]] || {
+    echo "no build: run packaging/dev.sh build first"; exit 1; }
+
+WORK="$ROOT/build/compat"
+mkdir -p "$WORK"
+OLD_SRV=sbdb-compat-oldsrv
+NEW_SRV=sbdb-compat-newsrv
+cleanup() { docker rm -f "$OLD_SRV" "$NEW_SRV" >/dev/null 2>&1 || true; }
+trap cleanup EXIT
+cleanup
+
+cat > "$WORK/config.json" <<'CFG'
+{"storage":{"data_directory":"/tmp/sbdb-data","bind_address":"127.0.0.1","rpc_port":9030,
+ "encryption":{"enabled":false},"migrations":{"enabled":false},"replication":{"enabled":false}}}
+CFG
+
+wait_ready() {
+    for _ in $(seq 1 240); do
+        docker logs "$1" 2>&1 | grep -q "Notified systemd: READY" && return 0
+        docker inspect -f '{{.State.Running}}' "$1" 2>/dev/null | grep -q true || break
+        sleep 1
+    done
+    echo "server in $1 did not become ready:"; docker logs "$1" 2>&1 | tail -20; return 1
+}
+
+FAILED=0
+
+echo "=== 1. client $(cat "$ROOT/VERSION") (this tree) -> server $OLD (released) ==="
+docker run -d --name "$OLD_SRV" -v "$POOL:/pool:ro" -v "$WORK/config.json:/c.json:ro" \
+    debian:trixie bash -c "
+        apt-get update -qq >/dev/null &&
+        apt-get install -y -qq /pool/smartbotic-database_${OLD}-${REV}_amd64.deb \
+            /pool/libsmartbotic-db-client_${OLD}-${REV}_amd64.deb >/dev/null 2>&1 &&
+        exec smartbotic-database --config /c.json" >/dev/null
+wait_ready "$OLD_SRV"
+docker run --rm -u "$(id -u):$(id -g)" -e HOME=/tmp -v "$ROOT:$ROOT" -w "$ROOT" "$DEV_IMAGE" \
+    g++ -std=c++20 -O1 -o build/compat/t tests/load_test/test_server_info.cpp \
+        -Iclient/include -Ibuild/client -Lbuild/client -lsmartbotic-db-client -lspdlog -lfmt -pthread
+in_old_net() {
+    docker run --rm -u "$(id -u):$(id -g)" -e HOME=/tmp --network "container:$OLD_SRV" \
+        -v "$ROOT:$ROOT" -w "$ROOT" -e LD_LIBRARY_PATH="$ROOT/build/client" "$DEV_IMAGE" "$@"
+}
+in_old_net build/compat/t old 127.0.0.1:9030 2>&1 | grep -v '\[error\]\|\[info\]' || FAILED=1
+in_old_net build/cli/smartbotic-db-cli --address 127.0.0.1:9030 server-info 2>&1 | grep -v '\[info\]' \
+    | tee "$WORK/server-info-old.txt"
+grep -q "predates 2.15.0" "$WORK/server-info-old.txt" || {
+    # A released server new enough to answer is fine too; it must name itself.
+    grep -q "server:   $OLD" "$WORK/server-info-old.txt" || { echo "FAIL: server-info"; FAILED=1; }
+}
+docker rm -f "$OLD_SRV" >/dev/null
+
+echo ""
+echo "=== 2. client $OLD (released) -> server $(cat "$ROOT/VERSION") (this tree) ==="
+docker run -d --name "$NEW_SRV" -u "$(id -u):$(id -g)" -e HOME=/tmp -v "$ROOT:$ROOT" -w "$ROOT" \
+    -v "$WORK/config.json:/c.json:ro" "$DEV_IMAGE" \
+    build/service/smartbotic-database --config /c.json >/dev/null
+wait_ready "$NEW_SRV"
+cat > "$WORK/old-client.sh" <<'EOS'
+#!/usr/bin/env bash
+# Inside debian:trixie: the released CLI and library against this tree's server.
+set -u
+apt-get update -qq >/dev/null
+apt-get install -y -qq "/pool/libsmartbotic-db-client_${OLD}-${REV}_amd64.deb" \
+    "/pool/smartbotic-db-cli_${OLD}-${REV}_amd64.deb" >/dev/null 2>&1 || { echo "FAIL: install"; exit 1; }
+# CLI packages before 2.15.0 did not declare liblmdb0 / libssl3t64, so alone
+# (without the server package) the CLI could not start. Say so, then supply
+# them so the protocol check below still means something.
+if ! smartbotic-db-cli --version >/dev/null 2>&1; then
+    echo "note: the released $OLD CLI does not start on its own (undeclared libraries); installing them"
+    apt-get install -y -qq liblmdb0 libssl3t64 >/dev/null 2>&1
+fi
+fail=0
+# The command's own exit code decides; output is kept for the grep checks.
+cli() { smartbotic-db-cli --address 127.0.0.1:9030 --project compat "$@" > /tmp/out 2>&1; }
+check() { if eval "$2"; then echo "ok   $1"; else echo "FAIL $1"; sed 's/^/     /' /tmp/out | tail -3; fail=1; fi; }
+smartbotic-db-cli --version | head -2
+check "upsert"       'cli upsert things t1 "{\"k\":\"a\",\"n\":1}"'
+check "get"          'cli get things t1 && grep -q "\"k\"" /tmp/out'
+check "find --eq"    'cli find things --eq k a && grep -q t1 /tmp/out'
+check "count"        'cli count things && grep -q 1 /tmp/out'
+check "index-create" 'cli index-create things k'
+check "indexes"      'cli indexes things && grep -q "k " /tmp/out'
+check "collections"  'cli collections && grep -q things /tmp/out'
+check "remove"       'cli remove things t1'
+check "count after"  'cli count things && grep -q 0 /tmp/out'
+check "status"       'cli status && grep -qi "read-only" /tmp/out'
+exit $fail
+EOS
+chmod +x "$WORK/old-client.sh"
+docker run --rm --network "container:$NEW_SRV" -e OLD="$OLD" -e REV="$REV" \
+    -v "$POOL:/pool:ro" -v "$WORK/old-client.sh:/old-client.sh:ro" debian:trixie bash /old-client.sh \
+    || FAILED=1
+
+echo ""
+if [[ $FAILED -ne 0 ]]; then echo "COMPAT FAILED against $OLD"; exit 1; fi
+echo "OK - compatible with $OLD in both directions"

+ 1 - 1
packaging/deb/templates/control.cli

@@ -9,5 +9,5 @@ Homepage: https://smartbotics.ai
 Section: contrib/utils
 Section: contrib/utils
 Priority: optional
 Priority: optional
 License: proprietary
 License: proprietary
-Depends: libsmartbotic-db-client (>= {{VERSION}})
+Depends: libsmartbotic-db-client (>= {{VERSION}}), liblmdb0, libssl3t64
 Installed-Size: {{INSTALLED_SIZE}}
 Installed-Size: {{INSTALLED_SIZE}}

+ 1 - 1
packaging/deb/templates/control.server

@@ -14,5 +14,5 @@ License: proprietary
 Provides: shadowman-database, callerai-storage
 Provides: shadowman-database, callerai-storage
 Conflicts: shadowman-database, callerai-storage
 Conflicts: shadowman-database, callerai-storage
 Replaces: shadowman-database, callerai-storage
 Replaces: shadowman-database, callerai-storage
-Depends: adduser, libsmartbotic-db-client (= {{VERSION}}), libssl3t64, liblz4-1, libsystemd0, libjemalloc2, libyyjson0, liblmdb0
+Depends: adduser, libprotobuf32t64, libgrpc++1.51t64, libspdlog1.15, libfmt10, libssl3t64, liblz4-1, libsystemd0, libjemalloc2, libyyjson0, liblmdb0
 Installed-Size: {{INSTALLED_SIZE}}
 Installed-Size: {{INSTALLED_SIZE}}

+ 26 - 0
proto/database.proto

@@ -157,6 +157,10 @@ service DatabaseService {
 
 
     // Health and stats
     // Health and stats
     rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse);
     rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse);
+    // v2.15.0 - what this server is and which features it has, so a client can
+    // refuse a call the server would misunderstand instead of sending it. A
+    // pre-2.15.0 server answers UNIMPLEMENTED.
+    rpc GetServerInfo(GetServerInfoRequest) returns (GetServerInfoResponse);
     rpc GetStats(GetStatsRequest) returns (GetStatsResponse);
     rpc GetStats(GetStatsRequest) returns (GetStatsResponse);
     rpc GetMemoryStats(GetMemoryStatsRequest) returns (GetMemoryStatsResponse);
     rpc GetMemoryStats(GetMemoryStatsRequest) returns (GetMemoryStatsResponse);
 
 
@@ -995,6 +999,28 @@ message NodeState {
 message HealthCheckRequest {
 message HealthCheckRequest {
 }
 }
 
 
+// v2.15.0 - capability negotiation.
+//
+// `capabilities` names features, not versions: a client gates a feature on its
+// NAME being present, so a patched or backported server reports exactly what it
+// can do. Names are stable forever and never reused; a feature that changes
+// meaning gets a new name. The list a server sends is in
+// service/src/server_capabilities.hpp.
+//
+// Clients send their own library version in the request metadata key
+// `sbdb-client-version` on every call, so a server can keep an old behaviour
+// for an old client if a meaning ever has to change. `client_version` echoes
+// what this call carried (empty if none).
+message GetServerInfoRequest {
+}
+
+message GetServerInfoResponse {
+    string version = 1;                // e.g. "2.15.0"
+    string commit = 2;                 // short git commit, or "unknown"
+    repeated string capabilities = 3;
+    string client_version = 4;
+}
+
 message HealthCheckResponse {
 message HealthCheckResponse {
     bool healthy = 1;
     bool healthy = 1;
     uint64 uptime_seconds = 2;
     uint64 uptime_seconds = 2;

+ 7 - 5
service/CMakeLists.txt

@@ -93,11 +93,13 @@ target_compile_definitions(smartbotic-database PRIVATE
 )
 )
 
 
 # Link dependencies
 # Link dependencies
-if(BUILD_SHARED_LIBS)
-    target_link_libraries(smartbotic-database PRIVATE smartbotic-db-client)
-else()
-    target_link_libraries(smartbotic-database PRIVATE smartbotic_db_proto)
-endif()
+# v2.15.0 - the server links the generated protobuf/gRPC code directly, never
+# the client library. It uses none of the client's code; it linked the shared
+# library only because that is where the proto objects were compiled, and the
+# result was an exact package dependency (smartbotic-database Depends on
+# libsmartbotic-db-client (= VERSION)) that made a client-only release
+# impossible on any host running the server.
+target_link_libraries(smartbotic-database PRIVATE smartbotic_db_proto)
 target_link_libraries(smartbotic-database PRIVATE
 target_link_libraries(smartbotic-database PRIVATE
     OpenSSL::SSL
     OpenSSL::SSL
     OpenSSL::Crypto
     OpenSSL::Crypto

+ 25 - 0
service/src/database_grpc_impl.cpp

@@ -1,4 +1,12 @@
 #include "database_grpc_impl.hpp"
 #include "database_grpc_impl.hpp"
+#include "server_capabilities.hpp"
+
+#ifndef SMARTBOTIC_DB_VERSION_STRING
+#define SMARTBOTIC_DB_VERSION_STRING "unknown"
+#endif
+#ifndef SMARTBOTIC_DB_GIT_COMMIT_STRING
+#define SMARTBOTIC_DB_GIT_COMMIT_STRING "unknown"
+#endif
 #include "database_service.hpp"
 #include "database_service.hpp"
 #include "project_addressing.hpp"
 #include "project_addressing.hpp"
 #include "storage/cosine_simd.hpp"
 #include "storage/cosine_simd.hpp"
@@ -3139,6 +3147,23 @@ grpc::Status DatabaseGrpcImpl::HealthCheck(
     return grpc::Status::OK;
     return grpc::Status::OK;
 }
 }
 
 
+grpc::Status DatabaseGrpcImpl::GetServerInfo(
+    grpc::ServerContext* context,
+    const pb::GetServerInfoRequest* /*request*/,
+    pb::GetServerInfoResponse* response
+) {
+    response->set_version(SMARTBOTIC_DB_VERSION_STRING);
+    response->set_commit(SMARTBOTIC_DB_GIT_COMMIT_STRING);
+    for (const auto& cap : smartbotic::database::kServerCapabilities) {
+        response->add_capabilities(std::string(cap));
+    }
+    const auto& md = context->client_metadata();
+    if (auto it = md.find("sbdb-client-version"); it != md.end()) {
+        response->set_client_version(std::string(it->second.data(), it->second.size()));
+    }
+    return grpc::Status::OK;
+}
+
 grpc::Status DatabaseGrpcImpl::GetStats(
 grpc::Status DatabaseGrpcImpl::GetStats(
     grpc::ServerContext* context,
     grpc::ServerContext* context,
     const pb::GetStatsRequest* /*request*/,
     const pb::GetStatsRequest* /*request*/,

+ 8 - 0
service/src/database_grpc_impl.hpp

@@ -421,6 +421,14 @@ public:
         pb::HealthCheckResponse* response
         pb::HealthCheckResponse* response
     ) override;
     ) override;
 
 
+    // v2.15.0 - version, commit and feature names (server_capabilities.hpp).
+    // Open like HealthCheck: a client asks before it knows what it may call.
+    grpc::Status GetServerInfo(
+        grpc::ServerContext* context,
+        const pb::GetServerInfoRequest* request,
+        pb::GetServerInfoResponse* response
+    ) override;
+
     grpc::Status GetStats(
     grpc::Status GetStats(
         grpc::ServerContext* context,
         grpc::ServerContext* context,
         const pb::GetStatsRequest* request,
         const pb::GetStatsRequest* request,

+ 45 - 0
service/src/server_capabilities.hpp

@@ -0,0 +1,45 @@
+// v2.15.0 - the feature names this server reports in GetServerInfo.
+//
+// A client gates a feature on its NAME, never on a version number, so a
+// backported or patched server can say exactly what it supports. Rules:
+//   - a name is never removed while the feature exists, and never reused;
+//   - a feature whose meaning changes gets a NEW name (the old one goes when the
+//     old meaning goes);
+//   - the client keeps the same names in client.hpp (Client::Capability) - add a
+//     name to both in the same change.
+// Features from before 2.15.0 are listed so the answer is complete; a client
+// talking to a pre-2.15.0 server gets UNIMPLEMENTED and must assume none of the
+// names introduced in 2.15.0 or later.
+
+#pragma once
+
+#include <array>
+#include <string_view>
+
+namespace smartbotic::database {
+
+inline constexpr std::array<std::string_view, 21> kServerCapabilities = {
+    "projects",              // 2.3.0  <project>:<collection> namespaces
+    "access_policy",         // 2.7.0  row/column security
+    "query_projection",      // 2.7.1  FindRequest.projection
+    "file_ttl",              // 2.8.0  file expiry, SetFileTtl
+    "document_ttl_update",   // 2.8.0  ttl_seconds on Update/PatchDocument
+    "secondary_indexes",     // 2.9.0  CreateIndex/DropIndex/ListIndexes
+    "index_values",          // 2.10.0 GetIndexValues
+    "relations",             // 2.11.0 referential integrity, DescribeDelete
+    "unique_indexes",        // 2.11.0 enforced unique constraints
+    "error_detail",          // 2.12.0 sbdb-error-detail-bin trailer, in-band codes
+    "patch_if_version",      // 2.12.0 PatchDocumentRequest.expected_version
+    "increment",             // 2.12.0 PatchDocumentRequest.increments_json
+    "composite_unique",      // 2.12.0 multi-field unique constraints
+    "batch_delete_ids",      // 2.12.0 BatchDeleteResponse.deleted_ids
+    "event_actor",           // 2.12.0 actor on DatabaseEvent / Delete
+    "vector_readback",       // 2.13.0 include_vector on Get/Find
+    "export_collection",     // 2.13.0 ExportCollection stream
+    "write_size_guard",      // 2.13.1 document_too_large refusals
+    "filtered_similarity",   // 2.14.0 SimilaritySearchRequest.filters
+    "server_info",           // 2.15.0 GetServerInfo itself
+    "client_version_header", // 2.15.0 the server reads sbdb-client-version
+};
+
+}  // namespace smartbotic::database

+ 134 - 0
tests/load_test/test_server_info.cpp

@@ -0,0 +1,134 @@
+// v2.15.0 client/server boundary test: capability negotiation.
+//
+// A client must be able to ask what the server is and which features it has,
+// so a client-only release can refuse a call an older server would misread
+// instead of sending it. Phases, run by test_server_info.sh (and, against
+// released servers, by packaging/compat.sh):
+//   current <version>  - against this tree's server: version, commit, the
+//                        feature list (every name the client knows is
+//                        reported), the version header arrives, caching.
+//   old <addr>         - against a pre-2.15.0 server: serverInfo() is nullopt,
+//                        serverSupports() is false, ordinary calls still work,
+//                        a filtered similaritySearch is refused.
+//   down               - server stopped: serverInfo() THROWS (an outage is not
+//                        "an old server").
+
+#include <smartbotic/database/client.hpp>
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+using namespace smartbotic::database;
+using Cap = Client::Capability;
+static int pass = 0, fail = 0;
+static void ck(bool c, const std::string& m) {
+    if (c) { ++pass; } else { ++fail; std::cerr << "FAIL: " << m << "\n"; }
+}
+
+static std::string gAddr = "127.0.0.1:9027";
+
+static Client::Config cfg() {
+    Client::Config c;
+    c.address = gAddr;
+    c.project = "si";
+    c.timeoutMs = 3000;
+    return c;
+}
+
+static const std::vector<const char*> kAllCaps = {
+    Cap::kProjects, Cap::kAccessPolicy, Cap::kQueryProjection, Cap::kFileTtl,
+    Cap::kDocumentTtlUpdate, Cap::kSecondaryIndexes, Cap::kIndexValues, Cap::kRelations,
+    Cap::kUniqueIndexes, Cap::kErrorDetail, Cap::kPatchIfVersion, Cap::kIncrement,
+    Cap::kCompositeUnique, Cap::kBatchDeleteIds, Cap::kEventActor, Cap::kVectorReadback,
+    Cap::kExportCollection, Cap::kWriteSizeGuard, Cap::kFilteredSimilarity, Cap::kServerInfo,
+    Cap::kClientVersionHeader,
+};
+
+// Ordinary calls a client of any version makes; they must work across versions.
+static void basics(Client& c, const std::string& tag) {
+    c.createCollection("v", 0, false, 0, 4);
+    const auto id = c.insert("v", {{"k", "a"}, {"_vector", std::vector<float>{1, 0, 0, 0}}});
+    ck(!id.empty(), tag + ": insert");
+    const auto got = c.get("v", id);
+    ck(got && got->value("k", "") == "a", tag + ": get");
+    Client::QueryOptions o;
+    o.filters = {Client::Filter::eq("k", "a")};
+    ck(!c.find("v", o).empty(), tag + ": find");
+    ck(!c.similaritySearch("v", {1, 0, 0, 0}, 3).empty(), tag + ": plain similaritySearch");
+    ck(c.remove("v", id), tag + ": remove");
+}
+
+static int current(const std::string& version) {
+    Client c(cfg());
+    ck(c.connect(), "connect");
+    const auto si = c.serverInfo();
+    ck(si.has_value(), "serverInfo answers");
+    if (!si) return 0;
+    ck(si->version == version, "version is " + version + " (got '" + si->version + "')");
+    ck(!si->commit.empty(), "commit is set ('" + si->commit + "')");
+    ck(si->clientVersionSeen == clientLibraryVersion(),
+       "the server received this library's version (" + si->clientVersionSeen + ")");
+    for (const char* cap : kAllCaps) {
+        ck(c.serverSupports(cap), std::string("server reports '") + cap + "'");
+    }
+    ck(si->capabilities.size() == kAllCaps.size(),
+       "client and server know the same feature names (" +
+           std::to_string(si->capabilities.size()) + " vs " + std::to_string(kAllCaps.size()) + ")");
+    ck(!c.serverSupports("no_such_feature"), "an unknown name is not supported");
+    ck(c.serverInfo(true).has_value(), "refresh answers too");
+    basics(c, "current");
+    const auto f = c.similaritySearch("v", {1, 0, 0, 0}, 3, -1.f, {Client::Filter::eq("k", "zz")});
+    ck(f.empty(), "filtered similaritySearch works against a server that has it");
+    return 0;
+}
+
+static int old() {
+    Client c(cfg());
+    ck(c.connect(), "old: connect");
+    bool threw = false;
+    std::optional<Client::ServerInfo> si;
+    try { si = c.serverInfo(); } catch (...) { threw = true; }
+    ck(!threw && !si.has_value(), "old: serverInfo is nullopt, not an error");
+    ck(!c.serverSupports(Cap::kServerInfo), "old: serverSupports is false");
+    basics(c, "old");
+    // A pre-2.14.0 server would answer a filtered search UNFILTERED; a 2.14.0
+    // one applies it. Either way the answer must never be unfiltered rows.
+    c.createCollection("w", 0, false, 0, 4);
+    c.insert("w", {{"k", "a"}, {"_vector", std::vector<float>{1, 0, 0, 0}}});
+    bool refused = false;
+    std::vector<Client::SimilarityResult> r;
+    try {
+        r = c.similaritySearch("w", {1, 0, 0, 0}, 3, -1.f, {Client::Filter::eq("k", "zz")});
+    } catch (const Client::FailedPrecondition& e) {
+        const auto* d = Client::errorDetail(e);
+        refused = d && d->reason == "filters_unsupported";
+    }
+    ck(refused || r.empty(), "old: a filtered search is refused or really filtered, never unfiltered");
+    return 0;
+}
+
+static int down() {
+    Client c(cfg());
+    c.connect();
+    bool threwUnavailable = false;
+    try {
+        (void)c.serverInfo(true);
+    } catch (const Client::Error& e) {
+        threwUnavailable = e.code() == Client::ErrorCode::Unavailable ||
+                           e.code() == Client::ErrorCode::DeadlineExceeded;
+    }
+    ck(threwUnavailable, "down: serverInfo throws, it does not claim an old server");
+    return 0;
+}
+
+int main(int argc, char** argv) {
+    const std::string phase = argc > 1 ? argv[1] : "";
+    if (argc > 3) gAddr = argv[3];
+    if (phase == "current" && argc > 2) current(argv[2]);
+    else if (phase == "old") { if (argc > 2) gAddr = argv[2]; old(); }
+    else if (phase == "down") down();
+    else { std::cerr << "usage: current <version> [addr] | old [addr] | down\n"; return 2; }
+    std::cout << phase << ": " << pass << " passed, " << fail << " failed\n";
+    return fail == 0 ? 0 : 1;
+}

+ 70 - 0
tests/load_test/test_server_info.sh

@@ -0,0 +1,70 @@
+#!/usr/bin/env bash
+# v2.15.0 client/server boundary e2e - capability negotiation (GetServerInfo,
+# the client version header). Against RELEASED servers and clients in both
+# directions, see packaging/compat.sh.
+
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
+cd "$SCRIPT_DIR"
+
+DIR=/tmp/sbdb-server-info
+PORT=9027
+
+rm -rf "$DIR"
+mkdir -p "$DIR/data"
+
+cat > "$DIR/config.json" <<CFG
+{
+  "storage": {
+    "data_directory": "$DIR/data",
+    "bind_address": "127.0.0.1",
+    "rpc_port": $PORT,
+    "encryption": { "enabled": false },
+    "migrations": { "enabled": false },
+    "replication": { "enabled": false }
+  }
+}
+CFG
+
+echo "=== building test binary ==="
+g++ -std=c++20 -O1 -o "$DIR/t" test_server_info.cpp \
+    -I"$ROOT/client/include" -I"$ROOT/build/client" \
+    -L"$ROOT/build/client" -lsmartbotic-db-client -lspdlog -lfmt -pthread
+
+SERVER_PID=""
+stop() {
+    [[ -n "$SERVER_PID" ]] || return 0
+    kill -CONT "$SERVER_PID" 2>/dev/null || true
+    kill "$SERVER_PID" 2>/dev/null || true
+    wait "$SERVER_PID" 2>/dev/null || true
+    SERVER_PID=""
+}
+trap stop EXIT
+
+"$ROOT/build/service/smartbotic-database" --config "$DIR/config.json" > "$DIR/server.log" 2>&1 &
+SERVER_PID=$!
+for _ in $(seq 1 60); do
+    grep -q "Notified systemd: READY" "$DIR/server.log" && break
+    sleep 0.5
+done
+grep -q "Notified systemd: READY" "$DIR/server.log" || { tail -30 "$DIR/server.log"; exit 1; }
+
+run() {
+    set +e
+    LD_LIBRARY_PATH="$ROOT/build/client" "$DIR/t" "$@" 2>&1 | grep -v '\[error\]' | tee "$DIR/out-$1.txt"
+    local rc=${PIPESTATUS[0]}
+    set -e
+    [[ $rc -eq 0 ]] || { echo "FAILED in phase $1"; exit $rc; }
+}
+
+echo "=== current ==="
+run current "$(cat "$ROOT/VERSION")"
+
+echo "=== down ==="
+stop
+run down
+
+echo ""
+echo "OK - server info e2e passed"

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác