-
Notifications
You must be signed in to change notification settings - Fork 1
Module llm Roadmap
The module provides production-grade LLM runtime surfaces across async inference, enhanced multi-model orchestration, adapter/plugin management, routing, streaming, and safety/policy controls.
Wave Alignment (see root ROADMAP.md § Program Execution Model):
- Wave A (Q3–Q4 2026): Distributed end-to-end optimization (SpeculativeDecoder + cross-node inference hardening)
- Wave B (Q3–Q4 2026): Wiki Phase B (RocksDB retrieval, cache hit-rate, query-latency gates)
- Wave A Exit Criteria: Deterministic chaos evidence + fail-closed verification + release-critical CI GREEN
- Wave B Exit Criteria: Full 4-layer retrieval chain with stable p95/p99 on representative hardware
Doxygen Documentation:
- All 90 .cpp source files have Doxygen @file headers with maturity/quality metadata
- Canonical Doxygen format applied to final_layer_orchestrator.cpp and model_switch_workflow.cpp
Build & Test Evidence:
- Build preset:
windows-release - Test target:
module_llm_test_active_vram_allocator_focused - Latest validation: 2026-07-19
- Result: PASS (exit 0, [ PASSED ] 45 tests)
- Test timeout budget: 120s
-
wiki_index_store.cpp—WikiIndexStore(BM25 + HNSW + RRF) +JsonWikiIndexReader -
wiki_chunk_splitter.cpp—WikiChunkSplitter(heading-aware, sliding-window) -
wiki_rag_source.cpp—WikiRagSource(RAGStageHandler, fail-open)
-
tests/llm/test_wiki_index_store.cpp— WIS-01..16 unit tests -
tests/llm/test_wiki_rag_quality.cpp— WISQ-01..05 quality gate tests (Recall@5 ≥ 80 %, latency < 200 ms/10 queries on 100 chunks) -
tests/llm/test_llm_doku_rag.cpp— RAG-01..12 doku.db CI test suite (2026-08-24)- RAG-01..07: existing BM25/HNSW/RRF/phase/AdaLoRA/community/latency gates
- RAG-08: Golden dataset keyword gate (≥ 1 expected keyword per entry in Top-5)
- RAG-09: Golden dataset Recall@5 ≥ 80 % across all curated entries
- RAG-10: Source-hint presence gate (expected doc source in Top-5 results)
- RAG-11: Median query latency < 500 ms across all golden-dataset queries
- RAG-12: Golden dataset schema/size/distribution guard:
- minimum dataset size ≥ 110 entries
- distribution 20 % general / 30 % specific / 50 % specialized (±3 % tolerance)
- specialized entries must be tagged as rare/non-generic knowledge points
-
tests/llm/data/themisdb_rag_golden_dataset.yaml— 110 curated Q/A entries (2026-08-24)- Levels: 22 general (20 %), 33 specific (30 %), 55 specialized (50 %)
- Categories: architecture, roadmap, AdaLoRA/training, branch/release, build, API contracts
- Generated bootstrap script:
scripts/generate_rag_golden_dataset.py
Delivered:
- Fix
ingestion::BaseEntity→themis::BaseEntitytype mismatch inwiki_index_store.cpp—writeChunk()andwriteBatch()now build storage-compatible entities viachunkToEntity()that usesthemis::BaseEntity::setField(). TheentityToChunk()dead-code stub (which referenced the non-existentgetProperty()API) was removed. -
tests/llm/test_wiki_index_store_phase_b.cpp— WIS-B-01..16 RocksDB-backed integration tests covering: construction, empty query, BM25-only retrieval, KNN-only retrieval, hybrid RRF,writeBatch(),top_k,min_score, pre-embedded chunks, concurrent reads, writer+reader concurrency, score monotonicity,flush()no-op, query embedding cache, and multi-doc-id ingestion. - Thread-safety hardening: removed
const_cast<EmbeddedLLM&>(llm_)fromquery(); addedmutable EmbeddedLLM* llm_ptr_+mutable std::mutex query_embed_mutex_+mutable std::unordered_map<...> query_embed_cache_so query-embedding caching is race-free under concurrent readers.
Remaining (Target: Q3–Q4 2026):
- Persistent embedding cache keyed by chunk_id in RocksDB (2026-08-09: WikiIndexConfig::enable_persistent_cache; lazy RocksDB lookup via fetchPersistedEmbedding + persistEmbedding)
- Embedding dimension auto-probe on first
embed()call (2026-08-09: WikiIndexConfig::auto_probe_dim; probeEmbeddingDim() called on first write; dim_probed_ atomic guard) - Streaming ingest via
WriteBatchwith configurable batch size (2026-08-09: WikiIndexConfig::batch_size, default=32; writeBatch() uses config batch size instead of hardcoded 32)
- [~] Cross-node and shard-aware inference hardening (Target: Q3 2026) — COMPLETE 2026-08-16
- [~] Runtime cancellation semantics and timeout behavior consistency across engine variants (Target: Q3 2026) — COMPLETE 2026-08-16
- [~] Runtime benchmark and regression gate alignment for RAID/RAG-heavy inference paths (Target: Q3 2026) — COMPLETE 2026-08-16
- GA Sign-off evidence bundling for delivered P5-L01/P5-L02 hardening (Target: Q3 2026 → delivered 2026-08-04)
- P5-L01 EXS tests (28 exception-safety tests) and P5-L02 MEM tests (24 memory-leak tests) PASS (
tests/llm/test_llm_phase5_hardening.cpp) - Residual-risk items documented in
docs/governance/GA_PROMOTION_SIGN_OFF.md - Evidence linked into root gate board and
FINAL_GA_READINESS_CHECKLIST.md - Attach residual-risk register for exception-safety/memory/recovery paths (Target: Q3 2026)
- Reconfirm focused + release-critical regression proof on current
developbaseline (Target: Q3 2026) - Link ownership/failure-mode sign-off evidence into root gate board docs (Target: Q3 2026)
- P5-L01 EXS tests (28 exception-safety tests) and P5-L02 MEM tests (24 memory-leak tests) PASS (
- [~] Multi-Subagent LLM Orchestration (Target: Q3 2026, Phases A–E)
- Phase A: SubagentConfig + SubagentFactory API contracts (
include/llm/subagent_config.h,include/llm/subagent_factory.h) → non-breaking, opt-in - Phase B: SubagentLifecycleManager with resource tracking (integrated in
src/llm/subagent_factory_impl.cpp) - Phase C: SubagentCoordinator with parallel fan-out + merge strategies (
include/llm/subagent_coordinator.h,src/llm/subagent_coordinator_impl.cpp) - Phase D: Comprehensive hardening tests SO-01..SO-48 (
tests/llm/test_subagent_orchestration_focused.cpp) - [~] Phase E: Operational deployment guide + ROADMAP updates (in progress)
- Phase A: SubagentConfig + SubagentFactory API contracts (
- [~] MODULE_GAPS.md Closure (Target: 2026-08-31, Parallel Execution)
- [~] Phase 1: Critical Structural Fixes (braces, thread-safety, RAII) → 4 parallel sub-agents
- [~] Braces imbalance in 37 files (Sub-Agent: llm-braces-critical-fixes)
- [~] Data-race synchronization fixes (Sub-Agent: llm-thread-safety-fixes)
- [~] Resource leak / RAII wrappers (Sub-Agent: llm-raii-resource-fixes)
- [~] Phase 2: Documentation Enhancements (11,074 DOC gaps)
- [~] Module architecture & design docs (Sub-Agent: llm-documentation-enhancements)
- [~] Inline code comments & Doxygen headers (Sub-Agent: llm-documentation-enhancements)
- [~] Operational runbooks & troubleshooting guides (Sub-Agent: llm-documentation-enhancements)
- Phase 3: Code Quality & Performance (150+ medium/low gaps) — Completed 2026-08-26
- Exception-safety patterns & tests — top-5 methods hardened (
~MLModelManagernoexcept,deployModel/updateModelrollback on exception,loadModelVRAM cleanup on throw); 20 tests intests/server/test_wave7_server_llm_hardening.cpp - Performance optimization (copy overhead) —
inferAsynccallback moved into lambda;loadLoRA/unloadLoRAgossip shard_id moved to announcement struct (eliminates second copy) - Security hardening (LLM input validation, injection prevention) — prompt/query 1 MB limit, lora_id alphanumeric regex, max_tokens 1–32768, temperature 0–2;
THEMIS_WARN("[SEC] ...")on each rejection (llm_api_handler.cppB2)
- Exception-safety patterns & tests — top-5 methods hardened (
- Phase 4: Testing & Validation
- 40+ focused hardening tests (thread-safety, exception-safety, resource cleanup)
- Performance regression gates established
- AddressSanitizer / ThreadSanitizer validation
- Deliverables
- GAP_CLOSURE_IMPLEMENTATION_GUIDE.md (created 2026-08-17)
- REMEDIATION_PATTERNS.md with standardized fix patterns (created 2026-08-17)
- All 12,474 gaps tracked, closed, or deferred with justification
- [~] Phase 1: Critical Structural Fixes (braces, thread-safety, RAII) → 4 parallel sub-agents
- End-to-end distributed draft/verify optimization in speculative decoding paths (COMPLETE 2026-08-16) —
SpeculativeDecoderremote-draft shard wiring and distributed end-to-end optimization completed in Wave A-8. Batch aggregation ≥8× speedup verified. - Stronger operational isolation for multi-tenant adapter lifecycle and cache surfaces (Target: Q4 2026)
- Extended operator diagnostics for model routing, queue pressure, and policy-deny causes (Target: Q4 2026)
- [~] Wave B B3: multi-task LoRA shared-base/domain-gating/joint-loss rollout (Target: Q1–Q2 2027) — core impl + ablation/benchmark tests done
Source: MODULE_GAP_ANALYSIS_WAVE2.md §Wave 2-B, gap scanner verified 2026-08-25
Gap count: 192db_connection_leak(CRITICAL), 108resource_leaked_in_exception, 118pointer_arithmetic_unbounded
- [~] Implement
ScopedDbConnectionRAII wrapper — replace all 192 raw DB-connection acquires inml_model_manager.cpp,lora_storage_service_themisdb.cpp,inference_engine_enhanced.cpp(Target: Q4 2026)-
include/llm/scoped_db_connection.hcreated (2026-08-26) -
inference_engine_enhanced.cpp: replacedstd::shared_ptr<void>RAII hack withScopedDbConnectionfor model-plugin acquisition guard (Wave-B L2, 2026-08-26) - Inputs: raw
getConnection()call sites; bounded pool size config - Outputs: RAII-wrapped connections released on scope exit or exception
- Constraints: zero new
db_connection_leakfindings post-fix;valgrind --leak-check=fullclean - Errors: pool exhaustion →
ErrorCode::LLM_RESOURCE_EXHAUSTED; test:tests/llm/test_llm_raii_db_connections.cpp - Perf: no throughput regression (benchmark:
bench_llm_hotpathsLLM-01..LLM-08)
-
- Fix
resource_leaked_in_exception—distributed_training_coordinator.cpp:saveCheckpointnow writes to a.tmpfile and renames atomically; partial-write on exception no longer corrupts checkpoint (Wave-B L3, 2026-08-26) - Bounds-check all pointer arithmetic in
gpu_memory_manager.cpp— 5pointer_arithmetic_unboundedsites in GPU/CPU defrag paths guarded with explicitoffset + bytes > totalcheck before everymemcpy/cudaMemcpy(Wave-B L4, 2026-08-26)
Source: Semantic analysis 2026-08-25 —
inference_engine_enhanced.cpp(8 stubs),inline_training_engine.cpp(5 stubs)
- Replace 8 stubs in
inference_engine_enhanced.cpp: speculative decode verify-step, CUDA kernel fusion for attention, KV-cache LRU eviction (Wave-7, 2026-08-26)- Inputs: draft-model logits + verify-model logits; KV-cache capacity config
- Outputs: accepted token count, cache hit/miss metrics
- Tests:
tests/llm/test_wave7_llm_kvcache_lru_checkpoint.cpp(LRU-01..LRU-10)
- [~] Complete
inline_training_engine.cpptraining loop (5 stubs → production): SGD/Adam gradient update, loss tracking, model-checkpoint persistence to RocksDB, cancellation/timeout support (Target: Q4 2026)- Persistent
model_params_vector added toImpl; training loop now updates real parameters across steps instead of a per-step zero-initialised dummy (Wave-B L5, 2026-08-26) - SGD, Adam, AdamW, AdaGrad, RMSProp optimizers fully implemented and wired
- Stop flag (
stop_flag) checked at epoch and batch boundaries - Loss tracked per step, logged via spdlog
- Checkpoint persistence to RocksDB —
setCheckpointDb()wired; dual-write (RocksDB + filesystem JSON) insaveCheckpoint(); RocksDB-first load with filesystem fallback inloadCheckpoint()(Wave-7, 2026-08-26) - Constraints: loss must decrease over 10 epochs on synthetic data (test criterion)
- Errors: checkpoint write failure, cancellation mid-epoch
- Tests:
tests/llm/test_inline_training_production.cpp
- Persistent
Source: Thread-safety audit — shared state in inference handlers; top-20 std::atomic/mutex additions
Gap count: 13 sites acrossml_model_manager.h/.cpp,llm_plugin_manager.h/.cpp
- Thread-safety audit — shared state in inference handlers; top-20 std::atomic/mutex additions (Wave-B L7, 2026-08-26)
-
include/llm/ml_model_manager.h: addedmutable std::mutex models_mutex_declaration (was used in 18 cpp call sites but undeclared — compile-time gap) -
include/llm/ml_model_manager.h: changedMLModelInstance::active_requestsfromsize_ttostd::atomic<size_t>— concurrentinfer()calls increment/decrement without a global lock -
include/llm/ml_model_manager.h: added explicit copy constructor forMLModelInstance(required bystd::atomicnon-copyability;listModelInstances()uses value-copy) -
src/llm/ml_model_manager.cpp:updateModel(),retireModel(),listModels(),getModelConfig(),getModelStatus()— Wave-B L7 comments added at each lock acquisition site -
src/llm/ml_model_manager.cppinfer():active_requests.fetch_add/fetch_subwithmemory_order_relaxedreplaces unguarded++/-- -
src/llm/ml_model_manager.cppupdateInstanceMetrics(): addedmetrics_lock_guard — per-instance metrics written here, read concurrently bygetModelMetrics()/listModelInstances() -
src/llm/ml_model_manager.cpphealthMonitorLoop(): fixed deadlock — previously heldmodels_mutex_while callinghealthCheck()which re-acquires the same mutex; fix collects instance IDs under the lock then releases before per-instancehealthCheck()calls -
include/llm/llm_plugin_manager.h: addedstd::atomic<uint64_t> plugin_operation_count_{0}— tracks totalregisterPlugin()calls race-free -
src/llm/llm_plugin_manager.cppregisterPlugin(): incrementsplugin_operation_count_atomically viafetch_add(1, memory_order_relaxed) - Tests:
tests/llm/test_wave_next_llm_threadsafety.cpp(L7-TS-01..04)- L7-TS-01: Concurrent
getModelConfig()/getModelStatus()from 4 threads × 1 000 iterations — no data race - L7-TS-02: Concurrent
registerModel()(2 writer threads) +listModels()(2 reader threads) — no crash or corruption - L7-TS-03:
initializeStateStore()from one thread while another callsgetPlugin()— no use-after-free onstate_db_ - L7-TS-04:
registerPlugin()from 8 threads × 100 registrations —plugin_operation_count_== 800 exactly
- L7-TS-01: Concurrent
-
Objective: Close all 13 LLM distributed optimization gaps for production readiness.
Deliverables:
- Remote draft shard integration in SpeculativeDecoder::Config::remote_draft_shard_id
- Batch request aggregation in FederatedInferenceCoordinator (≥8× speedup on batch size 32)
- Load balancing across shards (least-loaded prioritized, round-robin failover)
- Cross-shard communication error handling (500ms timeout, 2 retries, exponential backoff)
- Exception-safe RAII guards (strong guarantee on failure)
- Thread-safe batch accumulation (verified with TSan)
- 8 focused distributed inference tests (LLM-DI-01..08)
- 28 exception safety tests (EXS-01..28)
- 24 memory safety tests (MEM-01..24)
Performance Verified:
- Batch throughput: ≥8× vs sequential (batch size 32)
- Draft-verify pipeline latency: <50ms
- Cross-shard RPC timeout: <500ms (p99)
- Load balancing fairness: >80% across shards
- Fallback activation latency: <10ms
Test Coverage:
- LLM-DI-01: Sharded inference coordination (3 shards)
- LLM-DI-02: Draft-verify pipeline (100 draft, 95 verified)
- LLM-DI-03: Cross-shard communication
- LLM-DI-04: Speculative decode acceptance (partial token set)
- LLM-DI-05: Inference failure recovery
- LLM-DI-06: Load balancing across shards (9 ops, 3 shards)
- LLM-DI-07: Shard failure handling (2/3 healthy)
- LLM-DI-08: End-to-end distributed inference (3 workers, 10 tokens each)
Hardening & Production Readiness:
- Exception safety (EXS-01..28) — model load/unload, adapter, plugin cleanup
- Memory safety (MEM-01..24) — quota, cache, batch lifecycle, 1000-cycle stress
- Concurrency safety (RC-01..08) — atomic ops, mutex, lock-free reads, memory ordering
Evidence: WAVE_A8_CLOSURE_EVIDENCE.md
- Define and freeze non-breaking API contracts for inference, streaming, and routing extension points —
include/llm/llm_api_contract.h(§1 Inference API, §4 Streaming, §5 Cancellation, §8 Concurrency) (Target: Q3 2026) - Document ownership/lifecycle boundaries for plugin, model, and adapter resources —
include/llm/llm_api_contract.h(§3 Plugin/Adapter Lifecycle, §6 Resource Contracts VRAM/RAM) (Target: Q3 2026)
- Implement pending distributed inference and speculative decode integration items (Target: Q4 2026)
- Complete runtime wiring for queue/load telemetry propagation in all configured execution paths (Target: Q4 2026)
- Standardize failure envelopes for timeouts, cancellation, backend unavailability, and partial fan-out errors (Target: Q4 2026)
- Harden fallback behavior when optional acceleration/runtime features are unavailable (Target: Q4 2026)
- Expand focused tests for distributed orchestration, adapter hot-swap races, and stream abort handling (Target: Q4 2026)
- CBS-H-01..08: ContinuousBatchScheduler backpressure + quota tests (tests/llm/test_llm_hardening_phase4.cpp)
- TQM-H-01..04: TokenQuotaManager sliding-window semantics
- LAC-01..20: LLM API contract hardening (inference, batch, stream, plugin lifecycle, embed) —
tests/llm/test_llm_api_contract_hardening_focused.cpp - [~] Distributed orchestration / remote-shard failure paths (pending)
- Add deterministic regression suites for routing and policy enforcement under load (Target: Q4 2026)
- PCL-H-01..06: PromptPolicy concurrent access + hot-swap safety
- SHD-H-01..04: Engine + scheduler shutdown-under-load teardown
- P5-L01: Exception safety audit + RAII wrapper hardening — 28 EXS-* tests delivered (tests/llm/test_llm_phase5_hardening.cpp)
- P5-L02: Memory leak fixes (model loading, cache cleanup) — 24 MEM-* tests delivered (tests/llm/test_llm_phase5_hardening.cpp)
- Lock performance gates to benchmark-backed thresholds and release baselines — 8 release-gate benchmarks LLM-01..LLM-08 in
benchmarks/llm/bench_llm_hotpaths.cpp(GATE-LLM-01..GATE-LLM-08) (Target: Q4 2026) - [~] Validate memory-pressure and VRAM-recovery behavior under sustained multi-model load (Target: Q4 2026)
- EXS-01..28: Exception safety + RAII wrapper tests covering model load failures, move-only handle semantics, concurrent exception isolation, strong/basic guarantee proofs, shutdown under exception, and gate score (tests/llm/test_llm_phase5_hardening.cpp)
- MEM-01..24: Memory leak simulation tests covering load/unload cycles, cache eviction, KV-cache/stream/batch teardown, LoRA cleanup, quota reset, concurrent load, 1 000-cycle stress, and gate score (tests/llm/test_llm_phase5_hardening.cpp)
- 52 new deterministic GTest cases; CTest labels: llm;hardening;phase5; TIMEOUT 120
- Fixed Exception-Safety Violations (Target: Q3 2026)
- LLM-EXC-01..08: Exception-safety during model load/unload (8 tests) ✓
- LLM-EXC-01: Model load success (no exception)
- LLM-EXC-02: Load throws, cleanup on exception
- LLM-EXC-03: Unload success (no exception)
- LLM-EXC-04: Double unload idempotent
- LLM-EXC-05: Exception during destruction (no throw)
- LLM-EXC-06: Strong exception guarantee (state unchanged)
- LLM-EXC-07: Basic exception guarantee (consistent state)
- LLM-EXC-08: Adapter load/unload sequence validation
- Fixed Memory-Leak & Race-Condition Gaps (Target: Q3 2026)
- Audited include/llm/, src/llm/ (190 files) for non-RAII patterns
- LLM-RAII-01..08: RAII lifecycle and cleanup validation (8 tests) ✓
- LLM-RAII-01: UniquePtr automatic cleanup
- LLM-RAII-02: SharedPtr ref-counted cleanup
- LLM-RAII-03: SimAllocGuard move semantics
- LLM-RAII-04: Guard transfer ownership
- LLM-RAII-05: Multiple scopes cleanup
- LLM-RAII-06: Nested resource management
- LLM-RAII-07: Exception unwinding cleanup
- LLM-RAII-08: Cache lifecycle cleanup
- Race-Condition & Concurrency Hardening (Target: Q3 2026)
- LLM-RC-01..08: Race-condition & concurrency scenarios (8 tests) ✓
- LLM-RC-01: Atomic increment thread-safe (10 threads × 100 ops = 1000)
- LLM-RC-02: Mutex-protected access validation
- LLM-RC-03: Concurrent model loading (3 threads)
- LLM-RC-04: Producer-consumer pattern validation
- LLM-RC-05: Read-write lock pattern
- LLM-RC-06: Memory ordering constraints (release/acquire)
- LLM-RC-07: Double-checked locking (std::once_flag)
- LLM-RC-08: Deadlock prevention (consistent lock order)
- Multi-Tenant Operational Isolation (Target: Q4 2026)
- LLM-MT-01..08: Multi-tenant isolation (8 tests) ✓
- LLM-MT-01: Tenant isolation (no data leakage)
- LLM-MT-02: Per-tenant quota enforcement
- LLM-MT-03: Concurrent tenant access
- LLM-MT-04: Tenant cache isolation
- LLM-MT-05: Tenant resource cleanup
- LLM-MT-06: Cross-tenant contamination check
- LLM-MT-07: Tenant metadata consistency
- LLM-MT-08: Multi-tenant shutdown coordination
- Distributed Inference & Speculative Decode (Target: Q4 2026)
- LLM-DI-01..08: Distributed inference edge cases (8 tests) ✓
- LLM-DI-01: Sharded inference coordination (3 shards)
- LLM-DI-02: Draft-verify pipeline (100 draft, 95 verified)
- LLM-DI-03: Cross-shard communication
- LLM-DI-04: Speculative decode acceptance (partial token set)
- LLM-DI-05: Inference failure recovery
- LLM-DI-06: Load balancing across shards (9 ops, 3 shards)
- LLM-DI-07: Shard failure handling (2/3 healthy)
- LLM-DI-08: End-to-end distributed inference (3 workers, 10 tokens each)
- Created 40 Focused LLM Tests (Target: Q3 2026)
- LLM-EXC-01..08: Exception-safety (8 tests)
- LLM-RAII-01..08: RAII lifecycle (8 tests)
- LLM-RC-01..08: Race-condition/concurrency (8 tests)
- LLM-MT-01..08: Multi-tenant isolation (8 tests)
- LLM-DI-01..08: Distributed inference (8 tests)
- All tests: Use themis_register_module_focused_test(), tier unit/integration, timeout 120s
- Registered with label:
release_critical;llm;phase1
- P5-L01/P5-L02: Comprehensive Hardening Test Suite (Target: 2026-08-02)
- Extended include/llm/llm_memory_safety_utils.h with concurrency utilities (QuotaGuard, BatchGuard, ThreadSafeCounter)
- MEM-01..16: Memory safety lifecycle tests (quota/batch/resource management)
- MEM-17..28: Concurrency and backpressure tests (concurrent quota, batch scheduling, stress tests)
- EXS-01..25: Exception safety in model lifecycle (load/unload, adapter, plugin, cleanup guarantee)
- All 53 tests registered as module_llm_test_llm_memory_safety_hardening_focused
- File: tests/llm/test_llm_memory_safety_hardening.cpp
- Labels: release_critical llm batch1 memory_safety, TIMEOUT 120s each
- Deterministic (seed 42), ASan/TSan validated
- Phase 1 Exit Criteria (2026-08-02)
- 0 new CRITICAL findings in CodeQL
- 93 focused tests created and passing (40 legacy + 53 comprehensive hardening)
- Exception-safety audits complete with documented contracts
- Memory-leak and race-condition fixes validated with sanitizers (ASan/TSan)
- Sanitizer evidence archived in docs/security/GA_SANITIZER_EVIDENCE_BUNDLE.md
- All module-level ROADMAP.md updated with closure status
- Synchronize operator docs/runbooks with implemented runtime behavior and metrics —
include/llm/llm_api_contract.hdocuments all inference/embedding/plugin/streaming/cancellation/resource and error contracts for v1.x (Target: Q4 2026) - Publish acceptance checklist evidence for release sign-off — Phase 1 contract header, Phase 4 LAC-01..LAC-20 tests, Phase 5 LLM-01..LLM-08 benchmarks all delivered and referenced in this ROADMAP (Target: Q4 2026)
- API contracts for inference and streaming verified against tests and docs —
include/llm/llm_api_contract.h+tests/llm/test_llm_api_contract_hardening_focused.cpp - Security and policy checks verified on all externally reachable LLM entry points — Phase 4 security review complete; pentest evidence in
security/pentest/GA_PENTEST_EVIDENCE_BUNDLE.md - Performance expectations validated by reproducible release-profile benchmarks —
benchmarks/llm/bench_llm_hotpaths.cpp(LLM-01..LLM-08) - Failure handling validated for cancellation, timeout, and backend degradation cases — P5-L01 EXS tests cover exception propagation, RAII teardown, and timeout paths
- Audit and changelog documentation synchronized with implementation delta — CHANGELOG.md P5-L01/P5-L02 entries present;
src/llm/ROADMAP.mdup to date
- Some advanced distributed/remote execution optimizations depend on deployment wiring and are not universal defaults.
- Runtime behavior can vary with enabled backend/plugin combinations and available hardware acceleration.
- Not all benchmark targets currently represent transport- or topology-specific production mixes.
- Shared LoRA base with task-specific projections
- Domain-gating mechanism
- Joint loss with configurable task weighting
- 3-task benchmark evaluation and robustness checks
- Unit tests
MTL-01..10 - Ablation study: shared multi-task training vs per-task single-task baselines
- Average task performance ≥ +8% vs single-task baseline
- Training-time increase ≤ 15%
- Robustness across task configurations
- Wave A deployment complete (Speculative Decoding, DPR, Fairness)
- Stable adapter lifecycle and benchmark baselines in LLM module
- Detail tracker:
../ai/FUTURE_ENHANCEMENTS.md - Shared bibliography:
../../docs/research/ml_enhancements_bibliography.md - Issue scope:
https://github.com/makr-code/ThemisDB/issues/5039
- No breaking changes planned at roadmap level; any required API break must be explicitly documented in CHANGELOG and migration notes before merge.
- Raw CRITICALs scanned: 155 across 113 source files
- Real gaps confirmed: 5 (2 CRITICAL, 3 HIGH)
- False positives removed: 150 (96.8% FP rate, consistent with prior waves)
-
braces_imbalance(29): 100% FP — raw string literals (R"({...})") and#ifdef-gated brace blocks cause scanner heuristic to misfire; state-machine tokenizer confirms all files terminate at depth 0 -
circular_lock_ordering(108): 100% FP — scanner fires on any file with >1 mutex name; actual code uses consistent documented hierarchies and release-before-acquire patterns -
data_race(11): 100% FP — all counters arestd::atomic; collections protected bystd::mutex/std::shared_mutex -
sql_injection(7): 100% FP — RPC envelope strings namedrpc_query, not SQL; mock strings in test/stub mode
| ID | Severity | Pattern | Location | Fix |
|---|---|---|---|---|
| W3-SEC-01 | HIGH | insecure_model_url |
model_downloader.cpp validateOllamaUrl
|
Non-local HTTP rejected by default; ModelDownloadConfig::allow_insecure_http for explicit opt-in |
| W3-SEC-02 | HIGH | path_traversal |
model_downloader.cpp lines 150, 239 |
sanitizeModelName() rejects .., /, \, null bytes in downloadFromOllama/pullFromOllama
|
| W3-SEC-03 | CRITICAL | deadlock_risk |
ai_orchestrator.cpp PluginAdapterApplyService::applyAdapter
|
Capture state under lock; release mutex_ before unloadLoRA, path_resolver_, loadLoRA; re-lock to write |
| W3-SEC-04 | CRITICAL | prompt_injection |
docs_assistant.cpp lines 678, 683 |
getConfigHelp/getTroubleshootingHelp now apply sanitizePromptWithSharedPolicy with length caps (128 / 512 chars) |
| W3-SEC-05 | HIGH | hardcoded_path |
llm_prefix_cache.cpp line 46 |
LLMPrefixCache::Config::cache_dir field added; impl uses configured path with /tmp/themis_llm_prefix_cache as fallback |
-
tests/llm/test_llm_wave3_gap_fixes.cpp— 15 regression tests (W3_01..W3_15) -
tests/llm/test_model_downloader_url_validation.cpp— URL_VAL_05 updated; URL_VAL_10 added
- Triage 155 raw CRITICALs — triage report:
ai_working/gap_verifier_report_llm.md - W3-SEC-01: insecure_model_url fixed
- W3-SEC-02: path_traversal fixed
- W3-SEC-03: deadlock_risk fixed
- W3-SEC-04: prompt_injection fixed
- W3-SEC-05: hardcoded_path fixed
- Regression tests added (W3_01..W3_15)
- ROADMAP and MODULE_GAPS updated
- CRITICAL residual after W9-16: 135 (20
braces_imbalancescanner FPs closed) - Speculative decode bridges:
TokenizerFnwired;TargetLogitsFnnote updated - Tests:
tests/llm/test_wave9_speculative_decode_bridges.cpp(SD-BRG-01..07)
- Verified all 20
braces_imbalanceCRITICAL entries using a C++ state-machine parser that skips raw string literals — all 20 confirmed structurally balanced -
grafana_metrics.cppraw count −3 explained by R"()" JSON payloads - MODULE_GAPS.md updated with verification table (155 → 135 residual)
-
TokenizerFntype +setTokenizerFn()/clearTokenizerFn()added toInferenceEngineEnhancedpublic API (include/llm/inference_engine_enhanced.h) -
setTokenizerFn/clearTokenizerFnimplemented insrc/llm/inference_engine_enhanced.cpp(mutex-guarded, same pattern asTargetLogitsFn) - Remote draft path in
trySpeculativeGeneration()updated to callTokenizerFnbefore byte-modulo fallback; fail-closed on exception - STUB #263 note updated: "Removal Plan" → "Production Injection Point"
- STUB #262 note updated: "Removal Plan" → "Production Injection Point" (TargetLogitsFn was already fully wired; note corrected)
- Tests SD-BRG-01..SD-BRG-07 added
- STUB_INVENTORY.md entries 322/323 marked resolved
-
trySpeculativeGeneration()local draft path wired: whenTokenizerFnis set on the engine, aGenerateDraftTokensFnlambda is injected intoILLMPlugin::setDefaultGenerateDraftTokensFn()before callingdraft_plugin->generateDraftTokens(). - Lambda captures
draft_pluginby value (shared_ptr copy) — nothiscapture across thread boundaries. - Bridge cleared (
setDefaultGenerateDraftTokensFn(nullptr)) after the call, including on exception, to prevent global state pollution. - Byte-modulo heuristic retained as documented fallback when TokenizerFn is absent or returns empty / throws.
- STUB #261 comment updated in
include/llm/llm_plugin_interface.h: "Production Injection Point (wired by InferenceEngineEnhanced::trySpeculativeGeneration, 2026-08-27)". - Tests SD-LOCAL-01 and SD-LOCAL-02 added in
tests/llm/test_w10d_local_draft_bridge.cpp.
- Architecture-ACCESS-MODEL-IMPLEMENTATION-SUMMARY
- Architecture-ADR-003-pg-dump-sql-parser
- Architecture-BASEENTITY-PRINCIPLE
- Architecture-CACHE-STORAGE-INTEGRATION
- Architecture-CMAKE-ARCHITECTURE
- Architecture-CMAKE-FLAGS-REFERENCE
- Architecture-CMAKE-MODULAR-ARCHITECTURE
- Architecture-CONCERNS-ARCHITECTURE-DIAGRAM
- Architecture-CONCERNS-IMPLEMENTATION-SUMMARY
- Architecture-CONTENT-MODEL
- Architecture-COPILOT-THEMISDB-GRAPH-RAG-BACKEND-ARCHITECTURE
- Architecture-CRYPTO-AND-KEYS
- Architecture-FEATURE-FLAGS-REFERENCE
- Architecture-GPU-ARCHITECTURE-REVIEW-TEMPLATE
- Architecture-HTTP-SHUTDOWN-HARDENING
- Architecture-MIGRATION-GUIDE-CONCERNS
- Architecture-MIGRATION-GUIDE-v13-v14
- Architecture-MODULARIZATION-GUIDE
- Architecture-MODULAR-ARCHITECTURE-ROADMAP
- Architecture-MODULE-ARCHITECTURE-INDEX
- Architecture-P1D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D08-MAMBA-GOVERNANCE-CONTRACT
- Architecture-P1-P2-IMPLEMENTATION-COMPLETION-INDEX
- Architecture-PHASE0-COMPLETION-ASSESSMENT
- Architecture-PHASE3-QUERYENGINE-DI-ARCHITECTURE
- Architecture-PHASE4-INDEX-MANAGER-DI
- Architecture-POSTGRESQL-WIRE-PROTOCOL
- Architecture-QUERYENGINE-IMPLEMENTATION-GUIDE
- Architecture-QUERY-SCHEDULING
- Architecture-RAFT-CONSENSUS-DESIGN
- Architecture-README
- Architecture-README-SSM-HYBRID-IMPLEMENTATION
- Architecture-REFACTORING-SUMMARY
- Architecture-RESOURCE-POOLING
- Architecture-SOURCE-DIRECTORY-GUIDE
- Architecture-THEMIS-CORE-GUIDE
- Architecture-UNIFIED-ACCESS-MODEL
- Architecture-WAL-GRPC-MTLS-CONFIGURATION
- Architecture-WIRE-PROTOCOL-RETRY
- Architecture-boltzmann-observability-draft
- Architecture-experimental-logarithmic-vector-storage
- Architecture-llm-wiki-mvp-adr
- Architecture-rewrite-engine-architecture
- Architecture-rope-api-architecture
- Architecture-ssm-gguf-mamba-status
- Architecture-ssm-hybrid-analysis
- Architecture-ssm-hybrid-rollout-plan
- Architecture-ssm-plugin-interface-design-review
- Architecture-transaction-coordinators
- Architecture-wiki-secondary-index
- Architecture-wire-protocol
- Governance-DISABLED-STUB-POLICY
- Governance-DOCS-PR-POLICY
- Governance-GA-PROMOTION-SIGN-OFF
- Governance-GITHUB-MILESTONES-SETUP
- Governance-MATURITY-CLAIM-VERIFICATION-CHECKLIST
- Governance-MATURITY-EVIDENCE-REGISTRY
- Governance-MERGE-GATE-BOT-CONFIG
- Governance-MERGE-GATE-STATUS-LIVE
- Governance-PHASE3-ENFORCEMENT-RUNBOOK
- Governance-PHASE-1-CLOSURE-REPORT
- Governance-PHASE-CLOSURE-POLICY
- Governance-PHASE-DEPENDENCY-GRAPH
- Governance-PLUGIN-SUBMODULE-ROLLBACK
- Governance-PRODUCTION-READY-2026-DELIVERY-PLAN
- Governance-PR-VERSION-TARGETING
- Governance-PR-VERSION-TARGETING-BACKFILL
- Governance-QUERY-MODULE-STATUS
- Governance-README
- Governance-RELEASE-PROMOTION-GATE-POLICY
- Governance-RELEASE-VALIDATION-CHECKLIST
- Governance-SECURITY-MODULE-5671-EVIDENCE-SUMMARY
- Governance-SHARDING-P6-RESIDUAL-RISK-ACCEPTANCE
- Governance-SOURCECODE-COMPLIANCE-GOVERNANCE
- Governance-UPDATES-DEVELOPMENT-STATUS-SIGN-OFF
- Governance-WAVE-C-IMPLEMENTATION-COMPLETE
- Module-acceleration-Roadmap
- Module-access-model-Roadmap
- Module-ai-Roadmap
- Module-analytics-Roadmap
- Module-api-Roadmap
- Module-aql-Roadmap
- Module-auth-Roadmap
- Module-base-Roadmap
- Module-cache-Roadmap
- Module-cdc-Roadmap
- Module-chaos-Roadmap
- Module-chimera-Roadmap
- Module-config-Roadmap
- Module-content-Roadmap
- Module-core-Roadmap
- Module-distributed-knowledge-Roadmap
- Module-distributed-tensor-Roadmap
- Module-document-Roadmap
- Module-ethics-ai-Roadmap
- Module-evaluation-Roadmap
- Module-execution-Roadmap
- Module-exporters-Roadmap
- Module-failover-Roadmap
- Module-geo-Roadmap
- Module-governance-Roadmap
- Module-gpu-Roadmap
- Module-graph-Roadmap
- Module-image-analysis-Roadmap
- Module-importers-Roadmap
- Module-index-Roadmap
- Module-ingestion-Roadmap
- Module-llama-cpp-Roadmap
- Module-llm-Roadmap
- Module-llm-streaming-Roadmap
- Module-llm-wiki-Roadmap
- Module-maintenance-Roadmap
- Module-metadata-Roadmap
- Module-network-Roadmap
- Module-observability-Roadmap
- Module-onnx-clip-Roadmap
- Module-performance-Roadmap
- Module-plugins-Roadmap
- Module-process-Roadmap
- Module-projects-Roadmap
- Module-prompt-engineering-Roadmap
- Module-query-Roadmap
- Module-rag-Roadmap
- Module-replication-Roadmap
- Module-retrieval-Roadmap
- Module-rpc-grpc-Roadmap
- Module-scheduler-Roadmap
- Module-scraper-Roadmap
- Module-search-Roadmap
- Module-security-Roadmap
- Module-server-Roadmap
- Module-sharding-Roadmap
- Module-stable-diffusion-Roadmap
- Module-storage-Roadmap
- Module-temporal-Roadmap
- Module-tensor-Roadmap
- Module-themis-Roadmap
- Module-timeseries-Roadmap
- Module-toolbox-Roadmap
- Module-training-Roadmap
- Module-transaction-Roadmap
- Module-updates-Roadmap
- Module-user-storage-encrypted-Roadmap
- Module-utils-Roadmap
- Module-vector-search-Roadmap
- Module-voice-Roadmap
- Module-whisper-Roadmap