From 4384cc02d2f28331e25a33d39166485afedafacf Mon Sep 17 00:00:00 2001 From: Headgent Development Date: Thu, 16 Jul 2026 14:41:40 +0200 Subject: [PATCH] feat(kernel): ResponseStatus-Enum + eventListenerRegistry() + GeneratedContextInterface-Marker (v2 lokal) --- README.md | 45 ++++++++++++++++++++++-- src/Kernel/BoundedContextInterface.php | 8 +++++ src/Kernel/DomainKernelInterface.php | 16 +++++++++ src/Kernel/GeneratedContextInterface.php | 23 ++++++++++++ src/Kernel/ResponseStatus.php | 29 +++++++++++++++ 5 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 src/Kernel/GeneratedContextInterface.php create mode 100644 src/Kernel/ResponseStatus.php diff --git a/README.md b/README.md index 2470c96..cd6aa14 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This package provides all interface contracts for the Jardis ecosystem in a sing | Namespace | Contracts | Purpose | |-----------|-----------|---------| -| `Kernel` | 4 | DomainKernel, BoundedContext, ContextResponse, DomainResponse | +| `Kernel` | 7 | DomainKernel, BoundedContext (deprecated), ContextResponse, DomainResponse, EventScope, ResponseStatus, GeneratedContextInterface (marker) | | `ClassVersion` | 2 | Versioned class resolution | | `Connection` | 1 | Generic connection abstraction | | `Data` | 3 | Hydration, Identity, FieldMapper | @@ -33,7 +33,7 @@ This package provides all interface contracts for the Jardis ecosystem in a sing | `Filesystem` | 5 | Filesystem (Reader/Writer), FileInfo + Exception | | `Workflow` | 6 | Workflow engine + orchestration (Workflow, Builder, NodeBuilder, Config, Context, Result) — 7 named transitions: `onSuccess`, `onFail`, `onTimeout`, `onSkip`, `onCancel`, `onEvent`, `onExit` | -**67 contracts** across 15 domains. +**70 contracts** across 15 domains. --- @@ -71,6 +71,47 @@ JardisSupport\Contract\ --- +## Kernel — v2 additions (Kernel-Entkopplung) + +Three additions to `Kernel\` that let a generated domain drop its compile-time +dependency on `jardiscore/kernel`'s base classes while keeping the same +runtime vocabulary. + +### `ResponseStatus` enum + +`JardisSupport\Contract\Kernel\ResponseStatus` — an `int`-backed enum of +domain-neutral response status codes (`Success = 200`, `Created = 201`, +`NoContent = 204`, `ValidationError = 400`, `Unauthorized = 401`, +`Forbidden = 403`, `NotFound = 404`, `Conflict = 409`, `RuleViolation = 422`, +`InternalError = 500`), ported 1:1 from `jardiscore/kernel`'s +`JardisCore\Kernel\Response\ResponseStatus`. Generated domains import it from +here instead of from `jardiscore/kernel`. + +### `DomainKernelInterface::eventListenerRegistry()` + +The Kernel interface (the "Koffer") gained an 11th accessor: +`eventListenerRegistry(): ?EventListenerRegistryInterface`. It is paired with +`eventDispatcher()` — both are typically backed by the same underlying +provider instance, one side for dispatching (PSR-14), one side for +registering listeners. Generated `{Agg}EventRouter` scaffolds use this +accessor to self-register on the domain facade's constructor. Nullable like +every other service on the interface: without a registry, event routing +simply stays inactive. + +### `GeneratedContextInterface` marker + +`JardisSupport\Contract\Kernel\GeneratedContextInterface` is an empty marker +interface. Every generated `{Domain}Context` implements it, so the resolve +path recognizes generated context classes via +`is_subclass_of($resolved, GeneratedContextInterface::class)` — independent +of domain boundaries (cross-domain services included) and without requiring +a shared package base class to extend. It replaces the detection role +formerly played by `BoundedContextInterface`, which is now `@deprecated` (not +removed — kept for code still written against the old `jardiscore/kernel` +`BoundedContext` base class). + +--- + ## Design Principles - **One package, all contracts** — single dependency for the entire Jardis ecosystem diff --git a/src/Kernel/BoundedContextInterface.php b/src/Kernel/BoundedContextInterface.php index 2041954..ff86ce5 100644 --- a/src/Kernel/BoundedContextInterface.php +++ b/src/Kernel/BoundedContextInterface.php @@ -13,6 +13,14 @@ * - handle() pass-through, inherits the caller's payload+version * - context() fresh context, sets payload+version explicitly * (used at API boundaries to start a new call chain) + * + * @deprecated Superseded by {@see GeneratedContextInterface} (Kernel-Entkopplung, + * contract v2). BC-subclass detection in the resolve path no longer hangs off + * this interface; generated `{Domain}Context` classes implement the empty + * marker instead, which works across domain boundaries without a shared + * package base class. Kept for backward compatibility with code written + * against the old `jardiscore/kernel` `BoundedContext` base class — not + * implemented by newly generated domains. */ interface BoundedContextInterface { diff --git a/src/Kernel/DomainKernelInterface.php b/src/Kernel/DomainKernelInterface.php index 270026b..2f5d0a3 100644 --- a/src/Kernel/DomainKernelInterface.php +++ b/src/Kernel/DomainKernelInterface.php @@ -5,6 +5,7 @@ namespace JardisSupport\Contract\Kernel; use JardisSupport\Contract\DbConnection\ConnectionPoolInterface; +use JardisSupport\Contract\EventListener\EventListenerRegistryInterface; use JardisSupport\Contract\Filesystem\FilesystemServiceInterface; use JardisSupport\Contract\Mailer\MailerInterface; use PDO; @@ -76,6 +77,21 @@ public function logger(): ?LoggerInterface; */ public function eventDispatcher(): ?EventDispatcherInterface; + /** + * Gets the event listener registry for self-registering event routers. + * + * Paired with eventDispatcher(): implementations back both accessors with + * the same underlying provider instance — one PSR-14 dispatcher (send), + * one registry (add listeners). Generated `{Agg}EventRouter` scaffolds use + * it to register themselves on the domain facade's constructor, so a + * fresh build carries new routers automatically without any Application + * wiring. Nullable like every other service: without a registry, event + * routing stays inactive rather than failing. + * + * @return EventListenerRegistryInterface|null Registry or null if event routing is not configured + */ + public function eventListenerRegistry(): ?EventListenerRegistryInterface; + /** * Gets the PSR-18 HTTP client for external service calls. * diff --git a/src/Kernel/GeneratedContextInterface.php b/src/Kernel/GeneratedContextInterface.php new file mode 100644 index 0000000..ffad966 --- /dev/null +++ b/src/Kernel/GeneratedContextInterface.php @@ -0,0 +1,23 @@ +