Files
breakpilot-compliance/ai-compliance-sdk/internal/usecase/question_generator.go
T
Benjamin Admin 06bfbd1dca
Build + Deploy / build-admin-compliance (push) Successful in 2m46s
Build + Deploy / build-backend-compliance (push) Successful in 26s
Build + Deploy / build-ai-sdk (push) Successful in 52s
Build + Deploy / build-developer-portal (push) Successful in 22s
Build + Deploy / build-tts (push) Successful in 16s
Build + Deploy / build-document-crawler (push) Successful in 12s
Build + Deploy / build-dsms-gateway (push) Successful in 20s
Build + Deploy / build-dsms-node (push) Successful in 16s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 18s
CI / secret-scan (push) Has been skipped
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 3m16s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Successful in 1m0s
CI / test-python-backend (push) Successful in 41s
CI / test-python-document-crawler (push) Successful in 29s
CI / test-python-dsms-gateway (push) Successful in 23s
CI / validate-canonical-controls (push) Successful in 16s
Build + Deploy / trigger-orca (push) Successful in 2m36s
feat(use-case-compiler): MC-based compliance questionnaires with scoring
Implements the Use-Case Compiler that turns Master Controls into
interactive compliance audits. 5 templates (Vendor Check, SAST/DAST,
DSGVO, NIS2, CRA), deterministic + LLM question generation, scoring
engine with regulation/severity breakdown, and gap detection.

- Backend: 9 API endpoints, 22 unit tests (all pass)
- Frontend: Template selector, questionnaire, result dashboard
- Migration 027: usecase_audits + usecase_answers tables

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-12 13:49:16 +02:00

68 lines
2.1 KiB
Go

package usecase
import (
"fmt"
"strings"
)
// QuestionGenerator creates questions from MC metadata when no
// pre-defined questions or doc_check_controls exist (Mode A fallback).
// For LLM-based generation (Mode B), see compiler_llm.go (Phase 7).
// GenerateFromMC derives 1-3 questions from a single MC.
func GenerateFromMC(mc MCInfo) []Question {
name := mc.CanonicalName
readable := strings.ReplaceAll(name, "_", " ")
var questions []Question
qBase := fmt.Sprintf("MC-%s", mc.MasterControlID)
// Primary question: is the control implemented?
questions = append(questions, Question{
ID: qBase + "-1",
MCID: mc.MasterControlID,
MCName: name,
Text: fmt.Sprintf("Ist '%s' in Ihrem Unternehmen implementiert?", readable),
QuestionType: "yes_no",
Severity: inferMCSeverity(name),
Regulation: mc.RegSource,
PassCriteria: []string{"Massnahme implementiert und aktiv"},
FailCriteria: []string{"Nicht implementiert"},
})
// Secondary question: is there documentation?
if mc.TotalControls >= 5 {
questions = append(questions, Question{
ID: qBase + "-2",
MCID: mc.MasterControlID,
MCName: name,
Text: fmt.Sprintf("Ist '%s' dokumentiert und nachweisbar?", readable),
QuestionType: "yes_no",
EvidenceRequired: true,
Severity: "MEDIUM",
Regulation: mc.RegSource,
PassCriteria: []string{"Dokumentation vorhanden und aktuell"},
FailCriteria: []string{"Keine oder veraltete Dokumentation"},
DependsOn: qBase + "-1",
})
}
// Tertiary question for large MCs: review cycle
if mc.TotalControls >= 15 {
questions = append(questions, Question{
ID: qBase + "-3",
MCID: mc.MasterControlID,
MCName: name,
Text: fmt.Sprintf("Wird '%s' regelmaessig ueberprueft und aktualisiert?", readable),
QuestionType: "yes_no",
Severity: "LOW",
Regulation: mc.RegSource,
PassCriteria: []string{"Regelmaessiger Review-Zyklus definiert"},
FailCriteria: []string{"Kein Review-Prozess"},
DependsOn: qBase + "-1",
})
}
return questions
}