Skip to content

operations ¤

Operations models for CrewMaster v2.0.0.

MODULE DESCRIPTION
assemble_disclosure_test

Tests for assemble_disclosure integration.

operation

Operation model for CrewMaster v2.0.0.

operation_test

Tests for Operation model.

plans

Execution plan models for CrewMaster v2.0.0.

plans_resolve_test

Tests for resolve_plan — the ExecutionPlan resolver.

plans_test

Tests for ExecutionPlan, PlanNode, and DisclosurePayload models.

CLASS DESCRIPTION
Operation

A typed, recursive unit of work in the execution plan.

DisclosurePayload

The fully assembled disclosure for a single plan node.

ExecutionPlan

The resolved, immutable execution plan.

PlanBuildError

Raised when an ExecutionPlan cannot be built from an Operation tree.

PlanNode

A single node in the ExecutionPlan DAG.

FUNCTION DESCRIPTION
resolve_plan

Resolve an Operation tree into an immutable ExecutionPlan.

__all__ module-attribute ¤

__all__ = ['DisclosurePayload', 'ExecutionPlan', 'Operation', 'PlanBuildError', 'PlanNode', 'resolve_plan']

Operation ¤

A typed, recursive unit of work in the execution plan.

Operations form the nodes of the ExecutionPlan DAG. Each operation declares what type it produces, what context types it consumes, which agent executes it, and what sub-operations it contains.

ATTRIBUTE DESCRIPTION
name

Unique operation name within the plan.

TYPE: str

produces

The type produced by this operation.

TYPE: type[Any]

kind

Semantic category of the operation.

TYPE: Literal['artifact', 'cognition', 'communication']

agent

The AgentConfig for the executing agent (optional for sub-ops).

TYPE: Any | None

consumes

List of context types this operation requires from upstream.

TYPE: list[type[Any]]

task_blocks

List of blocks:// URIs for task prompt blocks.

TYPE: list[str]

sub_operations

Recursive list of child operations.

TYPE: list[Operation]

collaboration

Optional CollaborationProtocol for multi-agent execution.

TYPE: Any | None

max_retrieval_rounds

Max rounds of request_capability (0 = disabled).

TYPE: int

required_slots

Names of context variables that must be present.

TYPE: list[str]

METHOD DESCRIPTION
validate_sub_operations_names_unique

Ensure sub-operation names are unique within this operation.

name instance-attribute ¤

name: str

produces instance-attribute ¤

produces: type[Any]

kind instance-attribute ¤

kind: Literal['artifact', 'cognition', 'communication']

agent class-attribute instance-attribute ¤

agent: Any | None = Field(default=None)

consumes class-attribute instance-attribute ¤

consumes: list[type[Any]] = Field(default_factory=list)

task_blocks class-attribute instance-attribute ¤

task_blocks: list[str] = Field(default_factory=list)

sub_operations class-attribute instance-attribute ¤

sub_operations: list[Operation] = Field(default_factory=list)

collaboration class-attribute instance-attribute ¤

collaboration: Any | None = Field(default=None)

max_retrieval_rounds class-attribute instance-attribute ¤

max_retrieval_rounds: int = Field(default=0, ge=0)

required_slots class-attribute instance-attribute ¤

required_slots: list[str] = Field(default_factory=list)

model_config class-attribute instance-attribute ¤

model_config = {'arbitrary_types_allowed': True}

validate_sub_operations_names_unique ¤

validate_sub_operations_names_unique() -> 'Operation'

Ensure sub-operation names are unique within this operation.

DisclosurePayload ¤

The fully assembled disclosure for a single plan node.

Contains everything an agent needs to execute its assigned node: identity blocks, task blocks, resolved context, resolved tools, and the rendered prompt text.

ATTRIBUTE DESCRIPTION
identity_blocks

List of resolved identity PromptBlock ids.

TYPE: list[str]

task_blocks

List of resolved task PromptBlock ids.

TYPE: list[str]

resolved_context

The flattened context dictionary for template rendering.

TYPE: dict[str, Any]

resolved_tools

The list of ToolSchema instances visible to this node.

TYPE: list[Any]

rendered_prompt

The final rendered prompt text. .. deprecated:: 2.0.0 Rendering is now done in :func:crewmaster.api.execute via :class:PromptEngine. This field is kept for backward compatibility with pre-built plans that already contain rendered prompts.

TYPE: str

identity_blocks class-attribute instance-attribute ¤

identity_blocks: list[str] = Field(default_factory=list)

task_blocks class-attribute instance-attribute ¤

