37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
|
|
"""Planning debt read model — gate_fulfillment."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from typing import Any
|
||
|
|
|
||
|
|
from steering.eval_context import SteeringEvalContext
|
||
|
|
from steering.graph.execution_engine import compute_planning_debt
|
||
|
|
|
||
|
|
|
||
|
|
def compute_planning_debt_read_model(ctx: SteeringEvalContext) -> list[dict[str, Any]]:
|
||
|
|
from services import roadmap as roadmap_service
|
||
|
|
from steering.strategies.next_action.execution_ready import (
|
||
|
|
gate_horizon_scope_for_method,
|
||
|
|
)
|
||
|
|
|
||
|
|
gate_scope = gate_horizon_scope_for_method(
|
||
|
|
ctx.binding.primary_method_key, ctx.tenant_ctx, ctx.initiative_id
|
||
|
|
)
|
||
|
|
roadmap_items = roadmap_service.list_roadmap_items_for_initiative(
|
||
|
|
tenant_id=ctx.tenant_ctx.tenant_id, initiative_id=ctx.initiative_id
|
||
|
|
)
|
||
|
|
actions = ctx.actions
|
||
|
|
|
||
|
|
scoped_roadmap = roadmap_items
|
||
|
|
scoped_actions = actions
|
||
|
|
if gate_scope:
|
||
|
|
scope = str(gate_scope)
|
||
|
|
scoped_roadmap = [ri for ri in roadmap_items if str(ri.get("id")) == scope]
|
||
|
|
scoped_actions = [
|
||
|
|
a
|
||
|
|
for a in actions
|
||
|
|
if a.get("roadmap_item_id") and str(a["roadmap_item_id"]) == scope
|
||
|
|
]
|
||
|
|
|
||
|
|
return compute_planning_debt(actions=scoped_actions, roadmap_items=scoped_roadmap)
|