feat: Protocol interfaces + TypedDict schemas for target architecture (#496)#640
Merged
feat: Protocol interfaces + TypedDict schemas for target architecture (#496)#640
Conversation
…#496) Define ideal service contracts as Protocol classes and response types as TypedDicts for four domains: Knowledge, LLM, Chat, Auth. Protocols describe the *target* architecture (north star), not the current implementation. Current services do not yet conform — the Protocols guide future refactoring toward clean, unified facades. Schemas: - knowledge/schemas.py: SearchResult, CollectionInfo, DocumentInfo, SyncResult, FAQEntryInfo - llm/schemas.py: LLMConfig, ProviderInfo, LLMParams, StreamChunk, ToolCall, TokenUsage - chat/schemas.py: SessionInfo, SessionSummary, MessageInfo, StreamChunk, ShareInfo - core/schemas.py: UserInfo, TokenInfo, LoginResult, PermissionMap, RoleInfo, WorkspaceInfo Protocols: - knowledge/protocols.py: KnowledgeService (search + collections + documents + FAQ) - llm/protocols.py: LLMService (generate + stream + resolve_backend + list_providers) - chat/protocols.py: ChatService (sessions + messages + generation + sharing) - core/protocols.py: AuthService (auth + permissions + users + roles + workspaces) 28 unit tests covering schema construction and protocol method signatures. TCH lint rule suppressed for test files (runtime type usage). Closes #496 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
shikhalev
approved these changes
Mar 23, 2026
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.
Summary
KnowledgeService,LLMService,ChatService,AuthServiceSearchResult,SessionInfo,MessageInfo,ProviderInfo,UserInfo,LoginResult, etc.dict(minimal blast radius for future adoption)Structure
KnowledgeServicesearch,retrieve_context,get_collections,sync_documents,find_faq_answerLLMServicegenerate,stream,resolve_backend,list_providersChatServicecreate_session,send_message,stream_message,get_history,share_sessionAuthServiceauthenticate,validate_token,get_permissions,has_permission,get_rolesDesign decisions
session["id"]code works unchangedruntime_checkable: enablesisinstance()checks for future DI validationTest plan
pytest tests/unit/test_protocols.py)Closes #496
🤖 Generated with Claude Code