Skip to content

refactor(ai): complete model seam test migrations and client fake ducking (#1001) - #1707

Merged
dan-petty merged 1 commit into
release/v0.2.37from
refactor/1001-model-seam-final
Oct 19, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.37from
refactor/1001-model-seam-final

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Closes #1001

Description

This final pull request completes the AI model seam implementation (#1001, ADR 0007), migrating remaining test suites away from internal LLMClient monkeypatches to the shared in-memory model_fake fixture, completing client fake ducking, retiring private pydantic_ai._ssrf imports across src/, and publishing the changelog entry.

Changes Delivered in Part 5

  1. Caller Test Migrations:

    • tests/test_ai_prewarm.py: Migrated TestCLIPrewarmCommand tests to use model_fake and its preload_calls / set_preload_results helpers rather than patching LLMClient.preload_models.
    • tests/test_ai_chaos_model.py: Migrated test_injector_spans_and_max_retries away from patching LLMClient.
    • tests/test_ai_cmd.py: Migrated interactive chat, agents LLM generation, prewarm, streaming turn, and invariant seeding tests to the model_fake fixture.
  2. Client Ducking Completion (tests/support/fakes/model.py):

    • Added backend_info property ("fake (localhost)") and minimal _config (_FakeConfig) to ModelFake matching LLMClient interfaces expected by CLI commands (devops ai chat, devops ai test).
    • Added factory_calls, preload_calls, set_preload_results, set_available_models, and set_list_models_error helpers.
    • Refined sequential answering semantics in ModelFake.answer and _resolve_answer so sequentially queued answers execute in order and repeat the final entry cleanly.
  3. Factory Seam Refinement (src/devops_cli/ai/client/factory.py):

    • Added dispatch to _client_override.record_factory_call when present to capture factory invocation details during test assertions.
    • Decomposed override dispatch into _handle_override keeping McCabe cyclomatic complexity <= 10.
  4. SSRF Import Retirement (src/devops_cli/http/egress.py):

    • Replaced direct import from pydantic_ai._ssrf with public boundary helper from devops_cli.core.validation import is_cloud_metadata_ip.
  5. Changelog Fragment & Tracking:

    • Created changelog.d/1001.md documenting the unified model seam, client factory consolidation, egress SSRF guards, and caller migrations under ### Changed and ### Removed.
    • Updated docs/agent/tasks/task-1001-one-model-seam.md with Part 5 details and marked all deliverables complete.

Validation

  • devops ci completed locally with 100% passing status (pytest & coverage, bandit, mypy strict, ruff check, ruff format, actionlint, zizmor, deptry, docs, devcontainer).
  • Pre-push hook passed cleanly.
  • Contract suite (tests/test_model_contract.py), fixture tests (tests/test_model_fixture.py), and migrated suites (tests/test_ai_cmd.py, tests/test_ai_prewarm.py, tests/test_ai_chaos_model.py) all pass.

@dan-petty
dan-petty merged commit 20a0191 into release/v0.2.37 Oct 19, 2026
15 checks passed
@dan-petty
dan-petty deleted the refactor/1001-model-seam-final branch October 19, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant