8dc55655e9
CI / push-validation (push) Successful in 41s
CI / helm (push) Successful in 42s
CI / benchmark-publish (push) Failing after 56s
CI / build (push) Successful in 1m6s
CI / lint (push) Successful in 1m13s
CI / quality (push) Successful in 1m34s
CI / typecheck (push) Successful in 2m12s
CI / security (push) Successful in 2m13s
CI / e2e_tests (push) Successful in 3m45s
CI / integration_tests (push) Successful in 3m57s
CI / unit_tests (push) Successful in 4m53s
CI / docker (push) Successful in 1m34s
CI / coverage (push) Successful in 11m27s
CI / status-check (push) Successful in 3s
CI / benchmark-publish (pull_request) Has been skipped
CI / helm (pull_request) Successful in 32s
CI / push-validation (pull_request) Successful in 33s
CI / build (pull_request) Successful in 53s
CI / lint (pull_request) Successful in 59s
CI / quality (pull_request) Successful in 1m28s
CI / security (pull_request) Successful in 1m29s
CI / typecheck (pull_request) Successful in 1m32s
CI / e2e_tests (pull_request) Successful in 4m1s
CI / integration_tests (pull_request) Successful in 5m4s
CI / unit_tests (pull_request) Successful in 5m51s
CI / docker (pull_request) Successful in 1m27s
CI / coverage (pull_request) Successful in 11m51s
CI / status-check (pull_request) Successful in 3s
Replace the DB-persistence approach for built-in actors with in-memory virtual resolution. Built-in actors (e.g. openai/gpt-4o, anthropic/claude-sonnet) are now resolved on-demand from ProviderRegistry at query time and merged with persisted custom actors — no database writes occur for built-in actors. Key changes: - Add ActorRegistry._resolve_virtual_builtin_actors(): generates virtual Actor objects in-memory from configured providers (is_built_in=True, id=None) - ActorRegistry.list()/list_actors(): merges virtual built-ins with custom DB actors; custom actors win on name collision; result sorted alphabetically - ActorRegistry.get()/get_actor(): DB-first, virtual built-in fallback, NotFoundError if neither - ActorRegistry.remove()/remove_actor(): rejects virtual built-in names with ValidationError - ActorRegistry.set_default_actor(): stores only the actor name string via new actor_preferences singleton table; no actor row created for virtual built-ins - ActorRegistry.get_default_actor(): reads preference name, resolves via DB→virtual chain, returns actor with is_default=True - Remove ensure_built_in_actors() entirely — 20+ call sites cleaned up including plan.py - Remove ActorRepository.upsert_built_in() — no longer needed - Remove is_built_in from ActorModel DB column (kept on Actor domain model for virtual actors) - New Alembic migration m10_001_virtual_builtin_actors: drops is_built_in column, adds actor_preferences singleton table - Add ActorService.set_default_actor_name() and get_default_actor_name() for preference storage without requiring a DB actor row - Update 15+ Behave step files and 5 feature files; add new features/virtual_builtin_actors.feature with 8 scenarios covering list, show, remove, set-default, get-default, no-DB-writes guarantees - Rewrite tests/actor/test_registry_builtin_yaml.py: TestEnsureBuiltInActorsWithYaml → TestResolveVirtualBuiltinActors plus new TestListActors, TestGetActor, TestRemoveActor, TestDefaultActor test classes Quality gates: lint ✓, typecheck ✓, unit_tests ✓ (15674 scenarios), coverage ✓ (97.10%), integration_tests ✓ (1997 tests) ISSUES CLOSED: #10923
76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
"""Fake provider stubs for BDD and benchmark tests.
|
|
|
|
These lightweight stand-ins avoid importing the real ``ProviderInfo`` (which
|
|
pulls in heavy dependencies) while satisfying ``ActorRegistry``'s duck-typed
|
|
contract for provider discovery.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Any
|
|
from unittest.mock import MagicMock
|
|
|
|
from cleveragents.actor.registry import ActorRegistry
|
|
from cleveragents.providers.registry import ProviderCapabilities
|
|
|
|
|
|
@dataclass
|
|
class FakeProviderInfo:
|
|
"""Minimal stand-in for ``ProviderInfo``."""
|
|
|
|
name: str
|
|
default_model: str
|
|
provider_type: Any = None
|
|
capabilities: Any = None
|
|
api_key_env_var: str = ""
|
|
|
|
def __post_init__(self) -> None:
|
|
if self.provider_type is None:
|
|
self.provider_type = MagicMock(value=self.name)
|
|
if self.capabilities is None:
|
|
self.capabilities = ProviderCapabilities()
|
|
|
|
|
|
@dataclass
|
|
class FakeProviderRegistry:
|
|
"""Stand-in for ``ProviderRegistry``."""
|
|
|
|
providers: list[FakeProviderInfo] = field(default_factory=list)
|
|
|
|
def get_configured_providers(self) -> list[FakeProviderInfo]:
|
|
return self.providers
|
|
|
|
|
|
def make_registry(
|
|
providers: list[FakeProviderInfo] | None = None,
|
|
) -> tuple[MagicMock, ActorRegistry]:
|
|
"""Build a real ``ActorRegistry`` with mocked service/settings.
|
|
|
|
The ``ActorService`` is mocked so there is no database dependency, but
|
|
the ``ActorRegistry`` code (including ``_actor_name()``) runs for real.
|
|
|
|
After the virtual built-in refactor (issue #10923), built-in actors are
|
|
resolved in-memory from the provider registry and are never upserted.
|
|
The mock service's ``list_actors`` returns an empty list (no custom actors
|
|
in DB); virtual built-ins are produced by the registry itself.
|
|
"""
|
|
provider_reg = FakeProviderRegistry(providers=providers or [])
|
|
|
|
mock_service = MagicMock()
|
|
mock_service.list_actors.return_value = []
|
|
mock_service.get_default_actor.return_value = None
|
|
mock_service.get_default_actor_name.return_value = None
|
|
|
|
mock_settings = MagicMock()
|
|
mock_settings.resolve_provider_defaults.return_value = MagicMock(
|
|
provider=None, model=None
|
|
)
|
|
|
|
registry = ActorRegistry(
|
|
actor_service=mock_service,
|
|
provider_registry=provider_reg,
|
|
settings=mock_settings,
|
|
)
|
|
return mock_service, registry
|