---
id: w1/m22/t004
title: REST/GraphQL/MCP HA surface (enableHighAvailability, failover, replica URLs)
worker: worker1
status: todo
estimate: 60m
depends_on: [w1/m22/t002, w1/m22/t003]
---

## Objective

Expose HA over all three bex-api surfaces with Render-identical shape: enable/disable HA, a failover/promote action, and read-replica URLs in the connection-info; `highAvailabilityEnabled` reports the real state.

## Context

- `lego/backend/` imports `types/`; feature-package-per-feature (m2.5). The Postgres surface already exists from m17 — extend it.
- Render: `enableHighAvailability` on the Postgres resource, `failover` action, `replication`/read-replica connection strings — match field names + error shapes.
- Today bex hardcodes `highAvailabilityEnabled: false`; wire it to the CR state.

## Steps

1. Extend the Postgres core: HA enable/disable, failover verb, replica URLs in connection info.
2. Wire REST, GraphQL, and MCP adapters; make `highAvailabilityEnabled` reflect the CR.
3. Match Render's field names, error shapes, and the primary-vs-replica URL distinction.

## Files

- `lego/backend/internal/<postgres feature>/…` (core + REST/GraphQL/MCP adapters)

## Acceptance criteria

- [ ] Enable HA, trigger failover, and read replica URLs over REST; GraphQL + MCP identical; `highAvailabilityEnabled` is truthful.
- [ ] Backend `go build`/`go test` green; `make lint-backend` clean.

## Out of scope

- Mechanism (t001–t003); dashboard (t005).
