Skip to content

Commit 949b88e

Browse files
authored
Merge pull request #6089 from makr-code/copilot/core-modules-gaps-analysis-again
Harden ggml/LLM integration paths and remove simulation-backed LLM fallbacks
2 parents 170b0e4 + c97b478 commit 949b88e

64 files changed

Lines changed: 3593 additions & 2327 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ROADMAP.md

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- Status: [ ] open [~] in progress [x] done [I] Issue [P] PR [?] blocked [!] unclear -->
44

55
**Version:** 2.4.0-alpha
6-
**Last Updated:** 2026-08-18
6+
**Last Updated:** 2026-08-31
77
**Scope:** Aggregated roadmap across tracked modules in `src/` (improved scanner pipeline Phase 1–6 complete; Phase 1–6 execution contract evidence closure COMPLETE). GA hardening path: Phases 0-6 technical evidence complete, Phase 6 human governance sign-off (D-11) is the only remaining GA blocker at `docs/governance/GA_PROMOTION_SIGN_OFF.md` §9. Wave C (Security Production Validation) complete with all exit criteria passing 2026-08-18.
88

99
> For module-specific details see each module's `src/<module>/ROADMAP.md`.
@@ -30,19 +30,19 @@ ThemisDB is a high-performance multi-model database with native AI/LLM integrati
3030
- [~] Other modules use legacy four-column format; will be expanded on next per-module roadmap sync.
3131
- [x] A consolidated root-level Soll-Ist matrix for all research-backed roadmap claims is established via `research/implementation_influence/by_module.md` (6 modules, 21 implementation aspects); recurring sync enforced from Phase 6 onwards (✅ COMPLETE 2026-08-04).
3232

33-
## Implementation vs Documentation Gap Classification (2026-08-10)
33+
## Implementation vs Documentation Gap Classification (2026-08-31)
3434

3535
| Module | Open Items | Classification | Notes |
3636
|---|---|---|---|
37-
| ethics_ai | 22 listed | Mostly DOC gaps | ChainVisualizer, NormEvidence, legal_db, CSEP tests all implemented 2026-08-09 |
38-
| transaction | 19 listed | Mostly DOC gaps | Test files exist; chaos/production validation pending CI confirmation |
39-
| voice | 22 listed | DOC + IMPL gaps | Basic liveness/anti-spoof code exists; hardening under adversarial inputs is real remaining work |
40-
| LLM | 13 listed | DOC + IMPL gaps | SpeculativeDecoder exists; distributed end-to-end optimization is real remaining work |
41-
| search | 43 listed | REAL IMPL gaps | LayeredRetrievalOrchestrator uses mocks; real ANN/Tensor/Graph/LLM wiring pending |
42-
| GPU/CUDA | 21+53 listed | REAL IMPL gaps | CUDA kernels are stubs (filter/join/agg/sort/topk not implemented) |
43-
| RAG Phase B | 57 listed | REAL IMPL gaps | BM25+, HNSW, RRF in WikiIndexStore not implemented; Phase A only |
44-
| sharding | 20 listed | REAL IMPL gaps | Thread-safety gaps (340+), lock ordering violations (95) are real |
45-
| replication | 16 listed | MIXED | Multi-region base exists; geo placement policies and lag-limit WAL shipping are real gaps |
37+
| core | 9 listed | Mostly DOC / evidence gaps | Runtime adapter registry and plugin loading are delivered; remaining items are Wave D operability and refreshed evidence |
38+
| base | 8 listed | Mostly historical scanner noise | `src/base/MODULE_GAPS.md` re-scan shows 0 actionable current gaps; remaining items are documented false positives or follow-up docs |
39+
| server | 4 residual source gaps | REAL IMPL gaps | gRPC-Web proxy is still UNIMPLEMENTED-only in fallback builds; time-series aggregate/retention providers and RoPE metrics still rely on degraded fallback paths; non-Linux MCP stdio transport remains unsupported |
40+
| query | residual perf / validation follow-up | Mostly verification / perf gaps | Process-mining trace/pattern/ideal query paths and the three `ETHICS_*` runtime gaps were closed on 2026-08-31; remaining work is optimizer/federation hardening and benchmark evidence |
41+
| transaction | 19 listed | Mostly verification / benchmark evidence | Wave 4C code gaps are closed; build/run, chaos, and representative-hardware evidence remain open |
42+
| auth | 8+ listed | Mostly verification / perf follow-up | Wave 4B source gaps are closed; remaining work is Wave 8 tests, representative-hardware baselines, and protocol-matrix regressions |
43+
| LLM | 13 listed | MIXED | Major Wave 5 closures landed; remaining real gaps center on distributed collectives, multi-tenant isolation, and final cross-module speculative/TARG wiring |
44+
| RAG / LLM Wiki | 57 listed | Mostly perf / integration follow-up | BM25+, RRF, persistent cache, and real `LLMJudgeIntegration` path are implemented; remaining work is performance gates, Recall@k sign-off, Wikipedia ABI wiring, and entropy-bridge integration |
45+
| GPU/CUDA | 21+53 listed | REAL IMPL gaps | CUDA/HIP kernel parity and representative-hardware validation remain open release blockers for acceleration-heavy paths |
4646
| access_model | 21 listed | REAL IMPL gaps | Benchmarks and GATE-ACM-01..06 not yet implemented |
4747

