---
id: w1/m20/t003
title: REST/GraphQL/MCP autoscaling surface (PUT/DELETE …/autoscaling)
worker: worker1
status: done
estimate: 60m
depends_on: [w1/m20/t001]
---

## Objective

Expose autoscaling config over all three bex-api surfaces with Render-identical shape: `PUT /v1/services/{id}/autoscaling` (upsert), `DELETE …/autoscaling` (disable), plus the GraphQL mutation and MCP tool. One core, thin adapters (`docs/ADR006-bex-api.md`).

## Context

- `lego/backend/` (bex-api) imports `types/`, never `operator/`; feature-package-per-feature layout (m2.5).
- Render request/response: min/max instances + target CPU%/mem%; verify exact field names + error shapes against render.com API docs.
- Writes flow through the same App-CR mutation path the rest of bex-api uses (control plane / CR patch), not a bespoke endpoint.

## Steps

1. Add the core autoscaling verb (read/upsert/delete) in the appropriate feature package, mapping to `spec.autoscaling`.
2. Wire REST (`PUT`/`DELETE …/autoscaling`), GraphQL mutation, and MCP tool adapters over that core.
3. Match Render's field names, defaults, and error shapes; return the current autoscaling config on read.

## Files

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

## Acceptance criteria

- [ ] `PUT`/`DELETE …/autoscaling` round-trip the stanza; GraphQL + MCP expose identical fields/semantics.
- [ ] Field names + error shapes match Render (spot-checked against docs).
- [ ] Backend `go build ./... && go test ./...` green; `make lint-backend` clean.

## Out of scope

- Reconciler behavior (t002); dashboard UI (t004).
