2026-07-26 15:01:40 +02:00
|
|
|
"""Sequential dependency NextAction strategy — AP2.0d / Spec-D D6."""
|
2026-07-12 12:04:40 +02:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
|
|
from steering.strategies.next_action.default_strategy import DefaultNextActionStrategy
|
|
|
|
|
from steering.strategies.next_action.execution_ready import (
|
2026-07-26 15:01:40 +02:00
|
|
|
first_active_gate_id,
|
2026-07-12 12:04:40 +02:00
|
|
|
list_execution_ready_candidates,
|
|
|
|
|
)
|
|
|
|
|
from steering.strategies.next_action.registry import (
|
|
|
|
|
get_next_action_strategy,
|
|
|
|
|
register_next_action_strategy,
|
|
|
|
|
)
|
|
|
|
|
from tenant_context import TenantContext
|
|
|
|
|
|
|
|
|
|
_default = DefaultNextActionStrategy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SequentialDependencyStrategy:
|
|
|
|
|
key = "sequential_dependency"
|
|
|
|
|
|
|
|
|
|
def evaluate(
|
|
|
|
|
self,
|
|
|
|
|
ctx: TenantContext,
|
|
|
|
|
*,
|
|
|
|
|
initiative_id: str | None = None,
|
|
|
|
|
limit: int = 10,
|
|
|
|
|
) -> list[dict[str, Any]]:
|
|
|
|
|
if limit < 1:
|
|
|
|
|
limit = 1
|
|
|
|
|
if not initiative_id:
|
|
|
|
|
return _default.evaluate(ctx, limit=limit)
|
|
|
|
|
|
2026-07-26 15:01:40 +02:00
|
|
|
gate_scope = first_active_gate_id(ctx, initiative_id)
|
2026-07-12 12:04:40 +02:00
|
|
|
ready = list_execution_ready_candidates(
|
|
|
|
|
ctx,
|
|
|
|
|
initiative_id,
|
|
|
|
|
limit=limit,
|
2026-07-26 15:01:40 +02:00
|
|
|
scope_roadmap_item_id=gate_scope,
|
2026-07-12 12:04:40 +02:00
|
|
|
prefer_critical_path=True,
|
|
|
|
|
)
|
2026-07-26 15:01:40 +02:00
|
|
|
return ready[:limit]
|
2026-07-12 12:04:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
sequential_dependency_strategy = SequentialDependencyStrategy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def register_sequential_dependency_strategy() -> None:
|
|
|
|
|
if not get_next_action_strategy(sequential_dependency_strategy.key):
|
|
|
|
|
register_next_action_strategy(sequential_dependency_strategy)
|