Skip to content

antikythera_orchestrator.scopes ¤

Scope policies for controlling looping/retry behavior within a blueprint.

A Scope is a contiguous region of a blueprint DAG delimited by a scope_start task and a scope_end task. After the scope_end task completes, the Scope's policy decides whether all scope tasks should be reset and re-executed (loop) or if execution should continue forward.

Three policies are supported (a fourth — compensating scope — is future work):

  • skip – No explicit policy definition needed. A condition on the scope_start task is evaluated; if it returns False the entire scope is skipped.
  • retry – Re-runs the scope a fixed number of times.
  • while – Re-runs the scope as long as a condition expression evaluates to True in the current session data (with an optional iteration cap).

Classes¤

RuntimeScope dataclass ¤

RuntimeScope(
    name: str,
    start_fqn: str,
    end_fqn: str,
    task_fqns: set = set(),
    policy: dict = dict(),
)

Runtime representation of a scope within the flattened execution graph.

Built from the model-level :class:~antikythera.models.Scope stored on each :class:~antikythera.models.Blueprint, augmented with fully-qualified node IDs from the execution graph.

Attributes:

  • name (str) –

    Identifier for this scope — the task ID of the scope_start task.

  • start_fqn (str) –

    Fully-qualified node ID of the scope_start task.

  • end_fqn (str) –

    Fully-qualified node ID of the scope_end task.

  • task_fqns (set[str]) –

    All fully-qualified node IDs that belong to this scope (including start and end).

  • policy (dict) –

    Raw policy dict from task.scope_start (contains retry_policy and/or while_policy).

Functions¤

reset_tasks ¤
reset_tasks(graph: Graph) -> None

Reset all tasks in this scope back to PENDING and clear their outputs.

should_loop ¤
should_loop(iterations_so_far: int, eval_context: dict[str, Any]) -> bool

Decide whether the scope should reset for another iteration.

Parameters:

  • iterations_so_far (int) –

    Number of extra iterations already completed (0 after the first run through the scope).

  • eval_context (dict) –

    Session data + blueprint context used to evaluate while-conditions.

Returns:

skip_tasks ¤
skip_tasks(graph: Graph, excluded_fqn: str) -> None

Mark all scope tasks (except excluded_fqn) as SKIPPED.

ScopeRegistry ¤

ScopeRegistry(session: BlueprintSession, graph: Graph)

Discovers and manages all runtime scopes from blueprint scope definitions.

Functions¤

nested_within ¤
nested_within(scope: RuntimeScope) -> list

Return all scopes whose task set is fully contained within scope.