task_blocks: list[str] = Field(default_factory=list)

resolved_context class-attribute instance-attribute ¤

resolved_context: dict[str, Any] = Field(default_factory=dict)

resolved_tools class-attribute instance-attribute ¤

resolved_tools: list[Any] = Field(default_factory=list)

rendered_prompt class-attribute instance-attribute ¤

rendered_prompt: str = ''

model_config class-attribute instance-attribute ¤

model_config = {'arbitrary_types_allowed': True}

ExecutionPlan ¤

The resolved, immutable execution plan.

Built from an Operation tree. The plan contains all nodes in topological order, their dependency edges, the artifact type registry, and per-node disclosure payloads.

ATTRIBUTE DESCRIPTION
nodes

All PlanNodes in topological order.

TYPE: list[PlanNode]

edges

Dependency edges as (from_node, to_node) tuples.

TYPE: list[tuple[str, str]]

artifacts

Mapping of operation name to output type.

TYPE: dict[str, type[Any]]

disclosure

Mapping of operation name to DisclosurePayload.

TYPE: dict[str, DisclosurePayload]

nodes class-attribute instance-attribute ¤

nodes: list[PlanNode] = Field(default_factory=list)

edges class-attribute instance-attribute ¤

edges: list[tuple[str, str]] = Field(default_factory=list)

artifacts class-attribute instance-attribute ¤

artifacts: dict[str, type[Any]] = Field(default_factory=dict)

disclosure class-attribute instance-attribute ¤

disclosure: dict[str, DisclosurePayload] = Field(default_factory=dict)

model_config class-attribute instance-attribute ¤

model_config = {'arbitrary_types_allowed': True}

PlanBuildError ¤

Raised when an ExecutionPlan cannot be built from an Operation tree.

PlanNode ¤

A single node in the ExecutionPlan DAG.

Each PlanNode corresponds to one Operation and carries its agent, runtime driver, disclosure payload, and dependency information.

ATTRIBUTE DESCRIPTION
operation_name

The name of the Operation this node executes.

TYPE: str

agent

The AgentConfig for this node (resolved from Operation or defaults).

TYPE: Any | None

runtime

The RuntimeDriver instance for this node.

TYPE: Any | None

disclosure

The assembled DisclosurePayload.

TYPE: DisclosurePayload

produces

The type this node produces as output.

TYPE: type[Any] | None

depends_on

List of operation names this node depends on.

TYPE: list[str]

operation_name instance-attribute ¤

operation_name: str

agent class-attribute instance-attribute ¤

agent: Any | None = Field(default=None)

runtime class-attribute instance-attribute ¤

runtime: Any | None = Field(default=None)

disclosure class-attribute instance-attribute ¤

disclosure: DisclosurePayload = Field(default_factory=DisclosurePayload)

produces class-attribute instance-attribute ¤

produces: type[Any] | None = Field(default=None)

depends_on class-attribute instance-attribute ¤

depends_on: list[str] = Field(default_factory=list)

max_retrieval_rounds class-attribute instance-attribute ¤

max_retrieval_rounds: int = Field(default=0, ge=0)

model_config class-attribute instance-attribute ¤

model_config = {'arbitrary_types_allowed': True}

resolve_plan ¤

Resolve an Operation tree into an immutable ExecutionPlan.

Walks the Operation tree to collect leaf operations (those with an agent assigned), resolves consumes dependencies by type — checking both upstream node artifacts and the ContextStore for domain projectors — topologically sorts the resulting nodes, assembles per-node disclosure payloads, and returns a complete ExecutionPlan.

Dependency resolution rules:

  1. If a consumed type is a :class:ContextProjector, resolve it via the context_store. The projected context becomes part of the ctx namespace.
  2. If a consumed type matches the produces of another leaf operation in the same tree, it is an artifact dependency — the downstream node depends on the upstream node.
  3. If neither matches, the plan fails with a PlanBuildError.
PARAMETER DESCRIPTION

operation ¤

The root Operation to resolve.

TYPE: Operation

context_store ¤

The ContextStore holding domain instances for ContextProjector resolution.

TYPE: ContextStore

block_store ¤

The BlockStore for resolving blocks:// URIs during disclosure assembly.

TYPE: BlockStore

default_runtime ¤

Fallback RuntimeDriver when an AgentConfig does not specify its own.

TYPE: Any | None DEFAULT: None

tool_registry ¤

Optional ToolRegistry for populating resolved_tools in each node's disclosure.

TYPE: ToolRegistry | None DEFAULT: None

