Skip to content
github-actions[bot] edited this page Aug 31, 2026 · 2 revisions

AI Module - Future Enhancements

Scope

  • Hardening of endpoint safety, payload validation, and error observability for AI plugin generation.
  • Introduction of dedicated performance coverage for the AI generation path.
  • Future integration of external sandbox/static-analysis policy engines on top of the built-in artifact materialization gate.

Design Constraints

  • Public API contracts in include/ai/ai_plugin_generator.h remain backward compatible within major line.
  • Validation and error behavior must remain deterministic and fail-closed.
  • Runtime behavior must remain bounded by timeout/retry budgets.
  • Security-sensitive request content must not be persisted unredacted.

Required Interfaces

Interface Requirement
validatePrompt extend checks for required_capabilities and dependencies consistency
generatePlugin preserve validation-first execution and fail-closed return semantics
AIPluginGenerator::Config expose explicit safety knobs (allow-list, payload limit, retry policy)
benchmark integration maintain dedicated ai generation benchmark target and release mapping

Implementation Notes

  • Add response schema validation with explicit required and optional fields.
  • Add bounded retry/backoff only for transient transport failures.
  • Add response-size hard limit before parse to prevent memory pressure.
  • Field-level validation for required_capabilities/dependencies, configurable endpoint allow-list, request/response size limits, dedicated benchmark coverage, and built-in sandbox artifact materialization are implemented in the runtime path; remaining hardening focuses on external sandbox/static-analysis policy engines.
  • Standardize error classes for validation, transport, HTTP status, parse, and payload shape failures.

Test Strategy

  • Unit tests for new validation rules and schema failure cases.
  • Integration tests with deterministic endpoint fixtures (success, non-2xx, malformed JSON, oversized payload).
  • Regression tests for existing structured error contracts.
  • Benchmark regression tracking in release profile for mapped AI targets.

Performance Targets

  • Prompt validation path p99 remains within low-single-digit milliseconds.
  • Endpoint orchestration overhead remains stable versus current release baseline.
  • Proxy benchmark regressions stay within configured release threshold until dedicated benchmark is introduced.

Security / Reliability

  • Enforce endpoint allow-list checks before outbound calls (implemented).
  • Enforce maximum request and response size limits (implemented).
  • Materialize generated source bundles into sandbox/output directories with fail-closed read-back verification before optional callback policy execution (implemented).
  • Keep fail-closed behavior for malformed/untrusted responses.
  • Ensure logs remain redacted and bounded for sensitive fields.

Wave C β€” Strategic ML Enhancements (Q3 2027+)

Long-term strategic AI/ML features for enhanced safety, privacy, and governance. Lower urgency but high strategic value.

C1: Constitutional AI (CAI) Safety Module

  • Design constitutional principles registry (21 built-in rules)
  • Implement LLM-as-critic evaluation loop
  • Build revision prompt generation
  • Create critic-revision cycle (max 2 rounds)
  • Unit tests CAI-01..15 + CAI-BENCH-01 (tests/test_cai_safety_module.cpp)
  • Integration with EthicsEvaluator (include/ai/cai_ethics_integration.h)
  • Production runtime hook integration in LLMAQLHandler paths (executeInfer, executeInferStreaming, executeRAG, executeChat) with fail-closed callback handling
  • Human safety benchmark (500 samples, 3 annotators) β€” tests/test_cai_safety_module.cpp (CAI-BENCH-01)

Acceptance Criteria:

  • Safety score alignment β‰₯ 0.80 with human annotators
  • Latency overhead ≀ 2.0 s per response
  • False-positive rate ≀ 10% (benign content flagged as unsafe)

Reference: Bai et al. (2022) arXiv:2212.08073

C2: Federated Learning for Privacy-Preserving Training

  • Design synchronized SGD gradient aggregation
  • Implement secure aggregation primitive (stub: optional homomorphic encryption)
  • Build Byzantine-robust averaging (median/trimmed mean)
  • Create federated training coordinator
  • Unit tests FEDERATED-01..15 + FEDERATED-BENCH-01 (tests/test_federated_privacy_training.cpp)
  • Production telemetry hook integration in LLMAQLHandler paths (executeInfer, executeInferStreaming, executeRAG, executeChat) with fail-closed callback handling
  • Multi-node convergence benchmark (10 nodes, 10% data each) β€” tests/test_federated_privacy_training.cpp (FEDERATED-BENCH-01)
  • Differential privacy tuning framework

Acceptance Criteria:

  • Training convergence β‰₯ 95% of centralized baseline
  • Gradient communication overhead ≀ 2.0 s per round
  • Configurable epsilon-differential privacy budget

Reference: Kairouz et al. (2021) JMLR 2021, arXiv:2104.14881

