feat(entitlements): Staff preview grants for products not for sale yet #72

Merged
sharang merged 2 commits from feat/preview-grants into main 2026-10-14 08:42:40 +00:00
Owner

Lets BreakPilot staff open a product that is still disabled in the catalogue (Werkmeister) for one tenant, for a limited time. Example: a seeded staging tenant for portal#86. Stage and prod stay identical.

Changes

  • Migration 0018: adds tenant_products.preview and preview_expires_at (with a CHECK). These are separate from a booking's expires_at.
  • Entitlement check: a disabled product is allowed only under an active preview, and the answer then carries "preview": true.
    • Expiry is checked at evaluation time (reason preview_expired).
    • A plain row left over for a product that's off sale stays unknown_product.
  • Bookings win: a real booking (ERP, trial, catalogue upsert) clears the preview and its expiry, so a preview never cuts off a paid entitlement. A preview over an existing booking is refused with 409.
  • Usage: usage under a preview is accepted and tagged properties.preview=true, and it never goes to the ERP outbox, so it isn't invoiced.
  • Claims: a preview product is listed only while its preview is active.
  • Admin API (staff only, audited):
    • POST /v1/admin/tenants/{id}/preview-grants with {product, expires_at}, where expires_at is at most 180 days away.
    • DELETE …/preview-grants/{product}.
    • Both need a named staff member (X-Staff-Subject).

Tests

  • Full suite passes; coverage 77.6%; golangci-lint reports 0 issues.
  • New tests cover: grant, check, expiry, booking clearing a preview, the 409, usage tagging and outbox skip, claims filtering, admin auth.

The companion stage tooling is the orca-platform PR feat/stage-preview-grant (demo-console.sh preview-grant/preview-revoke).

🤖 Generated with Claude Code

Lets BreakPilot staff open a product that is still disabled in the catalogue (Werkmeister) for one tenant, for a limited time. Example: a seeded staging tenant for portal#86. Stage and prod stay identical. ## Changes - **Migration 0018:** adds `tenant_products.preview` and `preview_expires_at` (with a CHECK). These are separate from a booking's `expires_at`. - **Entitlement check:** a disabled product is allowed only under an active preview, and the answer then carries `"preview": true`. - Expiry is checked at evaluation time (reason `preview_expired`). - A plain row left over for a product that's off sale stays `unknown_product`. - **Bookings win:** a real booking (ERP, trial, catalogue upsert) clears the preview and its expiry, so a preview never cuts off a paid entitlement. A preview over an existing booking is refused with 409. - **Usage:** usage under a preview is accepted and tagged `properties.preview=true`, and it never goes to the ERP outbox, so it isn't invoiced. - **Claims:** a preview product is listed only while its preview is active. - **Admin API (staff only, audited):** - `POST /v1/admin/tenants/{id}/preview-grants` with `{product, expires_at}`, where `expires_at` is at most 180 days away. - `DELETE …/preview-grants/{product}`. - Both need a named staff member (`X-Staff-Subject`). ## Tests - Full suite passes; coverage 77.6%; golangci-lint reports 0 issues. - New tests cover: grant, check, expiry, booking clearing a preview, the 409, usage tagging and outbox skip, claims filtering, admin auth. The companion stage tooling is the orca-platform PR `feat/stage-preview-grant` (`demo-console.sh preview-grant/preview-revoke`). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-10-14 08:14:16 +00:00
feat(entitlements): Staff preview grants for products not for sale yet
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 25m20s
ci / image (pull_request) Skipped
c99aa6908d
Lets BreakPilot staff open a product that is still disabled in the
catalogue (Werkmeister) for one tenant for a limited time, e.g. a seeded
staging tenant for portal#86, without a stage/prod divergence:

- Migration 0018: tenant_products.preview and preview_expires_at, kept
  apart from a booking's expires_at.
- Entitlement check: a disabled product is allowed only under an active
  preview (answer carries "preview": true); expiry is enforced at check
  time (reason preview_expired). A leftover plain row of a product off
  sale stays unknown_product.
- A real booking (ERP, trial, catalogue upsert) clears the preview and
  its expiry, so it never cuts off a paid entitlement; a preview over a
  booking is refused (409).
- Usage under a preview is accepted, tagged properties.preview=true and
  kept out of the ERP outbox; claims list a preview product only while
  it is active.
- Staff only, audited: POST /v1/admin/tenants/{id}/preview-grants
  {product, expires_at ≤ 180 d}, DELETE …/preview-grants/{product}; a
  named staff member (X-Staff-Subject) is required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang added 1 commit 2026-10-14 08:16:18 +00:00
feat(entitlements): audit a preview overriding a disabled booking
ci / shared (pull_request) Successful in 14s
ci / test (pull_request) Successful in 25m25s
ci / image (pull_request) Skipped
a4136df554
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit fdebac1735 into main 2026-10-14 08:42:40 +00:00
Sign in to join this conversation.