RETURNS DESCRIPTION
ExecutionPlan

A fully resolved ExecutionPlan with nodes in topological order.

RAISES DESCRIPTION
PlanBuildError

If any consumes cannot be resolved, if there is a cycle in dependencies, or if no leaf operations are found.

assemble_disclosure_test ¤

Tests for assemble_disclosure integration.

CLASS DESCRIPTION
FakeOutput
TestAssembleDisclosure

Tests for assemble_disclosure: Operation + AgentConfig -> DisclosurePayload.

FakeOutput ¤

TestAssembleDisclosure ¤

Tests for assemble_disclosure: Operation + AgentConfig -> DisclosurePayload.

METHOD DESCRIPTION
test_combined_prompt_with_identity_and_task_blocks

Disclosure should contain both identity and task blocks rendered.

test_rendered_prompt_includes_both_block_types

The rendered prompt should combine identity + task blocks.

test_ctx_variables_rendered_correctly

ctx.* variables should be rendered in the prompt.

test_deps_variables_rendered_correctly

deps.* variables should be rendered in the prompt.

test_cfg_variables_rendered_correctly

cfg.* variables should be rendered in the prompt.

test_missing_ctx_requires_raises_descriptive_error

Fails with descriptive error when a ctx.* require is missing.

test_missing_deps_requires_raises_descriptive_error

Fails with descriptive error when a deps.* require is missing.

test_missing_requires_on_identity_block

Validation should also check requires on identity blocks.

test_requires_satisfied_on_both_block_types

Validation should pass when requires are satisfied in all blocks.

test_missing_required_slot_raises_error

Fails when Operation required_slots are not covered by block provides.

test_required_slots_satisfied_by_task_block

Should pass when a task block provides the required slot.

test_required_slots_satisfied_by_identity_block

Should pass when an identity block provides the required slot.

test_no_blocks_returns_empty_payload

When there are no blocks, returns empty disclosure.

test_no_required_slots_passes

Empty required_slots should pass validation.

test_resolved_context_preserved_in_payload

The context dict should be preserved in the DisclosurePayload.

test_combined_prompt_with_identity_and_task_blocks ¤

test_combined_prompt_with_identity_and_task_blocks()

Disclosure should contain both identity and task blocks rendered.

test_rendered_prompt_includes_both_block_types ¤

test_rendered_prompt_includes_both_block_types()

The rendered prompt should combine identity + task blocks.

test_ctx_variables_rendered_correctly ¤

test_ctx_variables_rendered_correctly()

ctx.* variables should be rendered in the prompt.

test_deps_variables_rendered_correctly ¤

test_deps_variables_rendered_correctly()

deps.* variables should be rendered in the prompt.

test_cfg_variables_rendered_correctly ¤

test_cfg_variables_rendered_correctly()

cfg.* variables should be rendered in the prompt.

test_missing_ctx_requires_raises_descriptive_error ¤

test_missing_ctx_requires_raises_descriptive_error()

Fails with descriptive error when a ctx.* require is missing.

test_missing_deps_requires_raises_descriptive_error ¤

test_missing_deps_requires_raises_descriptive_error()

Fails with descriptive error when a deps.* require is missing.

test_missing_requires_on_identity_block ¤

test_missing_requires_on_identity_block()

Validation should also check requires on identity blocks.

test_requires_satisfied_on_both_block_types ¤

test_requires_satisfied_on_both_block_types()

Validation should pass when requires are satisfied in all blocks.

test_missing_required_slot_raises_error ¤

test_missing_required_slot_raises_error()

Fails when Operation required_slots are not covered by block provides.

test_required_slots_satisfied_by_task_block ¤

test_required_slots_satisfied_by_task_block()

Should pass when a task block provides the required slot.

test_required_slots_satisfied_by_identity_block ¤

test_required_slots_satisfied_by_identity_block()

Should pass when an identity block provides the required slot.

test_no_blocks_returns_empty_payload ¤

test_no_blocks_returns_empty_payload()

When there are no blocks, returns empty disclosure.

test_no_required_slots_passes ¤

test_no_required_slots_passes()

Empty required_slots should pass validation.

test_resolved_context_preserved_in_payload ¤

test_resolved_context_preserved_in_payload()

The context dict should be preserved in the DisclosurePayload.

operation ¤

Operation model for CrewMaster v2.0.0.

Operation is the fundamental unit of work — a typed, recursive task that declares what it produces, what it consumes, and how to execute it.

CLASS DESCRIPTION
Operation

A typed, recursive unit of work in the execution plan.