Wave C Dependencies and Risk Mitigation

Blockers / Dependencies

  • Wave A + Wave B stability checks tracked in release verification artifacts (CTEST.md, issues #5038/#5039)
  • Constitutional AI principles formalized in ethics framework (src/ai/cai_ethics_integration.cpp, tests/test_cai_safety_module.cpp)
  • Multi-node federated benchmark infra/security review tracking established (FEDERATED-BENCH-01 + Wave issue traceability)

Risk Mitigation

  • C1 (CAI): Start with simple rule-based critic; LLM-based only after v0.1
  • C2 (Federated): Deploy in staging first; Byzantine-robustness is nice-to-have, not critical for v1.0

Timeline

  • Start: Q3 2027 (early July)
  • Target: End Q4 2027 (mid-December)
  • Estimated Effort: 16–24 weeks total (depending on C2 security requirements)

Research Publication Opportunity

  • Joint paper: ThemisDB Integration of Research-Backed ML Features
  • Target: ML Systems + Governance conference (e.g., MLSys 2028, FAccT 2028)

Related Documents

  • Research Bibliography: docs/research/ml_enhancements_bibliography.md
  • Roadmap: src/ai/ROADMAP.md
  • Future Enhancements: src/ai/FUTURE_ENHANCEMENTS.md
  • Wave C Issue: #5040
  • Wave A Issue: #5038
  • Wave B Issue: #5039

Wave B: High-Value ML Enhancements (Q1–Q2 2027)

Scope

Research-backed AI/ML features for mid-term deployment (Q1–Q2 2027). Builds on Wave A foundation and targets significant performance/capability improvements.

Items

B1: Self-RAG (Self-Retrieving, Auto-Critique)

  • Design retrieval controller (binary classify: Retrieve now?)
  • Implement critic model (3-class: Relevant/Partial/Irrelevant)
  • Build iterative refinement loop (max 3 rounds)
  • Unit tests SELF_RAG-01..12
  • Integration with InferenceEngineEnhanced callback
  • Benchmark vs. vanilla RAG on ALCE dataset

Acceptance Criteria:

  • βœ… Hallucination rate reduction β‰₯ 20% vs. standard RAG
  • βœ… Latency increase ≀ 1.5Γ— vs baseline
  • βœ… Precision@K retrieval β‰₯ 0.85 on golden-doc tests

B2: Knowledge Graph Completion (RotatE)

  • Implement RotatE embedding model (relation-as-rotation)
  • Build triple loss with negative sampling
  • Create link-prediction head
  • Unit tests KGC-01..15
  • Benchmark vs. TransE baseline
  • Integrate with KnowledgeGraphReasoner

Acceptance Criteria:

  • βœ… MRR β‰₯ 0.35, Hits@10 β‰₯ 0.55 on deterministic acceptance fixture
  • βœ… Inference latency ≀ 50 ms for top-20 predictions
  • βœ… Zero backward compatibility breaks

B3: Multi-Task LoRA Fine-Tuning

  • Design shared LoRA base with task-specific projections
  • Implement domain-gating mechanism
  • Build joint loss with configurable task weighting
  • Unit tests MTL-01..10
  • Ablation study: shared multi-task training vs. per-task single-task baselines
  • 3-task benchmark evaluation

Acceptance Criteria:

  • βœ… Average task performance β‰₯ +8% vs. single-task
  • βœ… Training time increase ≀ 15%
  • βœ… Robust across task configurations

Timeline

  • Start: Q1 2027 (early January)
  • Target: End Q2 2027 (mid-June)
  • Estimated effort: 12–16 weeks total

Blockers / Dependencies

  • Wave A (Speculative Decoding, DPR, Fairness) deployment complete
  • LLM inference P95 latency < 200 ms (prerequisite for iterative loops)
  • KnowledgeGraphReasoner stable + benchmarks passing

Related Documents

  • Research Bibliography: ../../docs/research/ml_enhancements_bibliography.md
  • Roadmap: ROADMAP.md
  • issue scope: https://github.com/makr-code/ThemisDB/issues/5039

ThemisDB 1.9.0-beta Β· Home Β· Module-Index Β· GitHub Β· Issues

ThemisDB Wiki

🏠 Overview

πŸš€ Getting Started

πŸ“– Tutorials

πŸ“— User Guide

βš™οΈ Operations & Security

πŸ“Ÿ Ops Runbooks

πŸ—οΈ Architecture

πŸ“ ADRs

πŸ”§ Contributing

πŸ“‹ Governance

πŸ” Audit

🧩 Plugins

πŸ”Œ Adapters

πŸ’‘ Examples

πŸ“¦ Client SDKs

πŸŽ“ Training

πŸ› οΈ Tools

πŸ€– Developer LLM Wiki

Clone this wiki locally