feat(gateway,storage): mosaic gateway doctor with tier health JSON (FED-M1-06) #475
Reference in New Issue
Block a user
Delete Branch "feat/federation-m1-doctor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
FED-M1-06 — Adds
mosaic gateway doctor [--json] [--config <path>]for tier-aware health reporting (postgres + valkey + pgvector). JSON mode emits a single parseableTierHealthReportfor CI consumption; exit 1 on red.Refactor: tier probes lifted from gateway to storage
The probes from
apps/gateway/src/bootstrap/tier-detector.ts(FED-M1-04) needed to be reused by the new doctor command, but gateway is an app — not a library. Lifted them to@mosaicstack/storage:detectAndAssertTier(config)— fail-fast on first failure (used by gateway boot)probeServiceHealth(config)— non-throwing, runs ALL required probes, returnsTierHealthReportwith overall green/red verdict (used by doctor)Old
apps/gateway/src/bootstrap/tier-detector.ts+ spec deleted; gatewaymain.tsnow imports from@mosaicstack/storage.Cycle break
Storage couldn't take a dependency on
@mosaicstack/config(config already depends on storage forStorageConfig). Defined a local structuralTierConfiginterface intier-detection.tscapturing only the fields the probes use. Callers continue passing fullMosaicConfigobjects via structural compatibility.Tests
packages/storage/src/tier-detection.spec.ts— 22 tests (11 ported + 11 new coveringprobeServiceHealth, real-timer assertion, federated non-bullmq branch, lazyConnect)packages/mosaic/src/commands/gateway-doctor.spec.ts— 12 tests (JSON contract, exit codes, output format,--configoverride, console.log silence in JSON mode)Process notes
pnpm typecheckpost-fix and triaged by structural typing rather than movingMosaicConfigTest plan
mosaic gateway doctoragainst a running standalone stack returns greenmosaic gateway doctor --jsonproduces valid JSONRefs #460