Operation ¤

A typed, recursive unit of work in the execution plan.

Operations form the nodes of the ExecutionPlan DAG. Each operation declares what type it produces, what context types it consumes, which agent executes it, and what sub-operations it contains.

ATTRIBUTE DESCRIPTION
name

Unique operation name within the plan.

TYPE: str

produces

The type produced by this operation.

TYPE: type[Any]

kind

Semantic category of the operation.

TYPE: Literal['artifact', 'cognition', 'communication']

agent

The AgentConfig for the executing agent (optional for sub-ops).

TYPE: Any | None

consumes

List of context types this operation requires from upstream.

TYPE: list[type[Any]]

task_blocks

List of blocks:// URIs for task prompt blocks.

TYPE: list[str]

sub_operations

Recursive list of child operations.

TYPE: list[Operation]

collaboration

Optional CollaborationProtocol for multi-agent execution.

TYPE: Any | None

max_retrieval_rounds

Max rounds of request_capability (0 = disabled).

TYPE: int

required_slots

Names of context variables that must be present.

TYPE: list[str]

METHOD DESCRIPTION
validate_sub_operations_names_unique

Ensure sub-operation names are unique within this operation.

name instance-attribute ¤

name: str

produces instance-attribute ¤

produces: type[Any]

kind instance-attribute ¤

kind: Literal['artifact', 'cognition', 'communication']

agent class-attribute instance-attribute ¤

agent: Any | None = Field(default=None)

consumes class-attribute instance-attribute ¤

consumes: list[type[Any]] = Field(default_factory=list)

task_blocks class-attribute instance-attribute ¤

task_blocks: list[str] = Field(default_factory=list)

sub_operations class-attribute instance-attribute ¤

sub_operations: list[Operation] = Field(default_factory=list)

collaboration class-attribute instance-attribute ¤

collaboration: Any | None = Field(default=None)

max_retrieval_rounds class-attribute instance-attribute ¤

max_retrieval_rounds: int = Field(default=0, ge=0)

required_slots class-attribute instance-attribute ¤

required_slots: list[str] = Field(default_factory=list)

model_config class-attribute instance-attribute ¤

model_config = {'arbitrary_types_allowed': True}

validate_sub_operations_names_unique ¤

validate_sub_operations_names_unique() -> 'Operation'

Ensure sub-operation names are unique within this operation.

operation_test ¤

Tests for Operation model.

CLASS DESCRIPTION
FakeOutput
FakeContext
TestOperation

FakeOutput ¤

FakeContext ¤

TestOperation ¤

METHOD DESCRIPTION
test_minimal_construction

Operation should construct with minimum required fields.

test_full_construction

Operation should accept all fields.

test_name_is_required

Operation should require a name.

test_produces_is_required

Operation should require a produces type.

test_kind_is_required

Operation should require a kind.

test_kind_rejects_invalid_values

Operation should reject invalid kind values.

test_kind_accepts_all_valid_values

Operation should accept all three kind values.

test_sub_operations_recursion

Operation should accept recursive sub_operations.

test_max_retrieval_rounds_non_negative

Operation should reject negative max_retrieval_rounds.

test_default_max_retrieval_rounds_is_zero

Operation should default max_retrieval_rounds to 0.

test_duplicate_sub_operation_names_rejected

Operation should reject duplicate names in sub_operations.

test_serialization_roundtrip

Operation should serialize and deserialize.

test_minimal_construction ¤

test_minimal_construction()

Operation should construct with minimum required fields.

test_full_construction ¤

test_full_construction()

Operation should accept all fields.

test_name_is_required ¤

test_name_is_required()

Operation should require a name.

test_produces_is_required ¤

test_produces_is_required()

Operation should require a produces type.

test_kind_is_required ¤

test_kind_is_required()

Operation should require a kind.

test_kind_rejects_invalid_values ¤

test_kind_rejects_invalid_values()

Operation should reject invalid kind values.

test_kind_accepts_all_valid_values ¤

test_kind_accepts_all_valid_values()

Operation should accept all three kind values.

test_sub_operations_recursion ¤

test_sub_operations_recursion()

Operation should accept recursive sub_operations.

test_max_retrieval_rounds_non_negative ¤

test_max_retrieval_rounds_non_negative()

Operation should reject negative max_retrieval_rounds.

test_default_max_retrieval_rounds_is_zero ¤

test_default_max_retrieval_rounds_is_zero()

Operation should default max_retrieval_rounds to 0.

test_duplicate_sub_operation_names_rejected ¤

