Pattern Proposal: Polymorphic Client Adapter
Summary
Provide interchangeable production and mock implementations conforming to a shared client interface.
Candidate Pattern
- ID:
polymorphic-client-adapter - 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 implementation interfacing with litellm library.
- src/cas_runner/llm/mock_client.py (MockLLMClient) - Mock test double implementing the client contract for offline/deterministic runs.
Scope Assessment
- Evidence Strength: high
- Confidence: high
- Applies to: ideas-to-life-cas
Rationale
- Intent: Enable offline testing, deterministic CI runs, and swappable backends without coupling core workflows to live external network services.
- Context: System relies on external model providers via LiteLLM during normal runs, but CI/test pipelines need deterministic execution without external API keys.
- Force: Network-dependent client invocations make automated test suites flaky and expensive.
- Force: Business logic should not know whether it is communicating with a live model or a mock provider.
Traceability
Artifact source: proposed-patterns