Files
llm-multiverse/implementation-plans/issue-049.md
Pi Agent 6ecc8b8f38 feat: implement Search gRPC endpoint with full pipeline (issue #49)
Wire the Search RPC handler to orchestrate the full search pipeline:
SearXNG query → content extraction → Model Gateway summarization.
Supports configurable pipeline stages (extraction/summarization can
be disabled), audit logging via Audit Service, and graceful degradation
at each stage. 14 tests covering full pipeline, partial pipelines,
validation, error handling, and audit logging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:48:11 +01:00

3.0 KiB

Implementation Plan — Issue #49: Implement Search gRPC endpoint

Metadata

Field Value
Issue #49
Title Implement Search gRPC endpoint
Milestone Phase 6: Search Service
Labels
Status COMPLETED
Language Python
Related Plans issue-046.md, issue-047.md, issue-048.md
Blocked by #48, #20

Acceptance Criteria

  • Search RPC handler implemented
  • Full pipeline: query → fetch → extract → summarize
  • Results include title, URL, snippet, extracted content, summary
  • Audit-logs the search via Audit Service
  • Configurable pipeline stages (skip extraction/summarization)
  • Timeout handling for the full pipeline

Architecture Analysis

Service Context

  • Module: services/search/src/search_service/service.py
  • Orchestrates the full search pipeline: SearXNG → extraction → summarization
  • Returns SearchResponse with SearchResult entries

Proto Messages

  • SearchRequest: context (SessionContext), query (str), num_results (int)
  • SearchResponse: results (repeated SearchResult), error_message (str)
  • SearchResult: claim (str), source_url (str), confidence (float), date (str), summary (str)

Existing Components

  • SearXNGClient (searxng.py) — query meta-search
  • PageExtractor (extractor.py) — fetch + readability extraction
  • Summarizer (summarizer.py) — Model Gateway summarization
  • AuditServiceStub (audit_pb2_grpc) — audit logging

Implementation Steps

1. Update SearchServiceImpl.__init__ to accept dependencies

  • SearXNGClient, PageExtractor, Summarizer (optional), AuditServiceStub (optional)
  • Add pipeline config flags: enable_extraction, enable_summarization

2. Implement Search RPC handler

  • Validate request (query non-empty, context present)
  • Query SearXNG for snippets
  • If extraction enabled: extract content from URLs
  • If summarization enabled: summarize extracted content
  • Map results to SearchResult proto messages
  • Audit-log the search
  • Handle timeouts and errors gracefully

3. Update __main__.py

  • Initialize gRPC channels and clients
  • Pass to SearchServiceImpl

4. Tests

  • Mock SearXNG, extractor, summarizer, audit
  • Test full pipeline, partial pipeline (no extraction, no summarization)
  • Test validation errors, SearXNG errors, timeout

Files to Create/Modify

File Action Purpose
services/search/src/search_service/service.py Modify Implement Search RPC handler
services/search/src/search_service/__main__.py Modify Wire dependencies
services/search/tests/test_service.py Create Tests for Search RPC

Deviation Log

Deviation Reason
Used AUDIT_ACTION_TOOL_INVOCATION enum instead of string "search" AuditEntry.action is an enum type, not a string; no search-specific enum exists
Used google.protobuf.timestamp_pb2.Timestamp for timestamp field Proto Timestamp field requires datetime object, not ISO string