test_duplicate_sub_operation_names_rejected()

Operation should reject duplicate names in sub_operations.

test_serialization_roundtrip ¤

test_serialization_roundtrip()

Operation should serialize and deserialize.

plans ¤

Execution plan models for CrewMaster v2.0.0.

The ExecutionPlan is the resolved, immutable DAG that drives execution. It is built from an Operation tree by resolving dependencies, ordering nodes topologically, and assembling per-node disclosure payloads.

CLASS DESCRIPTION
DisclosurePayload

The fully assembled disclosure for a single plan node.

PlanNode

A single node in the ExecutionPlan DAG.

ExecutionPlan

The resolved, immutable execution plan.

PlanBuildError

Raised when an ExecutionPlan cannot be built from an Operation tree.

FUNCTION DESCRIPTION
assemble_disclosure

Assemble a DisclosurePayload from an Operation and AgentConfig.

resolve_plan

Resolve an Operation tree into an immutable ExecutionPlan.

DisclosurePayload ¤

The fully assembled disclosure for a single plan node.

Contains everything an agent needs to execute its assigned node: identity blocks, task blocks, resolved context, resolved tools, and the rendered prompt text.

ATTRIBUTE DESCRIPTION
identity_blocks

List of resolved identity PromptBlock ids.

TYPE: list[str]

task_blocks

List of resolved task PromptBlock ids.

TYPE: list[str]

resolved_context

The flattened context dictionary for template rendering.

TYPE: dict[str, Any]

resolved_tools

The list of ToolSchema instances visible to this node.

TYPE: list[Any]

rendered_prompt

The final rendered prompt text. .. deprecated:: 2.0.0 Rendering is now done in :func:crewmaster.api.execute via :class:PromptEngine. This field is kept for backward compatibility with pre-built plans that already contain rendered prompts.

TYPE: str

identity_blocks class-attribute instance-attribute ¤

identity_blocks: list[str] = Field(default_factory=list)

task_blocks class-attribute instance-attribute ¤

task_blocks: list[str] = Field(default_factory=list)

resolved_context class-attribute instance-attribute ¤

resolved_context: dict[str, Any] = Field(default_factory=dict)

resolved_tools class-attribute instance-attribute ¤

resolved_tools: list[Any] = Field(default_factory=list)

rendered_prompt class-attribute instance-attribute ¤

rendered_prompt: str = ''

model_config class-attribute instance-attribute ¤

model_config = {'arbitrary_types_allowed': True}

PlanNode ¤

A single node in the ExecutionPlan DAG.

Each PlanNode corresponds to one Operation and carries its agent, runtime driver, disclosure payload, and dependency information.

ATTRIBUTE DESCRIPTION
operation_name

The name of the Operation this node executes.

TYPE: str

agent

The AgentConfig for this node (resolved from Operation or defaults).

TYPE: Any | None

runtime

The RuntimeDriver instance for this node.

TYPE: Any | None

disclosure

The assembled DisclosurePayload.

TYPE: DisclosurePayload

produces

The type this node produces as output.

TYPE: type[Any] | None

depends_on

List of operation names this node depends on.

TYPE: list[str]

operation_name instance-attribute ¤

operation_name: str

agent class-attribute instance-attribute ¤

agent: Any | None = Field(default=None)

runtime class-attribute instance-attribute ¤

runtime: Any | None = Field(default=None)

disclosure class-attribute instance-attribute ¤

disclosure: DisclosurePayload = Field(default_factory=DisclosurePayload)

produces class-attribute instance-attribute ¤

produces: type[Any] | None = Field(default=None)

depends_on class-attribute instance-attribute ¤

depends_on: list[str] = Field(default_factory=list)

max_retrieval_rounds class-attribute instance-attribute ¤

max_retrieval_rounds: int = Field(default=0, ge=0)

model_config class-attribute instance-attribute ¤

model_config = {'arbitrary_types_allowed': True}

ExecutionPlan ¤

The resolved, immutable execution plan.

Built from an Operation tree. The plan contains all nodes in topological order, their dependency edges, the artifact type registry, and per-node disclosure payloads.

ATTRIBUTE DESCRIPTION
nodes

All PlanNodes in topological order.

TYPE: list[PlanNode]

edges

Dependency edges as (from_node, to_node) tuples.

TYPE: list[tuple[str, str]]

artifacts

Mapping of operation name to output type.

TYPE: dict[str, type[Any]]

disclosure

Mapping of operation name to DisclosurePayload.

TYPE: dict[str, DisclosurePayload]

nodes class-attribute instance-attribute ¤

