v0.2.0 (2/N): HealthController deep-load canary → BridgeBundleInfo VO

Decouples /healthz from the publisher contract. v0.1.1 wired
HealthController to constructor-inject Publisher purely as a "is the
bundle resolvable" probe — that worked but cemented the publisher's
API as a readiness-test dependency, which was awkward once
PublisherInterface landed in v0.2.0 chunk 1.

Replace with BridgeBundleInfo: a tiny readonly VO carrying the
bundle's name + class FQCN. HealthController depends on this instead.
Same deep-load semantics (broken bundle → can't construct the VO →
500 on /healthz), no leaky publisher dep.

/healthz response shape:
  - `bundle`: was `PhpQml\\Bridge\\Publisher`,
              now `PhpQml\\Bridge\\BridgeBundle`
  - `name`:   new field, reports `php-qml/bridge`

bundled-supervisor.sh's grep updated to match the new canary value
plus an assertion that the new `name` field is present (catches a
botched BridgeBundleInfo wire-up that the bundle-class-name assertion
alone would miss).

Quality + maker snapshot + bundled-supervisor integration test all
pass locally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-03 19:57:52 +02:00
parent 56e3d671d9
commit 0cca0785c0
4 changed files with 47 additions and 12 deletions

View File

@@ -12,11 +12,13 @@ This section tracks work landing on `dev` toward **v0.2.0** (next minor; pre-1.0
- **`PublisherInterface`, `ModelPublisherInterface`, `CorrelationContextInterface`.** The bridge's three public services now ship as interfaces (same namespace as concrete, mirroring upstream `HubInterface`/`Hub`). App controllers and listeners should typehint these instead of the concrete classes so swappable implementations (offline-buffer publisher, request-stamp correlation context, etc.) remain non-breaking. Existing `Publisher` / `ModelPublisher` / `CorrelationContext` classes implement the new interfaces unchanged. - **`PublisherInterface`, `ModelPublisherInterface`, `CorrelationContextInterface`.** The bridge's three public services now ship as interfaces (same namespace as concrete, mirroring upstream `HubInterface`/`Hub`). App controllers and listeners should typehint these instead of the concrete classes so swappable implementations (offline-buffer publisher, request-stamp correlation context, etc.) remain non-breaking. Existing `Publisher` / `ModelPublisher` / `CorrelationContext` classes implement the new interfaces unchanged.
- **`BridgeOp` enum.** PHP 8.1 string-backed enum (`Upsert` / `Delete` / `Replace` / `Event`) replacing the raw `'upsert'`/`'delete'` strings previously passed between `DoctrineBridgeListener` and `ModelPublisher::publishEntityChange`. Values match PLAN.md §4's envelope `op` wire format. Typo'd ops are now caught at the type level instead of silently producing envelopes clients ignore. - **`BridgeOp` enum.** PHP 8.1 string-backed enum (`Upsert` / `Delete` / `Replace` / `Event`) replacing the raw `'upsert'`/`'delete'` strings previously passed between `DoctrineBridgeListener` and `ModelPublisher::publishEntityChange`. Values match PLAN.md §4's envelope `op` wire format. Typo'd ops are now caught at the type level instead of silently producing envelopes clients ignore.
- **`BridgeBundleInfo` value object** carrying the bundle's name + class FQCN. `HealthController` now constructor-injects this instead of `PublisherInterface` as the deep-load canary, so the readiness probe is no longer coupled to the publisher's contract. `/healthz` response gains a `name` field (`php-qml/bridge`); the `bundle` field now reports `PhpQml\Bridge\BridgeBundle` (was `PhpQml\Bridge\Publisher`).
### Changed ### Changed
- **`ModelPublisher::publishEntityChange()` signature: `string $op``BridgeOp $op`.** Pre-1.0 SemVer break. Internal callers updated; external callers (rare) need to migrate from raw strings to enum cases. - **`ModelPublisher::publishEntityChange()` signature: `string $op``BridgeOp $op`.** Pre-1.0 SemVer break. Internal callers updated; external callers (rare) need to migrate from raw strings to enum cases.
- **Internal typehints switched to interfaces.** `ModelPublisher` constructor takes `PublisherInterface` + `CorrelationContextInterface`; `DoctrineBridgeListener` takes `ModelPublisherInterface`; `HealthController` and the skeleton's `PingController` take `PublisherInterface`. Autowire continues to inject the concrete implementations transparently. - **Internal typehints switched to interfaces.** `ModelPublisher` constructor takes `PublisherInterface` + `CorrelationContextInterface`; `DoctrineBridgeListener` takes `ModelPublisherInterface`; `HealthController` takes `BridgeBundleInfo`; the skeleton's `PingController` takes `PublisherInterface`. Autowire continues to inject the concrete implementations transparently.
- **`/healthz` response shape.** `bundle` field's value changes from `PhpQml\Bridge\Publisher` to `PhpQml\Bridge\BridgeBundle`; new `name` field reports the Composer package name. JSON consumers ignoring unknown keys are unaffected; consumers asserting the `bundle` value need to migrate.
### Fixed ### Fixed

View File

@@ -122,8 +122,10 @@ done
step "/healthz body: $HEALTHZ_BODY" step "/healthz body: $HEALTHZ_BODY"
echo "$HEALTHZ_BODY" | grep -q '"status":"ok"' \ echo "$HEALTHZ_BODY" | grep -q '"status":"ok"' \
|| fail "/healthz didn't return status:ok" || fail "/healthz didn't return status:ok"
echo "$HEALTHZ_BODY" | grep -q '"bundle":"PhpQml\\\\Bridge\\\\Publisher"' \ echo "$HEALTHZ_BODY" | grep -q '"bundle":"PhpQml\\\\Bridge\\\\BridgeBundle"' \
|| fail "/healthz missing bundle field — HealthController deep-load broken" || fail "/healthz missing bundle field — HealthController deep-load broken"
echo "$HEALTHZ_BODY" | grep -q '"name":"php-qml\\/bridge"' \
|| fail "/healthz missing name field — BridgeBundleInfo not wired"
# ── Verify the cache/log redirect actually fired ─────────────────────── # ── Verify the cache/log redirect actually fired ───────────────────────
step "verify Symfony wrote cache to user data dir, not the read-only staging" step "verify Symfony wrote cache to user data dir, not the read-only staging"

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace PhpQml\Bridge;
/**
* Tiny readonly value-object that names the bundle. Exists for one
* reason: `HealthController` constructor-injects it as a deep-load
* canary. If the bundle's autoload or container wiring is broken
* (a dangling vendor path-repo symlink in a packaging build, for
* example), this service can't be resolved and `/healthz` fails 500
* — instead of misleadingly returning 200 against a half-loaded
* bundle, which is what bit v0.1.0.
*
* Decoupled from `PublisherInterface` (the v0.1.1 canary) so the
* publisher's contract stays free to evolve without rippling into
* the readiness probe's expectations.
*/
final readonly class BridgeBundleInfo
{
public string $name;
public string $bundle;
public function __construct()
{
$this->name = 'php-qml/bridge';
$this->bundle = BridgeBundle::class;
}
}

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace PhpQml\Bridge\Controller; namespace PhpQml\Bridge\Controller;
use PhpQml\Bridge\PublisherInterface; use PhpQml\Bridge\BridgeBundleInfo;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
@@ -12,18 +12,18 @@ use Symfony\Component\Routing\Attribute\Route;
* Readiness probe used by the Qt host to detect when the backend is up. * Readiness probe used by the Qt host to detect when the backend is up.
* See PLAN.md §3 (*Startup*, step 4). * See PLAN.md §3 (*Startup*, step 4).
* *
* `PublisherInterface` is injected purely as a deep-health canary: if the * `BridgeBundleInfo` is injected purely as a deep-load canary: if the
* bridge bundle's autoload or container wiring is broken (e.g. a packaging * bundle's autoload or container wiring is broken (e.g. a packaging build
* build with a dangling vendor path-repo symlink), this controller can't * with a dangling vendor path-repo symlink), this controller can't even
* even be constructed, so /healthz fails 500 instead of misleadingly * be constructed, so /healthz fails 500 instead of misleadingly returning
* returning 200 against a half-loaded bundle. The response includes the * 200 against a half-loaded bundle. Earlier (v0.1.1v0.2.0) this canary
* concrete class name so packagers can detect a wrong-implementation * was `PublisherInterface`; switching to a dedicated info VO decouples
* deployment from the canary value alone. * the readiness probe from the publisher's evolving contract.
*/ */
final class HealthController final class HealthController
{ {
public function __construct( public function __construct(
private readonly PublisherInterface $publisher, private readonly BridgeBundleInfo $info,
) { ) {
} }
@@ -32,7 +32,8 @@ final class HealthController
{ {
return new JsonResponse([ return new JsonResponse([
'status' => 'ok', 'status' => 'ok',
'bundle' => $this->publisher::class, 'bundle' => $this->info->bundle,
'name' => $this->info->name,
]); ]);
} }
} }