Skip to content

Fix/phase1 sdd compliance - #12

Merged
Teng91 merged 2 commits into
masterfrom
fix/phase1-sdd-compliance
May 26, 2026
Merged

Fix/phase1 sdd compliance#12
Teng91 merged 2 commits into
masterfrom
fix/phase1-sdd-compliance

Conversation

@Teng91

@Teng91 Teng91 commented May 26, 2026

Copy link
Copy Markdown
Owner
  1. 38ebe0d — 核心架構對齊(retriever、search_tsv、UUID job_id、init_db、Alembic)
  2. d139031 — SDD 完整合規(score 正規化、llm_providers_path 接線、Alembic env var、indexing cleanup)

Joy Teng and others added 2 commits May 26, 2026 15:11
- 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>
@Teng91 Teng91 self-assigned this May 26, 2026
@github-actions

Copy link
Copy Markdown

Coverage

Test Coverage
FileStmtsMissCoverMissing
src/chatbot_plugin
   __init__.py00100% 
   config.py130100% 
   db.py14378%26–28
   routers.py30486%36–38, 43
   service.py440100% 
src/chatbot_plugin/contracts
   __init__.py30100% 
   requests.py100100% 
   responses.py210100% 
src/chatbot_plugin/llm
   __init__.py60100% 
   base_provider.py270100% 
   bootstrap.py420100% 
   claude_provider.py120100% 
   config.py10190%22
   gemini_provider.py320100% 
   openrouter_provider.py180100% 
   resilient_llm_service.py330100% 
src/chatbot_plugin/llm/rate_limit
   __init__.py40100% 
   no_op_strategy.py60100% 
   quota_strategy.py70100% 
   sliding_window_strategy.py54394%37, 61, 63
src/chatbot_plugin/models
   __init__.py20100% 
   article.py23195%49
src/chatbot_plugin/rag
   __init__.py20100% 
   chain.py80100% 
   prompt.py290100% 
   retriever.py150100% 
TOTAL4651297% 

Tests Skipped Failures Errors Time
132 0 💤 0 ❌ 0 🔥 14.420s ⏱️

@Teng91
Teng91 merged commit ed6d430 into master May 26, 2026
1 check passed
@Teng91
Teng91 deleted the fix/phase1-sdd-compliance branch May 26, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant