On APP_ENV=onprem the registry's mails (new findings, published documents)
no longer carry our company signature, address, register entry, contact
address or legal pages. They say the installation sent them, name the
customer's contact (MAIL_CONTACT) and link the customer's imprint and
privacy notice (LEGAL_IMPRINT_URL, LEGAL_PRIVACY_URL), each only when set.
mail.View gets a Site; the zero value is the cloud, so cloud mails stay as
they were (checked byte for byte against the previous templates) apart from
the spelling "Breakpilot", also in the default sender name. The legal line
moved from every text template into signature.tmpl.
On-prem the registry also refuses to start when MAIL_FROM, PORTAL_URL,
INVITE_REDIRECT_URI or LEGAL_* point at breakpilot.com.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 6058a94254)
On-prem every account comes from the customer's AD through Keycloak's
federation, so an AD admin answered email_taken and invitations asked for a
new password. The Keycloak adapter gets a directory mode (DirectoryUsers,
on with APP_ENV=onprem):
- The first admin and invited members are existing directory users,
attached to the organization with their role. No local user is created,
no execute-actions mail is sent (invite status "added", audit user.added /
keycloak.admin_added).
- An unknown address (or one outside the admitted AD groups) answers 404
not_in_directory. For the workspace's admin it is checked before the
workspace is created, and the adapter looks the user up before creating
the organization, so nothing is left behind.
- Resend answers 409 no_invite_mail; directory members are never pending.
- Member lists read the roles from the user when Keycloak lists a federated
member with its LDAP attributes only (seen with Keycloak 26.8).
- The admin address is normalized once for lookup, store and Keycloak.
Checked against Keycloak 26.8.1 with a Samba AD (the test install in
platform/onprem, realm with UNSYNCED federation and realm-policy.sh).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b8206c553f)
- Start fails when PRODUCTS or a URL override names no catalog product.
- The on-prem catalog sets supports_trial=false (the portal hides the button).
- Test that seeded cloud provision URLs are never called on-prem, with a
cloud control; the outbox test gets its cloud control too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 3e42b1ceb8)
The registry on a customer's node must never reach a Breakpilot host and
must not run the cloud's commercial machinery.
- APP_ENV=onprem: no ERP (nothing queued, webhook off), no trial (new
workspaces start active, the ladder never escalates by time), and the
trial-offer, trial-terms, catalog/trial request and admin trial routes
answer 404 not_available.
- PRODUCTS, PRODUCT_LAUNCH_URLS, PRODUCT_PROVISION_URLS: one store
decorator applies the product list and URLs to every catalog read
(catalog, activation, provisioning, entitlement checks). On-prem has no
seeded URLs, so provisioning goes only to the local products. Checked at
start ({id} in provision URLs, absolute http(s)).
- On-prem start fails when the values leave something to a cloud or dev
default (auth off, no authz rules, ephemeral licence key, portal, invite,
sender, LLM gateway) or set an ERP or contract documents.
- SMTP_TLS=starttls|tls|none: a plain relay inside the customer's network;
no AUTH without encryption.
- Migration 0032: the Werkpilot text no longer names our LLM host.
Cloud behaviour is unchanged without the new variables (tested).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2f6fa5f3e8)
Daily Europe/Berlin job: Managed Git = members signed in to the tenant's
active instances; Werkpilot/Firmwerk = people with their own licence in
use in the month. Staff PUT for the Gitea admin token, staff and tenant
reads of the month's counts, POST /v1/internal/module-users/count on
demand (route group module-users). No invoicing yet (t72).
Refs: t81
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AGB § 10 allows restricting access only "trotz Mahnung und angemessener
Nachfrist". The ladder counted from the due date (restricted after 14,
halted after 30 days overdue) and escalated any warning after 14 days.
Now an overdue invoice alone means warning. The reconcile pass reads the
customer's submitted, unresolved ERPNext Dunnings; the earliest one that
names a still-open invoice sets the clock: restricted 14 days after its
posting date, halted a further 14 days after the restriction. A Mahnung
never halts directly, so a late-seen one errs in the customer's favour.
A failed Dunning read keeps the tenant on warning and is reported.
ERP_HALT_AFTER_DAYS defaults to 28 (was 30), so an expired trial is
read-only for 14 days instead of 16 before it is halted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Demonstration plan, phase D6 (registry side). A prospect trialling Werkpilot had no model access until someone created a LiteLLM key by hand. The registry issues one with the licence, scoped and budgeted per tenant.
**On issue** (`product=werkpilot`): `POST /key/generate` on LiteLLM with `key_alias = werkpilot-<slug>-<licence id>`, `metadata` carrying tenant id/slug/licence/product, the model list and the plan's budget (trial and default, USD per 30 days). LiteLLM's hashed token id goes on the `licences` row (migration `0007`, exposed as `llm_key_id` on `GET /v1/licences`); the `sk-…` secret is returned in that one response as `llm_api_key`, together with `llm_base_url`, and is never stored or returned again.
**On renewal** (licence heartbeat): the existing key moves to the new licence row rather than a second key being generated — the secret cannot be re-read, and the CLI still holds the one it stored.
**On revoke:** the key is deleted; a 404 from LiteLLM is treated as already gone. If the delete fails, the licence is still revoked and the key id stays on the row so it can be retried by hand.
**Failure is never fatal:** with `LITELLM_MASTER_KEY` unset, LiteLLM unreachable or refusing, the licence is issued anyway and the grant carries `warnings: ["llm_key_unavailable"]` with no LLM fields. Also, a key that cannot be persisted is deleted again rather than handed out un-revocable.
Config: `LITELLM_BASE_URL` (default `https://llm.breakpilot.com`), `LITELLM_MASTER_KEY`, `LITELLM_MODELS` (default `Qwen3-Coder-30B-A3B-Instruct,gpt-oss-120b`), `LITELLM_BUDGET_TRIAL` (5), `LITELLM_BUDGET_DEFAULT` (50). Startup logs whether provisioning is on.
Note the migration is numbered `0007`: `0006` is taken by the members PR (#28), which is independent of this one — merge order does not matter.
Verified locally: `go vet ./...`, `gofmt` clean, `go test ./...` green, CI coverage command at **74.4%** (gate 70%). `internal/llmkeys` is tested against an httptest fake; no live LiteLLM call was made.
Pairs with a `bp-licence` bump (the Rust `Grant` gains the optional fields) and with `LITELLM_MASTER_KEY` on `tenant-registry-stage`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com>
Reviewed-on: #29
internal/keycloak Adapter (HTTPAdapter + Mock). POST /v1/tenants now provisions a KC organization + IT_ADMIN invite when admin_email is set; KC failures emit keycloak.provision_failed but don't roll back. POST /v1/internal/keycloak/claims resolves the current claim bundle for any (tenant_id|tenant_slug|user_attrs.*) lookup. Mock used in tests + when KEYCLOAK_ADMIN_URL is empty. HTTPAdapter tested against an in-process stub KC (httptest.Server).
Refs: M4.3
Full M4.2 deliverable: 16 endpoints (tenants CRUD + lifecycle, catalog, entitlements, API keys with argon2 hashing, audit append + filter), Store interface with pgx-backed Postgres + in-memory parallel implementations exercised by the same eachStore harness, openapi.yaml at 3.1 with kin-openapi contract test. M4.3 adds auth.
Refs: M4.2
Minimal Go service: /healthz + /v1/tenants/by-slug/:slug + /v1/tenants/:id with an in-memory store seeded with the acme tenant. Stdlib-only; pgx + JWT validation land in M4.1 follow-up.