Pattern Proposal: Adapter-Based Client Substitution
Summary
Provide interchangeable client implementations using a shared interface to allow seamless switching between live external dependencies and local mocks.
Candidate Pattern
- ID:
adapter-based-client-substitution - Classification: architectural
- Maturity: strategic_direction
- Type: emerging
Observed Signals
No specific signals listed.
Evidence
Supporting Evidence
- src/cas_runner/llm/litellm_client.py (LiteLLMClient) - Production client adapter wrapping the third-party LiteLLM library.
- src/cas_runner/llm/mock_client.py (MockLLMClient) - Deterministic mock client adapter enabling test harness and offline runs.
Scope Assessment
- Evidence Strength: high
- Confidence: high
- Applies to: ideas-to-life-cas
Rationale
- Intent: Decouple external provider communications from internal execution flow and enable deterministic offline unit testing.
- Context: The system depends on external LLM inference providers via litellm, but must also be able to run offline, during automated CI, or in unit tests.
- Force: External API calls are non-deterministic, network-dependent, and introduce cost
- Force: Testing pipeline execution without external credentials requires deterministic mocking
Traceability
Artifact source: proposed-patterns