The onboarding company profile (Unternehmensprofil + Compliance-Umfang) moves from the workspace prototype into the portal. The registry becomes its authoritative store (decided 2026-10-20). This PR is the backend; the portal form follows in a separate PR.
Data model (migration 0021)
company_profiles: one row per tenant.
The form's document as JSONB, unchanged: every answer, option and the suggested list ("Vorschlag", unconfirmed system suggestions).
Also stored: schema_version, revision, status (draft/submitted), updated_by/at and submitted_by/at.
company_profile_revisions: every saved state, never changed afterwards, with its source (portal, submit or import) and who changed it.
API
Route
Group
What
GET /v1/tenants/{id}/company-profile
tenants.read
current revision; 404 when none (a {sub} of the tenant route)
PUT /v1/tenants/{id}/company-profile
tenants.write
save
POST /v1/tenants/{id}/company-profile/submit
tenants.write
submit
GET /v1/admin/tenants/{id}/company-profile
admin
staff view
PUT /v1/admin/tenants/{id}/company-profile
admin
staff import, only with a named staff member
Optimistic revisions:expected_revision is the revision the writer last read (0 for none). A stale write gets 409 with current_revision, so nothing is silently overwritten.
An unchanged save creates no new revision. The portal autosaves, and only real changes enter the history.
The status survives later edits: a submitted profile stays submitted while it is edited.
The registry checks only the outline:
known top-level keys;
the sections company_profile / compliance_scope / ai_act;
each answer is text, a number, yes/no, a list of texts, or null;
the audience is own_company (the tenant is the company);
at most 256 KiB.
Fields and their options are the portal's schema, which the portal validates.
Roles: as for projects, the portal checks the user's org role. Here IT_ADMIN, CXO and LEGAL write; FINANCE reads.
Audit:company_profile.saved / .submitted / .imported record the revision, never the answers.
openapi.yaml documents all five operations.
Tests
company_profile_test.go: the lifecycle (save, unchanged save, stale save and stale submit get 409, submit, edit after submit, history and audit with no answers in it), malformed documents, staff-only import, and access (a product client reads but does not write; a user of another tenant gets 404, while the tenant's own user can read).
company_profile_store_test.go: the store contract on memory and Postgres. Run locally against Postgres 16 with migration 0021, including JSONB round-trip and key-order independence.
go test -short ./... and go test ./migrations (up/down) pass locally.
Rollout
Stage first with test data, then promotion to prod on your go. After that, K-00001's profile is imported from the admin area (portal PR).
The onboarding company profile (Unternehmensprofil + Compliance-Umfang) moves from the workspace prototype into the portal. The registry becomes its **authoritative store** (decided 2026-10-20). This PR is the backend; the portal form follows in a separate PR.
## Data model (migration 0021)
- **`company_profiles`**: one row per tenant.
- The form's document as JSONB, unchanged: every answer, option and the `suggested` list ("Vorschlag", unconfirmed system suggestions).
- Also stored: `schema_version`, `revision`, `status` (draft/submitted), `updated_by/at` and `submitted_by/at`.
- **`company_profile_revisions`**: every saved state, never changed afterwards, with its source (`portal`, `submit` or `import`) and who changed it.
## API
| Route | Group | What |
|---|---|---|
| `GET /v1/tenants/{id}/company-profile` | tenants.read | current revision; 404 when none (a `{sub}` of the tenant route) |
| `PUT /v1/tenants/{id}/company-profile` | tenants.write | save |
| `POST /v1/tenants/{id}/company-profile/submit` | tenants.write | submit |
| `GET /v1/admin/tenants/{id}/company-profile` | admin | staff view |
| `PUT /v1/admin/tenants/{id}/company-profile` | admin | **staff import**, only with a named staff member |
- **Optimistic revisions:** `expected_revision` is the revision the writer last read (0 for none). A stale write gets **409** with `current_revision`, so nothing is silently overwritten.
- **An unchanged save creates no new revision.** The portal autosaves, and only real changes enter the history.
- **The status survives later edits:** a submitted profile stays submitted while it is edited.
- **The registry checks only the outline:**
- known top-level keys;
- the sections `company_profile` / `compliance_scope` / `ai_act`;
- each answer is text, a number, yes/no, a list of texts, or null;
- the audience is `own_company` (the tenant is the company);
- at most 256 KiB.
Fields and their options are the portal's schema, which the portal validates.
- **Roles:** as for projects, the portal checks the user's org role. Here IT_ADMIN, CXO and LEGAL write; FINANCE reads.
- **Audit:** `company_profile.saved` / `.submitted` / `.imported` record the revision, **never the answers**.
- `openapi.yaml` documents all five operations.
## Tests
- `company_profile_test.go`: the lifecycle (save, unchanged save, stale save and stale submit get 409, submit, edit after submit, history and audit with no answers in it), malformed documents, staff-only import, and access (a product client reads but does not write; a user of another tenant gets 404, while the tenant's own user can read).
- `company_profile_store_test.go`: the store contract on **memory and Postgres**. Run locally against Postgres 16 with migration 0021, including JSONB round-trip and key-order independence.
- `go test -short ./...` and `go test ./migrations` (up/down) pass locally.
## Rollout
Stage first with test data, then promotion to prod on your go. After that, K-00001's profile is imported from the admin area (portal PR).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Decided 2026-10-20: the onboarding company profile (Unternehmensprofil +
Compliance-Umfang) moves from the workspace prototype into the portal, and
the registry is its authoritative store.
- migration 0021: company_profiles (one per tenant: the form's document as
JSONB, schema version, revision, draft/submitted, who and when) and
company_profile_revisions (every state, with its source: portal, submit
or import)
- GET/PUT /v1/tenants/{id}/company-profile, POST …/submit: optimistic
revisions (409 with the current revision), an unchanged save is no new
revision (autosave), the status survives later edits
- GET/PUT /v1/admin/tenants/{id}/company-profile: staff import, only with a
named staff member
- the registry checks the document's outline only (keys, sections, answer
types, own_company, 256 KiB); fields and options are the portal's schema
- audit: company_profile.saved / .submitted / .imported with the revision,
never the answers
- openapi.yaml documents the five operations
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang
merged commit 174a2f1e01 into main2026-10-20 10:30:10 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The onboarding company profile (Unternehmensprofil + Compliance-Umfang) moves from the workspace prototype into the portal. The registry becomes its authoritative store (decided 2026-10-20). This PR is the backend; the portal form follows in a separate PR.
Data model (migration 0021)
company_profiles: one row per tenant.suggestedlist ("Vorschlag", unconfirmed system suggestions).schema_version,revision,status(draft/submitted),updated_by/atandsubmitted_by/at.company_profile_revisions: every saved state, never changed afterwards, with its source (portal,submitorimport) and who changed it.API
GET /v1/tenants/{id}/company-profile{sub}of the tenant route)PUT /v1/tenants/{id}/company-profilePOST /v1/tenants/{id}/company-profile/submitGET /v1/admin/tenants/{id}/company-profilePUT /v1/admin/tenants/{id}/company-profileOptimistic revisions:
expected_revisionis the revision the writer last read (0 for none). A stale write gets 409 withcurrent_revision, so nothing is silently overwritten.An unchanged save creates no new revision. The portal autosaves, and only real changes enter the history.
The status survives later edits: a submitted profile stays submitted while it is edited.
The registry checks only the outline:
company_profile/compliance_scope/ai_act;own_company(the tenant is the company);Fields and their options are the portal's schema, which the portal validates.
Roles: as for projects, the portal checks the user's org role. Here IT_ADMIN, CXO and LEGAL write; FINANCE reads.
Audit:
company_profile.saved/.submitted/.importedrecord the revision, never the answers.openapi.yamldocuments all five operations.Tests
company_profile_test.go: the lifecycle (save, unchanged save, stale save and stale submit get 409, submit, edit after submit, history and audit with no answers in it), malformed documents, staff-only import, and access (a product client reads but does not write; a user of another tenant gets 404, while the tenant's own user can read).company_profile_store_test.go: the store contract on memory and Postgres. Run locally against Postgres 16 with migration 0021, including JSONB round-trip and key-order independence.go test -short ./...andgo test ./migrations(up/down) pass locally.Rollout
Stage first with test data, then promotion to prod on your go. After that, K-00001's profile is imported from the admin area (portal PR).
🤖 Generated with Claude Code
Decided 2026-10-20: the onboarding company profile (Unternehmensprofil + Compliance-Umfang) moves from the workspace prototype into the portal, and the registry is its authoritative store. - migration 0021: company_profiles (one per tenant: the form's document as JSONB, schema version, revision, draft/submitted, who and when) and company_profile_revisions (every state, with its source: portal, submit or import) - GET/PUT /v1/tenants/{id}/company-profile, POST …/submit: optimistic revisions (409 with the current revision), an unchanged save is no new revision (autosave), the status survives later edits - GET/PUT /v1/admin/tenants/{id}/company-profile: staff import, only with a named staff member - the registry checks the document's outline only (keys, sections, answer types, own_company, 256 KiB); fields and options are the portal's schema - audit: company_profile.saved / .submitted / .imported with the revision, never the answers - openapi.yaml documents the five operations Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>