Commit Graph
38 Commits
Author SHA1 Message Date
Sharang ParnerkarandClaude Opus 5.5 bf302a4ab1 fix(trial): a product trial ends with the workspace's trial
ci / shared (pull_request) Successful in 16s
ci / test (pull_request) Successful in 25m37s
ci / image (pull_request) Skipped
A product trial started from the catalogue ran its own 14 days from that
moment. In a workspace whose trial staff had set to a later day, the product
stopped before the trial did: Prüfwerk refused the managed-Git automation of
a workspace on trial until 29.10 with entitlement_expired on 15.10.

- trial-request: in a workspace on trial, the product trial ends when the
  workspace trial ends; otherwise (a paying workspace) it keeps its own days.
- Migration 0019 aligns the existing product trials of workspaces still on
  trial that end before their trial (re-enabled), with an audit entry each
  (entitlement.trial_aligned). Booked products, preview grants and trials
  that end later are left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 17:47:16 +02:00
sharang c1de728d16 feat(projects): pass open vulnerabilities through to the portal (#76)
ci / shared (push) Successful in 16s
ci / test (push) Successful in 26m1s
ci / image (push) Successful in 36s
2026-10-14 18:20:57 +00:00
sharangandSharang Parnerkar 310c438aea fix(tenants): Setting the current status again is a no-op (#75)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 25m41s
ci / image (push) Successful in 37s
On stage, staff picked "Apply" (set status) with `trial` selected on a trial tenant, instead of "Extend". The registry wrote an update, a `tenant.status_changed` audit entry (`trial` → `trial`) and a Keycloak sync. The audit log showed an entry, but nothing had changed.

**Change:** `POST /v1/tenants/{id}/status` with the tenant's current status answers 200 with the unchanged tenant: no write, no audit entry, no Keycloak sync. The call stays idempotent for scripts. Other transitions are unchanged.

**Test:** `TestSetStatus_unchangedIsNoOp` (memory and Postgres) checks 200 and that no audit entry is added. It fails without the fix ("audit entries: 1, want 0"). `go vet` and `go test -short ./...` pass locally; the full Postgres suite runs in CI.

Companion: the portal staff page greys out "Apply" until a different status is chosen (separate portal PR).

🤖 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: #75
2026-10-14 11:09:29 +00:00
sharangandSharang Parnerkar 358c4abcb7 feat(audit): Products may pass their caller's address as source_ip (#73)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 25m31s
ci / image (push) Successful in 38s
`POST /v1/audit` recorded the address of the product that sent the event. So Prüfwerk's API-key writes showed the agent's container address (172.17.0.6 on stage) instead of the caller's.

- `appendAuditReq` gains `source_ip`. It is taken when `net.ParseIP` accepts it and stored in canonical form. The peer that sent the event is kept in `metadata.relayed_by`.
- Anything that doesn't parse is ignored, and the peer is recorded as before.
- Trust: `audit.write` is service-principal only, the same trust as the `actor_id` those callers already set.
- No migration, and existing callers are unchanged.
- Callers: Prüfwerk (pruefwerk #567, from the API host's proxy header); Werkmeister will reuse the field (agreed with werkmeister-18).

Test: `TestAppendAudit_sourceIP` covers a valid IP (recorded, `relayed_by` set) and junk (ignored), in each store.

Not in this PR: `clientIP()` takes the **leftmost** `X-Forwarded-For` entry. orca-proxy appends the peer it saw, so the rightmost entry is authoritative and the leftmost is chosen by the client. Separate issue for werkmeister-18.

Not run locally (RAM); CI runs the tests.

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

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com>
Reviewed-on: #73
2026-10-14 10:07:17 +00:00
sharang fdebac1735 feat(entitlements): Staff preview grants for products not for sale yet (#72)
ci / shared (push) Successful in 18s
ci / test (push) Successful in 25m44s
ci / image (push) Successful in 41s
2026-10-14 08:42:40 +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 97284b5008 feat(api-keys): Scope catalogue, kinds, expiry and sha256 keys (#70)
ci / shared (push) Successful in 14s
ci / test (push) Successful in 25m3s
ci / image (push) Successful in 39s
2026-10-13 21:21:16 +00:00
sharangandClaude Opus 5.5 557fbf85f5 feat(server): public GET /version with build version and commit (#63)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 24m47s
ci / image (push) Successful in 39s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-10-05 19:51:40 +00:00
sharangandClaude Opus 5.5 1f6236a754 feat(members): team management: role, block, remove, revoke, resend (#64)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 24m46s
ci / image (push) Successful in 33s
portal#74: PATCH/DELETE /v1/tenants/{id}/members/{uid}, POST .../resend and the staff variants; per-workspace block via org_blocked, session logout, last-admin and self guards, audit events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-10-05 18:43:31 +00:00
sharang 8753305ad4 feat(services): build runners INF-CI-* and managed service kind ci-runner (#62)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 24m26s
ci / image (push) Successful in 36s
2026-10-05 18:06:49 +00:00
sharangandClaude Opus 5.5 85934567f1 feat(services): managed services per tenant for the portal (#77) (#61)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 24m12s
ci / image (push) Successful in 35s
ci / shared (pull_request) Successful in 14s
ci / test (pull_request) Successful in 24m17s
ci / image (pull_request) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-10-04 19:33:20 +00:00
sharangandClaude Opus 5.5 60f20e6419 feat(trial): legal trial signup: offer, confirmation, activation (#58)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 23m58s
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 16:00:52 +00:00
sharangandClaude Opus 5.5 f0e1f52838 feat(legal): mails link the platform's privacy notice (#57)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 23m41s
ci / image (push) Successful in 33s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-30 15:07:30 +00:00
sharangandClaude Opus 5.5 fb9a2ee621 feat(erp): overdue invoices drive the ladder from the reconcile pass (#52)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 23m47s
ci / image (push) Successful in 33s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-30 11:06:30 +00:00
sharangandClaude Opus 5.5 f96525dd4d fix(projects): name the portal user in project audit events (#47)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 23m47s
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-29 14:50:38 +00:00
sharangandClaude Opus 5.5 f3450f84c7 feat(projects): Projekte for documents and product objects (#46)
ci / shared (push) Successful in 13s
ci / image (push) Successful in 35s
ci / test (push) Successful in 23m41s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-29 12:49:36 +00:00
sharangandClaude Opus 5.5 e8dcd1d259 feat(admin): repair a tenant's sign-in, delete an archived tenant (#42)
ci / shared (push) Successful in 15s
ci / test (push) Successful in 23m50s
ci / image (push) Successful in 45s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-26 11:00:14 +00:00
sharangandClaude Opus 5.5 7834907562 fix(signup): report when Keycloak refuses to send the invitation (#39)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 25m6s
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-24 11:50:23 +00:00
sharangandClaude Opus 5.5 0a26331ffd fix(signup): reject an email that already has an account (#37)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 23m29s
ci / image (push) Successful in 32s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-23 22:09: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 54e9f6a720 feat(admin): staff tenant list, detail, trial extension, invite resend (#33)
ci / shared (push) Successful in 11s
ci / test (push) Successful in 22m43s
ci / image (push) Successful in 44s
2026-09-23 19:57:59 +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
sharangandClaude Opus 5 13da983d1e feat(llmkeys): allow Qwen3.8-27B on tenant LiteLLM keys (#31)
ci / shared (push) Successful in 14s
ci / test (push) Successful in 22m20s
ci / image (push) Successful in 26s
Add Qwen3.8-27B to the default LITELLM_MODELS allowlist for per-tenant LiteLLM keys. Existing keys are updated separately via LiteLLM /key/update.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKb71CELE4iptE9em1ZEgv
2026-09-18 18:51:28 +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
sharangandSharang Parnerkar 99214c088b feat(members): tenant organization members, invites, admin email (#28)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 22m21s
ci / image (push) Successful in 25s
Demonstration plan, phase D1 (registry side). The portal's Settings/Users page renders design fixtures today and its "Invite member" button posts to a route that does not exist, because the registry had no membership surface.

**`GET /v1/tenants/{id}/members`** lists the tenant's Keycloak organization members — user id, email, first/last name, `org_roles`, `enabled`, `created_at`. A tenant whose organization was never created (sales-led) answers an empty list rather than an error.

**`POST /v1/tenants/{id}/invites`** `{email, first_name?, last_name?, role?}` creates the Keycloak user if missing, adds the organization member (KC 26: the member body is the bare user id), writes the tenant-context user attributes, sends the same execute-actions mail the first admin gets, and audits `user.invited` with the caller as actor. Idempotent: an existing member answers `200 {status:"member"}` and sends no mail; a new one `202 {status:"invited"}`.

**Scope.** A user token may only touch its own tenant — another tenant's id is a 404, never a hint that it exists. Inviting needs the `IT_ADMIN` or `OWNER` org role, so `Principal` now carries the `org_roles` claim and `IsTenantAdmin()`. Service clients stay gated by `AUTHZ_RULES` route groups: members on `tenants.read`, invites on `tenants.write`.

**`admin_email` on the tenant** (migration `0006`, backfilled from the `keycloak.invite_sent` audit trail, and from `keycloak.provision_failed` metadata where the first invite failed) so Settings can show a real contact instead of an em dash. The first `IT_ADMIN`/`OWNER` invite fills it in when it was empty.

**Routing note worth keeping:** `GET /v1/tenants/{id}/members` cannot be registered — Go's ServeMux calls it a conflict with `GET /v1/tenants/by-slug/{slug}`, since both match `/v1/tenants/by-slug/members` and neither pattern is more specific. It is registered as `GET /v1/tenants/{id}/{sub}` instead, which *is* less specific than the by-slug lookup, so the two coexist; anything but `members` answers 404.

`openapi.yaml` documents both endpoints, the `OrgMember`/`Invite` schemas, `admin_email` and a `Forbidden` response.

Verified locally: `go vet ./...`, `gofmt` clean, `go test ./...` green, CI coverage command at **74.3%** (gate 70%).

🤖 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: #28
2026-09-14 08:27:12 +00:00
sharang 8388e47742 feat(provision): service token on product lifecycle calls; stage/prod provision URLs (#26)
ci / shared (push) Successful in 15s
ci / test (push) Successful in 22m4s
ci / image (push) Successful in 24s
2026-09-12 09:27:40 +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 8fa1a1bffd feat(store): set trial_ends_at on tenant create
ci / shared (push) Successful in 6s
ci / test (push) Successful in 1m42s
ci / image (push) Has been skipped
trial_ends_at = NOW()+14d for customer kind; demo kind gets status=demo and no end. Unblocks M12.1 portal banner.

Refs: M4.1 + M12.1 prep
2026-05-19 16:27:09 +00:00
sharang a37ae1d121 fix(audit): strip IPv6 brackets before INET insert
ci / shared (push) Successful in 7s
ci / test (push) Successful in 1m46s
ci / image (push) Has been skipped
Caught during live local-smoke run.

Refs: M4.2/M5.3
2026-05-19 15:09:00 +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