Files
cleveragents-core/features/actor_registry_full_coverage.feature
T
freemo 30f8e08f7e
CI / lint (push) Failing after 16s
CI / typecheck (push) Successful in 24s
CI / coverage (push) Has been skipped
CI / security (push) Successful in 16s
CI / quality (push) Successful in 14s
CI / build (push) Successful in 13s
CI / behave (3.13) (push) Failing after 4m24s
CI / docker (push) Has been skipped
tests: Further improved test to get that 97% coverage we want
2026-02-12 23:35:53 -05:00

168 lines
9.3 KiB
Gherkin

Feature: Actor registry full coverage
As a developer
I want comprehensive actor registry coverage
So that all branches and methods are validated
# ensure_built_in_actors
Scenario: Registry returns empty list when no providers are configured
Given a fresh actor registry with no providers
When I run ensure_built_in_actors
Then the generated actor list should be empty
And no actors should exist in the service
Scenario: Registry generates built-in actors from configured providers and selects preferred default
Given preferred provider defaults provider "openai" and model "gpt-4o-mini"
And a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
| anthropic | Claude | opus |
When I run ensure_built_in_actors
Then the generated actors should be ["OpenAI/gpt-4o-mini", "Claude/opus"]
And the service default actor should be "OpenAI/gpt-4o-mini"
Scenario: Registry selects first built-in actor as default when no provider preference matches
Given a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
| anthropic | Claude | opus |
When I run ensure_built_in_actors
Then the generated actors should be ["OpenAI/gpt-4o-mini", "Claude/opus"]
And the service default actor should be "OpenAI/gpt-4o-mini"
Scenario: Registry selects preferred provider and model as default actor
Given preferred provider defaults provider "claude" and model "opus"
And a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
| anthropic | Claude | opus |
When I run ensure_built_in_actors
Then the service default actor should be "Claude/opus"
Scenario: Registry skips default selection when a default actor already exists
Given preferred provider defaults provider "claude" and model "opus"
And a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
| anthropic | Claude | opus |
And a pre-existing default actor "OpenAI/gpt-4o-mini"
When I run ensure_built_in_actors
Then the service default actor should be "OpenAI/gpt-4o-mini"
Scenario: Built-in actor includes graph descriptor with provider registry source and capabilities
Given a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
When I run ensure_built_in_actors
Then the built-in actor "OpenAI/gpt-4o-mini" should have graph descriptor with source "provider-registry"
And the built-in actor "OpenAI/gpt-4o-mini" config blob should include capabilities
# ── upsert_actor ────────────────────────────────────────────────────
Scenario: Registry upserts a custom actor with provider model and graph descriptor
Given a fresh actor registry with no providers
When I upsert a custom actor "custom/demo" with provider "custom" model "demo" and graph {"flow": "simple"}
Then the upserted actor should have name "custom/demo"
And the upserted actor should have provider "custom" and model "demo"
Scenario: Registry rejects unsafe actor configuration without explicit unsafe flag
Given a fresh actor registry with no providers
When I attempt to upsert an unsafe actor "local/danger" without allow_unsafe
Then a ValidationError should be raised with message containing "unsafe"
Scenario: Registry allows unsafe actor when allow_unsafe flag is set
Given a fresh actor registry with no providers
When I upsert an unsafe actor "local/allowed" with allow_unsafe flag
Then the upserted actor should have name "local/allowed"
And the upserted actor should be marked unsafe
Scenario: Registry allows unsafe actor when is_built_in flag is set
Given a fresh actor registry with no providers
When I upsert an unsafe actor "local/builtin" with is_built_in flag
Then the upserted actor should have name "local/builtin"
And the upserted actor should be marked unsafe
Scenario: Registry builds default graph descriptor when provider and model are supplied
Given a fresh actor registry with no providers
When I upsert a custom actor "local/graphed" with provider "openai" model "gpt-4o" and no explicit graph
Then the upserted actor config blob should contain a graph_descriptor with provider "openai" and model "gpt-4o"
Scenario: Registry upsert canonicalizes blob with default options and source
Given a fresh actor registry with no providers
When I upsert actor "local/canon" with config blob {"provider": "test", "model": "m1", "foo": "bar"}
Then the upserted actor config blob should have key "source" with value "custom"
And the upserted actor config blob should have key "unsafe" with value false
# ── Wrapper methods ─────────────────────────────────────────────────
Scenario: Registry get_actor delegates to actor service after ensuring built-ins
Given a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
When I call registry get_actor with "OpenAI/gpt-4o-mini"
Then the fetched actor via registry should be named "OpenAI/gpt-4o-mini"
Scenario: Registry list_actors delegates to actor service after ensuring built-ins
Given a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
| anthropic | Claude | opus |
When I call registry list_actors
Then the returned actor list should contain ["OpenAI/gpt-4o-mini", "Claude/opus"]
Scenario: Registry remove_actor delegates to actor service after ensuring built-ins
Given a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
| anthropic | Claude | opus |
When I call registry remove_actor with "OpenAI/gpt-4o-mini"
Then the service should no longer contain actor "OpenAI/gpt-4o-mini"
Scenario: Registry set_default_actor delegates to actor service after ensuring built-ins
Given a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
| anthropic | Claude | opus |
When I call registry set_default_actor with "Claude/opus"
Then the service default actor should be "Claude/opus"
Scenario: Registry get_default_actor delegates to actor service after ensuring built-ins
Given a fresh actor registry with providers
| type | name | model |
| openai | OpenAI | gpt-4o-mini |
When I call registry get_default_actor
Then the returned default actor should be "OpenAI/gpt-4o-mini"
# ── _canonical_blob ─────────────────────────────────────────────────
Scenario: Canonical blob sets provider model and source defaults from configuration
Given a fresh actor registry with no providers
When I upsert actor "local/defaults" with config blob {"provider": "p1", "model": "m1"}
Then the upserted actor config blob should have key "provider" with value "p1"
And the upserted actor config blob should have key "model" with value "m1"
And the upserted actor config blob should have key "source" with value "custom"
Scenario: Canonical blob preserves existing graph descriptor in raw blob
Given a fresh actor registry with no providers
When I upsert actor "local/existing" with config blob {"provider": "p1", "model": "m1", "graph_descriptor": {"custom": true}}
Then the upserted actor config blob graph_descriptor should equal {"custom": true}
Scenario: Canonical blob handles non-dict options by resetting to empty dict
Given a fresh actor registry with no providers
When I upsert actor "local/badopts" with config blob {"provider": "p1", "model": "m1", "options": "not-a-dict"}
Then the upserted actor config blob should have key "options" with value {}
# ── _build_graph_descriptor ─────────────────────────────────────────
Scenario: Build graph descriptor includes provider model source and capabilities
Given a fresh actor registry with no providers
When I call _build_graph_descriptor with provider "openai" model "gpt-4o" source "test" and capabilities
Then the graph descriptor should have provider "openai" model "gpt-4o" source "test"
And the graph descriptor capabilities should not be None
Scenario: Build graph descriptor omits capabilities when not provided
Given a fresh actor registry with no providers
When I call _build_graph_descriptor with provider "openai" model "gpt-4o" source "test" and no capabilities
Then the graph descriptor should have provider "openai" model "gpt-4o" source "test"
And the graph descriptor capabilities should be None