feat: AI Act Decision Tree — Zwei-Achsen-Klassifikation (GPAI + High-Risk)
Interaktiver 12-Fragen-Entscheidungsbaum für die AI Act Klassifikation auf zwei Achsen: High-Risk (Anhang III, Q1-Q7) und GPAI (Art. 51-56, Q8-Q12). Deterministische Auswertung ohne LLM. Backend (Go): - Neue Structs: GPAIClassification, DecisionTreeAnswer, DecisionTreeResult - Decision Tree Engine mit BuildDecisionTreeDefinition() und EvaluateDecisionTree() - Store-Methoden für CRUD der Ergebnisse - API-Endpoints: GET/POST /decision-tree, GET/DELETE /decision-tree/results - 12 Unit Tests (alle bestanden) Frontend (Next.js): - DecisionTreeWizard: Wizard-UI mit Ja/Nein-Fragen, Dual-Progress-Bar, Ergebnis-Ansicht - AI Act Page refactored: Tabs (Übersicht | Entscheidungsbaum | Ergebnisse) - Proxy-Route für decision-tree Endpoints Migration 083: ai_act_decision_tree_results Tabelle Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1122,6 +1122,114 @@ func (h *UCCAHandlers) GetWizardSchema(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// AI Act Decision Tree Endpoints
|
||||
// ============================================================================
|
||||
|
||||
// GetDecisionTree returns the decision tree structure for the frontend
|
||||
// GET /sdk/v1/ucca/decision-tree
|
||||
func (h *UCCAHandlers) GetDecisionTree(c *gin.Context) {
|
||||
tree := ucca.BuildDecisionTreeDefinition()
|
||||
c.JSON(http.StatusOK, tree)
|
||||
}
|
||||
|
||||
// EvaluateDecisionTree evaluates the decision tree answers and stores the result
|
||||
// POST /sdk/v1/ucca/decision-tree/evaluate
|
||||
func (h *UCCAHandlers) EvaluateDecisionTree(c *gin.Context) {
|
||||
tenantID := rbac.GetTenantID(c)
|
||||
if tenantID == uuid.Nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "tenant ID required"})
|
||||
return
|
||||
}
|
||||
|
||||
var req ucca.DecisionTreeEvalRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if req.SystemName == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "system_name is required"})
|
||||
return
|
||||
}
|
||||
|
||||
// Evaluate
|
||||
result := ucca.EvaluateDecisionTree(&req)
|
||||
result.TenantID = tenantID
|
||||
|
||||
// Parse optional project_id
|
||||
if projectIDStr := c.Query("project_id"); projectIDStr != "" {
|
||||
if pid, err := uuid.Parse(projectIDStr); err == nil {
|
||||
result.ProjectID = &pid
|
||||
}
|
||||
}
|
||||
|
||||
// Store result
|
||||
if err := h.store.CreateDecisionTreeResult(c.Request.Context(), result); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, result)
|
||||
}
|
||||
|
||||
// ListDecisionTreeResults returns stored decision tree results for a tenant
|
||||
// GET /sdk/v1/ucca/decision-tree/results
|
||||
func (h *UCCAHandlers) ListDecisionTreeResults(c *gin.Context) {
|
||||
tenantID := rbac.GetTenantID(c)
|
||||
if tenantID == uuid.Nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "tenant ID required"})
|
||||
return
|
||||
}
|
||||
|
||||
results, err := h.store.ListDecisionTreeResults(c.Request.Context(), tenantID)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"results": results, "total": len(results)})
|
||||
}
|
||||
|
||||
// GetDecisionTreeResult returns a single decision tree result by ID
|
||||
// GET /sdk/v1/ucca/decision-tree/results/:id
|
||||
func (h *UCCAHandlers) GetDecisionTreeResult(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid ID"})
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.store.GetDecisionTreeResult(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
if result == nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "not found"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DeleteDecisionTreeResult deletes a decision tree result
|
||||
// DELETE /sdk/v1/ucca/decision-tree/results/:id
|
||||
func (h *UCCAHandlers) DeleteDecisionTreeResult(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid ID"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.store.DeleteDecisionTreeResult(c.Request.Context(), id); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "deleted"})
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Helper functions
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user