Files
tenant-registry/internal/roles/catalogue.go
sharangandClaude Opus 5.5 5fff4dd581
ci / shared (push) Successful in 13s
ci / test (push) Successful in 24m30s
ci / image (push) Successful in 38s
fix(roles): first releases are management's; external-only decides nothing (#101)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
2026-10-28 16:13:09 +00:00

166 lines
9.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package roles is the role and authority dataset of a company (R1 S0,
// docgen#1 plan 13781 §3.2 no. 2, owner addendum 13791): functions, who holds
// them, deputies with their basis, and which function decides which decision
// type. The catalogue of functions and decision types lives here, in code and
// versioned; the registry stores one dataset document per tenant and checks
// it against the catalogue and the rules of B7 and B8 (dataset.go).
package roles
// CatalogueVersion names this catalogue. A save names the version it was
// made against; another version is refused, so the portal reloads.
const CatalogueVersion = "r1-2026-10-26.1"
// Per is the scope an assignment of a function needs.
type Per string
const (
PerCompany Per = "company" // no scope
PerDocument Per = "document" // an R1 document key (Documents)
PerProduct Per = "product" // an opaque product id (not checked yet: product states are not built, N-3)
PerArea Per = "area" // free text naming the area of a review
)
// External says whether a person outside the company may hold a function.
type External string
const (
ExternalNo External = "no"
ExternalAllowed External = "allowed"
ExternalOnly External = "only"
)
// Function is one entry of the catalogue. Labels are the owner's wording.
type Function struct {
Code string `json:"key"`
Label string `json:"label"`
// Sources: A1 (R1 frontend spec v4 §2.3) and/or A4 (document contract
// R1-D01/R1-D02 §4, the seven functions of R1-D02 §18).
Sources []string `json:"sources"`
Per Per `json:"per"`
Multiple bool `json:"multiple"`
External External `json:"external"`
// AnyMember: held by every customer person with an account; no
// assignment is recorded (Änderungsinitiierung).
AnyMember bool `json:"any_member,omitempty"`
// NotApplicable: may be recorded as "nicht anwendbar" (R1-D02 §18 only
// for product safety, tied to the module decision).
NotApplicable bool `json:"not_applicable,omitempty"`
// D02Row is the row of the function in R1-D02 §18 (1–7), 0 for none.
D02Row int `json:"d02_row,omitempty"`
}
// Management is the function B7 and B8 single out.
const Management = "r1.geschaeftsleitung"
// DocumentOwner is the second function that may maintain the dataset (B7).
const DocumentOwner = "r1.dokumentenverantwortung"
// Functions is the union of A1 §2.3 and A4 §4 (B14): the same name in both
// lists is one entry, different names stay apart even where they sound alike
// (Technischer Ansprechpartner vs. Technischer Produktverantwortlicher).
var Functions = []Function{
{Code: Management, Label: "Geschäftsleitung", Sources: []string{"A1", "A4"}, Per: PerCompany, Multiple: true, External: ExternalNo, D02Row: 1},
{Code: "r1.produkt_cybersecurity", Label: "Produkt-Cybersecurity-Verantwortlicher", Sources: []string{"A1", "A4"}, Per: PerCompany, Multiple: true, External: ExternalNo, D02Row: 2},
{Code: "r1.technischer_produktverantwortlicher", Label: "Technischer Produktverantwortlicher", Sources: []string{"A4"}, Per: PerCompany, Multiple: true, External: ExternalNo, D02Row: 3},
{Code: "r1.externer_cybersecurity_dienstleister", Label: "Externer Cybersecurity-Dienstleister", Sources: []string{"A4"}, Per: PerCompany, Multiple: true, External: ExternalOnly, D02Row: 4},
{Code: "r1.produktsicherheit", Label: "Produktsicherheitsverantwortlicher", Sources: []string{"A1", "A4"}, Per: PerCompany, Multiple: true, External: ExternalNo, NotApplicable: true, D02Row: 5},
{Code: "r1.konformitaet", Label: "Konformitätsverantwortlicher / autorisierte Herstellerfunktion", Sources: []string{"A4"}, Per: PerCompany, Multiple: true, External: ExternalNo, D02Row: 6},
{Code: "r1.meldeberechtigt", Label: "Regulatorisch Meldeberechtigter", Sources: []string{"A1", "A4"}, Per: PerCompany, Multiple: true, External: ExternalNo, D02Row: 7},
{Code: "r1.technischer_ansprechpartner", Label: "Technischer Ansprechpartner", Sources: []string{"A1"}, Per: PerCompany, Multiple: true, External: ExternalAllowed},
{Code: "r1.vorfallkontakt", Label: "Vorfallkontakt", Sources: []string{"A1"}, Per: PerCompany, Multiple: true, External: ExternalAllowed},
{Code: DocumentOwner, Label: "Dokumentenverantwortlicher", Sources: []string{"A1"}, Per: PerDocument, Multiple: false, External: ExternalNo},
{Code: "r1.freigabestelle", Label: "Freigabestelle", Sources: []string{"A1"}, Per: PerDocument, Multiple: true, External: ExternalNo},
{Code: "r1.aenderungsinitiierung", Label: "Änderungsinitiierung", Sources: []string{"A1"}, Per: PerCompany, External: ExternalNo, AnyMember: true},
{Code: "r1.produktverantwortung", Label: "Produktverantwortung", Sources: []string{"A1"}, Per: PerProduct, Multiple: true, External: ExternalNo},
{Code: "r1.aenderungskoordination", Label: "Änderungskoordination", Sources: []string{"A1"}, Per: PerCompany, Multiple: true, External: ExternalNo},
{Code: "r1.fachpruefung", Label: "Fachprüfung", Sources: []string{"A1"}, Per: PerArea, Multiple: true, External: ExternalAllowed},
{Code: "r1.freigabe_produktaenderung", Label: "Freigabe von Produktänderungen", Sources: []string{"A1"}, Per: PerCompany, Multiple: true, External: ExternalNo},
{Code: "r1.dokumentenlenkung", Label: "Dokumentenlenkung", Sources: []string{"A1"}, Per: PerCompany, Multiple: true, External: ExternalNo},
{Code: "r1.massnahmenausfuehrer", Label: "Maßnahmenausführer", Sources: []string{"A1"}, Per: PerCompany, Multiple: true, External: ExternalAllowed},
{Code: "r1.prueffunktion", Label: "Prüffunktion", Sources: []string{"A1"}, Per: PerCompany, Multiple: true, External: ExternalAllowed},
{Code: "r1.abschlussverantwortung", Label: "Abschlussverantwortlicher", Sources: []string{"A1"}, Per: PerCompany, Multiple: true, External: ExternalNo},
{Code: "r1.fachlich_verantwortliche_stelle", Label: "Fachlich verantwortliche Stelle", Sources: []string{"A1"}, Per: PerCompany, Multiple: true, External: ExternalNo},
}
// DecisionType is a customer decision (BM-4: Breakpilot's own steps are
// execution, not decisions, and do not appear here). Default is the deciding
// function where the owner has fixed one; "" means the company must set it,
// and until then resolve answers rolle_offen (BM-5, AM-3).
type DecisionType struct {
Code string `json:"key"`
Label string `json:"label"`
Default string `json:"default,omitempty"`
}
// ReleaseD02Update is the decision type of B8.
const ReleaseD02Update = "r1.release_d02_update"
// DecisionTypes: only the three releases carry a default (A2 §1, §5; B8).
// The defaults the process data suggests for the others need the owner's
// confirmation (S0 spec Q9) and are not preset, so the platform preselects
// no customer authority (13791 Nr. 5).
var DecisionTypes = []DecisionType{
{Code: "r1.release_d01", Label: "Freigabe R1-D01", Default: Management},
{Code: "r1.release_d02", Label: "Freigabe R1-D02", Default: Management},
{Code: ReleaseD02Update, Label: "Freigabe einer Aktualisierung der R1-D02", Default: Management},
{Code: "r1.new_version_needed", Label: "Neue Fassung nötig"},
{Code: "r1.measure_close", Label: "Maßnahme abschließen"},
{Code: "r1.measure_not_applicable", Label: "Nichtanwendbarkeit einer Maßnahme"},
{Code: "r1.product_responsibility", Label: "Produktverantwortung eindeutig"},
{Code: "r1.simplified_procedure", Label: "Vereinfachtes Verfahren"},
{Code: "r1.release_product_change", Label: "Freigabe einer Produktänderung"},
{Code: "r1.standard_release_applies", Label: "Standardfreigabe deckt den Vorgang"},
{Code: "r1.escalation", Label: "Eskalationskriterium erfüllt"},
{Code: "r1.procedure_choice", Label: "Wahl des Verfahrens"},
{Code: "r1.event_takeover", Label: "Übernahme eines Sicherheitsereignisses"},
{Code: "r1.acceptance", Label: "Abnahme"},
}
// FirstReleases are management's alone (A2 §1: Erstfreigabe durch die
// Geschäftsleitung): a company names no other body for them. The update of
// R1-D02 is different; it follows B8.
var FirstReleases = []string{"r1.release_d01", "r1.release_d02"}
// Documents are the R1 document keys a document-scoped function refers to.
var Documents = []string{"r1_d01", "r1_d02"}
var (
functionIndex = map[string]Function{}
decisionTypeIndex = map[string]DecisionType{}
)
func init() {
for _, f := range Functions {
functionIndex[f.Code] = f
}
for _, d := range DecisionTypes {
decisionTypeIndex[d.Code] = d
}
}
// FunctionByKey looks a function up in the catalogue.
func FunctionByKey(key string) (Function, bool) {
f, ok := functionIndex[key]
return f, ok
}
// DecisionTypeByKey looks a decision type up in the catalogue.
func DecisionTypeByKey(key string) (DecisionType, bool) {
d, ok := decisionTypeIndex[key]
return d, ok
}
// Catalogue is the catalogue as the GET answer carries it, so the portal
// needs no copy of its own.
type Catalogue struct {
Version string `json:"version"`
Functions []Function `json:"functions"`
DecisionTypes []DecisionType `json:"decision_types"`
Documents []string `json:"documents"`
}
// CurrentCatalogue returns the catalogue of this build.
func CurrentCatalogue() Catalogue {
return Catalogue{Version: CatalogueVersion, Functions: Functions, DecisionTypes: DecisionTypes, Documents: Documents}
}