4848
## Release Hardening Program (current canonical version: v2.4.0-alpha)
@@ -71,6 +71,7 @@ ThemisDB is a high-performance multi-model database with native AI/LLM integrati
7171
- [x] Wave 8, chaos/fault-injection, sanitizer/recovery, penetration-test, and 99.99% SLA sign-off artefacts are closed: sanitizer evidence bundle at `docs/security/GA_SANITIZER_EVIDENCE_BUNDLE.md`; pentest evidence bundle at `security/pentest/GA_PENTEST_EVIDENCE_BUNDLE.md`; Wave 9 SLA/chaos gates PASS; final governance sign-off pending human approval at `docs/governance/GA_PROMOTION_SIGN_OFF.md`.
7272
- [x] Phase 1-6 execution contract complete: all technical gates PASS; human sign-off (Section 9 of `docs/governance/GA_PROMOTION_SIGN_OFF.md`) is the only remaining GA blocker.
7373
- [x] Tools build-option transition complete: canonical flag for desktop tools is `THEMIS_BUILD_TOOLS` (default `ON`); legacy alias removed.
74+
- [~] Core-first residual source-gap queue revalidated: finish server runtime fallback gaps and query feature gaps first, then close LLM/RAG integration and GPU representative-hardware gates (Target: Q4 2026).
7475

7576
## Program Execution Model (Wave A → B → C → D)
7677

@@ -625,30 +626,24 @@ Status: [x] complete (analysis baseline for 2PC/3PC refactoring epic)
625626

626627
**Scope:** `src/rag/`, `src/llm/`, `plugins/themisdb_llm_wiki/`, `src/importers/`
627628

