AP1.0: Steering Foundation — Lifecycle, Context, Signal Engine
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 1m19s
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 11s
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 1m19s
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 11s
Persistierter Standard Lifecycle pro Initiative, backend/steering/ Skeleton, Attention-Refactor und Hook-Dispatch als Basis für Method Registry. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
451d62ed46
commit
95feba6204
36 files changed
+2006
-724
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,35 @@
|
||||
"""Hook dispatch — AP1.0 stub with audit trail."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
from steering.hooks.registry import get_hook
|
||||
from tenant_context import TenantContext
|
||||
|
||||
|
||||
def dispatch_hook(
|
||||
slug: str,
|
||||
ctx: TenantContext | None,
|
||||
payload: dict[str, Any],
|
||||
*,
|
||||
tenant_id: Optional[str] = None,
|
||||
user_id: Optional[str] = None,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Dispatch hook — AP1.0: audit only, no handlers yet."""
|
||||
hook = get_hook(slug)
|
||||
if not hook:
|
||||
return [{"kind": "hook_unknown", "slug": slug}]
|
||||
|
||||
tid = tenant_id or (ctx.tenant_id if ctx else None)
|
||||
if tid and user_id:
|
||||
from services.audit import log_audit
|
||||
|
||||
log_audit(
|
||||
f"steering.hook.{slug}",
|
||||
user_id=user_id,
|
||||
tenant_id=tid,
|
||||
details={"slug": slug, "payload": payload},
|
||||
)
|
||||
|
||||
return [{"kind": "hook_dispatched", "slug": slug, "lifecycle_step": hook.lifecycle_step}]
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Hook Registry — stabile Einhängepunkte (AP1.0 definitions only)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
_HOOKS: dict[str, "HookDefinition"] = {}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class HookDefinition:
|
||||
slug: str
|
||||
lifecycle_step: str
|
||||
description: str
|
||||
since_version: str = "0.11.0"
|
||||
|
||||
|
||||
def register_hook(defn: HookDefinition) -> None:
|
||||
if defn.slug in _HOOKS:
|
||||
raise ValueError(f"Hook already registered: {defn.slug}")
|
||||
_HOOKS[defn.slug] = defn
|
||||
|
||||
|
||||
def get_hook(slug: str) -> HookDefinition | None:
|
||||
return _HOOKS.get(slug)
|
||||
|
||||
|
||||
def list_hooks() -> tuple[HookDefinition, ...]:
|
||||
return tuple(_HOOKS.values())
|
||||
|
||||
|
||||
def clear_hooks_for_tests() -> None:
|
||||
_HOOKS.clear()
|
||||
|
||||
|
||||
def register_builtin_hooks() -> None:
|
||||
"""Slugs aus Target Architecture §7.3 — Handler folgen in AP1.3."""
|
||||
builtins = (
|
||||
("on_goal_captured", "intake", "Ziel erfasst"),
|
||||
("on_method_selected", "method_selection", "Methode gewählt"),
|
||||
("on_structure_required", "structure_setup", "Struktur erforderlich"),
|
||||
("on_backlog_required", "structure_setup", "Backlog erforderlich"),
|
||||
("on_next_action_requested", "action_selection", "Nächste Aktion angefragt"),
|
||||
("on_assignment_required", "assignment", "Zuweisung erforderlich"),
|
||||
("on_blocker_open", "waiting", "Blocker gemeldet"),
|
||||
("on_blocker_resolved", "action_selection", "Blocker geschlossen"),
|
||||
("on_wait_started", "waiting", "Warten begonnen"),
|
||||
("on_result_received", "result_intake", "Ergebnis eingegangen"),
|
||||
("on_evidence_required", "validation", "Nachweis erforderlich"),
|
||||
("on_review_due", "review", "Review fällig"),
|
||||
("on_review_completed", "review", "Review abgeschlossen"),
|
||||
("on_replan_required", "adaptation", "Anpassung nötig"),
|
||||
("on_closure_requested", "closure", "Abschluss angefragt"),
|
||||
)
|
||||
for slug, step, desc in builtins:
|
||||
if slug not in _HOOKS:
|
||||
register_hook(
|
||||
HookDefinition(
|
||||
slug=slug,
|
||||
lifecycle_step=step,
|
||||
description=desc,
|
||||
)
|
||||
)
|
||||
Reference in new issue
Block a user