Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: separate risk generation from approval flow (#18241)
p0nyd60370bcbec7
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.goindex 0735275ff9..19363c0b76 100644--- a/backend/runner/approval/runner.go+++ b/backend/runner/approval/runner.go@@ -186,14 +186,9 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.}}- // Calculate risk level from statement types- var riskLevel storepb.RiskLevel- if celVarsList != nil {- statementTypes := collectStatementTypes(celVarsList)- riskLevel = common.GetRiskLevelFromStatementTypes(statementTypes)- } else {- riskLevel = storepb.RiskLevel_LOW- }+ // Calculate risk level separately from approval flow+ // TODO(p0ny): maybe move risk calculation to another runner in the future+ riskLevel := calculateRiskLevelFromCELVars(celVarsList)payload.Approval = &storepb.IssuePayloadApproval{ApprovalFindingDone: true,@@ -269,6 +264,16 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.return true, nil}+// calculateRiskLevelFromCELVars calculates the risk level from CEL variables.+// This is separated from approval flow generation to allow independent evolution.+func calculateRiskLevelFromCELVars(celVarsList []map[string]any) storepb.RiskLevel {+ if celVarsList == nil {+ return storepb.RiskLevel_LOW+ }+ statementTypes := collectStatementTypes(celVarsList)+ return common.GetRiskLevelFromStatementTypes(statementTypes)+}+// getApprovalTemplate finds the first matching approval template for the given source and CEL variables.// After the risk layer removal (3.13), approval rules are directly evaluated with full CEL context.// The rules are ordered by priority (HIGH risk rules first, then MODERATE, then LOW, then UNSPECIFIED).