Fix/phase1 sdd compliance - #12
Merged
Merged
Conversation
Teng91
commented
May 26, 2026
Owner
- 38ebe0d — 核心架構對齊(retriever、search_tsv、UUID job_id、init_db、Alembic)
- d139031 — SDD 完整合規(score 正規化、llm_providers_path 接線、Alembic env var、indexing cleanup)
- Add search_tsv TSVECTOR generated column + GIN index to Article model - Create rag/retriever.py (Retriever class) per spec, using search_tsv instead of on-the-fly to_tsvector() — enables GIN index usage - Refactor service.py: remove _search_articles, use self.retriever.search - Fix trigger_index: return UUID job_id instead of "stub-job-id", add 409 Conflict for already-indexing articles - Fix get_status: return pending_articles=0 (not total article count) - Add db.init_db() for CREATE EXTENSION vector + create_all - Set up Alembic: async env.py, initial migration with search_tsv + GIN - Add alembic dependency to pyproject.toml - New test_retriever.py: verify SQL uses search_tsv @@, not to_tsvector - Update test_service.py: mock retriever.search, add UUID/409 tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Normalize ts_rank to 0-1 in Retriever (rank/(rank+1)), re-add le=1.0 to ChunkResult.score — now matches spec's 0-1 range - Wire CHATBOT_LLM_PROVIDERS_PATH: change default from "" to None, pass settings.llm_providers_path in init_llm_service(), add to spec - Fix Alembic env.py to read CHATBOT_DATABASE_URL from env var - Fix _indexing_articles never cleaned up — discard after stub returns - Update contract test: score=5.0 now correctly fails validation - Add retriever tests for score normalization and zero rank - Fix 409 test: simulate in-progress state instead of sequential calls Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Test Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.