FastEmbed v2 Audit Report (Plan vs Current Codebase)
This audit compares fastembed-improvement-plan.md against the current implementation in:
cascadeflow/routing/domain.pycascadeflow/quality/complexity.pytests/test_domain_detection.py
Scope exclusions (per request):
- OpenClaw integrations
- Skills integration
Executive Summary
- P0 items: ✅ Implemented.
- P1 items: ✅ Implemented.
- P2 item (SemanticAlignmentChecker): ⏭️ Not implemented in the audited files and not required for this session.
- No missing P0/P1 gaps found in the audited scope.
Plan Item Status Matrix
| Priority | Plan item | Status | Evidence | Action needed |
|---|---|---|---|---|
| P0 | Add domain exemplars (finance, conversation, factual) | ✅ Implemented | DOMAIN_EXEMPLARS includes expanded exemplar sets for FINANCIAL, CONVERSATION, and FACTUAL. |
None |
| P0 | Enable hybrid mode by default | ✅ Implemented | SemanticDomainDetector.__init__(..., use_hybrid: bool = True) defaults hybrid on. |
None |
| P1 | Domain-specific confidence thresholds | ✅ Implemented | DOMAIN_THRESHOLDS exists with lowered thresholds for conversation/financial/factual and stricter ones for medical/legal. |
None |
| P1 | Add FastEmbed semantic layer to complexity detection | ✅ Implemented | COMPLEXITY_EXEMPLARS and SemanticComplexityDetector are present in complexity.py. |
None |
| P2 | SemanticAlignmentChecker for query-response alignment | ⏭️ Not in audited files | No alignment checker implementation in reviewed files; likely handled elsewhere (alignment_scorer.py area mentioned in AGENTS context). |
Not required for this task |
Detailed Findings
1) Enhanced Domain Exemplars (P0)
Implemented.
The plan called for richer exemplar coverage in weak domains. Current DOMAIN_EXEMPLARS contains expanded and targeted examples for:
Domain.FINANCIAL(e.g., compound interest, ROI, tax implications, diversification, P/E ratio)Domain.CONVERSATION(greetings, chat prompts, social dialogue markers)Domain.FACTUAL(capital/country questions, historical fact checks, verification-style prompts)
Test coverage present:
TestFastEmbedPlanEnhancementschecks exemplar counts and representative prompts for these domains.
2) Smart Hybrid Mode Default (P0)
Implemented.
SemanticDomainDetector has use_hybrid=True by default and blends semantic + rule-based scoring in detect_with_scores.
Notes:
- Hybrid weighting is dynamic (
70/30when semantic confidence is high, else50/50). - This differs from the exact pseudo-logic in the plan but achieves the same goal (hybrid-first behavior with confidence-aware blending).
3) Domain-Specific Thresholds (P1)
Implemented.
DOMAIN_THRESHOLDS includes domain-specific cutoffs:
- Lower:
CONVERSATION=0.50,FINANCIAL=0.55,FACTUAL=0.50 - Higher safety bars:
MEDICAL=0.70,LEGAL=0.70 - Fallback:
GENERAL=0.40
SemanticDomainDetector.detect_with_scores applies per-domain thresholding before fallback.
Test coverage present:
- Threshold-focused assertions exist and verify lower/higher threshold expectations.
4) Semantic Complexity Detection (P1)
Implemented.
complexity.py contains:
COMPLEXITY_EXEMPLARSfor each complexity levelSemanticComplexityDetectorusing embeddings + cosine similarity- Optional hybrid blending with rule-based detector
Notes:
- The plan named this concept
SemanticComplexityBooster; the implementation name isSemanticComplexityDetector. - Functional intent is satisfied.
5) Semantic Alignment Checker (P2)
Not in this audited scope.
No code changes required here for requested deliverables.
What’s Not Needed (for this session)
- No additional P0/P1 implementation work is required in the audited files because those items are already present.
- No OpenClaw or Skills integration work performed (explicitly skipped).
- No UI/frontend screenshot required (backend/test/docs-only changes).
Recommended Follow-ups (Optional)
- Add dedicated tests for
SemanticDomainDetectorruntime behavior (with mocked embedder) to validate:- hybrid default behavior,
- per-domain threshold fallback logic,
- disagreement resolution between rule vs semantic scores.
- Add/verify complexity semantic tests if not present in
tests/forSemanticComplexityDetector. - If alignment enhancement is still desired, audit
cascadeflow/quality/alignment_scorer.pyseparately for FastEmbed parity.