feat(pruefwerk): entry plan for one-off orders, granted by staff #150

Merged
sharang merged 2 commits from feat/einstieg-plan into main 2026-11-28 11:43:57 +00:00
Owner

Option B for the entry offers (decided 28.11.): a small Prüfwerk plan for one-off orders, granted by staff, so a CRA-Check, SBOM-Erstellung or CVE-Scan buyer can see and export their results for 90 days without using or being billed for anything beyond the order.

What it does

  • POST /v1/admin/tenants/{id}/entry-offer {"included_targets": 1..10, "expires_at": RFC3339, "order_ref": "<invoice no.>"}: named staff member only, audited (entitlement.entry_granted, with the previous end on a resend), cloud only.
    • Grants Prüfwerk with source: "entry", skus: ["CRA-CSA-CLD-EIN"], the order's targets and the end date. Sent again at delivery to set the end to 90 days after it (LB Einstiegsangebote § 7 Abs. 2).
    • A trial workspace becomes active, so the customer sees no trial banner.
    • Refused (409) when the workspace booked Prüfwerk (subscription, ERP or activation grant) or is neither trial nor active. A Prüfwerk trial or preview grant is replaced.
    • order_ref only takes invoice or order numbers (letters, digits, . _ / -), never names.
  • Plan einstieg: no monthly quota and a Prüftag cap of 0, whatever the workspace saved; cap_applies false, as on Enterprise.
    • Checked in Prüfwerk 0.4.17 (compliance-core/src/models/metering.rs): support scans never count and change scans of included targets don't count, so our delivery runs work; customer-requested scans are refused.
  • Plan order unchanged: any subscription plan SKU wins over the entry SKU, and no plan SKU at all is still Standard, so trials and previews are unchanged (existing tests untouched).
  • ERP guard: recomputeEntitlements does not halt a workspace while an entry grant runs; after it ends the old rule applies.

Decision for Sharang

  • SKU string CRA-CSA-CLD-EIN follows the STD/BUS/ENT pattern. ERP item numbers aren't assigned yet; change it here if the ERP gets another code. It is not added to the catalogue, so an ERP sales order with it maps to no product.

Known limits (not in this PR)

  • Extra targets (Prüfwerk): targets beyond included_targets are marked "extra" (billed per month), not refused. A customer adding one would see billing text that doesn't apply to them; its change scans are refused (quota 0, cap 0). Flagged to the Prüfwerk session.
  • Daily CVE re-match: Prüfwerk keeps matching new CVEs daily during the 90 days, which is more than the LB promises (§ 9 c). That's harmless, but worth knowing next to Monitor.
  • Halting: the halt guard depends on not creating ERP sales orders for entry customers. Book Stripe sales as Sales Invoices only (checklist).
  • Purge: deleting the workspace after 90 days still doesn't delete Prüfwerk data (known gap).

Tests

go test ./... green locally (Postgres harness skipped without Docker; CI runs it). New: TestAdminEntryOffer (validation, staff, trial→active, resend audit, ERP guard while running and after the end, refusals over bookings and subscriptions, trial grant replaced), TestPruefwerkLimitsEntry, entry cases in TestPruefwerkPlanFor.

Portal form follows in a separate PR. Don't merge before your OK.

🤖 Generated with Claude Code

