feat(steering): Kernel Spine v0.2 — Events, Slot-Provider, continuous_product
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 3m49s
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 19s
Test Suite / playwright-smoke (push) Successful in 12s
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 3m49s
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 19s
Test Suite / playwright-smoke (push) Successful in 12s
apply_steering_event an Action done, Gate verify/reopen und Blocker resolve; lifecycle-Ketten methodenaware via slot_map; continuous_product slot_map; pytest v0.2. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
606dd960b8
commit
fe1edb84f8
18 files changed
+595
-34
No files matched your search
@@ -0,0 +1,66 @@
|
||||
"""Lifecycle transition chains for kernel event ingress v0.2."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Literal
|
||||
|
||||
from steering.lifecycle.slot_maps import SlotStatus
|
||||
|
||||
EventKind = Literal[
|
||||
"actor_result",
|
||||
"gate_verified",
|
||||
"gate_reopened",
|
||||
"external_event",
|
||||
"cadence_due",
|
||||
"situational",
|
||||
]
|
||||
|
||||
|
||||
def _slot_accepts_event(status: SlotStatus, *, event_targets_slot: bool) -> bool:
|
||||
if status == "active":
|
||||
return True
|
||||
if status == "optional" and event_targets_slot:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def resolve_lifecycle_chain(
|
||||
*,
|
||||
primary_method_key: str,
|
||||
event_kind: EventKind,
|
||||
payload: dict[str, Any] | None = None,
|
||||
) -> tuple[str, ...]:
|
||||
"""
|
||||
Ordered lifecycle slots to visit for an event (method-aware via slot_map).
|
||||
|
||||
Returns slot keys; caller persists the last applicable state.
|
||||
"""
|
||||
from steering.kernel.lifecycle import resolve_method_slot_map
|
||||
|
||||
payload = payload or {}
|
||||
slot_map = resolve_method_slot_map(primary_method_key)
|
||||
|
||||
if event_kind == "actor_result" and payload.get("to_status") == "done":
|
||||
candidates = ("result_intake", "adaptation", "action_selection")
|
||||
event_slot = "result_intake"
|
||||
elif event_kind == "gate_verified":
|
||||
candidates = ("validation", "adaptation", "action_selection")
|
||||
event_slot = "validation"
|
||||
elif event_kind == "gate_reopened":
|
||||
candidates = ("adaptation", "planning", "action_selection")
|
||||
event_slot = "adaptation"
|
||||
elif event_kind == "situational" and payload.get("reason") == "blocker_resolved":
|
||||
candidates = ("action_selection",)
|
||||
event_slot = "action_selection"
|
||||
else:
|
||||
return ()
|
||||
|
||||
chain: list[str] = []
|
||||
for step in candidates:
|
||||
status = slot_map.get(step, "n/a")
|
||||
if _slot_accepts_event(
|
||||
status, # type: ignore[arg-type]
|
||||
event_targets_slot=(step == event_slot or step in ("adaptation", "action_selection")),
|
||||
):
|
||||
chain.append(step)
|
||||
return tuple(chain)
|
||||
@@ -43,6 +43,23 @@ GENERIC_OPERATING_SLOTS: dict[str, SlotStatus] = {
|
||||
}
|
||||
|
||||
|
||||
# Spec-D continuous_product D5 (method_bind → method_selection)
|
||||
CONTINUOUS_PRODUCT_SLOTS: dict[str, SlotStatus] = {
|
||||
"intake": "active",
|
||||
"method_selection": "active",
|
||||
"structure_setup": "active",
|
||||
"planning": "active",
|
||||
"action_selection": "active",
|
||||
"assignment": "active",
|
||||
"waiting": "active",
|
||||
"result_intake": "active",
|
||||
"validation": "optional",
|
||||
"review": "optional",
|
||||
"adaptation": "active",
|
||||
"closure": "n/a",
|
||||
}
|
||||
|
||||
|
||||
def validate_slot_map(slot_map: dict[str, SlotStatus]) -> None:
|
||||
for step, status in slot_map.items():
|
||||
if step not in STANDARD_LIFECYCLE_STEPS:
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
"""Lifecycle slot providers — minimal registry v0.2."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Callable, Literal
|
||||
|
||||
from steering.lifecycle.event_transitions import EventKind
|
||||
|
||||
SlotKey = Literal[
|
||||
"result_intake",
|
||||
"validation",
|
||||
"adaptation",
|
||||
"action_selection",
|
||||
"planning",
|
||||
]
|
||||
|
||||
TransitionResolver = Callable[
|
||||
[str, EventKind, dict[str, Any] | None],
|
||||
tuple[str, ...],
|
||||
]
|
||||
|
||||
_PROVIDERS: dict[SlotKey, TransitionResolver] = {}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SlotProviderRegistration:
|
||||
slot_key: SlotKey
|
||||
event_kinds: frozenset[EventKind]
|
||||
|
||||
|
||||
def register_slot_provider(
|
||||
slot_key: SlotKey,
|
||||
*,
|
||||
event_kinds: frozenset[EventKind],
|
||||
resolver: TransitionResolver,
|
||||
) -> None:
|
||||
_PROVIDERS[slot_key] = resolver
|
||||
_REGISTRATIONS[slot_key] = SlotProviderRegistration(
|
||||
slot_key=slot_key, event_kinds=event_kinds
|
||||
)
|
||||
|
||||
|
||||
_REGISTRATIONS: dict[SlotKey, SlotProviderRegistration] = {}
|
||||
|
||||
|
||||
def list_slot_provider_registrations() -> tuple[SlotProviderRegistration, ...]:
|
||||
return tuple(_REGISTRATIONS.values())
|
||||
|
||||
|
||||
def resolve_event_via_providers(
|
||||
*,
|
||||
primary_method_key: str,
|
||||
event_kind: EventKind,
|
||||
payload: dict[str, Any] | None = None,
|
||||
) -> tuple[str, ...]:
|
||||
"""First matching provider wins; fallback to default event_transitions."""
|
||||
from steering.lifecycle.event_transitions import resolve_lifecycle_chain
|
||||
|
||||
payload = payload or {}
|
||||
for slot_key, registration in _REGISTRATIONS.items():
|
||||
if event_kind not in registration.event_kinds:
|
||||
continue
|
||||
resolver = _PROVIDERS.get(slot_key)
|
||||
if resolver:
|
||||
chain = resolver(primary_method_key, event_kind, payload)
|
||||
if chain:
|
||||
return chain
|
||||
return resolve_lifecycle_chain(
|
||||
primary_method_key=primary_method_key,
|
||||
event_kind=event_kind,
|
||||
payload=payload,
|
||||
)
|
||||
|
||||
|
||||
def register_default_slot_providers() -> None:
|
||||
from steering.lifecycle.event_transitions import resolve_lifecycle_chain
|
||||
|
||||
if _PROVIDERS:
|
||||
return
|
||||
|
||||
def _default_resolver(
|
||||
primary_method_key: str,
|
||||
event_kind: EventKind,
|
||||
payload: dict[str, Any] | None,
|
||||
) -> tuple[str, ...]:
|
||||
return resolve_lifecycle_chain(
|
||||
primary_method_key=primary_method_key,
|
||||
event_kind=event_kind,
|
||||
payload=payload,
|
||||
)
|
||||
|
||||
register_slot_provider(
|
||||
"result_intake",
|
||||
event_kinds=frozenset({"actor_result"}),
|
||||
resolver=_default_resolver,
|
||||
)
|
||||
register_slot_provider(
|
||||
"validation",
|
||||
event_kinds=frozenset({"gate_verified"}),
|
||||
resolver=_default_resolver,
|
||||
)
|
||||
register_slot_provider(
|
||||
"adaptation",
|
||||
event_kinds=frozenset({"actor_result", "gate_verified", "gate_reopened"}),
|
||||
resolver=_default_resolver,
|
||||
)
|
||||
Reference in new issue
Block a user