Pattern Proposal: Swappable Provider Adapter
Summary
Isolates external client interfaces behind interchangeable client implementations, enabling mock substitution for tests and offline runs.
Candidate Pattern
- ID:
swappable-provider-adapter - Classification: architectural
- Maturity: established
- Type: implemented
Observed Signals
No specific signals listed.
Evidence
Supporting Evidence
- src/cas_runner/llm/litellm_client.py (LiteLLMClient) - Live external provider implementation.
- src/cas_runner/llm/mock_client.py (MockLLMClient) - Deterministic mock provider implementation for offline or test scenarios.
Scope Assessment
- Evidence Strength: high
- Confidence: high
- Applies to: ideas-to-life-cas
Rationale
- Intent: Decouple application services from concrete external API clients to facilitate offline development and unit testing.
- Context: External integrations (like LiteLLM) incur costs, latency, and require API keys that may not be present in CI environments.
- Force: Automated CI testing requires deterministic responses without network calls.
- Force: Production runtime requires real remote API invocation.
Traceability
Artifact source: proposed-patterns