196 lines
7.6 KiB
Gherkin
196 lines
7.6 KiB
Gherkin
Feature: Actor configuration uncovered lines coverage
|
|
As a developer maintaining actor configuration parsing
|
|
I want robust coverage for actor config edge cases
|
|
So that failures and overrides are validated
|
|
|
|
Background:
|
|
Given an isolated actor config workspace
|
|
|
|
Scenario: Missing config file surfaces helpful error
|
|
When I load the actor config blob from "missing.json"
|
|
Then a ValueError should be raised containing "Config file not found"
|
|
|
|
Scenario: YAML dependency absence surfaces requirement
|
|
Given PyYAML parsing is unavailable for actor config
|
|
And an actor config file "missing.yaml" with content:
|
|
"""
|
|
provider: openai
|
|
"""
|
|
When I load the actor config blob from "missing.yaml"
|
|
Then a ValueError should be raised containing "PyYAML is required for YAML actor configs"
|
|
|
|
Scenario: Invalid YAML raises parsing failure error
|
|
Given an actor config file "invalid.yaml" with content:
|
|
"""
|
|
provider: [unclosed
|
|
"""
|
|
When I load the actor config blob from "invalid.yaml"
|
|
Then a ValueError should be raised containing "Failed to parse config"
|
|
|
|
Scenario: Empty YAML returns empty object
|
|
Given an actor config file "empty.yaml" with content:
|
|
"""
|
|
"""
|
|
When I load the actor config blob from "empty.yaml"
|
|
Then the loaded actor config blob should equal {}
|
|
|
|
Scenario: Non-object config raises validation error
|
|
Given an actor config file "list.yaml" with content:
|
|
"""
|
|
- provider: openai
|
|
"""
|
|
When I load the actor config blob from "list.yaml"
|
|
Then a ValueError should be raised containing "Config must be a JSON or YAML object"
|
|
|
|
Scenario: from_file applies overrides and unsafe flag
|
|
Given an actor config file "valid.json" with content:
|
|
"""
|
|
{"provider": "file-provider", "model": "file-model", "options": {"k": "v"}, "graph_descriptor": {"node": true}}
|
|
"""
|
|
When I parse the actor configuration from file "valid.json" with overrides:
|
|
"""
|
|
{"name": "cli-name", "graph_descriptor": {"node": "override"}, "unsafe": true}
|
|
"""
|
|
Then the actor configuration should have provider "file-provider" and model "file-model"
|
|
And the actor configuration name should be "cli-name"
|
|
And the actor configuration graph descriptor should equal {"node": "override"}
|
|
And the actor configuration options should equal {"k": "v"}
|
|
And the actor configuration unsafe flag should be true
|
|
|
|
Scenario: from_blob rejects missing model values
|
|
When I build an actor configuration from blob {"provider": "only-provider"}
|
|
Then a ValueError should be raised containing "model is required"
|
|
|
|
Scenario: v2 YAML actor config infers provider and model
|
|
Given an actor config file "v2.yaml" with content:
|
|
"""
|
|
cleveragents:
|
|
default_router: main_router
|
|
agents:
|
|
paper_writer:
|
|
type: llm
|
|
config:
|
|
provider: openai
|
|
model: gpt-4
|
|
unsafe: true
|
|
options:
|
|
temperature: 0.5
|
|
routes:
|
|
main_router:
|
|
type: stream
|
|
operators:
|
|
- type: map
|
|
params:
|
|
agent: paper_writer
|
|
publications:
|
|
- __output__
|
|
"""
|
|
When I parse the actor configuration from file "v2.yaml" with overrides:
|
|
"""
|
|
{}
|
|
"""
|
|
Then the actor configuration should have provider "openai" and model "gpt-4"
|
|
And the actor configuration unsafe flag should be true
|
|
And the actor configuration graph descriptor should include key "routes"
|
|
And the actor configuration graph descriptor should include key "agents"
|
|
And the actor configuration options should equal {"temperature": 0.5}
|
|
|
|
Scenario: JSON null config becomes empty mapping
|
|
Given an actor config file "null.json" with content:
|
|
"""
|
|
null
|
|
"""
|
|
When I load the actor config blob from "null.json"
|
|
Then the loaded actor config blob should equal {}
|
|
|
|
Scenario: JSON list config raises validation error
|
|
Given an actor config file "list.json" with content:
|
|
"""
|
|
[1, 2, 3]
|
|
"""
|
|
When I load the actor config blob from "list.json"
|
|
Then a ValueError should be raised containing "Config must be a JSON or YAML object"
|
|
|
|
Scenario: Templated YAML preserves placeholders
|
|
Given an actor config file "templated.yaml" with content:
|
|
"""
|
|
provider: openai
|
|
model: gpt-4
|
|
system_prompt: "Use {{ context.paper_details.topic }} to write."
|
|
messages:
|
|
- role: system
|
|
content: "{% if context.brainstorming_summary %}summary{% endif %}"
|
|
"""
|
|
When I load the actor config blob from "templated.yaml"
|
|
Then the loaded actor config value at "system_prompt" should equal "Use {{ context.paper_details.topic }} to write."
|
|
And the loaded actor config value at "messages.0.content" should equal "<<<BLOCK_START>>> if context.brainstorming_summary <<<BLOCK_END>>>summary<<<BLOCK_START>>> endif <<<BLOCK_END>>>"
|
|
|
|
Scenario: Environment placeholders use defaults and conversions
|
|
Given an actor config file "envs.yaml" with content:
|
|
"""
|
|
provider: openai
|
|
model: gpt-4
|
|
options:
|
|
truthy: "${MISSING_BOOL:true}"
|
|
count: "${MISSING_INT:7}"
|
|
ratio: "${MISSING_FLOAT:2.5}"
|
|
greeting: "${MISSING_TEXT:hello}"
|
|
"""
|
|
And the actor config environment variable "MISSING_BOOL" is unset
|
|
And the actor config environment variable "MISSING_INT" is unset
|
|
And the actor config environment variable "MISSING_FLOAT" is unset
|
|
And the actor config environment variable "MISSING_TEXT" is unset
|
|
When I load the actor config blob from "envs.yaml"
|
|
Then the loaded actor config value at "options.truthy" should equal True
|
|
And the loaded actor config value at "options.count" should equal 7
|
|
And the loaded actor config value at "options.ratio" should equal 2.5
|
|
And the loaded actor config value at "options.greeting" should equal "hello"
|
|
|
|
Scenario: Missing required environment variable raises an error
|
|
Given an actor config file "required_env.yaml" with content:
|
|
"""
|
|
provider: openai
|
|
model: gpt-4
|
|
secret: "${REQUIRED_SECRET}"
|
|
"""
|
|
And the actor config environment variable "REQUIRED_SECRET" is unset
|
|
When I load the actor config blob from "required_env.yaml"
|
|
Then a ValueError should be raised containing "Environment variable 'REQUIRED_SECRET' is not set"
|
|
|
|
Scenario: from_blob merges default, v2 and override options
|
|
When I build an actor configuration from structured blob with defaults and overrides:
|
|
"""
|
|
{
|
|
"blob": {
|
|
"provider": "cli-provider",
|
|
"model": "cli-model",
|
|
"options": {"user": "blob"},
|
|
"agents": {
|
|
"writer": {
|
|
"config": {
|
|
"options": {"v2": "v2-option"}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"default_options": {"base": "default"},
|
|
"option_overrides": {"user": "override", "extra": "added"}
|
|
}
|
|
"""
|
|
Then the actor configuration should have provider "cli-provider" and model "cli-model"
|
|
And the actor configuration options should equal {"base": "default", "v2": "v2-option", "user": "override", "extra": "added"}
|
|
|
|
Scenario: v2 extraction skips non-dict agent entries
|
|
Given an actor config file "invalid_v2.yaml" with content:
|
|
"""
|
|
provider: fallback-provider
|
|
model: fallback-model
|
|
agents:
|
|
first: not-a-dict
|
|
"""
|
|
When I parse the actor configuration from file "invalid_v2.yaml" with overrides:
|
|
"""
|
|
{}
|
|
"""
|
|
Then the actor configuration should have provider "fallback-provider" and model "fallback-model"
|