Sprint 4 — Smart indexing, streaming search, production hardening#4
Merged
svalench merged 2 commits intoMay 8, 2026
Merged
Conversation
added 2 commits
May 8, 2026 07:10
Adds opt-in SmartIndexer that builds structured per-section documents, an event hub for the LangGraph search pipeline, and an NDJSON/SSE streaming endpoint. All features are off by default and gated behind flags so the public API stays backward compatible. Smart indexing * SmartIndexer pipeline: inspect_model -> collect_fields -> enrich_document -> embed_batch -> persist * DocumentTemplate / FieldSection dataclasses; per-model templates via SMART_INDEXING.TEMPLATES, with a deterministic heuristic fallback (default_template_for) when no template is registered * Always appends legacy text as safety net so smart indexing never produces less content than the classic indexer * New get_indexer() factory in indexer.py routes to SmartIndexer when enabled and back to Indexer otherwise. Signals, app-level index(), and the build_search_index command all use the factory now. Event hub & streaming endpoint * events.EventHub with subscribe/publish, thread-safe and tolerant of subscriber exceptions; get_default_hub() singleton helper * Both LangGraph and the in-tree fallback runner emit lifecycle events: query_received, query_expanded, vector_search_completed, rerank_completed, completed * Searcher now accepts an event_hub kwarg and forwards it into the graph factory only when supported (TypeError-tolerant) * StreamingSearchAPIView: NDJSON (default) or SSE, runs search in a worker thread, drains events through queue.Queue, terminal 'end' event for reliable client-side stream termination, sets X-Accel-Buffering: no for proxies * Endpoint returns 404 when STREAMING.ENABLED is false Hardening * Settings additions are dataclass-frozen and validated (STREAMING.FORMAT must be ndjson|sse, SMART_INDEXING.TEMPLATES must be a dict, etc.) * No new hard dependencies; LangGraph and LLM SDKs remain optional Tests: +22 tests (10 smart indexing, 12 events/streaming). All 58 tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sprint 4 — Smart indexing, streaming, and production hardening
This PR is stacked on top of PR #3 (Sprint 3 conversational search). Merging PR #2 → PR #3 → this one delivers the full LangGraph integration described in the original plan.
What's new
Smart indexing (
SMART_INDEXING.ENABLED)SmartIndexerorchestration that builds structured documents with labelled sections (Title:,Description:,Category:…) so the embedder can distinguish field roles.SMART_INDEXING.TEMPLATES, with a deterministic heuristic fallback when none is provided.get_indexer()factory returns the right implementation based on settings. Signals,index(), and thebuild_search_indexmanagement command all use the factory now.Event hub & streaming endpoint
events.EventHub— thread-safe, error-tolerant pub/sub used by the LangGraph nodes.query_received,query_expanded,vector_search_completed,rerank_completed,completed.StreamingSearchAPIViewat/api/search/stream/:STREAMING.FORMAT.queue.Queueso users see progress in real time.endevent gives clients a reliable stream-termination marker.X-Accel-Buffering: noso reverse proxies don't buffer the response.STREAMING.ENABLED=False, so the URL is safe to leave registered.Production hardening
_build_*_confighelpers and stored in frozen dataclasses (SmartIndexingConfig,StreamingConfig).STREAMING.FORMATmust be"ndjson"or"sse"; invalid values raiseConfigurationErrorat boot.Searcherforwardsevent_hubto the graph factory only when supported (TypeError-tolerant), so custom graph factories don't have to be updated.Backward compatibility
False. Existing users see zero behavioural change.Searcher.search,Searcher.find_similar,Indexer, REST endpoints) is unchanged.Document.textpayloads continue to work.Tests
Quick demo
Merge order
#2(Sprint 1+2) →main#3(Sprint 3) →mainmainOr merge into the corresponding base branches in stacked order if preferred.