628-
- [ ] WikiIndexStore Phase B activation (gate: `THEMIS_WIKI_PHASE_B`):
629-
- BM25+ scorer (Robertson & Zaragoza 2009, δ=0.5, k1=1.5, b=0.75) in `WikiIndexStore::query()`.
630-
- HNSW index (M=16, ef_construction=200) for dense embeddings.
631-
- RRF fusion (k=60) combining BM25+ and HNSW scores.
632-
- Perf target: ≥2× query throughput vs Phase A at 50K chunks; p95 < 100ms.
633-
- Automatic Phase A→B index migration with progress log; rollback path on failure.
634-
(Target: Q4 2026)
635-
- [ ] Persistent embedding cache: RocksDB column family `"embedding_cache"`; key = `sha256(doc_id + content)`; cache-miss triggers re-embedding call; ≥99% hit rate on re-ingest (measured); LRU eviction at configurable byte limit. (Target: Q4 2026)
629+
- [x] WikiIndexStore Phase B activation (gate: `THEMIS_WIKI_PHASE_B`): BM25+ scorer, HNSW index initialization, RRF fusion, automatic Phase A→B migration, and persistent embedding cache are implemented in `src/llm/wiki_index_store.cpp`; remaining work is representative-hardware performance proof and production gate evidence. (Target: Q4 2026)
630+
- [ ] Perf target for Phase B: ≥2× query throughput vs Phase A at 50K chunks; p95 < 100ms on representative hardware. (Target: Q4 2026)
636631
- [ ] `ingestWikipediaDump()` ABI wiring: sub-feature gate `"llm_wiki_wikipedia"` check at runtime; `ILLMWikiPlugin::Status::PermissionDenied` in Community/Minimal editions; test `LWP-WIKI-01` (enterprise smoke) + `LWP-WIKI-02` (community gate). (Target: Q4 2026)
637-
- [ ] FTS enhancement: phrase queries via positional inverted index (`"hello world"` → documents where tokens adjacent); proximity queries (`NEAR(term1, term2, distance=5)`); ≤100ms on 100K documents at p95. (Target: Q4 2026)
632+
- [ ] FTS enhancement gate: phrase/proximity query path is implemented; remaining work is the ≤100ms p95 benchmark gate on 100K documents. (Target: Q4 2026)
638633
- [ ] `TensorRagCostModel`: 5-phase RAG cost model — C_RAG = C_embed + C_retrieve + C_rerank + C_assemble + C_generate; `TENSOR_RAG` WorkloadType in `TensorWorkloadClassifier`; TTFT comparison table (150-400ms llama.cpp vs 40-90ms cached); integrate with `TensorRagCostModel::estimate()`. (Target: Q4 2026)
634+
- [x] LLM↔RAG entropy bridge: speculative decoding now installs a scoped per-request entropy override so downstream `TARGRetrieval` calls can reuse the already-available exact target-logit rows without cross-thread global callback leakage; the default TARG runtime still keeps its built-in exact full-vocabulary fallback when no bridge is active. (Target: Q4 2026)
639635
- [ ] LWP tests Phase 4 (LWP-01..20 + LWP-GATE-01): see `plugins/themisdb_llm_wiki/ROADMAP.md` Phase 4 for full list; Recall@k ≥0.8 gate on LWP-01..08. (Target: Q4 2026)
640636

641637
### 6. Evaluation Framework
642638

643639
**Scope:** `src/rag/`, `src/evaluation/`, `include/llm_wiki/`
644640

645-
- [ ] LLM-Judge Integration: replace mock-mode in `src/rag/llm_judge_integration.cpp` with real LLM judge calls via internal `ILLMBackend` adapter; gate `THEMIS_ENABLE_LLM_JUDGE`; when gate off or LLM unavailable → `LLMJudgeResult{score: -1, reason: "llm_unavailable"}` — never silently return fixed score. (Target: Q4 2026)
646-
- Stub removal: current mock returns fixed score 0.85; MUST be replaced — mark with `STUB/SIMULATION NOTE` until replaced.
647-
- [ ] Recall@k / MRR / p95-Reporting in `ILLMWikiPlugin::stats()`:
641+
- [x] LLM-Judge Integration: `src/rag/llm_judge_integration.cpp` has a real `ILLMInferenceEngine` path under `THEMIS_ENABLE_LLM_JUDGE`; when the gate is off or no backend is available it returns `llm_unavailable` fail-closed, and the former mock-mode fallback has been removed from runtime behavior. (Target: Q4 2026)
642+
- [x] Recall@k / MRR / p95-Reporting in `ILLMWikiPlugin::stats()`:
648643
- `EvaluationStats::recall_at_k` (k=1,3,5,10) — fraction of queries with relevant doc in top-k.
649644
- `EvaluationStats::mrr` — mean reciprocal rank over last N queries.
650645
- `EvaluationStats::p95_query_latency_ms`.
651-
- Recall@k ≥ 0.8 as gate criterion for LWP-01..08 acceptance. (Target: Q4 2026)
646+
- Remaining open gate: Recall@k ≥ 0.8 as formal sign-off criterion for LWP-01..08 acceptance. (Target: Q4 2026)
652647
- [ ] Production observability dashboards: per-layer handoff quality metrics (ANN Recall@10, Tensor routing accuracy, Graph provenance precision, LLM ROUGE-L); anomaly detection (z-score ≥3 → alert); root-cause hint attached to alert payload. (Target: Q4 2026)
653648
- [ ] Per-query retrieval guardrails: `RetrievalGuardrail::checkFederatedCost(query, plan)` returns `GuardrailDecision{allow, deny_reason, estimated_cost_ms}`; SLO-validated benchmarks confirm ≤5% throughput regression vs no-guardrail. (Target: Q4 2026)
654649

