feat(m-mig-5): products table, entitlement check, tenant ladder, per-client authz #23

Merged
sharang merged 4 commits from feat/m-mig-5-products-entitlements into main 2026-09-12 07:38:47 +00:00
Owner

What

  • Migrations 0002 (ladder statuses warning|restricted|halted) and 0003 (products table seeded with pruefwerk + werkbank add-on, werkpilot, firmwerk; compliance disabled until M-MIG-9).
  • GET /v1/tenants (keyset pagination), POST /v1/internal/entitlements/check, POST /v1/tenants/{id}/status; cancel → halted; activate accepts products[] with limits and provisions via catalog provision_urls.
  • Keycloak SyncTenantStatus (coarse claim only, attributes merged); AUTHZ_RULES per-client route groups; invite client/redirect from env.
  • Catalog served from the store with type/launch_url/skus/addons/trial_days. OpenAPI + README updated.

Why

M-MIG-5: the registry is the entitlement authority; products stop reading products from the token. Catalog keys for the first-line products did not exist.

Test plan

  • go test ./... locally incl. the testcontainers Postgres harness (ladder, add-on, pagination, catalog, authz, migration round-trip)
  • coverage total 70.5 %
  • CI

Risk

Behaviour change: cancel now yields halted (was frozen); consumers that compared against frozen must switch to the ladder. Existing frozen rows are treated as restricted.

Linked milestone

M-MIG-5

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

## What - Migrations 0002 (ladder statuses `warning|restricted|halted`) and 0003 (`products` table seeded with pruefwerk + werkbank add-on, werkpilot, firmwerk; `compliance` disabled until M-MIG-9). - `GET /v1/tenants` (keyset pagination), `POST /v1/internal/entitlements/check`, `POST /v1/tenants/{id}/status`; `cancel` → `halted`; `activate` accepts `products[]` with limits and provisions via catalog `provision_urls`. - Keycloak `SyncTenantStatus` (coarse claim only, attributes merged); `AUTHZ_RULES` per-client route groups; invite client/redirect from env. - Catalog served from the store with type/launch_url/skus/addons/trial_days. OpenAPI + README updated. ## Why M-MIG-5: the registry is the entitlement authority; products stop reading `products` from the token. Catalog keys for the first-line products did not exist. ## Test plan - [x] `go test ./...` locally incl. the testcontainers Postgres harness (ladder, add-on, pagination, catalog, authz, migration round-trip) - [x] coverage total 70.5 % - [ ] CI ## Risk Behaviour change: `cancel` now yields `halted` (was `frozen`); consumers that compared against `frozen` must switch to the ladder. Existing `frozen` rows are treated as `restricted`. ## Linked milestone M-MIG-5 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-11 14:29:47 +00:00
feat(m-mig-5): products table, entitlement check, tenant ladder, per-client authz
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Failing after 14m36s
ci / image (pull_request) Skipped
62335a9be3
Registry becomes the entitlement authority (ERP/02, PRODUCT_INTEGRATION_SPEC 2.0):

- migrations 0002/0003: ladder statuses warning|restricted|halted on
  tenant_status; products table replaces the hard-coded catalog, seeded with
  pruefwerk (+ werkbank add-on), werkpilot, firmwerk; compliance disabled
  until the dsms migration (M-MIG-9)
- GET /v1/tenants (keyset pagination, status/kind filters) for product
  schedulers and reconcile jobs
- POST /v1/internal/entitlements/check → {allowed, read_only, status, limits,
  expires_at, reason}; add-on limits from tenant_products.config
- POST /v1/tenants/{id}/status — the single ladder transition endpoint;
  cancel now moves to halted; activate accepts products[] with limits and
  provisions them via the catalog's per-env provision_urls
- SyncTenantStatus: coarse tenant_status attribute on every Keycloak org
  member after every status change (attributes merged, roles untouched)
- AUTHZ_RULES: per-client (JWT azp) route groups; 403 FORBIDDEN_CLIENT
- INVITE_CLIENT_ID / INVITE_REDIRECT_URI replace the hard-coded dev-portal
  invite parameters
- catalog entries carry type, launch_url (per APP_ENV), skus, addons,
  trial_days; openapi.yaml + README updated

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
CODEOWNERS rules requested review from Benjamin_Boenisch 2026-09-11 14:29:47 +00:00
sharang added 1 commit 2026-09-11 15:30:36 +00:00
chore(lint): simplify the memory keyset cursor check (staticcheck QF1001)
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Failing after 16m19s
ci / image (pull_request) Skipped
5a74d84681
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-11 16:05:51 +00:00
test: cover tenant listing, status ladder, authz gate, KC status sync
ci / shared (pull_request) Successful in 14s
ci / test (pull_request) Successful in 22m5s
ci / image (pull_request) Skipped
9b50b98678
Coverage gate (70%) fell to 67.6% with the new M-MIG-5 code paths.
Adds tests for GET /v1/tenants pagination + filters + validation,
GET /v1/tenants/{id}, POST /v1/tenants/{id}/status validation and the
Keycloak-failure audit path, /readyz, the requireAuthz middleware and
LogAuthz, and HTTPAdapter.SyncTenantStatus / findUserByEmail against a
stub Keycloak admin API. CI package set now reports 73.5%.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-11 21:44:26 +00:00
ci: image to Harbor platform project, orca webhook via repo variable
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 22m1s
ci / image (pull_request) Skipped
f530bc9cbe
M-MIG-3/5: the platform cluster (bp-platform-stage) deploys
tenant-registry-stage from repo.breakpilot.com/platform/tenant-registry.
The image job now logs in with the org secrets REGISTRY_USERNAME /
REGISTRY_PASSWORD, pushes under platform/, and POSTs the orca webhook
only when the repo variable ORCA_WEBHOOK_URL is set (it no longer targets
the core master). release.yaml (env-stage/env-prod promotion against a
cluster layout that no longer exists) is removed; prod deploys get their
own trigger with the prod node.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang merged commit 2ea49be29d into main 2026-09-12 07:38:47 +00:00
sharang deleted branch feat/m-mig-5-products-entitlements 2026-09-12 07:38:48 +00:00
Sign in to join this conversation.