Files
cleveragents-core/features/actor_compiler.feature
freemo c47e6445d0
CI / quality (pull_request) Successful in 19s
CI / lint (pull_request) Successful in 22s
CI / benchmark-publish (pull_request) Has been skipped
CI / security (pull_request) Successful in 33s
CI / build (pull_request) Successful in 26s
CI / typecheck (pull_request) Successful in 1m0s
CI / integration_tests (pull_request) Successful in 4m56s
CI / unit_tests (pull_request) Successful in 15m11s
CI / docker (pull_request) Successful in 1m33s
CI / benchmark-regression (pull_request) Successful in 20m55s
CI / coverage (pull_request) Successful in 33m42s
CI / lint (push) Successful in 13s
CI / build (push) Successful in 15s
CI / quality (push) Successful in 17s
CI / security (push) Successful in 28s
CI / typecheck (push) Successful in 32s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 3m3s
CI / benchmark-publish (push) Successful in 10m8s
CI / unit_tests (push) Successful in 12m42s
CI / docker (push) Successful in 39s
CI / coverage (push) Has been cancelled
feat(actor): compile hierarchical actor configs to LangGraph
Add ActorCompiler module that translates GRAPH-type ActorConfigSchema
definitions into LangGraph NodeConfig/Edge structures with LSP binding
metadata. Includes subgraph resolution with cross-actor cycle detection,
entry/exit validation, and CompilationMetadata for diagnostics.

New files:
- src/cleveragents/actor/compiler.py: Core compiler with compile_actor()
- features/actor_compiler.feature: 13 Behave scenarios
- features/steps/actor_compiler_steps.py: Step definitions
- robot/actor_compiler.robot: 4 Robot smoke tests
- benchmarks/actor_compiler_bench.py: ASV performance benchmarks
- docs/reference/actor_compiler.md: Compilation pipeline reference

Modified:
- src/cleveragents/actor/__init__.py: Export compiler types
- vulture_whitelist.py: Whitelist new public API

ISSUES CLOSED: #158
2026-02-24 17:57:18 +00:00

103 lines
5.4 KiB
Gherkin

Feature: Actor compiler translates hierarchical actor configs to LangGraph
As a CleverAgents developer
I want to compile GRAPH actor configs into LangGraph node/edge structures
So that actor YAML definitions can be executed as LangGraph StateGraphs
#
# Successful compilation scenarios
#
Scenario: Compile a simple two-node graph actor
Given a GRAPH actor config with a linear two-node topology
When I compile the actor config
Then the compilation should succeed
And the compiled actor should have 2 nodes
And the compiled actor entry point should be "planner"
And the compilation metadata should list node IDs "executor" and "planner"
Scenario: Compile a graph with a tool node
Given a GRAPH actor config with an agent and a tool node
When I compile the actor config
Then the compilation should succeed
And the compilation metadata should have 1 tool node
Scenario: Compile a graph with LSP bindings on a node
Given a GRAPH actor config with LSP bindings on the agent node
When I compile the actor config
Then the compilation should succeed
And the compilation metadata should have 1 LSP binding
And the LSP binding should reference server "local/pyright"
Scenario: Compile a graph with a conditional node
Given a GRAPH actor config with a conditional routing node
When I compile the actor config
Then the compilation should succeed
And the compiled actor should have 3 nodes
Scenario: Compile a graph with a subgraph reference
Given a GRAPH actor config with a subgraph node referencing "workflows/inner"
When I compile the actor config with a resolver
Then the compilation should succeed
And the compilation metadata subgraph refs should map "sub" to "workflows/inner"
Scenario: Compile a single-node graph actor
Given a GRAPH actor config with a single node
When I compile the actor config
Then the compilation should succeed
And the compiled actor should have 1 nodes
# ────────────────────────────────────────────────────────────
# Subgraph resolution and cycle detection
# ────────────────────────────────────────────────────────────
Scenario: Detect cross-actor subgraph cycle
Given a GRAPH actor config "workflows/outer" referencing "workflows/inner"
And a resolver where "workflows/inner" references "workflows/outer"
When I compile the actor config with a resolver
Then the compilation should fail with SubgraphCycleError
And the compiler error message should contain "cycle"
Scenario: Accept acyclic subgraph chain
Given a GRAPH actor config "workflows/top" referencing "workflows/mid"
And a resolver where "workflows/mid" has no subgraph nodes
When I compile the actor config with a resolver
Then the compilation should succeed
# ────────────────────────────────────────────────────────────
# Missing node and invalid entry/exit errors
# ────────────────────────────────────────────────────────────
Scenario: Reject non-GRAPH actor type
Given an LLM actor config
When I attempt to compile the non-graph actor
Then the compilation should fail with ActorCompilationError
And the compiler error message should contain "GRAPH"
Scenario: Reject GRAPH actor without route
Given a GRAPH actor config with route set to None
When I attempt to compile the routeless actor
Then the compilation should fail with ActorCompilationError
And the compiler error message should contain "no route"
# ────────────────────────────────────────────────────────────
# Metadata inspection
# ────────────────────────────────────────────────────────────
Scenario: Metadata lists all node IDs sorted
Given a GRAPH actor config with nodes "alpha", "beta", and "gamma"
When I compile the actor config
Then the compilation should succeed
And the metadata node IDs should be sorted alphabetically
Scenario: Metadata records entry and exit nodes
Given a GRAPH actor config with entry "start_node" and exit "end_node"
When I compile the actor config
Then the compilation should succeed
And the metadata entry node should be "start_node"
And the metadata exit nodes should contain "end_node"
Scenario: Compilation metadata is JSON-serializable
Given a GRAPH actor config with LSP bindings on the agent node
When I compile the actor config
Then the compilation metadata should be JSON-serializable