Commit Graph
35 Commits
Author SHA1 Message Date
Sharang ParnerkarandClaude Opus 5.5 e99b79f3ff chore(merge): main into feat/documents after #33
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 23m3s
ci / image (pull_request) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-23 21:58:29 +02: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 ParnerkarandClaude Opus 5.5 da6eef6d30 feat(documents): tenant documents in object storage
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 23m11s
ci / image (pull_request) Skipped
Staff upload a file for a tenant as a draft (streamed to an S3 bucket,
hashed on the way, never buffered whole), publish it, or delete it;
the tenant lists its published documents and gets a five-minute
presigned download link. Uploads, publications and downloads are
audited, a download under the person the portal names.

Migration 0008 adds the documents table; internal/storage wraps
minio-go (Hetzner Object Storage, the bucket is created in its
region when missing). Without DOCUMENTS_S3_* the routes answer 503
and the rest of the registry is unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-23 19:35:05 +02:00
Sharang ParnerkarandClaude Opus 5.5 bab7475a6c feat(admin): staff tenant list, detail, trial extension, invite resend
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 22m40s
ci / image (pull_request) Skipped
A new route group "admin" (the portal's service client only) serves
the staff admin area: tenant search with 30-day usage and last
activity, one detail call with entitlements, subscriptions, licences,
members and recent audit, trial extension (moves trial entitlements
with it and reopens a trial that expired into read-only), invite
resend, and the audit log across tenants.

Changes made from the admin area are audited under the staff member
the portal names in X-Staff-Subject / X-Staff-Email; the header only
counts from a client that holds the admin group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-23 19:23:00 +02: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
sharang 33ba32ef30 fix(keycloak): resolve an organization by alias, not by display name (#30)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 22m28s
ci / image (push) Successful in 25s
2026-09-14 11:30:00 +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 8f5c9ba0b9 fix(keycloak): KC 26 org member body is the bare user id; set org tenant_id (#27)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 21m54s
ci / image (push) Successful in 22s
2026-09-12 09:39:27 +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
pre-mvp-2026-09-02
2026-09-01 21:20:03 +00:00
sharang 80565fdbf2 fix(keycloak): org create must send a domain (KC 26 rejects domainless) (#20)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 21m24s
ci / image (push) Successful in 17s
2026-09-01 09:18:15 +00:00
sharang 84516e9b4f feat(keycloak): organizations become the membership authority source (#19)
ci / shared (push) Successful in 11s
ci / test (push) Successful in 21m22s
ci / image (push) Successful in 19s
2026-09-01 09:03:23 +00:00
sharang 4eaee521d4 fix(build): builder image Go 1.25, go.mod requires >= 1.25.0 (#18)
ci / shared (push) Successful in 14s
ci / test (push) Successful in 21m24s
ci / image (push) Successful in 27s
2026-08-31 17:18:10 +00:00
sharang 03b479ab6f fix(ci): image job needs a docker CLI, build in docker:27-cli (#17)
ci / shared (push) Successful in 12s
ci / test (push) Successful in 21m18s
ci / image (push) Failing after 6s
2026-08-31 15:51:36 +00:00
sharang 583d8f8f25 ci: the image job never ran — fix condition, tag :latest, deploy for real (#16)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 21m20s
ci / image (push) Failing after 11s
2026-08-30 21:10:33 +00:00
sharang 739b19341c fix(deps): clear the HIGH/CRITICAL CVEs failing the trivy CI gate (#15)
ci / shared (push) Successful in 13s
ci / test (push) Successful in 21m13s
ci / image (push) Canceled after 0s
2026-08-25 08:49:01 +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 31cb06cf3d Repoint registry.breakpilot.com -> repo.breakpilot.com (Harbor) (#13)
ci / shared (push) Failing after 11s
ci / test (push) Successful in 21m10s
ci / image (push) Skipped
2026-08-09 21:22:11 +00:00
sharang 52cbfc2b82 chore(ci): repoint registry/git/cargo meghsakha.com -> breakpilot.com (#12)
ci / shared (push) Failing after 12s
ci / test (push) Successful in 21m9s
ci / image (push) Skipped
2026-08-06 09:49:53 +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 e70ed771ca fix(dev): default port :8080 → :8090
ci / shared (push) Successful in 4s
ci / test (push) Successful in 9s
ci / image (push) Has been skipped
Unblock local dev: Keycloak owns :8080, so tenant-registry shifts to :8090. Prod is functionally unchanged.

Refs: M5.1
2026-05-19 09:47:36 +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
sharang e960a5ff9d chore(domain): yourplatform.com → breakpilot.com
ci / shared (push) Successful in 4s
ci / test (push) Has been skipped
ci / image (push) Has been skipped
Apply platform-domain decision (2026-05-18). No services touched; docs/config only.

Refs: M1.1
2026-05-18 20:28:42 +00:00
sharang daff430960 ci: rework workflow for Gitea Actions (M0.2)
ci / shared (push) Successful in 3s
ci / test (push) Has been skipped
ci / image (push) Has been skipped
Switches commitlint to bash regex, gitleaks to inline binary, trivy to inline binary (v0.70.0). Per-stack jobs gated on hashFiles.

Refs: M0.2
2026-05-18 19:42:27 +00:00
sharang db14bfac9f chore: bootstrap repo scaffolding (M0.1)
ci / shared (push) Failing after 6s
ci / test (push) Failing after 3s
ci / image (push) Has been skipped
Bootstraps §1.2 scaffolding (README, CONTRIBUTING, CODEOWNERS, CHANGELOG, PR + issue templates, LICENSE, CI workflow, release workflow, commitlint, cliff, .editorconfig, .gitignore, .env.example) and ships a proprietary all-rights-reserved LICENSE naming both founders.

Refs: M0.1
2026-05-18 19:15:33 +00:00
sharang a24d372bcb Initial commit 2026-05-18 19:05:34 +00:00