-
Notifications
You must be signed in to change notification settings - Fork 1
Module prompt engineering Roadmap
Production-capable prompt engineering runtime exists for template lifecycle operations, context injection, revision/version control, optimization/evaluation loops, feedback ingestion, and prompt metrics support.
- hardening adversarial/edge-case template and injection validation behavior (Target: Q3 2026) — COMPLETED 2026-08-08
- [~] improving optimization/evaluation diagnostics consistency across failure classes (Target: Q3 2026)
- [~] stabilizing benchmark-backed release guardrails for prompt engineering hot paths (Target: Q3 2026)
- tighten deterministic behavior for concurrent template/version mutation traffic (Target: Q4 2026)
- expand stress coverage for optimization loops and feedback-heavy scenarios (Target: Q4 2026)
- improve operator-facing diagnostics for prompt incident triage (Target: Q4 2026)
- introduce deterministic
RewriteEnginefor prompt normalization, policy rewrites, and NL→AQL preprocessing (Target: Q4 2026)
- re-baseline p95/p99 envelopes for prompt template/version/quality paths (Target: Q1 2027)
- broaden benchmark depth for module-native advanced prompt workflows (Target: Q1 2027)
- harden long-run reliability under sustained prompt update/evaluation pressure (Target: Q1 2027)
- extend
RewriteEngineto post-generation canonicalization and structured agent/tool output normalization (Target: Q1 2027)
- freeze template/versioning/optimization contracts for current major line (Target: Q3 2026) — See PHASE_1_CONTRACT.md
- define explicit error taxonomy for prompt engineering failure classes (Target: Q3 2026) — See ERROR_TAXONOMY_REFERENCE.md and prompt_engineering_errors.h (52 error codes)
- define
RewriteEngineinterfaces (RewriteDocument,RewriteContext,RewriteResult,RewriteTrace,IRewriteRule) and phase boundaries (Target: Q4 2026) — See rewrite_engine.h
- complete hardening for manager/version control and validator internals (Target: Q4 2026) — PHASE_1_CONTRACT.md baseline established
- align optimization/evaluation behavior to bounded runtime contracts (Target: Q4 2026) — baseline contracts defined
- implement deterministic ordered rule execution, rule registration, and YAML-backed low-risk rewrite loading (Target: Q4 2026) — RewriteEngine implementation complete
-
rewrite_engine.cpp: Core orchestration with phase ordering, priority-based execution, max-steps prevention -
rewrite_rule_base.cpp: Concrete rule types (RegexRewriteRule, DictionaryRewriteRule, PolicyRewriteRule, SemanticRewriteRule) -
rewrite_rule_loader.cpp: YAML schema validation and lexical rule loading -
rewrite_metrics.cpp: Observability with per-rule and per-phase metrics
-
- implement
RewriteEngineexecutor with deterministic rule evaluation and phase isolation (Target: Q4 2026) — all 4 phases (input normalization, policy, NL→AQL, post-gen) implemented - implement YAML configuration schema for input normalization rules (Target: Q4 2026) — regex and dictionary rules with schema validation
- standardize fail-safe behavior for invalid templates, injection mismatches, and version faults (Target: Q4 2026) — COMPLETED 2026-08-08
-
PromptTemplateValidatorextended with injection detection methods - SQL, command, path traversal, and template injection patterns detected
- Adversarial test cases: 54+ malicious payloads covering evasion attempts and edge cases
- Integration:
validate()automatically checks template content for injection patterns
-
- unify diagnostics across manager/version/optimizer/evaluator incidents using
PromptEngineeringErrorContext(Target: Q4 2026) - enforce rewrite step bounds, phase isolation, malformed-rule rejection, and terminal policy behavior (Target: Q4 2026)
- BATCH 3: Adversarial/Edge-Case Validation (Target: Q3 2026) — COMPLETED 2026-08-15
- 8 test classes covering: SQL injection, Command injection, Path traversal, XSS, Template recursion, Unicode evasion, Null byte injection, Mixed attacks
- 54+ malicious payloads for comprehensive injection pattern detection
- File:
tests/prompt_engineering/test_prompt_engineering_adversarial_focused.cpp - Target detection rate: 100% on known malicious inputs, <1% false positives on benign prompts
- [~] expand focused regressions for invalid template and concurrent mutation scenarios (Target: Q4 2026) — Focused test suite PE-FT-001..PE-FT-015 established; BATCH 3 adversarial suite PE-ADV-01..08 complete (2026-08-15)
- [~] extend deterministic stress fixtures for optimization/evaluation workloads (Target: Q4 2026) — Synthetic workload generators implemented; stress test harness ready (2026-08-07)
- [~] add unit/integration coverage for rewrite rule ordering, trace generation, normalization idempotence, and NL→AQL preprocessing flows (Target: Q4 2026) — Rewrite rule test cases drafted; NL→AQL preprocessing validation pending (2026-08-07)
- lock benchmark-backed release gates for prompt engineering hot paths (Target: Q4 2026) — Complete: bench_prompt_engineering.cpp (PromptManager/VersionControl/Optimizer/Evaluator gates) + bench_rewrite_engine.cpp (PEG-01..06 RewriteEngine gates) delivered (2026-08-07)
- [~] validate p95/p99 and throughput behavior against release baselines (Target: Q4 2026) — Benchmark suite ready for execution; p95/p99 validation in progress (2026-08-07)
- [~] benchmark rewrite latency/trace overhead and harden regex/rule execution against adversarial expansion or loop behavior (Target: Q4 2026) — PEG-04..06 (rule loading, trace gen, step limits) implemented; adversarial testing in progress (2026-08-07)
- core prompt_engineering docs aligned to source-verifiable behavior (Target: Q3-Q4 2026) — Complete with Phase 1-2 deliverables
- roadmap/future planning separated from historical changelog entries
- focused test infrastructure (PE-FT-001..PE-FT-015) implemented at
tests/prompt_engineering/test_prompt_engineering_focused.cpp(Target: Q3 2026) - document and integrate rewrite engine architecture and operational guidance (
docs/architecture/rewrite_engine_architecture.md) (Target: Q4 2026) — Complete 2026-08-07 - benchmark gates documented: GATE-PE-01..06 (PEG-01..06) in
benchmarks/prompt_engineering/bench_rewrite_engine.cpp(Target: Q4 2026) — Delivered 2026-08-07 - [~] acceptance checklist sign-off ready for final human review (Target: Q4 2026)
- core prompt engineering surfaces documented and source-verified
- module-level security and failure behavior documented (Phase 1: error taxonomy in prompt_engineering_errors.h and ERROR_TAXONOMY_REFERENCE.md)
- benchmark mapping documented in performance expectations (Phase 5: bench_prompt_engineering.cpp + bench_rewrite_engine.cpp with GATE-PE-01..06)
- focused test infrastructure (PE-FT-001..PE-FT-015) implemented for core surfaces
- [~] remaining hardening tasks in progress for template/versioning/quality edge paths (Phase 3 + Phase 4 work, target completion 2026-08-15)
- [~] release benchmark stabilization in progress (Phase 5 work, target completion 2026-08-15)
- [~] rewrite engine deterministic rule execution, bounded behavior, and audit trace support validated in production-like test profiles (Phase 2–5 work, target completion 2026-08-15)
- backward compatibility guarantee documented and reviewed (Phase 1: PHASE_1_CONTRACT.md)
- RewriteEngine benchmarks with 6 release gates (GATE-PE-01..06) documented and registered (2026-08-07)
- runtime behavior depends on template quality, injected context shape, optimizer configuration, and downstream model behavior.
- selected adversarial and concurrency-heavy edge scenarios need continued hardening.
- benchmark depth should continue expanding for advanced prompt engineering workflows.
- rewrite-driven normalization and policy behavior are not yet implemented and remain roadmap work.
No breaking prompt engineering contract planned. Any contract-breaking change requires migration notes and changelog entry before merge.
Implemented focused test suite at tests/prompt_engineering/test_prompt_engineering_focused.cpp:
| Test ID | Area | Coverage | Status |
|---|---|---|---|
| PE-FT-001 | PromptManager template lifecycle | create/get/list operations | ✅ PASS |
| PE-FT-002 | Context injection | context map substitution | ✅ PASS |
| PE-FT-003 | Template validation | valid/invalid template checks | ✅ PASS |
| PE-FT-004 | PromptVersionControl | commit/history operations | ✅ PASS |
| PE-FT-005 | FeedbackCollector | feedback recording and stats | ✅ PASS |
| PE-FT-006 | PromptOptimizer | basic optimization loop | ✅ PASS |
| PE-FT-007 | PromptEvaluator | structural evaluation | ✅ PASS |
| PE-FT-008 | PromptEngineeringMetrics | metrics recording | ✅ PASS |
| PE-FT-009 | Error handling | missing template edge case | ✅ PASS |
| PE-FT-010 | Error handling | invalid context injection edge case | ✅ PASS |
| PE-FT-011 | Concurrency | basic concurrent template access | ✅ PASS |
| PE-FT-012 | Injection validation | empty placeholder edge case | ✅ PASS |
| PE-FT-013 | Version control | commit history consistency | ✅ PASS |
| PE-FT-014 | Optimizer diagnostics | diagnostic output validation | ✅ PASS |
| PE-FT-015 | Evaluator consistency | multiple evaluation consistency | ✅ PASS |
-
benchmarks/prompt_engineering/bench_prompt_engineering.cppprovides performance validation - Covers 13 benchmark targets for template operations, context injection, version control, feedback, optimization, and evaluation
- Performance targets documented and tracked (e.g., createTemplate < 10 µs, getTemplate < 1 µs)
-
Build (Preset:
community-release-allow-missing-rocksdb)-
module_prompt_engineering_test_prompt_engineering_focused_focused- focused test executable -
bench_prompt_engineering- benchmark executable
-
-
Test Registry
- Focused tests registered with:
themis_register_module_focused_test(MODULE prompt_engineering TIER unit TIMEOUT 120) - CTest labels:
prompt_engineeringfor filtering and aggregation
- Focused tests registered with:
- ✅ Roadmap priorities (8 Q3/Q4/Q1 2027 items) synced with ROADMAP.md
- ✅ Future enhancements scope aligned with FUTURE_ENHANCEMENTS.md
- ✅ Core API surfaces tested (template, versioning, feedback, optimization, evaluation, metrics)
- ✅ Error handling and edge cases covered (15 focused test cases)
- ✅ Concurrency sanity check included
- ✅ Benchmark infrastructure exists and measurable against documented targets
Core Engine Implementation
-
src/prompt_engineering/rewrite_engine.cpp(495 lines)- Phase-ordered deterministic execution (phases 1-4 in strict sequence)
- Thread-safe rule registration and management with shared_mutex
- Max-steps loop prevention (default 1000, configurable per context)
- Rule lookup optimization by phase
- Trace collection with optional max_trace_entries limit
- JSON stats export with rule counts, latency, transformation metrics
Concrete Rule Type Implementations
-
src/prompt_engineering/rewrite_rule_base.cpp(409 lines)-
RegexRewriteRule: Precompiled regex patterns with backreference support, max_replacements bound -
DictionaryRewriteRule: Hash-based substitution with case-sensitive/insensitive modes -
PolicyRewriteRule: Custom match/apply callbacks for semantic policy enforcement (terminal mode) -
SemanticRewriteRule: Base class for complex C++-only rule implementations
-
YAML Rule Loader
-
src/prompt_engineering/rewrite_rule_loader.cpp(328 lines)- Schema validation for YAML rule definitions
- Lexical-only constraint enforcement (regex and dictionary rules only from YAML)
- All-or-nothing loading semantics (partial failures don't modify registry)
- Phase/priority/mapping validation with detailed error messages
- Regex compilation validation at load time
Observability
-
src/prompt_engineering/rewrite_metrics.cpp(230 lines)- Per-rule metrics: match/apply/error counts, min/max/avg latency
- Per-phase metrics: aggregated rules_evaluated/rules_applied/total_latency
- Global singleton metrics collection with reset capability
- JSON export with timestamp for integration with monitoring systems
| Test ID | Coverage | Location | Status |
|---|---|---|---|
| RW-P2-01 | Rule registration and deduplication | test_rewrite_engine_focused.cpp:45-113 | ✅ PASS |
| RW-P2-02 | Phase ordering enforcement | test_rewrite_engine_focused.cpp:125-160 | ✅ PASS |
| RW-P2-03 | Priority-based execution within phases | test_rewrite_engine_focused.cpp:172-207 | ✅ PASS |
| RW-P2-04 | Max-steps loop prevention | test_rewrite_engine_focused.cpp:219-256 | ✅ PASS |
| RW-P2-05 | Trace correctness and completeness | test_rewrite_engine_focused.cpp:268-330 | ✅ PASS |
| RW-P2-06 | Thread-safety under concurrent register/rewrite | test_rewrite_engine_focused.cpp:342-427 | ✅ PASS |
Additional Tests
- Multi-phase execution integration test
- Dictionary rule substitution
- Statistics tracking and JSON export
- 28 focused test cases total covering RW-FT-001..028 scenarios
-
include/prompt_engineering/rewrite_rule.h(238 lines)- Interface declarations for all 4 rule types
- Callback function type aliases for PolicyRewriteRule
- Doxygen documentation for all public methods
-
include/prompt_engineering/rewrite_rule_loader.h(62 lines)- RewriteRuleLoader class with load/validate/error reporting
- All-or-nothing semantics documented
-
src/prompt_engineering/CMakeLists.txtcreated-
themis_prompt_engineering_rewritelibrary target - Linked against nlohmann_json, spdlog, yaml-cpp
- C++17 standard requirement
- Integrated with test infrastructure via glob pattern in tests/prompt_engineering/CMakeLists.txt
-
- ✅ RewriteEngine core implemented and linked
- ✅ All rule types (regex, dictionary, policy, semantic) compilable and functional
- ✅ YAML loading works for lexical rules with schema validation
- ✅ 6 focused RW-P2 tests passing (28 total test cases)
- ✅ No blocking compile/link errors
- ✅ Thread-safety verified under concurrent operations
- ✅ Deterministic phase ordering enforced
- ✅ Observability metrics collected and exported
- Stream B (Secondary): Phase 3 error paths (RW-P3-01..04) — can proceed immediately
- Stream C (Tertiary): Phase 4 comprehensive tests (RW-FT-001..060 expansion)
- Stream D (Performance): Phase 5 benchmarking (bench_rewrite_engine.cpp)
- Stream E (Documentation): Phase 6 docs (operational guidance, YAML schema reference)
This module is a contributing module in the program-level Wave A → B → C → D execution model.
It does not own a primary wave deliverable but must remain release_critical-green throughout all waves
and must deliver Wave D operability improvements in Q1 2027.
See [[../../ROADMAP.md|ROADMAP]] for the full wave model and exit criteria.
- Deliver or validate distributed tracing, high-cardinality stress coverage, exporter reliability, and operator remediation hints as applicable to this module (Target: Q1 2027)
- Contribute to or validate long-duration soak test coverage for this module's primary paths (Target: Q1 2027)
- Ensure runbook coverage for operator-critical scenarios in this module (Target: Q1 2027)
-
release_criticalCI must remain green ondevelopthroughout all waves (Target: ongoing) - p95/p99 benchmarks must be refreshed on representative hardware before Wave D sign-off (Target: Q1 2027)
- No behavioral regression may be introduced into modules in Wave A/B/C scope from changes in this module.
- This module's distributed/acceleration paths fail closed (Target: Q1 2027)
- Benchmark-backed p95/p99 baselines exist on representative hardware (Target: Q1 2027)
- Operator-critical paths have diagnostics, alerts, and runbooks (Target: Q1 2027)
- 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