Skip to content

[P2-Enhancement] Add explain API for search result debugging #72

@VirtualAgentics

Description

@VirtualAgentics

Description

Add explain API endpoint to help developers understand and debug search results by showing the factors that contributed to each result's ranking.

Background

This enhancement extends Issue #58 (hybrid search) by providing debugging capabilities that help developers understand why certain results were returned and how to tune search parameters.

Requirements

  • Add /v1/search/explain endpoint
  • Show scoring factors: similarity, BM25, freshness, quality
  • Display individual factor contributions
  • Add debugging information for search tuning
  • Include result metadata and processing details
  • Add explain API documentation
  • Add explain API tests

Implementation Details

Files to modify:

  • src/contextforge_memory/main.py - Add explain endpoint
  • src/contextforge_memory/search/ - Add explain functionality
  • src/contextforge_memory/explain/ - New explain module
  • tests/ - Add explain tests
  • README.md - Document explain API

Technical approach:

  • Create explain service that breaks down search scoring
  • Add detailed result analysis with factor contributions
  • Implement debugging information collection
  • Add explain response formatting
  • Create explain API documentation

Acceptance Criteria

  • Explain endpoint returns detailed scoring breakdown
  • All scoring factors are explained clearly
  • Debugging information is helpful for tuning
  • API documentation is complete
  • Tests cover explain functionality

Testing Requirements

  • Unit tests for explain logic
  • Integration tests for explain endpoint
  • Performance tests for explain overhead
  • Documentation tests for explain API

Documentation Updates

  • README.md - Document explain API
  • API documentation - Explain endpoint
  • Debugging guide - Search tuning
  • Examples - Explain API usage

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions