Source:
Local role: Declarative strategy tree composed of StrategyNode objects and their StrategyOutcomeBranch links.
Big-picture role: Current strategy-layer root object. It is the first model-level structure that chains action projections through successive perceived states.
Inheritance:
Parameters and fields:
- id: str
- actor_id: str
- goal_id: Optional[str]
- root_node_id: str
- nodes: list[StrategyNode]
- projection_policy: str
Methods:
add_node(node) -> Noneget_node(node_id) -> Optional[StrategyNode]validate_tree() -> Noneto_dict() -> dictfrom_dict(data) -> Strategy
Important behavior:
- validates that
root_node_idexists - validates branch ids are unique per node
- validates branch child references
- validates that child nodes consume the parent node’s projected successor perception when a parent branch links to that child
Builder functions in the same source module:
build_linear_strategy(...)build_branching_strategy(...)
Example:
from ometeotl_core.model.strategies import build_linear_strategy, StrategyBuildStep
# Build a two-step linear strategy
step1 = StrategyBuildStep(action=action1, branch_label="step-1")
step2 = StrategyBuildStep(action=action2, branch_label="step-2")
strategy = build_linear_strategy(
id="strategy-1",
actor_id="actor-1",
steps=[step1, step2],
goal_id="goal-1",
)
strategy.validate_tree()
# Navigate the tree
node = strategy.get_node(strategy.root_node_id)
print(node.action_id)
See also:
