Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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.

---

Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/Kernel/BoundedContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
16 changes: 16 additions & 0 deletions src/Kernel/DomainKernelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down
23 changes: 23 additions & 0 deletions src/Kernel/GeneratedContextInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace JardisSupport\Contract\Kernel;

/**
* Marker interface for generated Bounded Context classes.
*
* Deliberately empty — carries no methods. Every generated `{Domain}Context`
* implements it, so the resolve path can recognize generated context classes
* via `is_subclass_of($resolved, GeneratedContextInterface::class)` instead of
* `instanceof`/base-class checks tied to a shared package base class. This
* works across domain boundaries (cross-domain services included), which a
* check against a common ancestor class could not guarantee once the domain
* no longer extends a package class (Kernel-Entkopplung).
*
* Supersedes the detection role formerly played by
* {@see BoundedContextInterface}, which is now `@deprecated`.
*/
interface GeneratedContextInterface
{
}
29 changes: 29 additions & 0 deletions src/Kernel/ResponseStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace JardisSupport\Contract\Kernel;

/**
* Status codes for domain responses.
*
* Inspired by HTTP status codes but domain-neutral.
* Can be mapped 1:1 to HTTP codes by the API layer if needed.
*
* Ported 1:1 from `jardiscore/kernel` (`JardisCore\Kernel\Response\ResponseStatus`,
* Kernel-Entkopplung contract v2): the contract is the vocabulary home generated
* domains import from, so this enum moves here alongside {@see EventScope}.
*/
enum ResponseStatus: int
{
case Success = 200;
case Created = 201;
case NoContent = 204;
case ValidationError = 400;
case Unauthorized = 401;
case Forbidden = 403;
case NotFound = 404;
case Conflict = 409;
case RuleViolation = 422;
case InternalError = 500;
}