nodes: list[PlanNode] = Field(default_factory=list)

edges class-attribute instance-attribute ¤

edges: list[tuple[str, str]] = Field(default_factory=list)

artifacts class-attribute instance-attribute ¤

artifacts: dict[str, type[Any]] = Field(default_factory=dict)

disclosure class-attribute instance-attribute ¤

disclosure: dict[str, DisclosurePayload] = Field(default_factory=dict)

model_config class-attribute instance-attribute ¤

model_config = {'arbitrary_types_allowed': True}

PlanBuildError ¤

Raised when an ExecutionPlan cannot be built from an Operation tree.

assemble_disclosure ¤

Assemble a DisclosurePayload from an Operation and AgentConfig.

Resolves the agent's identity blocks and the operation's task blocks through the block_store, validates that all frontmatter requires are satisfied by the available context variables, validates that all required_slots on the Operation are covered by block provides, renders all blocks via Jinja2, and returns a DisclosurePayload.

This is called at plan-build time. If any validation fails, the plan fails before any LLM call is made.

PARAMETER DESCRIPTION

operation ¤

The Operation being assembled into a disclosure.

TYPE: Operation

agent ¤

The AgentConfig that will execute this operation.

TYPE: AgentConfig

context ¤

Variables structured as {"ctx": {...}, "deps": {...}, "cfg": {...}} for template rendering.

TYPE: dict[str, Any]

block_store ¤

The BlockStore implementation for resolving blocks:// URIs.

TYPE: BlockStore

RETURNS DESCRIPTION
DisclosurePayload

A DisclosurePayload with identity blocks, task blocks, resolved

DisclosurePayload

context, and the fully rendered prompt.

RAISES DESCRIPTION
ValueError

If any block require is unsatisfied by the context, or if any required_slot is not provided by any block.

FileNotFoundError

If a block URI cannot be resolved.

resolve_plan ¤

Resolve an Operation tree into an immutable ExecutionPlan.

Walks the Operation tree to collect leaf operations (those with an agent assigned), resolves consumes dependencies by type — checking both upstream node artifacts and the ContextStore for domain projectors — topologically sorts the resulting nodes, assembles per-node disclosure payloads, and returns a complete ExecutionPlan.

Dependency resolution rules:

  1. If a consumed type is a :class:ContextProjector, resolve it via the context_store. The projected context becomes part of the ctx namespace.
  2. If a consumed type matches the produces of another leaf operation in the same tree, it is an artifact dependency — the downstream node depends on the upstream node.
  3. If neither matches, the plan fails with a PlanBuildError.
PARAMETER DESCRIPTION

operation ¤

The root Operation to resolve.

TYPE: Operation

context_store ¤

The ContextStore holding domain instances for ContextProjector resolution.

TYPE: ContextStore

block_store ¤

The BlockStore for resolving blocks:// URIs during disclosure assembly.

TYPE: BlockStore

default_runtime ¤

Fallback RuntimeDriver when an AgentConfig does not specify its own.

TYPE: Any | None DEFAULT: None

tool_registry ¤

Optional ToolRegistry for populating resolved_tools in each node's disclosure.

TYPE: ToolRegistry | None DEFAULT: None

RETURNS DESCRIPTION
ExecutionPlan

A fully resolved ExecutionPlan with nodes in topological order.

RAISES DESCRIPTION
PlanBuildError

If any consumes cannot be resolved, if there is a cycle in dependencies, or if no leaf operations are found.

plans_resolve_test ¤

Tests for resolve_plan — the ExecutionPlan resolver.

Covers: - Walking the Operation tree and collecting leaf nodes - Resolving consumes by type (ContextProjectors and upstream artifacts) - Topological sort - Error on unresolved consumes - Error on cycles - Error on missing agents - Disclosure assembly per node - Runtime assignment (AgentConfig.runtime vs default_runtime) - Tool retrieval from ToolRegistry

CLASS DESCRIPTION
Greeting
UserInfo
Colors
Typography
FinalDesign
InvalidOutput
User
UserNameProjector

Projects a User to context.

NotAProjector

Does NOT implement ContextProjector.

FakeOutput
FakeDriver

A fake RuntimeDriver that records calls and returns canned responses.

TestLeafCollection

Tests for leaf operation collection from the Operation tree.

TestConsumesResolution

Tests for resolving consumes via ContextStore and upstream artifacts.

TestTopologicalSort

Tests for topological ordering of plan nodes.

TestRuntimeAssignment

Tests for runtime driver assignment to each node.

