fix(health): report real per-dependency status instead of hardcoded ok:true #18

Merged
admin merged 1 commits from fix/honest-health-check into main 2026-08-11 12:31:36 +00:00
Owner

Summary

Fixes BACKLOG P0-3: /api/health used to hardcode ok: true and only ever check presence of DATABASE_URL/REDIS_URL — never whether anything was actually reachable. docs/architecture/ARCHITECTURE.md's own words: "an uptime monitor watching HTTP 200 would show green for a dying instance."

  • lib/health-checks.ts — real dependency probes: db (live select 1), engine (real HTTP call to the FastAPI engine's own GET /health), stripe (Stripe's documented lightweight balance.retrieve() call), queue (honestly reports not_integrated when REDIS_URL is set but unused — no Redis client is wired anywhere in this repo).
  • GET /api/health stays a liveness check (always 200 while the process can respond); the body's ok field is now the honest signal instead of a hardcoded literal.
  • New GET /api/ready — fails closed with 503 when the load-bearing dependency (db) isn't both configured and reachable. This was the other half of the finding: "no /ready route existed at all" (CD-04/OBS-04).
  • contracts/openapi.yaml, docs/architecture/ARCHITECTURE.md, docs/slo.md updated to match.

Test plan

  • pnpm run typecheck — clean, no errors (blocking gate).
  • pnpm run test — 156 passed, 1 pre-existing skip (unrelated live-infra test), including 17 new unit tests (dependency-injected fakes, no real network/DB) + 5 new route-level tests.
  • pnpm run build — succeeds, /api/ready registered as a new route.
  • pnpm run typecheck:app (advisory) — identical 9 pre-existing errors as clean main baseline, confirmed via git stash diff. No new advisory errors introduced.
  • pnpm exec eslint on every new file — 0 errors, 0 warnings.
  • Confirmed via curl against a real pnpm run build && pnpm run start that both routes respond correctly with the new dependency fields.

Not merged

Per instructions — needs a final human look. main on this repo has had recent contention; this PR does not touch the WAF-bypass/scraper code or any frozen path.

🤖 Generated with Claude Code

## Summary Fixes BACKLOG **P0-3**: `/api/health` used to hardcode `ok: true` and only ever check *presence* of `DATABASE_URL`/`REDIS_URL` — never whether anything was actually reachable. `docs/architecture/ARCHITECTURE.md`'s own words: "an uptime monitor watching HTTP 200 would show green for a dying instance." - `lib/health-checks.ts` — real dependency probes: `db` (live `select 1`), `engine` (real HTTP call to the FastAPI engine's own `GET /health`), `stripe` (Stripe's documented lightweight `balance.retrieve()` call), `queue` (honestly reports `not_integrated` when `REDIS_URL` is set but unused — no Redis client is wired anywhere in this repo). - `GET /api/health` stays a **liveness** check (always 200 while the process can respond); the body's `ok` field is now the honest signal instead of a hardcoded literal. - New **`GET /api/ready`** — fails closed with 503 when the load-bearing dependency (`db`) isn't both configured and reachable. This was the other half of the finding: "no `/ready` route existed at all" (CD-04/OBS-04). - `contracts/openapi.yaml`, `docs/architecture/ARCHITECTURE.md`, `docs/slo.md` updated to match. ## Test plan - [x] `pnpm run typecheck` — clean, no errors (blocking gate). - [x] `pnpm run test` — 156 passed, 1 pre-existing skip (unrelated live-infra test), including 17 new unit tests (dependency-injected fakes, no real network/DB) + 5 new route-level tests. - [x] `pnpm run build` — succeeds, `/api/ready` registered as a new route. - [x] `pnpm run typecheck:app` (advisory) — identical 9 pre-existing errors as clean `main` baseline, confirmed via `git stash` diff. No new advisory errors introduced. - [x] `pnpm exec eslint` on every new file — 0 errors, 0 warnings. - [x] Confirmed via `curl` against a real `pnpm run build && pnpm run start` that both routes respond correctly with the new dependency fields. ## Not merged Per instructions — needs a final human look. `main` on this repo has had recent contention; this PR does not touch the WAF-bypass/scraper code or any frozen path. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
admin added 1 commit 2026-08-11 12:18:50 +00:00
fix(health): report real per-dependency status instead of hardcoded ok:true
CI (SIAX Cloud) / security (push) Successful in 21s
Security Scan (SIAX Cloud) / security (push) Successful in 21s
CI (SIAX Cloud) / quality (push) Successful in 41s
CI (SIAX Cloud) / security (pull_request) Successful in 22s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 21s
CI (SIAX Cloud) / quality (pull_request) Successful in 41s
a88ad04867
BACKLOG P0-3: /api/health only ever checked *presence* of DATABASE_URL/
REDIS_URL and always returned ok:true regardless of whether anything was
reachable -- ARCHITECTURE.md's own words, "an uptime monitor watching HTTP
200 would show green for a dying instance".

lib/health-checks.ts adds real dependency probes:
  - db: a live `select 1` round trip (not just DATABASE_URL presence)
  - engine: a real HTTP call to the FastAPI engine's own GET /health
  - stripe: Stripe's documented lightweight balance.retrieve() liveness call
  - queue: honestly reports "not_integrated" when REDIS_URL is set but
    unused -- no Redis client is wired anywhere in this repo, so reporting
    "ok" would fabricate a check that doesn't exist

/api/health stays a liveness check (always 200 while the process can
respond; the body's `ok` field is the honest signal). New GET /api/ready
fails closed with 503 when the load-bearing dependency (db) isn't both
configured and reachable -- the "no /ready route" gap.

contracts/openapi.yaml, docs/architecture/ARCHITECTURE.md, and docs/slo.md
updated to match. 17 new unit tests (dependency-injected fakes, no real
network/DB) + 5 route-level tests.
admin merged commit into main 2026-08-11 12:31:36 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/0pt#18