Option B for the entry offers (decided 28.11.): a small Prüfwerk plan for one-off orders, granted by staff, so a CRA-Check, SBOM-Erstellung or CVE-Scan buyer can see and export their results for 90 days without using or being billed for anything beyond the order. ## What it does - **`POST /v1/admin/tenants/{id}/entry-offer`** `{"included_targets": 1..10, "expires_at": RFC3339, "order_ref": "<invoice no.>"}`: named staff member only, audited (`entitlement.entry_granted`, with the previous end on a resend), cloud only. - Grants Prüfwerk with `source: "entry"`, `skus: ["CRA-CSA-CLD-EIN"]`, the order's targets and the end date. Sent again at delivery to set the end to 90 days after it (LB Einstiegsangebote § 7 Abs. 2). - A trial workspace becomes active, so the customer sees no trial banner. - Refused (409) when the workspace booked Prüfwerk (subscription, ERP or activation grant) or is neither trial nor active. A Prüfwerk trial or preview grant is replaced. - `order_ref` only takes invoice or order numbers (letters, digits, `. _ / -`), never names. - **Plan `einstieg`:** no monthly quota and a Prüftag cap of 0, whatever the workspace saved; `cap_applies` false, as on Enterprise. - Checked in Prüfwerk 0.4.17 (`compliance-core/src/models/metering.rs`): support scans never count and change scans of included targets don't count, so our delivery runs work; customer-requested scans are refused. - **Plan order unchanged:** any subscription plan SKU wins over the entry SKU, and no plan SKU at all is still Standard, so trials and previews are unchanged (existing tests untouched). - **ERP guard:** `recomputeEntitlements` does not halt a workspace while an entry grant runs; after it ends the old rule applies. ## Decision for Sharang - **SKU string `CRA-CSA-CLD-EIN`** follows the STD/BUS/ENT pattern. ERP item numbers aren't assigned yet; change it here if the ERP gets another code. It is not added to the catalogue, so an ERP sales order with it maps to no product. ## Known limits (not in this PR) - **Extra targets (Prüfwerk):** targets beyond `included_targets` are marked "extra" (billed per month), not refused. A customer adding one would see billing text that doesn't apply to them; its change scans are refused (quota 0, cap 0). Flagged to the Prüfwerk session. - **Daily CVE re-match:** Prüfwerk keeps matching new CVEs daily during the 90 days, which is more than the LB promises (§ 9 c). That's harmless, but worth knowing next to Monitor. - **Halting:** the halt guard depends on not creating ERP sales orders for entry customers. Book Stripe sales as Sales Invoices only (checklist). - **Purge:** deleting the workspace after 90 days still doesn't delete Prüfwerk data (known gap). ## Tests `go test ./...` green locally (Postgres harness skipped without Docker; CI runs it). New: `TestAdminEntryOffer` (validation, staff, trial→active, resend audit, ERP guard while running and after the end, refusals over bookings and subscriptions, trial grant replaced), `TestPruefwerkLimitsEntry`, entry cases in `TestPruefwerkPlanFor`. Portal form follows in a separate PR. Don't merge before your OK. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-28 11:09:42 +00:00
feat(pruefwerk): entry plan for one-off orders, granted by staff
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 8m36s
ci / image (pull_request) Skipped
03f59c3114
Entry offers (CRA-Check, SBOM-Erstellung, CVE-Scan) are paid at booking
outside the ERP. Staff grant them with POST /v1/admin/tenants/{id}/entry-offer
(named staff member, audited, cloud only): Prüfwerk with source "entry",
SKU CRA-CSA-CLD-EIN, the order's included targets (1..10) and an end date
that is sent again at delivery (90 days after it).

- Plan "einstieg": no monthly quota and a Prüftag cap of 0 whatever the
  workspace saved, so only support scans (never counted) and change scans
  of the included targets run. Any subscription plan SKU wins over it; no
  plan SKU at all stays Standard, so trials and previews are unchanged.
- cap_applies is false on the entry plan, as on Enterprise.
- A trial workspace becomes active (no trial banner).
- recomputeEntitlements does not halt a workspace while an entry grant
  runs; once it has ended the old rule applies.
- Refused for a workspace that booked Prüfwerk (subscription, ERP or
  activation grant) or is neither trial nor active.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang added 1 commit 2026-11-28 11:17:57 +00:00
test(entry-offer): trial end does not restrict, subscription takes over
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 9m44s
ci / image (pull_request) Skipped
c424e7b1d0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit 17bffab165 into main 2026-11-28 11:43:57 +00:00
Sign in to join this conversation.