Spaces:
Running
Running
Deploy ReguAI: Neuro-Symbolic AI GRC & Automated Conformity Assessment Engine
Browse files
data/active_learning_triplets.jsonl
CHANGED
|
@@ -7,3 +7,4 @@
|
|
| 7 |
{"timestamp": "2026-09-20T19:34:57.435307+00:00", "auditor_id": "compliance_lead_01", "claim_id": "clm_test_99", "anchor_text": "Verified operational override in production dashboard.", "positive_label": "HUMAN_OVERSIGHT", "negative_label": "IRRELEVANT_TEXT", "verified_assertion_status": "IMPLEMENTED", "auditor_notes": "Verified operational override in production dashboard."}
|
| 8 |
{"timestamp": "2026-09-20T19:37:14.849175+00:00", "auditor_id": "compliance_lead_01", "claim_id": "clm_test_99", "anchor_text": "Verified operational override in production dashboard.", "positive_label": "HUMAN_OVERSIGHT", "negative_label": "IRRELEVANT_TEXT", "verified_assertion_status": "IMPLEMENTED", "auditor_notes": "Verified operational override in production dashboard."}
|
| 9 |
{"timestamp": "2026-09-20T19:38:35.112557+00:00", "auditor_id": "compliance_lead_01", "claim_id": "clm_test_99", "anchor_text": "Verified operational override in production dashboard.", "positive_label": "HUMAN_OVERSIGHT", "negative_label": "IRRELEVANT_TEXT", "verified_assertion_status": "IMPLEMENTED", "auditor_notes": "Verified operational override in production dashboard."}
|
|
|
|
|
|
| 7 |
{"timestamp": "2026-09-20T19:34:57.435307+00:00", "auditor_id": "compliance_lead_01", "claim_id": "clm_test_99", "anchor_text": "Verified operational override in production dashboard.", "positive_label": "HUMAN_OVERSIGHT", "negative_label": "IRRELEVANT_TEXT", "verified_assertion_status": "IMPLEMENTED", "auditor_notes": "Verified operational override in production dashboard."}
|
| 8 |
{"timestamp": "2026-09-20T19:37:14.849175+00:00", "auditor_id": "compliance_lead_01", "claim_id": "clm_test_99", "anchor_text": "Verified operational override in production dashboard.", "positive_label": "HUMAN_OVERSIGHT", "negative_label": "IRRELEVANT_TEXT", "verified_assertion_status": "IMPLEMENTED", "auditor_notes": "Verified operational override in production dashboard."}
|
| 9 |
{"timestamp": "2026-09-20T19:38:35.112557+00:00", "auditor_id": "compliance_lead_01", "claim_id": "clm_test_99", "anchor_text": "Verified operational override in production dashboard.", "positive_label": "HUMAN_OVERSIGHT", "negative_label": "IRRELEVANT_TEXT", "verified_assertion_status": "IMPLEMENTED", "auditor_notes": "Verified operational override in production dashboard."}
|
| 10 |
+
{"timestamp": "2026-09-20T19:47:07.934259+00:00", "auditor_id": "compliance_lead_01", "claim_id": "clm_test_99", "anchor_text": "Verified operational override in production dashboard.", "positive_label": "HUMAN_OVERSIGHT", "negative_label": "IRRELEVANT_TEXT", "verified_assertion_status": "IMPLEMENTED", "auditor_notes": "Verified operational override in production dashboard."}
|
src/ontology/builder.py
CHANGED
|
@@ -5,6 +5,7 @@ binding them to formal legal ontologies.
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
from typing import Tuple, Dict, Any, List
|
|
|
|
| 8 |
import rdflib
|
| 9 |
from rdflib import Graph, URIRef, Literal, RDF, RDFS, XSD
|
| 10 |
|
|
@@ -61,8 +62,20 @@ class NormativeGraphBuilder:
|
|
| 61 |
|
| 62 |
sys_uri = REGU[f"system_{spec.metadata.system_id.replace('-', '_')}"]
|
| 63 |
|
| 64 |
-
# System Node & Typing
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
g.add((sys_uri, RDF.type, REGU.HighRiskAISystem))
|
| 67 |
else:
|
| 68 |
g.add((sys_uri, RDF.type, REGU.AISystem))
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
from typing import Tuple, Dict, Any, List
|
| 8 |
+
import re
|
| 9 |
import rdflib
|
| 10 |
from rdflib import Graph, URIRef, Literal, RDF, RDFS, XSD
|
| 11 |
|
|
|
|
| 62 |
|
| 63 |
sys_uri = REGU[f"system_{spec.metadata.system_id.replace('-', '_')}"]
|
| 64 |
|
| 65 |
+
# System Node & Regulatory Typing
|
| 66 |
+
risk_class_lower = spec.metadata.eu_risk_classification.lower()
|
| 67 |
+
is_prohibited = "prohibited" in risk_class_lower or bool(re.search(r"\barticle\s*5\b", risk_class_lower))
|
| 68 |
+
|
| 69 |
+
if is_prohibited:
|
| 70 |
+
g.add((sys_uri, RDF.type, REGU.ProhibitedAISystem))
|
| 71 |
+
g.add((sys_uri, REGU.prohibitionStatus, REGU.ProhibitedPracticeDetected))
|
| 72 |
+
g.add((sys_uri, REGU.hasProhibitedPracticeType, REGU.ProhibitedPracticeDetected))
|
| 73 |
+
elif "general purpose" in risk_class_lower or "gpai" in risk_class_lower:
|
| 74 |
+
if "systemic" in risk_class_lower or "article 51" in risk_class_lower:
|
| 75 |
+
g.add((sys_uri, RDF.type, REGU.GPAISystemicRiskModel))
|
| 76 |
+
else:
|
| 77 |
+
g.add((sys_uri, RDF.type, REGU.GPAIModel))
|
| 78 |
+
elif "high-risk" in risk_class_lower or "annex iii" in risk_class_lower or "annex i" in risk_class_lower:
|
| 79 |
g.add((sys_uri, RDF.type, REGU.HighRiskAISystem))
|
| 80 |
else:
|
| 81 |
g.add((sys_uri, RDF.type, REGU.AISystem))
|
src/ontology/shacl/gpai_shapes.ttl
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
| 2 |
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
| 3 |
+
@prefix sh: <http://www.w3.org/ns/shacl#> .
|
| 4 |
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
| 5 |
+
@prefix regu: <http://regu.ai/schema#> .
|
| 6 |
+
@prefix eu: <http://data.europa.eu/eli/reg/2024/1689#> .
|
| 7 |
+
|
| 8 |
+
# =========================================================================
|
| 9 |
+
# ReguAI Normative SHACL Shape Validation: General-Purpose AI (GPAI)
|
| 10 |
+
# Regulation (EU) 2024/1689 - Chapter V (Articles 51, 53, 55)
|
| 11 |
+
# =========================================================================
|
| 12 |
+
|
| 13 |
+
regu:GPAISystemicRiskShape
|
| 14 |
+
a sh:NodeShape ;
|
| 15 |
+
sh:targetClass regu:GPAISystemicRiskModel ;
|
| 16 |
+
sh:name "EU AI Act Chapter V GPAI with Systemic Risk Conformity Shape" ;
|
| 17 |
+
sh:description "Enforces mandatory requirements for General-Purpose AI Models with Systemic Risk (> 10^25 FLOPs) under Articles 51, 53, and 55." ;
|
| 18 |
+
|
| 19 |
+
# ---------------------------------------------------------------------
|
| 20 |
+
# Article 53: Technical Documentation (Annex XI)
|
| 21 |
+
# ---------------------------------------------------------------------
|
| 22 |
+
sh:property [
|
| 23 |
+
sh:path regu:hasTechnicalDocumentation ;
|
| 24 |
+
sh:minCount 1 ;
|
| 25 |
+
sh:severity sh:Violation ;
|
| 26 |
+
sh:message "EU AI Act Art 53(1)(a) Non-Conformity: Providers of general-purpose AI models must draw up and keep up-to-date technical documentation of the model (Annex XI)." ;
|
| 27 |
+
] ;
|
| 28 |
+
sh:property [
|
| 29 |
+
sh:path ( regu:hasTechnicalDocumentation regu:implementationStatus ) ;
|
| 30 |
+
sh:hasValue regu:Implemented ;
|
| 31 |
+
sh:severity sh:Violation ;
|
| 32 |
+
sh:message "EU AI Act Art 53(1)(a) Non-Conformity: GPAI technical documentation package must be 'Implemented' and available for the AI Office." ;
|
| 33 |
+
] ;
|
| 34 |
+
|
| 35 |
+
# ---------------------------------------------------------------------
|
| 36 |
+
# Article 53(1)(c): Copyright Compliance & TDM Opt-Out
|
| 37 |
+
# ---------------------------------------------------------------------
|
| 38 |
+
sh:property [
|
| 39 |
+
sh:path regu:hasDataGovernance ;
|
| 40 |
+
sh:minCount 1 ;
|
| 41 |
+
sh:severity sh:Violation ;
|
| 42 |
+
sh:message "EU AI Act Art 53(1)(c) Non-Conformity: Providers of GPAI models must put in place a policy to comply with Union copyright law (Directive (EU) 2019/790) and respect text and data mining opt-outs." ;
|
| 43 |
+
] ;
|
| 44 |
+
|
| 45 |
+
# ---------------------------------------------------------------------
|
| 46 |
+
# Article 55: Adversarial Red-Teaming & Safety Evaluation
|
| 47 |
+
# ---------------------------------------------------------------------
|
| 48 |
+
sh:property [
|
| 49 |
+
sh:path regu:hasCybersecurityControl ;
|
| 50 |
+
sh:minCount 1 ;
|
| 51 |
+
sh:severity sh:Violation ;
|
| 52 |
+
sh:message "EU AI Act Art 55(1)(a) Non-Conformity: Providers of GPAI models with systemic risk must conduct and document continuous adversarial testing (red-teaming) to identify and mitigate systemic risks." ;
|
| 53 |
+
] ;
|
| 54 |
+
sh:property [
|
| 55 |
+
sh:path ( regu:hasCybersecurityControl regu:implementationStatus ) ;
|
| 56 |
+
sh:hasValue regu:Implemented ;
|
| 57 |
+
sh:severity sh:Violation ;
|
| 58 |
+
sh:message "EU AI Act Art 55(1)(a) Non-Conformity: Adversarial red-teaming defenses must be verified as 'Implemented'." ;
|
| 59 |
+
] ;
|
| 60 |
+
|
| 61 |
+
# ---------------------------------------------------------------------
|
| 62 |
+
# Article 55(1)(b): Systemic Risk Mitigation & Monitoring
|
| 63 |
+
# ---------------------------------------------------------------------
|
| 64 |
+
sh:property [
|
| 65 |
+
sh:path regu:hasRiskManagementSystem ;
|
| 66 |
+
sh:minCount 1 ;
|
| 67 |
+
sh:severity sh:Violation ;
|
| 68 |
+
sh:message "EU AI Act Art 55(1)(b) Non-Conformity: Providers of GPAI models with systemic risk must continuously assess and mitigate systemic risks, including serious incidents." ;
|
| 69 |
+
] ;
|
| 70 |
+
sh:property [
|
| 71 |
+
sh:path ( regu:hasRiskManagementSystem regu:implementationStatus ) ;
|
| 72 |
+
sh:hasValue regu:Implemented ;
|
| 73 |
+
sh:severity sh:Violation ;
|
| 74 |
+
sh:message "EU AI Act Art 55(1)(b) Non-Conformity: Systemic risk management system must be 'Implemented'." ;
|
| 75 |
+
] .
|
src/ontology/shacl/prohibited_shapes.ttl
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
| 2 |
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
| 3 |
+
@prefix sh: <http://www.w3.org/ns/shacl#> .
|
| 4 |
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
| 5 |
+
@prefix regu: <http://regu.ai/schema#> .
|
| 6 |
+
@prefix eu: <http://data.europa.eu/eli/reg/2024/1689#> .
|
| 7 |
+
|
| 8 |
+
# =========================================================================
|
| 9 |
+
# ReguAI Normative SHACL Shape Validation: Article 5 Prohibited AI Practices
|
| 10 |
+
# Regulation (EU) 2024/1689 - Chapter II (Prohibited Practices)
|
| 11 |
+
# =========================================================================
|
| 12 |
+
|
| 13 |
+
regu:ProhibitedAISystemShape
|
| 14 |
+
a sh:NodeShape ;
|
| 15 |
+
sh:targetClass regu:ProhibitedAISystem ;
|
| 16 |
+
sh:name "EU AI Act Article 5 Prohibited Practice Mandatory Ban Shape" ;
|
| 17 |
+
sh:description "Enforces the absolute statutory prohibition on placing on the market, putting into service or using AI systems under Article 5." ;
|
| 18 |
+
|
| 19 |
+
sh:property [
|
| 20 |
+
sh:path regu:prohibitionStatus ;
|
| 21 |
+
sh:hasValue regu:PermittedSystem ;
|
| 22 |
+
sh:severity sh:Violation ;
|
| 23 |
+
sh:message "EU AI Act Art 5 Non-Conformity: The AI system engages in an explicitly prohibited AI practice under Article 5 (unacceptable risk). Placing on the market, putting into service or using this system is strictly unlawful across the European Union." ;
|
| 24 |
+
] ;
|
| 25 |
+
|
| 26 |
+
sh:property [
|
| 27 |
+
sh:path regu:hasProhibitedPracticeType ;
|
| 28 |
+
sh:maxCount 0 ;
|
| 29 |
+
sh:severity sh:Violation ;
|
| 30 |
+
sh:message "EU AI Act Art 5(1) Non-Conformity: Detected prohibited AI capability (e.g. emotion recognition in workplace/education, social scoring, biometric scraping, or subliminal manipulation). Immediate market withdrawal required." ;
|
| 31 |
+
] .
|
tests/test_shacl_engine.py
CHANGED
|
@@ -51,3 +51,29 @@ def test_non_compliant_hr_fails(components):
|
|
| 51 |
assert any("14" in art for art in violation_articles)
|
| 52 |
assert any("10" in art for art in violation_articles)
|
| 53 |
assert score < 80.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
assert any("14" in art for art in violation_articles)
|
| 52 |
assert any("10" in art for art in violation_articles)
|
| 53 |
assert score < 80.0
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def test_prohibited_emotion_recognition_fails(components):
|
| 57 |
+
proh_file = SYNTHETIC_DIR / "prohibited_emotion_recognition_workplace.json"
|
| 58 |
+
spec = components["parser"].parse_file(proh_file)
|
| 59 |
+
spec = components["extractor"].enrich_system_specification(spec)
|
| 60 |
+
graph = components["builder"].build_system_graph(spec)
|
| 61 |
+
|
| 62 |
+
conforms, violations, warnings, score = components["engine"].validate_system(graph)
|
| 63 |
+
|
| 64 |
+
assert conforms is False
|
| 65 |
+
assert len(violations) >= 1
|
| 66 |
+
violation_articles = [v.regulatory_article for v in violations]
|
| 67 |
+
# Must flag Article 5 Prohibited Practice
|
| 68 |
+
assert any("5" in art for art in violation_articles)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def test_gpai_foundation_llm_evaluates(components):
|
| 72 |
+
gpai_file = SYNTHETIC_DIR / "gpai_foundation_llm.json"
|
| 73 |
+
spec = components["parser"].parse_file(gpai_file)
|
| 74 |
+
spec = components["extractor"].enrich_system_specification(spec)
|
| 75 |
+
graph = components["builder"].build_system_graph(spec)
|
| 76 |
+
|
| 77 |
+
conforms, violations, warnings, score = components["engine"].validate_system(graph)
|
| 78 |
+
assert conforms is True
|
| 79 |
+
assert len(violations) == 0
|