TestToolRegistryIntegration

Tests for tool retrieval during plan building.

TestPlanStructure

Tests for ExecutionPlan structure correctness.

TestErrorMessages

Tests for descriptive error messages.

Greeting ¤

UserInfo ¤

Colors ¤

Typography ¤

FinalDesign ¤

InvalidOutput ¤

User ¤

User(name: str)
ATTRIBUTE DESCRIPTION
name

name instance-attribute ¤

name = name

UserNameProjector ¤

UserNameProjector(user_name: str)

Projects a User to context.

METHOD DESCRIPTION
from_domain
to_context

from_domain classmethod ¤

from_domain(data: User) -> 'UserNameProjector'

to_context ¤

to_context() -> dict

NotAProjector ¤

Does NOT implement ContextProjector.

FakeOutput ¤

FakeDriver ¤

FakeDriver(output: object = None)

A fake RuntimeDriver that records calls and returns canned responses.

METHOD DESCRIPTION
execute
astream
ATTRIBUTE DESCRIPTION
calls

TYPE: list[RuntimeRequest]

calls instance-attribute ¤

calls: list[RuntimeRequest] = []

execute async ¤

execute(request: RuntimeRequest) -> RuntimeResponse

astream async ¤

astream(request: RuntimeRequest)

TestLeafCollection ¤

Tests for leaf operation collection from the Operation tree.

METHOD DESCRIPTION
test_single_leaf_root_with_agent

Root with agent → single leaf.

test_sub_operations_as_leaves

Container root with sub_operations → each sub-op is a leaf.

test_deeply_nested_sub_operations

Three-level nested operations → collect only those with agents.

test_no_agent_in_tree_raises

A tree with no agents at all should fail.

test_single_leaf_root_with_agent ¤

test_single_leaf_root_with_agent()

Root with agent → single leaf.

test_sub_operations_as_leaves ¤

test_sub_operations_as_leaves()

Container root with sub_operations → each sub-op is a leaf.

test_deeply_nested_sub_operations ¤

test_deeply_nested_sub_operations()

Three-level nested operations → collect only those with agents.

test_no_agent_in_tree_raises ¤

test_no_agent_in_tree_raises()

A tree with no agents at all should fail.

TestConsumesResolution ¤

Tests for resolving consumes via ContextStore and upstream artifacts.

METHOD DESCRIPTION
test_context_projector_resolved

consumes=[UserNameProjector] → resolved via ContextStore.

test_upstream_artifact_dependency

consumes=[Colors] where upstream node produces Colors → dependency.

test_mixed_consumes_projectors_and_artifacts

consumes=[UserNameProjector, Colors] → both resolved.

test_consumes_not_resolvable_raises

A consumed type that is neither a projector nor produced → error.

test_self_consuming_raises

Operation consuming its own output type → error.

test_context_projector_resolved ¤

test_context_projector_resolved()

consumes=[UserNameProjector] → resolved via ContextStore.

test_upstream_artifact_dependency ¤

test_upstream_artifact_dependency()

consumes=[Colors] where upstream node produces Colors → dependency.

test_mixed_consumes_projectors_and_artifacts ¤

test_mixed_consumes_projectors_and_artifacts()

consumes=[UserNameProjector, Colors] → both resolved.

test_consumes_not_resolvable_raises ¤

test_consumes_not_resolvable_raises()

A consumed type that is neither a projector nor produced → error.

test_self_consuming_raises ¤

test_self_consuming_raises()

Operation consuming its own output type → error.

TestTopologicalSort ¤

Tests for topological ordering of plan nodes.

METHOD DESCRIPTION
test_linear_chain

A → B → C linear chain should order correctly.

test_diamond_dependency

step1 → step2, step1 → step3 → step4 (diamond) should work.

test_cycle_detection

Cyclic dependencies should be detected and fail.

test_independent_nodes_any_order

Two independent nodes → both should appear, no dependency edges.

test_linear_chain ¤

test_linear_chain()

A → B → C linear chain should order correctly.

test_diamond_dependency ¤

test_diamond_dependency()

step1 → step2, step1 → step3 → step4 (diamond) should work.

test_cycle_detection ¤

test_cycle_detection()

Cyclic dependencies should be detected and fail.

test_independent_nodes_any_order ¤

test_independent_nodes_any_order()

Two independent nodes → both should appear, no dependency edges.

TestRuntimeAssignment ¤

Tests for runtime driver assignment to each node.

METHOD DESCRIPTION
test_agent_runtime_overrides_default

AgentConfig.runtime should be used when set, not default_runtime.

