Conversation
Co-authored-by: makr-code <150588092+makr-code@users.noreply.github.com>
|
@copilot Review und Code Audit. Wurden alle Aufgaben des issue erfüllt? |
|
@copilot retry |
Alle vier Akzeptanzkriterien des Issues sind erfüllt. Hier das vollständige Audit-Ergebnis: AC1 — AC2 — RocksDB-Persistence-Block aktiviert; StorageEngine injiziert ✅ AC3 — AC4 — JWT-User-Context in Tests: 6 neue Tests in 3 Fixtures decken alle ACs ab ( Commit: |
There was a problem hiding this comment.
Pull request overview
This PR completes the planned RocksDB persistence integration for LLMDeploymentPlugin, propagates authenticated user identity into audit entries, and hardens local source selection by verifying on-disk model presence before choosing a "local" source.
Changes:
- Enable and wire
LLMModelStorageinLLMDeploymentPluginand persist metadata after successful deploys. - Replace hardcoded audit user
"system"withTaskScheduler::currentUserId()and add local-source existence validation infindBestSource(). - Add unit tests for RocksDB persistence, audit user propagation, and source selection; introduce a focused CI workflow for these tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/llm/llm_deployment_plugin.cpp |
Enables RocksDB-backed storage, switches audit user source, adds local source validation, and refactors model-id-to-filename logic. |
include/llm/llm_deployment_plugin.h |
Includes llm_model_storage.h directly and updates default collection_name; declares modelIdToFilename(). |
include/llm/llm_model_storage.h |
Updates default collection_name to align with the llm_model::{model_id} keyspace. |
tests/llm/test_llm_deployment_plugin.cpp |
Adds tests for persistence, audit user context, and local-source selection behavior. |
.github/workflows/02-feature-modules/llm/llm-deployment-rocksdb-ci.yml |
Adds a CI workflow to build and run the new/updated LLM deployment plugin tests. |
src/llm/FUTURE_ENHANCEMENTS.md |
Marks the corresponding enhancement items as completed. |
You can also share your feedback on Copilot code review. Take the survey.
| bool use_base_entity_storage = true; // Store models in RocksDB as BaseEntity | ||
| std::shared_ptr<RocksDBWrapper> db; // RocksDB instance | ||
| std::string collection_name = "llm_models"; // Collection name in RocksDB | ||
| std::string collection_name = "llm_model:"; // Collection name prefix in RocksDB (keys: llm_model::{model_id}) |
| DeploymentConfig config; | ||
| config.mode = DeploymentMode::OFFLINE; | ||
| config.cache_directory = test_dir_ + "/cache"; | ||
| config.enable_audit_log = false; | ||
| config.verify_checksums = false; |
| } | ||
|
|
||
| DeploymentConfig config; | ||
| config.mode = DeploymentMode::OFFLINE; |
| run: | | ||
| cd build | ||
| ctest --output-on-failure -R "LlmDeploymentPlugin" |
| @@ -280,7 +275,6 @@ std::optional<ModelStatus> LLMDeploymentPlugin::deployModel(const std::string& m | |||
| LOG_WARN("Failed to store model metadata in RocksDB: {}", model_id); | |||
| } | |||
| } | |||
|
|
||
| // Collection settings | ||
| std::string collection_name = "llm_models"; | ||
| std::string collection_name = "llm_model:"; // Key prefix: llm_model::{model_id} |
LLMDeploymentPluginwas silently dropping model metadata on every restart because the RocksDB persistence path was commented out pendingllm_model_storage.cpp. Audit entries hardcoded"system"instead of the authenticated caller, andfindBestSource()never validated whether a local source actually contained the requested model.Description
Storage Integration
llm_deployment_plugin.h; the header now#includesllm_model_storage.hdirectly.collection_namechanged from"llm_models"→"llm_model:"in bothDeploymentConfigandLLMModelStorage::Config— keys now follow thellm_model::{model_id}prefix convention.model_storage_(previously commented out) whenuse_base_entity_storage=trueand a validdbis provided.deployModel()callssaveModelToStorage()after each successful deploy — metadata is persisted to RocksDB alongside the filesystem registry.JWT User Context Propagation
All three
audit.user = "system"hardcodings replaced withscheduler::TaskScheduler::currentUserId(), which reads the TLS request context set by the HTTP handler from the validated JWT claims:Local Source Existence Check
findBestSource()now validates"local"sources before selecting them — if the expected model file is absent in the configured directory, the source is skipped and the next lower-priority source is tried. Non-local sources (Ollama, HTTP) pass through unconditionally. A safe final fallback returns the highest-priority source so remote downloads still work.Refactoring
Extracted
static std::string modelIdToFilename(const std::string& model_id)to eliminate the duplicated sanitisation logic (':'/'/'→'_',.gguffallback extension) that previously existed independently in bothgetModelPath()andfindBestSource().Audit (Code Review)
A full audit confirmed all four acceptance criteria from the issue are fulfilled:
src/llm/llm_model_storage.cpp(996 lines) providesstoreModel()andloadModel()using thellm_model::{model_id}key prefix viaRocksDBWrapper.model_storage_viaconfig_.db;deployModel()persists metadata at lines 270–277.findBestSource()(lines 909–923) validates local file existence, skips missing files, and falls back to the next source.audit.userassignments usescheduler::TaskScheduler::currentUserId()(lines 171, 489, 514). No"system"hardcoding remains.src/llm/FUTURE_ENHANCEMENTS.mdupdated: all 4 items marked[x].Type of Change
Testing
6 new tests across 3 fixtures in
tests/llm/test_llm_deployment_plugin.cpp:LLMDeploymentPluginRocksDBTest— deploy with RocksDB enabled verifies metadata is readable viaLLMModelStorage::exists()andloadModel(); storage-disabled path verifies nothing is written.LLMDeploymentPluginAuditUserTest— no TLS context →"system";TaskScheduler::setRequestContext({"alice@example.com", …})→"alice@example.com"in audit log.LLMDeploymentPluginSourceTest— missing local source is skipped and fallback source used; present local file is selected correctly.New CI workflow:
.github/workflows/02-feature-modules/llm/llm-deployment-rocksdb-ci.yml.📚 Research & Knowledge (wenn applicable)
/docs/research/angelegt?/docs/research/implementation_influence/eingetragen?Relevante Quellen:
Checklist
Original prompt
LLMDeploymentPlugin: RocksDB Model Storage #4011✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.