feat(steering): Kernel v0.3 mit Read-Model- und Proposal-Registry (K-Ext-1, P6)
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Successful in 4m11s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 15s
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Successful in 4m11s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 15s
Erweitert evaluate_steering um read_models und proposals, migriert epic_rollup auf Registry, liefert sprint_commit-Vorschlaege und UI auf Plan-Sprint. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c5e2c69b1e
commit
20636f88d2
22 files changed
+779
-56
No files matched your search
@@ -0,0 +1,75 @@
|
||||
"""AP2.2i — Sprint commit proposals via Kernel v0.3 (P6)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from tests.factories import provision_user_in_tenant
|
||||
from tests.test_initiatives_actions import _auth, _create_initiative, _login
|
||||
|
||||
|
||||
def test_steering_snapshot_includes_sprint_commit_proposals(client):
|
||||
user = provision_user_in_tenant(tenant_role="admin")
|
||||
token = _login(client, user)
|
||||
|
||||
created = _create_initiative(
|
||||
client,
|
||||
token,
|
||||
title="Sprint Proposal",
|
||||
archetype_key="initiative.product",
|
||||
)
|
||||
initiative_id = created.json()["id"]
|
||||
|
||||
client.post(
|
||||
f"/api/initiatives/{initiative_id}/work-cycles",
|
||||
json={"title": "Sprint R2", "status": "planned"},
|
||||
headers=_auth(token),
|
||||
)
|
||||
|
||||
client.post(
|
||||
f"/api/initiatives/{initiative_id}/backlog",
|
||||
json={"title": "Fix login", "item_kind": "bug", "status": "accepted", "priority": "high"},
|
||||
headers=_auth(token),
|
||||
)
|
||||
client.post(
|
||||
f"/api/initiatives/{initiative_id}/backlog",
|
||||
json={"title": "Checkout story", "item_kind": "story", "status": "accepted"},
|
||||
headers=_auth(token),
|
||||
)
|
||||
|
||||
snapshot = client.get(
|
||||
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert snapshot.status_code == 200
|
||||
body = snapshot.json()
|
||||
assert body["steering_kernel"]["data_source"] == "steering_kernel_v0.3"
|
||||
proposals = body.get("sprint_commit_proposals") or []
|
||||
assert len(proposals) >= 2
|
||||
assert proposals[0]["item_kind"] == "bug"
|
||||
assert proposals[0]["scope_type"] == "backlog_item"
|
||||
assert proposals[0]["proposal_key"] == "sprint_commit"
|
||||
|
||||
attention_codes = [
|
||||
item.get("code") or item.get("reason_code")
|
||||
for item in body.get("attention_items", [])
|
||||
]
|
||||
assert "sprint_commit_suggested" in attention_codes
|
||||
|
||||
|
||||
def test_linear_initiative_has_no_sprint_proposals(client):
|
||||
user = provision_user_in_tenant(tenant_role="admin")
|
||||
token = _login(client, user)
|
||||
|
||||
created = _create_initiative(
|
||||
client,
|
||||
token,
|
||||
title="Linear Proposals",
|
||||
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("sprint_commit_proposals") == []
|
||||
@@ -42,7 +42,7 @@ def test_evaluate_steering_returns_horizon_and_next(client):
|
||||
|
||||
ctx = tenant_context_from_user(user)
|
||||
evaluation = evaluate_steering(ctx, initiative_id=initiative_id)
|
||||
assert evaluation.data_source == "steering_kernel_v0.2"
|
||||
assert evaluation.data_source == "steering_kernel_v0.3"
|
||||
assert evaluation.lifecycle.slot_map.get("action_selection") == "active"
|
||||
assert evaluation.lifecycle.slot_map.get("validation") == "active"
|
||||
assert evaluation.lifecycle.slot_map.get("review") == "optional"
|
||||
@@ -77,7 +77,7 @@ def test_snapshot_routes_through_kernel_not_side_path(client):
|
||||
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert snap.json()["steering_kernel"]["data_source"] == "steering_kernel_v0.2"
|
||||
assert snap.json()["steering_kernel"]["data_source"] == "steering_kernel_v0.3"
|
||||
assert "lifecycle" in snap.json()["steering_kernel"]
|
||||
assert snap.json()["steering_kernel"]["lifecycle"]["slot_map"]["closure"] == "active"
|
||||
|
||||
@@ -103,4 +103,4 @@ def test_apply_steering_event_stub(client):
|
||||
)
|
||||
assert result["accepted"] is True
|
||||
assert result["handled"] is True
|
||||
assert result["evaluation"]["data_source"] == "steering_kernel_v0.2"
|
||||
assert result["evaluation"]["data_source"] == "steering_kernel_v0.3"
|
||||
@@ -106,7 +106,7 @@ def test_continuous_product_routes_through_spine(client):
|
||||
body = snap.json()
|
||||
kernel = body["steering_kernel"]
|
||||
assert kernel["primary_method_key"] == "continuous_product"
|
||||
assert kernel["data_source"] == "steering_kernel_v0.2"
|
||||
assert kernel["data_source"] == "steering_kernel_v0.3"
|
||||
assert kernel["lifecycle"]["slot_map"]["closure"] == "n/a"
|
||||
assert kernel["lifecycle"]["slot_map"]["planning"] == "active"
|
||||
assert body.get("next_actions") is not None
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"""Unit tests — sprint commit proposal (P6)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from steering.eval_context import SteeringEvalContext
|
||||
from steering.kernel.models import HorizonMarker, LifecycleContext, SteeringBinding
|
||||
from steering.proposals.sprint_commit import propose_sprint_commit
|
||||
from tenant_context import TenantContext
|
||||
|
||||
|
||||
def _ctx(
|
||||
*,
|
||||
backlog_items: list,
|
||||
work_cycles: list,
|
||||
vocabulary: dict | None = None,
|
||||
) -> SteeringEvalContext:
|
||||
binding = SteeringBinding(
|
||||
primary_method_key="continuous_product",
|
||||
composition_modifier="agile_iteration",
|
||||
next_work_strategy_key="agile_iteration",
|
||||
)
|
||||
lifecycle = LifecycleContext(
|
||||
current_state="execution",
|
||||
current_state_label="Ausführung",
|
||||
slot_map={},
|
||||
active_slots=(),
|
||||
operational_slots=(),
|
||||
)
|
||||
horizon = HorizonMarker(kind="work_cycle", work_cycle_id="wc-1", work_cycle_title="S1")
|
||||
eval_ctx = SteeringEvalContext(
|
||||
tenant_ctx=TenantContext(
|
||||
user_id="u1",
|
||||
email="t@example.com",
|
||||
display_name="Test",
|
||||
portal_role="user",
|
||||
tenant_id="t1",
|
||||
tenant_slug="t",
|
||||
tenant_name="T",
|
||||
tenant_role="admin",
|
||||
actor_id=None,
|
||||
actor_type=None,
|
||||
session_token="test",
|
||||
capabilities=frozenset(),
|
||||
),
|
||||
initiative_id="init-1",
|
||||
binding=binding,
|
||||
horizon=horizon,
|
||||
lifecycle=lifecycle,
|
||||
operating_context={
|
||||
"steering_elements": ["work_cycle_scope", "backlog_epic_hierarchy"],
|
||||
"data_slices": ["backlog", "work_cycles"],
|
||||
"backlog_vocabulary": vocabulary
|
||||
or {"convertible_kinds": ["story", "bug", "issue"]},
|
||||
},
|
||||
)
|
||||
eval_ctx._backlog_items = backlog_items
|
||||
eval_ctx._work_cycles = work_cycles
|
||||
return eval_ctx
|
||||
|
||||
|
||||
def test_sprint_commit_ranks_bugs_before_stories():
|
||||
proposals = propose_sprint_commit(
|
||||
_ctx(
|
||||
work_cycles=[{"id": "wc-1", "title": "Sprint 1", "status": "planned", "sort_order": 0}],
|
||||
backlog_items=[
|
||||
{"id": "s1", "title": "Story", "item_kind": "story", "status": "accepted", "priority": "normal", "sort_order": 0},
|
||||
{"id": "b1", "title": "Bug", "item_kind": "bug", "status": "accepted", "priority": "normal", "sort_order": 1},
|
||||
],
|
||||
)
|
||||
)
|
||||
assert len(proposals) == 2
|
||||
assert proposals[0]["scope_id"] == "b1"
|
||||
assert proposals[0]["reason_code"] == "bug_default"
|
||||
assert proposals[0]["work_cycle_id"] == "wc-1"
|
||||
|
||||
|
||||
def test_sprint_commit_empty_without_planable_cycle():
|
||||
proposals = propose_sprint_commit(
|
||||
_ctx(
|
||||
work_cycles=[],
|
||||
backlog_items=[
|
||||
{"id": "s1", "title": "Story", "item_kind": "story", "status": "accepted", "priority": "normal", "sort_order": 0},
|
||||
],
|
||||
)
|
||||
)
|
||||
assert proposals == []
|
||||
Reference in new issue
Block a user