test_fallback_to_default_runtime

When AgentConfig has no runtime, use default_runtime.

test_missing_runtime_raises

No runtime anywhere → error.

test_agent_runtime_overrides_default ¤

test_agent_runtime_overrides_default()

AgentConfig.runtime should be used when set, not default_runtime.

test_fallback_to_default_runtime ¤

test_fallback_to_default_runtime()

When AgentConfig has no runtime, use default_runtime.

test_missing_runtime_raises ¤

test_missing_runtime_raises()

No runtime anywhere → error.

TestToolRegistryIntegration ¤

Tests for tool retrieval during plan building.

METHOD DESCRIPTION
test_tools_retrieved_for_agent_scope

Agent with default_tool_scope → tools should appear in disclosure.

test_no_tools_without_registry

No ToolRegistry → resolved_tools should be empty.

test_global_scope_tools_visible

Tools registered under '*' should be visible to any scope.

test_tools_retrieved_for_agent_scope ¤

test_tools_retrieved_for_agent_scope()

Agent with default_tool_scope → tools should appear in disclosure.

test_no_tools_without_registry ¤

test_no_tools_without_registry()

No ToolRegistry → resolved_tools should be empty.

test_global_scope_tools_visible ¤

test_global_scope_tools_visible()

Tools registered under '*' should be visible to any scope.

TestPlanStructure ¤

Tests for ExecutionPlan structure correctness.

METHOD DESCRIPTION
test_plan_has_nodes_edges_artifacts_disclosure

Plan should have all top-level fields populated.

test_disclosure_rendered_prompt_empty_after_resolve

After resolve_plan, rendered_prompt is empty — rendering moved to api.execute().

test_plan_has_nodes_edges_artifacts_disclosure ¤

test_plan_has_nodes_edges_artifacts_disclosure()

Plan should have all top-level fields populated.

test_disclosure_rendered_prompt_empty_after_resolve ¤

test_disclosure_rendered_prompt_empty_after_resolve()

After resolve_plan, rendered_prompt is empty — rendering moved to api.execute().

TestErrorMessages ¤

Tests for descriptive error messages.

METHOD DESCRIPTION
test_duplicate_operation_names

Duplicate leaf operation names → descriptive error.

test_duplicate_produces_types

Duplicate produces types → descriptive error.

test_duplicate_operation_names ¤

test_duplicate_operation_names()

Duplicate leaf operation names → descriptive error.

test_duplicate_produces_types ¤

test_duplicate_produces_types()

Duplicate produces types → descriptive error.

plans_test ¤

Tests for ExecutionPlan, PlanNode, and DisclosurePayload models.

CLASS DESCRIPTION
FakeOutput
TestDisclosurePayload
TestPlanNode
TestExecutionPlan

FakeOutput ¤

TestDisclosurePayload ¤

METHOD DESCRIPTION
test_defaults

DisclosurePayload should have sensible defaults.

test_full_construction

DisclosurePayload should accept all fields.

test_serialization_roundtrip

DisclosurePayload should serialize and deserialize.

test_defaults ¤

test_defaults()

DisclosurePayload should have sensible defaults.

test_full_construction ¤

test_full_construction()

DisclosurePayload should accept all fields.

test_serialization_roundtrip ¤

test_serialization_roundtrip()

DisclosurePayload should serialize and deserialize.

TestPlanNode ¤

METHOD DESCRIPTION
test_defaults

PlanNode should have sensible defaults.

test_operation_name_required

PlanNode should require operation_name.

test_full_construction

PlanNode should accept all fields.

test_serialization_roundtrip

PlanNode should serialize and deserialize.

test_defaults ¤

test_defaults()

PlanNode should have sensible defaults.

test_operation_name_required ¤

test_operation_name_required()

PlanNode should require operation_name.

test_full_construction ¤

test_full_construction()

PlanNode should accept all fields.

test_serialization_roundtrip ¤

test_serialization_roundtrip()

PlanNode should serialize and deserialize.

TestExecutionPlan ¤

METHOD DESCRIPTION
test_defaults

ExecutionPlan should have sensible defaults.

test_full_construction

ExecutionPlan should accept all fields.

test_serialization_roundtrip

ExecutionPlan should serialize and deserialize.

test_defaults ¤

test_defaults()

ExecutionPlan should have sensible defaults.

test_full_construction ¤

test_full_construction()

ExecutionPlan should accept all fields.

test_serialization_roundtrip ¤

test_serialization_roundtrip()

ExecutionPlan should serialize and deserialize.