This restructure upgrades alibaba/tair-kvcache from a single-component kv_cache_manager repository into a multi-component Tair KVCache workspace (src/master, src/common, src/server, src/client), while decoupling third-party dependencies and extension injection. The existing open-source scope and public service/client APIs remain unchanged; this change focuses strictly on directory layout and build-extension decoupling.
Previously, kv_cache_manager/ lived directly at the repository root and mixed global metadata service (Master) code with client SDKs and engine connectors. As Tair KVCache evolves into a full distributed KVCache system spanning shared libraries, Master, storage Server, and unified Client:
- Multi-component layering was missing: top-level directories for shared
common,server, andclientcomponents were not yet established. - Build extension coupling: switching between default open-source stubs and external extensions previously relied on toggling a tracked symlink inside the repository, which easily left working trees dirty and coupled dependency mirrors with code extensions.
This restructure flattens the Master components directly under src/master/ in one step (avoiding a second move later), while keeping client SDKs and Python connectors under kv_cache_manager/ until the future src/client/ migration so downstream RPMs and Python wheels remain 100% compatible.
| Before | After | Notes |
|---|---|---|
kv_cache_manager/{BUILD,main.cpp,common,config,data_storage,event,manager,meta,metrics,optimizer,protocol,service} |
src/master/... |
Flattened directly into src/master/ via git mv to preserve full Git history; C++ includes updated to #include "src/master/..." with no strip_include_prefix or -iquote shims required |
kv_cache_manager/{client,client_java,manager_client,py_connector} |
kv_cache_manager/{client,client_java,manager_client,py_connector} (unchanged for now) |
Kept in place to avoid moving client packages twice and to preserve full downstream compatibility for import kv_cache_manager.* wheels and client RPMs; will migrate to src/client/ in a dedicated follow-up |
| (none) | src/common/ |
Reserved for shared cross-component libraries (utilities, protocols, observability) |
| (none) | src/server/ |
Reserved for the distributed cache storage server to be open-sourced |
| (none) | src/client/ |
Reserved for the unified cache client |
open_source/kv_cache_manager/ |
open_source/src/{master,common,client}/ |
Default open-source stubs aligned with the src/ layout |
WORKSPACE is the independent build entry point, using Bazel 6.4.0. Public recipes remain in open_source/deps/, adapters and sources in 3rdparty/, existing patches in patches/, and shared macros in bazel/. Building and using this project directly requires only the included defaults; no separate assembly project is needed.
For custom features or extensions, a separate extension project can register a pinned checkout in its own WORKSPACE, declare additional dependencies and select implementations through label flags. This repository supplies the interfaces and defaults without reading the extension project's directories, rules or parent configuration.
Storage, SDK, discovery, metrics and process lifecycle hooks use this boundary. See Build dependencies and Process extensions for configuration examples.
.github/workflows/and.github/CODEOWNERShave been updated to cover bothsrc/master/andkv_cache_manager/.README.md,README_zh.md,docs/,package/,tools/, andintegration_test/build targets and paths have been updated.
- Service APIs & protocols: MetaService, AdminService, and DebugService RPC/HTTP contracts (
kv_cache_manager.proto.*) and configuration semantics are unchanged. - C++ namespaces: existing sources and public APIs retain
kv_cache_manager. A custom product that needs different API names can provide a facade in its extension project. - C++ Client RPM & Python wheels:
kv-cache-manager-clientRPM continues to install public headers underinclude/kv_cache_manager/*.h;kvcm_vllm_connector,kvcm_sglang_connector,tair-kvcache-manager-client, andkvcm_py_clientwheels retain their existingimport kv_cache_manager.*package names and public APIs.
| Task | Before | After |
|---|---|---|
| Master C++ includes | #include "kv_cache_manager/manager/..." |
#include "src/master/manager/..." |
| Client C++ includes | #include "kv_cache_manager/client/..." |
#include "kv_cache_manager/client/..." (unchanged) |
| Build Master binary | bazelisk build //kv_cache_manager:main |
bazelisk build //src/master:main |
| Build all Master targets | bazelisk build //kv_cache_manager/... |
bazelisk build //src/master/... |
| Run all unit tests | bazelisk test //kv_cache_manager/... |
bazelisk test //src/master/... //kv_cache_manager/... |
| Build Python client / connector wheels | bazelisk build //kv_cache_manager/manager_client:... |
bazelisk build //kv_cache_manager/manager_client:... (unchanged) |
| In-repo Python protobuf / optimizer imports | from kv_cache_manager.protocol.protobuf import ... |
from src.master.protocol.protobuf import ... |
Because the directory relocation is isolated in a pure git mv commit, Git automatically follows renames for most modified files:
git fetch origin
git rebase origin/main- Modified Master files: Git will typically transplant edits from
kv_cache_manager/{service,manager,meta,...}tosrc/master/{service,manager,meta,...}automatically; update any newly added#include "kv_cache_manager/<master_subdir>/..."lines to#include "src/master/<master_subdir>/...". - Newly added Master files: move any new files created under old Master directories to
src/master/...and update theirBUILDlabels. - Client /
py_connector/manager_clientfiles: remain underkv_cache_manager/; only update references to Mastercommon/protocolheaders or Bazel targets tosrc/master/....
# Build all public Master and Client/Connector targets
bazelisk build //src/master/... //kv_cache_manager/...
# Run core unit tests
bazelisk test \
//src/master/metrics/test:MetricsRegistryTest \
//src/master/metrics/test:MetricsReporterFactoryTest \
//kv_cache_manager/manager_client:all \
//kv_cache_manager/py_connector/test:test_service_discovery_factory