Domain layer (zero framework imports):
- domain/models.py: pure dataclasses (RuleDocument, RuleSearchResult,
Conversation, ChatMessage, LLMResponse, ChatResult)
- domain/ports.py: ABC interfaces (RuleRepository, LLMPort,
ConversationStore, IssueTracker)
- domain/services.py: ChatService orchestrates Q&A flow using only ports
Outbound adapters (implement domain ports):
- adapters/outbound/openrouter.py: OpenRouterLLM with persistent httpx
client, robust JSON parsing, regex citation fallback
- adapters/outbound/sqlite_convos.py: SQLiteConversationStore with
async_sessionmaker, timezone-aware datetimes, cleanup support
- adapters/outbound/gitea_issues.py: GiteaIssueTracker with markdown
injection protection (fenced code blocks)
- adapters/outbound/chroma_rules.py: ChromaRuleRepository with clamped
similarity scores
Inbound adapter:
- adapters/inbound/api.py: thin FastAPI router with input validation
(max_length constraints), proper HTTP status codes (503 for missing LLM)
Configuration & wiring:
- config/settings.py: Pydantic v2 SettingsConfigDict (no module-level singleton)
- config/container.py: create_app() factory with lifespan-managed DI
- main.py: minimal entry point
Test infrastructure (90 tests, all passing):
- tests/fakes/: in-memory implementations of all 4 ports
- tests/domain/: 26 tests for models and ChatService
- tests/adapters/: 64 tests for all adapters using fakes/mocks
- No real API calls, no model downloads, no disk I/O in fast tests
Also fixes: aiosqlite version constraint (>=0.19.0), adds hatch build
targets for new package layout.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Discord bot: store full conversation UUID in footer instead of truncated
8-char prefix, fixing completely broken follow-up threading. Add footer
to follow-up embeds so conversation chains work beyond depth 1. Edit
loading message in-place instead of leaving ghost messages. Replace bare
except with specific exception types. Fix channel_id attribute access.
- GiteaClient: remove broken async context manager pattern that caused
every create_unanswered_issue call to raise RuntimeError. Use per-request
httpx.AsyncClient instead.
- Database: return singleton ConversationManager from app.state instead of
creating a new SQLAlchemy engine (and connection pool) on every request.
- Vector store: clamp cosine similarity to [0, 1] to prevent Pydantic
ValidationError crashes when ChromaDB returns distances > 1.0.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add vector store with sentence-transformers for semantic search
- FastAPI backend with /chat and /health endpoints
- Conversation state persistence via SQLite
- OpenRouter integration with structured JSON responses
- Discord bot with /ask slash command and reply-based follow-ups
- Automated Gitea issue creation for unanswered questions
- Docker support with docker-compose for easy deployment
- Example rule file and ingestion script
- Comprehensive documentation in README