Some checks failed
Deploy Development / deploy (push) Successful in 48s
Test Suite / pytest-backend (push) Failing after 3m33s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
evaluate_steering() vereinheitlicht Horizon, Next Work und Attention; Snapshot und Signal Engine delegieren dorthin; slot_map deklarativ fuer sequential_dependency und generic_operating. Co-authored-by: Cursor <cursoragent@cursor.com>
112 lines
3.8 KiB
Python
112 lines
3.8 KiB
Python
"""Steering Kernel Spine v0.1 — unit and integration tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from steering.kernel import apply_steering_event, evaluate_steering
|
|
from steering.kernel.binding import resolve_steering_binding
|
|
from tests.factories import provision_user_in_tenant
|
|
from tests.test_initiatives_actions import _auth, _create_initiative, _login
|
|
|
|
|
|
def test_evaluate_steering_linear_binding(client):
|
|
user = provision_user_in_tenant(tenant_role="member")
|
|
token = _login(client, user)
|
|
|
|
created = _create_initiative(
|
|
client,
|
|
token,
|
|
title="Kernel Binding",
|
|
archetype_key="initiative.linear_project",
|
|
)
|
|
initiative_id = created.json()["id"]
|
|
|
|
from tenant_context import TenantContext
|
|
|
|
ctx = TenantContext(tenant_id=user["tenant_id"], user_id=user["id"])
|
|
binding = resolve_steering_binding(ctx, initiative_id)
|
|
assert binding.primary_method_key == "sequential_dependency"
|
|
assert binding.composition_modifier is None
|
|
assert binding.next_work_strategy_key == "sequential_dependency"
|
|
|
|
|
|
def test_evaluate_steering_returns_horizon_and_next(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = _create_initiative(
|
|
client,
|
|
token,
|
|
title="Kernel Eval",
|
|
archetype_key="initiative.linear_project",
|
|
)
|
|
initiative_id = created.json()["id"]
|
|
|
|
from tenant_context import TenantContext
|
|
|
|
ctx = TenantContext(tenant_id=user["tenant_id"], user_id=user["id"])
|
|
evaluation = evaluate_steering(ctx, initiative_id=initiative_id)
|
|
assert evaluation.data_source == "steering_kernel_v0.1.1"
|
|
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"
|
|
assert evaluation.horizon.kind in ("gate", "none", "work_cycle")
|
|
if evaluation.horizon.kind == "gate":
|
|
assert evaluation.horizon.gate_roadmap_item_id
|
|
|
|
snap = client.get(
|
|
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
|
headers=_auth(token),
|
|
)
|
|
assert snap.status_code == 200
|
|
body = snap.json()
|
|
assert body.get("steering_kernel")
|
|
assert body["steering_kernel"]["primary_method_key"] == "sequential_dependency"
|
|
assert body["next_actions"] == evaluation.next_work
|
|
|
|
|
|
def test_snapshot_routes_through_kernel_not_side_path(client):
|
|
user = provision_user_in_tenant(tenant_role="admin")
|
|
token = _login(client, user)
|
|
|
|
created = _create_initiative(
|
|
client,
|
|
token,
|
|
title="Kernel Path",
|
|
archetype_key="initiative.linear_project",
|
|
)
|
|
initiative_id = created.json()["id"]
|
|
|
|
snap = client.get(
|
|
f"/api/initiatives/{initiative_id}/steering-snapshot",
|
|
headers=_auth(token),
|
|
)
|
|
assert snap.json()["steering_kernel"]["data_source"] == "steering_kernel_v0.1.1"
|
|
assert "lifecycle" in snap.json()["steering_kernel"]
|
|
assert snap.json()["steering_kernel"]["lifecycle"]["slot_map"]["closure"] == "active"
|
|
|
|
|
|
def test_apply_steering_event_stub(client):
|
|
user = provision_user_in_tenant(tenant_role="member")
|
|
token = _login(client, user)
|
|
|
|
created = _create_initiative(
|
|
client,
|
|
token,
|
|
title="Event Stub",
|
|
archetype_key="initiative.linear_project",
|
|
)
|
|
initiative_id = created.json()["id"]
|
|
|
|
from tenant_context import TenantContext
|
|
|
|
ctx = TenantContext(tenant_id=user["tenant_id"], user_id=user["id"])
|
|
result = apply_steering_event(
|
|
ctx,
|
|
initiative_id=initiative_id,
|
|
event_kind="actor_result",
|
|
payload={"action_id": "test"},
|
|
)
|
|
assert result["accepted"] is True
|
|
assert result["handled"] is False
|
|
assert result["evaluation"]["data_source"] == "steering_kernel_v0.1.1"
|