feat(iace): Phase 1 — Haftungs-Fixes, Massnahmen-Verkabelung, Explainability Engine
Phase 1A — Haftungs-kritische Fixes: - SIL/PL-Badges als "Vorab-Einschaetzung" mit Tooltip gekennzeichnet - Coverage-Disclaimer in CE-Akte, Projekt-Uebersicht und Print-Export - Norm-Referenzen: 42 Kapitelverweise durch Themen-Deskriptoren ersetzt Phase 1B — Massnahmen-Verkabelung: - 16 neue Massnahmen (M201-M216) fuer bisher unabgedeckte Kategorien (communication_failure, hmi_error, firmware_corruption, maintenance, sensor_fault, mode_confusion) - Kategorie-Fallback im Initialize-Endpoint: ordnet Massnahmen aus der Bibliothek automatisch per HazardCategory zu (max 8 pro Kategorie) - Total: 225 → 241 Massnahmen, 0 Kategorien ohne Massnahmen Phase 1C — Explainability Engine: - MatchReason Struct in PatternMatch (type, tag, met) - Pattern Engine schreibt fuer jeden Match strukturierte Begruendungen - Frontend zeigt "Erkannt weil: Komponente X, Energie Y, Kein Ausschluss Z" Weitere Aenderungen: - BAuA/OSHA Regulatory Hints: 3 Enrich-Endpoints (per Hazard, per Measure, Batch) - Dokumente-Tab in IACE-Bibliothek (36.708 Chunks aus Qdrant) - Varianten-UX: Basis-Projekt-Summary auf Varianten-Seite - Projekt-Initialisierung: POST /initialize kettet Parse→Komponenten→Patterns→Hazards→Massnahmen→Normen - 18 pre-existing TS-Fehler gefixt, Route-Konflikt behoben - Component-Library + Measures-Library Tests aktualisiert Tests: Go alle bestanden, TS 0 Fehler, Playwright 141+ bestanden Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -148,5 +148,13 @@ func (c *LegalRAGClient) ListAvailableRegulations() []CERegulationInfo {
|
||||
{ID: "enisa_ics_scada_dependencies", NameDE: "ENISA ICS/SCADA Abhaengigkeiten", NameEN: "ENISA ICS/SCADA Communication Dependencies", Short: "ENISA ICS/SCADA", Category: "guidance"},
|
||||
{ID: "cisa_secure_by_design", NameDE: "CISA Secure by Design", NameEN: "CISA Secure by Design", Short: "CISA SbD", Category: "guidance"},
|
||||
{ID: "enisa_cybersecurity_state_2024", NameDE: "ENISA State of Cybersecurity 2024", NameEN: "ENISA State of Cybersecurity in the Union 2024", Short: "ENISA 2024", Category: "guidance"},
|
||||
// BAuA — Technische Regeln (gemeinfrei, §5 UrhG)
|
||||
{ID: "trbs", NameDE: "TRBS — Technische Regeln fuer Betriebssicherheit", NameEN: "TRBS — Technical Rules for Operational Safety", Short: "TRBS", Category: "trbs"},
|
||||
{ID: "trgs", NameDE: "TRGS — Technische Regeln fuer Gefahrstoffe", NameEN: "TRGS — Technical Rules for Hazardous Substances", Short: "TRGS", Category: "trgs"},
|
||||
{ID: "asr", NameDE: "ASR — Arbeitsstaettenregeln", NameEN: "ASR — Workplace Rules", Short: "ASR", Category: "asr"},
|
||||
// OSHA
|
||||
{ID: "osha_1910", NameDE: "OSHA 1910 Subpart O — Maschinenschutz", NameEN: "OSHA 1910 Subpart O — Machinery and Machine Guarding", Short: "OSHA 1910", Category: "osha"},
|
||||
// EuGH
|
||||
{ID: "eugh_c_588_21", NameDE: "EuGH C-588/21 P — Datenschutz-Urteil", NameEN: "ECJ C-588/21 P — Data Protection Judgment", Short: "EuGH C-588/21", Category: "eu_recht"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,90 @@ func (c *LegalRAGClient) ScrollChunks(ctx context.Context, collection string, of
|
||||
return chunks, nextOffset, nil
|
||||
}
|
||||
|
||||
// ScrollDocumentIndex scrolls through all chunks in a collection using minimal
|
||||
// payload (no text/vectors) and returns a deduplicated list of documents.
|
||||
func (c *LegalRAGClient) ScrollDocumentIndex(ctx context.Context, collection string) ([]CEDocumentInfo, error) {
|
||||
includeFields := []string{"regulation_id", "regulation_name_de", "regulation_name_en", "category", "source", "source_org"}
|
||||
|
||||
// regulation_id → aggregated info
|
||||
docMap := make(map[string]*CEDocumentInfo)
|
||||
var offset interface{}
|
||||
batchLimit := 500
|
||||
|
||||
for {
|
||||
reqBody := map[string]interface{}{
|
||||
"limit": batchLimit,
|
||||
"with_payload": map[string]interface{}{"include": includeFields},
|
||||
"with_vectors": false,
|
||||
}
|
||||
if offset != nil {
|
||||
reqBody["offset"] = offset
|
||||
}
|
||||
|
||||
jsonBody, err := json.Marshal(reqBody)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal scroll request: %w", err)
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/collections/%s/points/scroll", c.qdrantURL, collection)
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", url, bytes.NewReader(jsonBody))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create scroll request: %w", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
if c.qdrantAPIKey != "" {
|
||||
req.Header.Set("api-key", c.qdrantAPIKey)
|
||||
}
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("scroll request failed: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
return nil, fmt.Errorf("qdrant returned %d: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
|
||||
var scrollResp qdrantScrollResponse
|
||||
if err := json.NewDecoder(resp.Body).Decode(&scrollResp); err != nil {
|
||||
return nil, fmt.Errorf("failed to decode scroll response: %w", err)
|
||||
}
|
||||
|
||||
for _, pt := range scrollResp.Result.Points {
|
||||
regID := getString(pt.Payload, "regulation_id")
|
||||
if regID == "" {
|
||||
continue
|
||||
}
|
||||
if existing, ok := docMap[regID]; ok {
|
||||
existing.ChunkCount++
|
||||
continue
|
||||
}
|
||||
docMap[regID] = &CEDocumentInfo{
|
||||
RegulationID: regID,
|
||||
NameDE: getString(pt.Payload, "regulation_name_de"),
|
||||
NameEN: getString(pt.Payload, "regulation_name_en"),
|
||||
Category: getString(pt.Payload, "category"),
|
||||
SourceURL: getString(pt.Payload, "source"),
|
||||
SourceOrg: getString(pt.Payload, "source_org"),
|
||||
ChunkCount: 1,
|
||||
}
|
||||
}
|
||||
|
||||
if scrollResp.Result.NextPageOffset == nil {
|
||||
break
|
||||
}
|
||||
offset = scrollResp.Result.NextPageOffset
|
||||
}
|
||||
|
||||
docs := make([]CEDocumentInfo, 0, len(docMap))
|
||||
for _, d := range docMap {
|
||||
docs = append(docs, *d)
|
||||
}
|
||||
return docs, nil
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
|
||||
func getString(m map[string]interface{}, key string) string {
|
||||
|
||||
@@ -47,6 +47,17 @@ type ScrollChunkResult struct {
|
||||
SourceURL string `json:"source_url,omitempty"`
|
||||
}
|
||||
|
||||
// CEDocumentInfo represents a document in the CE corpus with metadata.
|
||||
type CEDocumentInfo struct {
|
||||
RegulationID string `json:"regulation_id"`
|
||||
NameDE string `json:"name_de"`
|
||||
NameEN string `json:"name_en"`
|
||||
Category string `json:"category"`
|
||||
SourceURL string `json:"source_url"`
|
||||
SourceOrg string `json:"source_org"`
|
||||
ChunkCount int `json:"chunk_count"`
|
||||
}
|
||||
|
||||
// --- Internal Qdrant / Ollama HTTP types ---
|
||||
|
||||
type ollamaEmbeddingRequest struct {
|
||||
|
||||
Reference in New Issue
Block a user