feat(steering): Epic Roll-up Read Model und Attention (ADP P4)
Test Suite / pytest-backend (push) Waiting to run
Test Suite / lint-backend (push) Waiting to run
Test Suite / compose-smoke (push) Waiting to run
Test Suite / k6 /api/health Baseline (push) Blocked by required conditions
Test Suite / playwright-smoke (push) Blocked by required conditions
Deploy Development / deploy (push) Has been cancelled
Test Suite / pytest-backend (push) Waiting to run
Test Suite / lint-backend (push) Waiting to run
Test Suite / compose-smoke (push) Waiting to run
Test Suite / k6 /api/health Baseline (push) Blocked by required conditions
Test Suite / playwright-smoke (push) Blocked by required conditions
Deploy Development / deploy (push) Has been cancelled
Schliesst den Backlog/Epic-Track mit kernel-basiertem Fortschritt pro Epic, Steuerungs-Attention und UI-Fortschrittsanzeige im Plan-Eingang ab. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a13913f1a0
commit
ef5ee0d19b
13 files changed
+708
-5
No files matched your search
@@ -0,0 +1,141 @@
|
||||
"""AP2.2h — Epic Roll-up Read Model (ADP P4)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from tests.factories import provision_user_in_tenant
|
||||
from tests.test_initiatives_actions import _auth, _create_initiative, _login
|
||||
|
||||
|
||||
def _create_product_initiative(client, token, title="Epic Rollup"):
|
||||
created = _create_initiative(
|
||||
client,
|
||||
token,
|
||||
title=title,
|
||||
archetype_key="initiative.product",
|
||||
)
|
||||
assert created.status_code == 201
|
||||
return created.json()["id"]
|
||||
|
||||
|
||||
def test_steering_snapshot_includes_epic_rollup(client):
|
||||
user = provision_user_in_tenant(tenant_role="admin")
|
||||
token = _login(client, user)
|
||||
initiative_id = _create_product_initiative(client, token)
|
||||
|
||||
epic = client.post(
|
||||
f"/api/initiatives/{initiative_id}/backlog",
|
||||
json={"title": "Checkout Epic", "item_kind": "epic", "status": "accepted"},
|
||||
headers=_auth(token),
|
||||
)
|
||||
epic_id = epic.json()["id"]
|
||||
|
||||
story_a = client.post(
|
||||
f"/api/initiatives/{initiative_id}/backlog",
|
||||
json={
|
||||
"title": "Login Story",
|
||||
"item_kind": "story",
|
||||
"parent_backlog_id": epic_id,
|
||||
"status": "accepted",
|
||||
},
|
||||
headers=_auth(token),
|
||||
)
|
||||
story_a_id = story_a.json()["id"]
|
||||
|
||||
client.post(
|
||||
f"/api/initiatives/{initiative_id}/backlog",
|
||||
json={
|
||||
"title": "Payment Story",
|
||||
"item_kind": "story",
|
||||
"parent_backlog_id": epic_id,
|
||||
"status": "accepted",
|
||||
},
|
||||
headers=_auth(token),
|
||||
)
|
||||
|
||||
converted = client.post(
|
||||
f"/api/backlog/{story_a_id}/convert-to-action",
|
||||
json={},
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert converted.status_code == 201
|
||||
action_id = converted.json()["action"]["id"]
|
||||
|
||||
done = client.patch(
|
||||
f"/api/actions/{action_id}",
|
||||
json={"status": "done"},
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert done.status_code == 200
|
||||
|
||||
snapshot = client.get(
|
||||
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert snapshot.status_code == 200
|
||||
body = snapshot.json()
|
||||
assert "epic_rollup" in body
|
||||
assert len(body["epic_rollup"]) == 1
|
||||
|
||||
rollup = body["epic_rollup"][0]
|
||||
assert rollup["epic_backlog_id"] == epic_id
|
||||
assert rollup["child_total"] == 2
|
||||
assert rollup["child_uncommitted"] == 1
|
||||
assert rollup["child_committed"] == 1
|
||||
assert rollup["actions_done"] == 1
|
||||
assert rollup["status"] == "in_progress"
|
||||
assert rollup["completion_ratio"] == 0.5
|
||||
|
||||
|
||||
def test_steering_snapshot_epic_attention_awaiting_commit(client):
|
||||
user = provision_user_in_tenant(tenant_role="admin")
|
||||
token = _login(client, user)
|
||||
initiative_id = _create_product_initiative(client, token, title="Epic Attention")
|
||||
|
||||
epic = client.post(
|
||||
f"/api/initiatives/{initiative_id}/backlog",
|
||||
json={"title": "Epic", "item_kind": "epic", "status": "accepted"},
|
||||
headers=_auth(token),
|
||||
)
|
||||
epic_id = epic.json()["id"]
|
||||
|
||||
client.post(
|
||||
f"/api/initiatives/{initiative_id}/backlog",
|
||||
json={
|
||||
"title": "Story",
|
||||
"item_kind": "story",
|
||||
"parent_backlog_id": epic_id,
|
||||
"status": "accepted",
|
||||
},
|
||||
headers=_auth(token),
|
||||
)
|
||||
|
||||
snapshot = client.get(
|
||||
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert snapshot.status_code == 200
|
||||
attention_codes = [
|
||||
item.get("code") or item.get("reason_code")
|
||||
for item in snapshot.json().get("attention_items", [])
|
||||
]
|
||||
assert "epic_awaiting_commit" in attention_codes
|
||||
|
||||
|
||||
def test_linear_initiative_has_no_epic_rollup(client):
|
||||
user = provision_user_in_tenant(tenant_role="admin")
|
||||
token = _login(client, user)
|
||||
|
||||
created = _create_initiative(
|
||||
client,
|
||||
token,
|
||||
title="Linear Rollup",
|
||||
archetype_key="initiative.linear_project",
|
||||
)
|
||||
initiative_id = created.json()["id"]
|
||||
|
||||
snapshot = client.get(
|
||||
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert snapshot.status_code == 200
|
||||
assert snapshot.json().get("epic_rollup") == []
|
||||
@@ -0,0 +1,125 @@
|
||||
"""Unit tests — Epic roll-up read model (P4)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from steering.read_models.epic_rollup import (
|
||||
compute_epic_rollup,
|
||||
epic_rollup_attention_items,
|
||||
)
|
||||
|
||||
|
||||
def _item(
|
||||
*,
|
||||
id: str,
|
||||
title: str,
|
||||
item_kind: str = "story",
|
||||
status: str = "accepted",
|
||||
parent_backlog_id: str | None = None,
|
||||
converted_action_id: str | None = None,
|
||||
) -> dict:
|
||||
return {
|
||||
"id": id,
|
||||
"title": title,
|
||||
"item_kind": item_kind,
|
||||
"status": status,
|
||||
"parent_backlog_id": parent_backlog_id,
|
||||
"converted_action_id": converted_action_id,
|
||||
}
|
||||
|
||||
|
||||
def test_epic_rollup_empty_epic():
|
||||
rollups = compute_epic_rollup(
|
||||
backlog_items=[_item(id="e1", title="Epic", item_kind="epic")],
|
||||
actions=[],
|
||||
)
|
||||
assert len(rollups) == 1
|
||||
assert rollups[0]["status"] == "empty"
|
||||
assert rollups[0]["child_total"] == 0
|
||||
|
||||
|
||||
def test_epic_rollup_intake_only():
|
||||
rollups = compute_epic_rollup(
|
||||
backlog_items=[
|
||||
_item(id="e1", title="Checkout", item_kind="epic"),
|
||||
_item(id="s1", title="Login", parent_backlog_id="e1"),
|
||||
_item(id="s2", title="Pay", parent_backlog_id="e1"),
|
||||
],
|
||||
actions=[],
|
||||
)
|
||||
assert rollups[0]["status"] == "intake_only"
|
||||
assert rollups[0]["child_total"] == 2
|
||||
assert rollups[0]["child_uncommitted"] == 2
|
||||
assert rollups[0]["completion_ratio"] == 0.0
|
||||
|
||||
|
||||
def test_epic_rollup_partial_and_done():
|
||||
rollups = compute_epic_rollup(
|
||||
backlog_items=[
|
||||
_item(id="e1", title="Epic", item_kind="epic"),
|
||||
_item(
|
||||
id="s1",
|
||||
title="Done story",
|
||||
parent_backlog_id="e1",
|
||||
status="converted",
|
||||
converted_action_id="a1",
|
||||
),
|
||||
_item(id="s2", title="Open story", parent_backlog_id="e1"),
|
||||
],
|
||||
actions=[
|
||||
{"id": "a1", "status": "done"},
|
||||
{"id": "a2", "status": "in_progress"},
|
||||
],
|
||||
)
|
||||
assert rollups[0]["status"] == "in_progress"
|
||||
assert rollups[0]["actions_done"] == 1
|
||||
assert rollups[0]["child_uncommitted"] == 1
|
||||
assert rollups[0]["completion_ratio"] == 0.5
|
||||
|
||||
|
||||
def test_epic_rollup_all_done():
|
||||
rollups = compute_epic_rollup(
|
||||
backlog_items=[
|
||||
_item(id="e1", title="Epic", item_kind="epic"),
|
||||
_item(
|
||||
id="s1",
|
||||
title="A",
|
||||
parent_backlog_id="e1",
|
||||
status="converted",
|
||||
converted_action_id="a1",
|
||||
),
|
||||
],
|
||||
actions=[{"id": "a1", "status": "done"}],
|
||||
)
|
||||
assert rollups[0]["status"] == "done"
|
||||
assert rollups[0]["completion_ratio"] == 1.0
|
||||
|
||||
|
||||
def test_epic_rollup_attention_awaiting_commit():
|
||||
rollups = compute_epic_rollup(
|
||||
backlog_items=[
|
||||
_item(id="e1", title="Epic", item_kind="epic"),
|
||||
_item(id="s1", title="Story", parent_backlog_id="e1"),
|
||||
],
|
||||
actions=[],
|
||||
)
|
||||
items = epic_rollup_attention_items(initiative_id="init-1", rollups=rollups)
|
||||
assert any(i["reason_code"] == "epic_awaiting_commit" for i in items)
|
||||
|
||||
|
||||
def test_epic_rollup_attention_split_focus():
|
||||
rollups = compute_epic_rollup(
|
||||
backlog_items=[
|
||||
_item(id="e1", title="Epic", item_kind="epic"),
|
||||
_item(
|
||||
id="s1",
|
||||
title="Running",
|
||||
parent_backlog_id="e1",
|
||||
status="converted",
|
||||
converted_action_id="a1",
|
||||
),
|
||||
_item(id="s2", title="Waiting", parent_backlog_id="e1"),
|
||||
],
|
||||
actions=[{"id": "a1", "status": "in_progress"}],
|
||||
)
|
||||
items = epic_rollup_attention_items(initiative_id="init-1", rollups=rollups)
|
||||
assert any(i["reason_code"] == "epic_uncommitted_during_execution" for i in items)
|
||||
Reference in new issue
Block a user