benchmarks/llm/bench_llm_judge_integration.cpp

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
* @brief Performance benchmarks for LLMJudgeIntegration
44
*
55
* Benchmarks:
6-
* - Mock mode evaluation performance
6+
* - Injected inference evaluation performance
77
* - Custom inference function overhead
88
* - Configuration change overhead
99
* - Retry mechanism performance
1010
* - Different evaluation dimensions
1111
*
1212
* Performance targets:
13-
* - Mock mode evaluation: < 10ms
13+
* - Injected inference evaluation: < 10ms
1414
* - Custom inference call: < 5ms overhead
1515
* - Configuration update: < 1ms
1616
* - Retry logic: < 50ms for 3 retries
@@ -72,15 +72,12 @@ static std::string slowInferenceFunction(const std::string& prompt) {
7272
}
7373

7474
// ============================================================================
75-
// Mock Mode Benchmarks
75+
// Injected Inference Benchmarks
7676
// ============================================================================
7777

7878
static void BM_MockModeEvaluation(benchmark::State& state) {
79-
LLMJudgeIntegration::Config config;
80-
config.use_mock_mode = true;
81-
config.warn_on_mock_mode = false; // Disable warnings for benchmarking
82-
83-
LLMJudgeIntegration integration(config);
79+
LLMJudgeIntegration integration;
80+
integration.setInferenceFunction(fastInferenceFunction);
8481
PromptTemplateManager template_manager = PromptTemplateManager::createDefault();
8582
EvaluationInput input = createTestInput();
8683

@@ -93,16 +90,13 @@ static void BM_MockModeEvaluation(benchmark::State& state) {
9390
benchmark::DoNotOptimize(result);
9491
}
9592

96-
state.SetLabel("Mock mode evaluation");
93+
state.SetLabel("Injected inference evaluation");
9794
}
9895
BENCHMARK(BM_MockModeEvaluation)->Unit(benchmark::kMillisecond);
9996

10097
static void BM_MockModeMultipleDimensions(benchmark::State& state) {
101-
LLMJudgeIntegration::Config config;
102-
config.use_mock_mode = true;
103-
config.warn_on_mock_mode = false;
104-
105-
LLMJudgeIntegration integration(config);
98+
LLMJudgeIntegration integration;
99+
integration.setInferenceFunction(fastInferenceFunction);
106100
PromptTemplateManager template_manager = PromptTemplateManager::createDefault();
107101
EvaluationInput input = createTestInput();
108102

@@ -120,7 +114,7 @@ static void BM_MockModeMultipleDimensions(benchmark::State& state) {
120114
}
121115
}
122116

123-
state.SetLabel("4 dimensions in mock mode");
117+
state.SetLabel("4 dimensions with injected inference");
124118
}
125119
BENCHMARK(BM_MockModeMultipleDimensions)->Unit(benchmark::kMillisecond);
126120

