feat(gateway): tier-detector with fail-fast PG/Valkey/pgvector probes (FED-M1-04) #473
Reference in New Issue
Block a user
Delete Branch "feat/federation-m1-detector"
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-04 — Implements
apps/gateway/src/bootstrap/tier-detector.ts, invoked frommain.tsbefore NestJS bootstraps. For each storage tier:local: no-op (PGlite is in-process)standalone: probes Postgres + Valkeyfederated: probes Postgres + Valkey + pgvector extension; rejects config upfront ifqueue.type !== 'bullmq'Each probe enforces a 5-second hard cap and emits a structured
TierDetectionErrorcarryingservice,host,port, and an actionableremediation. The pgvector probe discriminates between two failure modes:extension "vector" is not available) → remediation points topgvector/pgvector:pg17imageCREATEpermission / superuserAdds
postgresandioredisas direct gateway dependencies (previously transitive only).Process notes
connectTimeout, no error discrimination in pgvector catch, and federated tier silently skipping Valkey ifqueue.type !== 'bullmq'. All three fixed in this PR.Tests
12 unit tests in
tier-detector.spec.ts:Test plan
Refs #460
Implements `apps/gateway/src/bootstrap/tier-detector.ts` invoked from `main.ts` before NestJS bootstraps. For each tier: - `local`: no-op (PGlite is in-process) - `standalone`: probe Postgres + Valkey - `federated`: probe Postgres + Valkey + pgvector extension; reject config upfront if `queue.type !== 'bullmq'` Each probe has a 5-second hard cap and emits a structured `TierDetectionError` with service / host / port / remediation. The remediation field discriminates pgvector failure modes ("library not available" vs "permission denied") so operators get actionable hints without leaking credentials. Adds `postgres` and `ioredis` as direct gateway deps; previously only transitive. 12 unit tests cover happy paths and each fail-fast branch. Refs #460