Commit Graph
26 Commits
Author SHA1 Message Date
sharang 0b0343b680 feat(branding): derive colour and logo from the signup domain (#155, part 2) (#159)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 8m18s
ci / image (push) Successful in 51s
2026-12-01 13:33:08 +00:00
sharang 69c15be333 feat(onprem): APP_ENV=onprem with directory users and installation mail (#146)
ci / shared (push) Successful in 12s
ci / image (push) Successful in 36s
ci / test (push) Successful in 9m8s
2026-11-20 16:31:11 +00:00
Sharang ParnerkarandClaude Opus 5.5 692a9dd378 feat(metering): count module users per tenant and month
ci / test (pull_request) Failing after 26s
ci / image (pull_request) Skipped
ci / shared (pull_request) Failing after 3s
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>
2026-11-17 09:28:20 +01:00
sharang 5525759392 feat(contracts): serve contract documents in Vertragsunterlagen (#118)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 25m50s
ci / image (push) Successful in 35s
2026-11-09 12:59:20 +00:00
sharangandSharang Parnerkar 1332ad7bc5 feat(erpsetup): catalogue for Leistungsbeschreibung 1.0.0, opt-in -sync-catalog (#115)
ci / shared (push) Successful in 15s
ci / test (push) Successful in 26m35s
ci / image (push) Successful in 53s
Brings the ERPNext sales catalogue in line with the frozen Leistungsbeschreibungen 1.0.0. This PR changes code and tests only. No ERP was called; the live run is yours, using the erpsetup CLI.

## Dry run first (with the flag; only this path prints `field old → new`)

```sh
ERP_BASE_URL=https://erp.breakpilot.com ERP_API_KEY=… ERP_API_SECRET=… ERP_WEBHOOK_SECRET=… \
  go run ./cmd/erpsetup -webhook-url https://registry.breakpilot.com/v1/internal/erp/webhook -sync-catalog -dry-run
```

(`ERP_LEAD_DOCTYPE` is optional, as before.) Leave out `-dry-run` for the real run.

## What a run does with and without `-sync-catalog`

| | without the flag (as today) | with `-sync-catalog` |
|---|---|---|
| New items, unit "Prüftag", their list prices | created | created |
| Item **description** | **updated (this already happens on every run today)** | updated |
| Item `item_name`, `disabled` | untouched | updated when they differ |
| Standard Selling `price_list_rate` (rows without a customer) | set once, never changed | updated when it differs |
| Customer-specific Item Prices | untouched | untouched |
| Quote print format (Mehrverbrauch row) | updated | updated |

**A plain run is not inert.** It creates the 5 new items, the new unit and 5 new prices, rewrites every changed description, and updates the quote template. Only names, the disabled flags and price changes wait for the flag. Nothing is ever deleted. Only the doctypes Item, Item Price and UOM are touched beyond what erpsetup already manages.

## Catalogue changes

| Code | Status | Price old → new (EUR) |
|---|---|---|
| PLT-CORE-CLD-STD/BUS/ENT | keep (name "Breakpilot …", new text) | 290 / 790 / 1990 (unchanged) |
| PLT-BNDL-CLD-STD | **new** Starter-Modulpaket | 990 |
| PLT-BNDL-CLD-ADD | **new** Weiteres Modul | 499 |
| CRA-CSA-CLD-STD | keep | **1490 → 490** |
| CRA-CSA-CLD-BUS | keep | **3990 → 1290** |
| CRA-CSA-CLD-ENT | keep | **9900 → 0** (Preis nach Vereinbarung: a quote shows 0,00 € unless the rate is entered by hand) |
| CRA-CSA-CLD-TGT | **new** extra Prüfobjekt / Monat | 5.99 |
| CRA-CSA-CLD-DAY | **new** Prüftag (unit Prüftag) | 9.99 |
| CRA-CSA-CLD-SCAN | **disable** | 12 (unchanged) |
| CRA-WBK-CLD-STD/BUS/ENT | **disable** | unchanged |
| DEV-WP-CLD-STD | keep ("Werkpilot Cloud") | 59 |
| DEV-WP-CLD-BUS/ENT | **disable** | unchanged |
| DEV-WP-OPR-*, DEV-FWK-OPR-*, INF-GIT-OPR-*, INF-CI-OPR-* | keep, new texts | unchanged |
| DEV-FWK-CLD-STD | keep ("Firmwerk Cloud") | 89 |
| DEV-FWK-CLD-BUS/ENT | **disable** | unchanged |
| INF-GIT-CLD-STD/BUS/ENT | keep, new texts | 190 / 390 / 790 |
| INF-GIT-CLD-USR | **new** extra user | 19 |
| INF-CI-CLD-STD/BUS/ENT | keep, new texts | 149 / 290 / 590 |

The item group stays "BreakPilot Abonnements".

Correction to the spec, applied here: PLT-CORE-CLD-STD no longer mentions "Rechnungen", because LB Plattform §2(3) says the portal provides no invoices. The text is now "Arbeitsbereich mit Anmeldung und Team für bis 25 Nutzer, Standard-Support. Module werden einzeln gebucht." No other item text mentions invoices, and a test now checks that none does.

## Other changes

- `sku.Disabled` is sent to ERPNext as the Item field `disabled: 1`. Disabled items stay in ERPNext so old documents keep working. Since the disabled items already exist on prod, their flag only changes with `-sync-catalog`.
- **Quote, Mehrverbrauch row:** "Zusätzliche Prüfobjekte werden mit {TGT} netto je Monat berechnet, Prüftage nach verbrauchtem Monatskontingent mit {DAY} netto (Leistungsbeschreibung Prüfwerk, Abschnitt 7)." If a rate is missing, the text says "gemäß der jeweils gültigen Preisliste" instead, per rate. If both are missing, one combined sentence is printed. Quotes with INF-GIT-CLD-STD/BUS/ENT or PLT-BNDL-* add the sentence on extra users (Leistungsbeschreibung Breakpilot Plattform, Abschnitt 4). The Jinja was parsed and rendered locally with jinja2 against mocks for eight item mixes.
- **Migration 0026** adds CRA-CSA-CLD-TGT and -DAY to the `pruefwerk` product. SCAN stays so old orders still map. The up is guarded so it can run twice; the down removes the two SKUs. `DefaultProducts` and the ERP mock's SKU list follow. **Run `migrate-up` with the deploy.** Without it, TGT/DAY lines on an order log "sales order item without catalog product".
- **0 € module lines:** nothing needed fixing. Neither the webhook path nor reconcile reads the rate: the webhook template sends only `item_code` and `qty`, and `SubscriptionPlan` has no rate. A new test covers both paths: a bundle order with modules at rate 0 and qty 15 gives an active tenant, plan standard, and seats 15 per module.

## Decisions the spec did not cover

1. **No Prüfwerk Mehrverbrauch sentence on Enterprise quotes.** CRA-CSA-CLD-ENT is "ohne Begrenzung". Edge case: a quote with both -STD and -ENT also prints no Prüfwerk sentence. The extra-users sentence is not affected.
2. The run without the flag still writes descriptions, as `Run` has done until now (see the table).
3. `-sync-catalog` only changes Item Price rows without a `customer`. If there are several such rows for an item, the run reports "not synced". If there are none, it creates the list price.
4. The quote template's Item Price lookup still has no customer filter (unchanged from before).
5. INF-GIT-OPR texts: STD uses the spec text exactly, so "kein Quellcode verlässt das Haus" is gone. BUS keeps "für mittelgroße Teams" and loses "schnellerer Patch-Rhythmus", like CI. ENT says "für große Entwicklungsorganisationen".
6. INF-CI-OPR texts differ only by size ("mindestens 2 vCPU / 4 GB" etc.); "für größere/umfangreiche Builds" was dropped.
7. DEV-WP-OPR and DEV-FWK-OPR texts: the tier phrase sits after "im eigenen Netz", e.g. "Werkpilot im eigenen Netz für mittlere Teams, mit einem vom Kunden betriebenen KI-Modell; …".
8. TGT/DAY quantities on an order or subscription count toward Prüfwerk `seats`, exactly as SCAN already does. Not changed here.
9. Bundle revenue goes to cost center Plattform (PLT-*). Module lines at 0 € book nothing on Prüfwerk, Firmwerk or Werkpilot. Whether to allocate it is an accounting decision for you.
10. The dry run prints texts in full (no truncation), so the wording can be read before it goes live.
11. `TestEverySKUHasAListPrice` now allows exactly one item at 0: CRA-CSA-CLD-ENT.
12. The ERP mock's `DefaultSKUs` now also lists PLT-BNDL-* and CRA-CSA-CLD-TGT/DAY.

## Tests

`go build ./... && go vet ./... && go test ./...` all pass. The Postgres testcontainers suites ran (podman socket) with no skips: server 463 s, migrations 32 s. New tests:

- catalogue consistency: unique codes, units, disabled set, prices including 5.99/9.99, brand spelling
- `TestSyncCatalog`: the dry run writes nothing and names every change; the run updates name, description, disabled and price and keeps the customer price; a second run makes no updates; without the flag only the description changes
- quote template phrases
- `TestMigrate_productsSeedMatchesDefaults`: seed equals `DefaultProducts`, 0026 applied twice, down
- `TestErp_zeroRateModuleLinesEntitle`: webhook and reconcile, memory and Postgres

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com>
Reviewed-on: #115
2026-11-06 16:20:22 +00:00
sharang 286f50c5fb feat(invoiceintake): send every invoice mail on to DATEV from invoice@ (#110)
ci / shared (push) Successful in 12s
ci / image (push) Successful in 39s
ci / test (push) Successful in 26m6s
2026-11-02 11:59:00 +00:00
Sharang ParnerkarandClaude Opus 5.5 e5ed990bf7 fix(outbox): dead-letter after a week; ERP mock names unique per boot
ci / shared (pull_request) Successful in 11s
ci / test (pull_request) Successful in 25m15s
ci / image (pull_request) Skipped
Stage logged ~11,100 failed usage.record items a day ('tenant has no ERP
customer yet') behind 36 customer.upsert failures on the unique
tenants_erp_customer_id_key (backlog t25). The ERP mock keeps its docs
in memory and restarts with every registry deploy on stage: its counter
began at CUST-00001 again and handed new tenants names older tenants are
still linked to, so they never got linked and their usage waited
forever.

- erpmock: Config.NameToken goes into every assigned name; cmd/erpmock
  sets one per boot (CUST-<yymmddHHMMSS>-00001). Tests keep plain names.
- outbox: after maxOutboxAttempts (170, about a week at the 1 h cap) an
  item is dead-lettered instead of retried forever: done_at set,
  last_error 'dead letter: <err>', payload kept for a re-queue, and an
  ERROR line (the prod error alert sees it). Store gains
  DeadLetterOutbox (memory + postgres).

Tests: dead letter after the last attempt and nothing claimed after,
memory and postgres; mock names carry the token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
2026-10-29 18:21:01 +01:00
Sharang ParnerkarandClaude Opus 5.5 65ad1b52f6 feat(telemetry): traces to SigNoz for requests, outbound calls and SQL
ci / shared (pull_request) Failing after 12s
ci / test (pull_request) Failing after 15m24s
ci / image (pull_request) Skipped
internal/telemetry: OTLP/HTTP tracer provider from the OTEL_* env
(already set on stage and prod; unset = off), W3C propagation, one server
span per request named after the ServeMux pattern, client spans on the
default transport (Keycloak, ERP, LiteLLM, OIDC) and a pgx QueryTracer.
Client and DB spans only inside a request, so the background loops add
no traces. No raw paths, query strings, bodies, SQL parameters or client
addresses in spans; outbound spans carry the host only.

slog lines logged with a request context get trace_id/span_id; the
access log names the route instead of the raw path (slugs are names).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
2026-10-28 22:24:34 +01:00
sharangandClaude Opus 5.5 cee669d2bd feat(invoiceintake): invoice@ mails become draft Eingangsrechnungen (#82)
ci / shared (push) Successful in 14s
ci / test (push) Successful in 25m31s
ci / image (push) Successful in 46s
Reads the mails of ERPNext's Email Account Eingangsrechnung via the API: e-invoices become E Invoice Import drafts, other PDFs draft Purchase Invoices (supplier by sender, placeholder line, original attached), the rest ToDos. Never submits; state lives in ERPNext (unique Link intake_communication, ToDo reference). erpsetup adds the marker fields, the placeholder item EINGANGSRECHNUNG and its SKR04 6300 account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 08:15:32 +00:00
sharang 5b4590d3bc feat(api-keys): CI licences by API key and integration keys (#71)
ci / shared (push) Successful in 13s
ci / image (push) Successful in 36s
ci / test (push) Successful in 25m10s
2026-10-13 22:12:05 +00:00
sharang 89487bbf50 fix(server): keep idle connections longer than orca-proxy's pool (502s on prod) (#65)
ci / shared (push) Successful in 17s
ci / test (push) Successful in 24m22s
ci / image (push) Failing after 14s
2026-10-12 07:21:11 +00:00
sharangandClaude Opus 5.5 40a198c56f feat(erpsetup): BreakPilot document layout and list prices (#51)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 23m50s
ci / image (push) Successful in 36s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-30 10:44:03 +00:00
sharangandClaude Opus 5.5 8a03be188d feat(erpsetup): sales catalogue — SKU items, units, SEPA mandate fields (#48)
ci / image (push) Successful in 34s
ci / shared (push) Successful in 14s
ci / test (push) Successful in 23m42s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-29 16:25:00 +00:00
sharangandClaude Opus 5.5 e0bff8c793 feat(notify): branded mails for published documents and new findings (#35)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 23m16s
ci / image (push) Successful in 36s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-23 21:10:06 +00:00
sharangandClaude Opus 5.5 8d3cda4bb0 feat(documents): tenant documents with staff upload and signed downloads (#34)
ci / test (push) Successful in 23m15s
ci / shared (push) Successful in 12s
ci / image (push) Successful in 31s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-23 20:31:55 +00:00
sharang ceeff16f26 feat(erp): erpsetup for live ERPNext, reserved tenant slugs (#32)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 22m58s
ci / image (push) Successful in 37s
2026-09-23 17:16:24 +00:00
sharangandSharang Parnerkar e0ae19f2a7 feat(licences): per-tenant LiteLLM key with a Werkpilot grant (#29)
ci / shared (push) Successful in 11s
ci / test (push) Successful in 22m23s
ci / image (push) Successful in 24s
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
2026-09-14 08:27:25 +00:00
sharang 209524e5ac feat(erp): always-on ERP link, usage events, outbox, CLI licences (#25)
ci / shared (push) Successful in 14s
ci / image (push) Successful in 28s
ci / test (push) Successful in 22m28s
2026-09-12 08:35:13 +00:00
sharang 2ea49be29d feat(m-mig-5): products table, entitlement check, tenant ladder, per-client authz (#23)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 21m58s
ci / image (push) Successful in 56s
2026-09-12 07:38:47 +00:00
sharang 6b82c14573 chore: module path gitea.meghsakha.com → git.breakpilot.com (#22)
ci / shared (push) Successful in 13s
ci / test (push) Failing after 16m16s
ci / image (push) Skipped
2026-09-11 14:06:43 +00:00
sharang a048d47959 feat(tenants): provision the product tenant with the registry UUID on create (#21)
ci / shared (push) Successful in 12s
ci / test (push) Failing after 16m8s
ci / image (push) Skipped
2026-09-01 21:20:03 +00:00
sharangandSharang Parnerkar ce75ed04c2 RBAC Phase 1: membership authority endpoint + fail-closed API auth (#14)
ci / shared (push) Failing after 14s
ci / test (push) Successful in 21m13s
ci / image (push) Skipped
Implements the model-B2 membership authority (ratified compliance auth design) and inbound token verification.

- GET /v1/users/{id}/memberships: Keycloak supplies user->tenant links + org_roles (attribute projection until the realm migrates to Organizations); registered tenants override status/plan/products from registry tables (source: registry|keycloak). Closes the M5.2-deferred org_roles stub.
- New internal/authn: OIDC discovery + JWKS verification (go-oidc/v3), audience tenant-registry. /healthz + /readyz stay PUBLIC_EXPLICIT; all other routes INTERNAL_SERVICE_ONLY. AUTH_ENABLED=true refuses to start on incomplete config (fail-closed); false (dev default) keeps current behavior.
- Full suite green incl. postgres testcontainers; openapi.yaml updated (contract test passes).

Activation is a separate step (Auth-5): requires the orca-infra env merge and a portal service token (portal currently calls with no auth).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com>
Reviewed-on: #14
2026-08-24 18:21:46 +00:00
sharang 9138731eea feat(keycloak): M4.3 — Admin API adapter + claim resolver
ci / shared (push) Successful in 5s
ci / test (push) Successful in 1m32s
ci / image (push) Has been skipped
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
2026-05-19 11:51:09 +00:00
sharang ffab866c87 feat(api): M4.2 — REST surface + pgx Postgres store + OpenAPI 3.1
ci / shared (push) Successful in 6s
ci / test (push) Successful in 1m15s
ci / image (push) Has been skipped
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
2026-05-19 10:51:59 +00:00
sharang d66760b246 feat(schema): M4.1 — tenant_registry schema + migrate binary
ci / shared (push) Successful in 5s
ci / test (push) Successful in 20s
ci / image (push) Has been skipped
PLATFORM_ARCHITECTURE.md §5c schema as one initial migration: 6 tables + 4 enums + updated_at triggers. cmd/migrate binary (golang-migrate library, embedded SQL). testcontainers round-trip + seed + slug-constraint tests.

Refs: M4.1
2026-05-19 10:10:14 +00:00
sharang af9f331781 feat(server): tenant-registry skeleton boots against dev stack
ci / shared (push) Successful in 4s
ci / test (push) Successful in 11s
ci / image (push) Has been skipped
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.
2026-05-19 09:35:04 +00:00