@@ -227,16 +221,14 @@ static void BM_ConfigurationRetrieval(benchmark::State& state) {
227221
BENCHMARK(BM_ConfigurationRetrieval)->Unit(benchmark::kNanosecond);
228222

229223
static void BM_MockModeCheck(benchmark::State& state) {
230-
LLMJudgeIntegration::Config config;
231-
config.use_mock_mode = true;
232-
LLMJudgeIntegration integration(config);
224+
LLMJudgeIntegration integration;
233225

234226
for (auto _ : state) {
235227
bool is_mock = integration.isMockMode();
236228
benchmark::DoNotOptimize(is_mock);
237229
}
238230

239-
state.SetLabel("Mock mode check");
231+
state.SetLabel("Mock mode compatibility check");
240232
}
241233
BENCHMARK(BM_MockModeCheck)->Unit(benchmark::kNanosecond);
242234

@@ -303,11 +295,8 @@ BENCHMARK(BM_RetryMechanism_SingleRetry)->Unit(benchmark::kMillisecond);
303295
// ============================================================================
304296

305297
static void BM_EvaluateFaithfulness(benchmark::State& state) {
306-
LLMJudgeIntegration::Config config;
307-
config.use_mock_mode = true;
308-
config.warn_on_mock_mode = false;
309-
310-
LLMJudgeIntegration integration(config);
298+
LLMJudgeIntegration integration;
299+
integration.setInferenceFunction(fastInferenceFunction);
311300
PromptTemplateManager template_manager = PromptTemplateManager::createDefault();
312301
EvaluationInput input = createTestInput();
313302

@@ -323,11 +312,8 @@ static void BM_EvaluateFaithfulness(benchmark::State& state) {
323312
BENCHMARK(BM_EvaluateFaithfulness)->Unit(benchmark::kMillisecond);
324313

325314
static void BM_EvaluateRelevance(benchmark::State& state) {
326-
LLMJudgeIntegration::Config config;
327-
config.use_mock_mode = true;
328-
config.warn_on_mock_mode = false;
329-
330-
LLMJudgeIntegration integration(config);
315+
LLMJudgeIntegration integration;
316+
integration.setInferenceFunction(fastInferenceFunction);
331317
PromptTemplateManager template_manager = PromptTemplateManager::createDefault();
332318
EvaluationInput input = createTestInput();
333319

@@ -343,11 +329,8 @@ static void BM_EvaluateRelevance(benchmark::State& state) {
343329
BENCHMARK(BM_EvaluateRelevance)->Unit(benchmark::kMillisecond);
344330

345331
static void BM_EvaluateCompleteness(benchmark::State& state) {
346-
LLMJudgeIntegration::Config config;
347-
config.use_mock_mode = true;
348-
config.warn_on_mock_mode = false;
349-
350-
LLMJudgeIntegration integration(config);
332+
LLMJudgeIntegration integration;
333+
integration.setInferenceFunction(fastInferenceFunction);
351334
PromptTemplateManager template_manager = PromptTemplateManager::createDefault();
352335
EvaluationInput input = createTestInput();
353336

@@ -363,11 +346,8 @@ static void BM_EvaluateCompleteness(benchmark::State& state) {
363346
BENCHMARK(BM_EvaluateCompleteness)->Unit(benchmark::kMillisecond);
364347

365348
static void BM_EvaluateCoherence(benchmark::State& state) {
366-
LLMJudgeIntegration::Config config;
367-
config.use_mock_mode = true;
368-
config.warn_on_mock_mode = false;
369-
370-
LLMJudgeIntegration integration(config);
349+
LLMJudgeIntegration integration;
350+
integration.setInferenceFunction(fastInferenceFunction);
371351
PromptTemplateManager template_manager = PromptTemplateManager::createDefault();
372352
EvaluationInput input = createTestInput();
373353

@@ -387,11 +367,8 @@ BENCHMARK(BM_EvaluateCoherence)->Unit(benchmark::kMillisecond);
387367
// ============================================================================
388368

389369
static void BM_BatchEvaluation_10Inputs(benchmark::State& state) {
390-
LLMJudgeIntegration::Config config;
391-
config.use_mock_mode = true;
392-
config.warn_on_mock_mode = false;
393-
394-
LLMJudgeIntegration integration(config);
370+
LLMJudgeIntegration integration;
371+
integration.setInferenceFunction(fastInferenceFunction);
395372
PromptTemplateManager template_manager = PromptTemplateManager::createDefault();
396373

397374
std::vector<EvaluationInput> inputs;
@@ -416,11 +393,8 @@ static void BM_BatchEvaluation_10Inputs(benchmark::State& state) {
416393
BENCHMARK(BM_BatchEvaluation_10Inputs)->Unit(benchmark::kMillisecond);
417394

418395
static void BM_BatchEvaluation_100Inputs(benchmark::State& state) {
419-
LLMJudgeIntegration::Config config;
420-
config.use_mock_mode = true;
421-
config.warn_on_mock_mode = false;
422-
423-
LLMJudgeIntegration integration(config);
396+
LLMJudgeIntegration integration;
397+
integration.setInferenceFunction(fastInferenceFunction);
424398
PromptTemplateManager template_manager = PromptTemplateManager::createDefault();
425399

426400
std::vector<EvaluationInput> inputs;

0 commit comments

Comments
 (0)