Skip to content

Deep health, readiness probes & dependency observability — backend EPIC #80

Description

@grantfox-oss

DESCRIPTION

HealthService.check() (apps/api/src/health/health.service.ts) only pings Supabase and generic Stellar Horizon reachability. It never checks SOROBAN_RPC_URL (already defined in apps/api/src/escrow/stellar.config.ts but unused by health), even though every VELAR bond is a Soroban contract — so a healthy Horizon can mask a broken contract RPC, and there's no visibility into the platform/escrow wallet's funding status. This epic deepens the health surface into real readiness/liveness probes with dependency-specific detail.

GOAL

/health distinguishes liveness (process is up) from readiness (all real dependencies — Supabase, Horizon, Soroban RPC, escrow wallet funding — are reachable and healthy), each dependency is checked independently, and the payload carries enough detail for on-call debugging.

REQUIREMENTS

  • Split into GET /health/live (process responsive, no dependency checks, always fast) and GET /health/ready (all dependency checks, used by deploy/readiness probes) — or keep GET /health as readiness and add /health/live as the new lightweight endpoint; document whichever shape is chosen.
  • Add a Soroban RPC check (SOROBAN_RPC_URL) distinct from the existing Horizon check.
  • Add an escrow/platform wallet funding check (low XLM balance is a real incident risk — reuse WalletService/apps/api/src/escrow/ to read balance) and surface a degraded/warning state before it's fully down.
  • Keep the existing 3-second per-dependency timeout pattern; do not let one slow dependency block the others (checks already run in parallel via Promise.all — preserve that).
  • Add build/version info to the payload (e.g. git SHA or package version, deploy timestamp) for on-call debugging.

ACCEPTANCE CRITERIA

  • /health/live responds fast with no external calls.
  • /health/ready (or /health) reports Supabase, Horizon, Soroban RPC, and escrow wallet funding independently, with HTTP 200 when healthy and 503 when any critical dependency is down.
  • A simulated low/zero escrow balance is surfaced as degraded, not silently ok.
  • Response time stays under 5s in normal operation (existing constraint, preserved).
  • npm run build, npm run lint, npm run test pass in apps/api with NO VELAR credentials.
  • docs/BACKEND.md updated with the new health contract.

NOTES

Relevant files: apps/api/src/health/health.service.ts, apps/api/src/health/health.controller.ts, apps/api/src/escrow/stellar.config.ts (SOROBAN_RPC_URL), apps/api/src/escrow/wallet.service.ts (balance reading). This EXTENDS the existing health module (originally built for issue #5) — don't rewrite the Supabase/Horizon checks, add to them (docs/AGENTS.md §3). Endpoint(s) stay unauthenticated.

No VELAR credentials required: verifiable locally/against testnet — no VELAR database credentials or service_role key.

Difficulty: Intermediate
Priority: Medium

PR REQUIREMENTS

  • Ship this as a single pull request — do not split into stacked/sequential PRs.
  • Your PR description must include Closes #<this-issue-number> (this issue's GitHub number) so merging auto-closes it.

CAMPAIGN REQUIREMENTS (FWC26)

To be eligible for the reward on this issue, the contributor must:

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Third CampaignCampaign: Third Campaign

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions