4.0 KiB
4.0 KiB
1. Pipeline Models
- 1.1 Add query transformation model for original query, rewritten query, domain hints, matched keywords, entities, category filter, and trace-only L0 titles.
- 1.2 Add retrieved evidence candidate model that normalizes vector result metadata, score semantics, source, title, breadcrumb, content, retrieval attempt, and original rank.
- 1.3 Add context pack, retrieval trace, and rerank trace DTOs for the new
LookupResultcontract. - 1.4 Update
LookupResultto expose evidence blocks, context pack, retrieval trace, rerank trace, relevance level, completeness hint, retrieved domains, and message.
2. Query And Retrieval Pipeline
- 2.1 Implement
KnowledgeQueryTransformerby reusingKnowledgeIndexService.analyzeQueryand mapping L0 output to query hints and optional category filter. - 2.2 Implement
KnowledgeDocumentRetrieveras a wrapper aroundVectorSearchServicefor filtered and unfiltered vector retrieval attempts. - 2.3 Implement low-quality detection using empty candidates, empty final evidence, or top normalized similarity below
retrieval.normalization.reference-threshold. - 2.4 Implement unfiltered raw-query retry when filtered retrieval is low quality and record fallback reason in retrieval trace.
3. Post-Retrieval Processing
- 3.1 Move relevance normalization out of
LookupKnowledgeToolintoKnowledgeEvidencePostProcessor. - 3.2 Move evidence block creation and source-level deduplication out of
LookupKnowledgeToolinto the post-processor. - 3.3 Implement rule-based lightweight rerank using vector similarity, domain match, entity match, keyword match, and metadata/source-type signals.
- 3.4 Ensure L0 hints influence filter/rerank/trace only and are not returned as standalone fact evidence when L1 has no usable evidence.
4. Context Packing And Result Assembly
- 4.1 Implement
KnowledgeContextPackerwith a configurable MVP character budget. - 4.2 Pack evidence blocks while preserving source, title, breadcrumb, and hit reasons before truncating content.
- 4.3 Implement
LookupResultAssemblerto build evidence-first results for usable evidence, no-evidence, and session dedup cases. - 4.4 Remove or migrate all
primaryandsupplementresult usage from production code.
5. Tool Boundary And Trace Recording
- 5.1 Refactor
LookupKnowledgeToolinto a thin orchestrator that invokes the pipeline and handles tool boundary concerns. - 5.2 Update
ToolInvocationRecorder.LookupKnowledgeRecordto summarize context pack, retrieval trace, rerank trace, fallback reason, and evidence blocks without relying onresult.getPrimary(). - 5.3 Preserve stable
tool_invocationtable fields and store new retrieval details in JSON. - 5.4 Update
@Tooldescription and relevant executor prompt text to describe evidence blocks, context pack, and no-realtime-data boundaries.
6. Tests And Evaluation
- 6.1 Update
LookupKnowledgeToolTestfor evidence-first result contract and removal ofprimary/supplement. - 6.2 Add tests for filtered L1 success without retry.
- 6.3 Add tests for filtered low-quality retrieval triggering raw unfiltered L1 retry.
- 6.4 Add tests proving L0 hint data does not become standalone fact evidence when L1 fails.
- 6.5 Add tests for rerank ordering, rerank trace, context pack budget behavior, and source metadata preservation.
- 6.6 Update
ToolInvocationRecorderTestfor new retrieval detail summaries and output preview source. - 6.7 Run targeted Java tests for lookup knowledge and recorder changes.
- 6.8 Run OpenSpec validation for
modular-rag-pipeline.
7. Documentation Cleanup
- 7.1 Update RAG architecture docs to reflect modular pipeline, unfiltered vector retry, and evidence-first contract.
- 7.2 Update retrieval observability docs to remove L0 primary fallback and
primary/supplementcompatibility language. - 7.3 Review git diff to confirm only expected RAG, prompt, test, and spec files changed.