Files
OpenMAIC/render-service/test
f760f58a70 feat(render-service): machine-readable admission state (429 reasons + health accepting) (#1351)
* feat(render-service): expose machine-readable admission state

429 rejections carried only prose, so clients couldn't distinguish
deployment-wide backpressure from a personal limit, and /health gave
load balancers no way to shed traffic before probing with a render.

- RenderRejectedError now carries a reason code: queue_full (global
  RENDER_MAX_QUEUE cap) or per_identity_limit (RENDER_MAX_JOBS_PER_USER
  guard). The internal reservation invariant stays reason-less.
- POST /render serializes the reason on 429 bodies via spread-omission,
  so reason-less rejections don't emit a reason field at all.
- /health gains `accepting: boolean` (queue below the global cap).
  Deliberately aggregate-only: no occupancy counts and never
  per-identity data — identity keys are client IPs when
  TRUST_PROXY_HEADERS=true, so the map must not leave the process.
- README documents the 429 reason codes, the accepting flag and why it
  is boolean-only, and the shared-`direct`-identity model that makes the
  default Compose disable the per-user guard.

Refs #1348

Co-Authored-By: Claude Code <noreply@anthropic.com>

* refactor(render-service): extract 429 body serialization and shared test helpers

Review findings on the admission-observability change: the 429 body was
built identically in both catch sites, and the parked-executor /
bounded-poll-loop shapes were duplicated across the route and
coordinator admission tests. The spec review also flagged that
/health's negative space was only verified by inspection.

- rejectionBody(error) serializes an admission rejection once; both
  RenderRejectedError catch sites collapse back to one-line mappings.
- The /health inline comment now cites RenderCoordinator#accepting
  instead of restating its aggregate-only rationale.
- parkingExecutor() moves to test/support/fakes.ts beside
  succeedingExecutor; waitUntil() lands in test/support/async.ts and
  backs both waitForPoll (route) and the coordinator settle check, with
  descriptive timeout messages.
- A new route test pins /health to its exact key set (accepting, ok,
  resourceProfile, versions) and a boolean accepting, so any new field
  must be a deliberate, reviewed change.

Refs #1348

Co-Authored-By: Claude Code <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
2026-09-02 08:38:59 -04:00
..