story: DGR-037 Bind llama.cpp to the standalone worker

This commit is contained in:
Dobromir Popov
2026-08-01 01:28:06 +03:00
parent dfa403adc6
commit 8217b4c4a2
9 changed files with 482 additions and 54 deletions

View File

@@ -62,20 +62,28 @@ message(STATUS "Pinned gRPC ${gRPC_VERSION}: building ShardRuntime service stubs
enable_testing()
# The standalone fake Shard worker (DGR-033): a real gRPC server over the
# ShardRuntime service, backed by the model-free FakeShardEngine. It links the
# grpc service stubs only — no llama.cpp, no graph-execution entry point.
# DGR-037: the standalone worker owns exactly one loaded llama.cpp artifact.
# Its implementation types stay in worker/llama_shard_engine.cpp; the gRPC
# service receives only the project-owned ShardEngine surface.
set(MESHNET_LLAMA_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../../build/llama.cpp/source" CACHE PATH
"Applied pinned llama.cpp source directory")
set(MESHNET_LLAMA_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/../../../build/llama.cpp/build/bin" CACHE PATH
"Directory containing the matching applied-patch libllama")
find_path(MESHNET_LLAMA_INCLUDE_DIR llama.h PATHS "${MESHNET_LLAMA_SOURCE_DIR}/include" NO_DEFAULT_PATH REQUIRED)
find_path(MESHNET_LLAMA_GGML_INCLUDE_DIR ggml.h PATHS "${MESHNET_LLAMA_SOURCE_DIR}/ggml/include" NO_DEFAULT_PATH REQUIRED)
find_library(MESHNET_LLAMA_LIBRARY NAMES llama PATHS "${MESHNET_LLAMA_LIBRARY_DIR}" NO_DEFAULT_PATH REQUIRED)
add_executable(shard_worker
worker/shard_worker_main.cpp
worker/shard_service.cpp)
target_include_directories(shard_worker PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/worker")
target_link_libraries(shard_worker PRIVATE shard_runtime_grpc gRPC::grpc++)
worker/shard_service.cpp
worker/llama_shard_engine.cpp)
target_include_directories(shard_worker PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/worker" "${MESHNET_LLAMA_INCLUDE_DIR}" "${MESHNET_LLAMA_GGML_INCLUDE_DIR}")
target_link_libraries(shard_worker PRIVATE shard_runtime_grpc gRPC::grpc++ "${MESHNET_LLAMA_LIBRARY}")
set_target_properties(shard_worker PROPERTIES BUILD_RPATH "${MESHNET_LLAMA_LIBRARY_DIR}")
# Pure-C++ CTest: the worker binds an ephemeral port, self-drives the full
# lifecycle (capability, health, fragmented prefill, decode, release) over a
# real loopback gRPC channel, and exits non-zero on any mismatch. This proves
# the worker serves the contract without needing a Python environment.
add_test(NAME shard_worker_selftest COMMAND shard_worker --selftest)
add_executable(shard_protocol_conformance tests/test_shard_protocol_conformance.cpp)
target_link_libraries(shard_protocol_conformance PRIVATE shard_runtime_proto)