Pattern Proposal: Swappable Client Adapter with Mock Implementation
Summary
Abstracts external network service interactions behind concrete client adapters paired with local mock equivalents for zero-dependency testing.
Candidate Pattern
- ID:
swappable-client-adapter - Classification: architectural
- Maturity: established
- Type: implemented
Observed Signals
No specific signals listed.
Evidence
Supporting Evidence
- src/cas_runner/llm/litellm_client.py (LiteLLMClient) - Production network adapter calling external LLM proxies.
- src/cas_runner/llm/mock_client.py (MockLLMClient) - Test-double client enabling offline execution without API keys.
Scope Assessment
- Evidence Strength: high
- Confidence: high
- Applies to: ideas-to-life-cas
Rationale
- Intent: Isolate external provider network dependencies and enable fast, deterministic unit and offline test runs.
- Context: External API calls require network connectivity and credentials; local test suites and isolated CI environments require predictable local stubs.
- Force: Testing without external service credentials or internet access
- Force: Swappable provider implementations without modifying core domain callers
Traceability
Artifact source: proposed-patterns