@musashishao/agent-kit 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
  2. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
  3. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
  4. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
  5. package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
  6. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
  7. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
  8. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  9. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  10. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  11. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  12. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  13. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  14. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  15. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
  16. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  17. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  18. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  19. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  20. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
  21. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
  22. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  23. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  24. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
  25. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
  26. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +487 -0
  27. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +76 -0
  28. package/.agent/adr/ADR-TEMPLATE.md +57 -0
  29. package/.agent/adr/README.md +30 -0
  30. package/.agent/agents/backend-specialist.md +1 -1
  31. package/.agent/agents/devops-engineer.md +1 -1
  32. package/.agent/agents/performance-optimizer.md +1 -1
  33. package/.agent/agents/security-auditor.md +1 -1
  34. package/.agent/dashboard/index.html +169 -0
  35. package/.agent/rules/REFERENCE.md +14 -0
  36. package/.agent/skills/ai-incident-management/SKILL.md +517 -0
  37. package/.agent/skills/ai-security-guardrails/SKILL.md +405 -0
  38. package/.agent/skills/ai-security-guardrails/owasp-llm-top10.md +160 -0
  39. package/.agent/skills/ai-security-guardrails/scripts/prompt_injection_scanner.py +230 -0
  40. package/.agent/skills/compliance-for-ai/SKILL.md +411 -0
  41. package/.agent/skills/observability-patterns/SKILL.md +484 -0
  42. package/.agent/skills/observability-patterns/scripts/otel_validator.py +330 -0
  43. package/.agent/skills/opentelemetry-expert/SKILL.md +738 -0
  44. package/.agent/skills/opentelemetry-expert/scripts/trace_analyzer.py +351 -0
  45. package/.agent/skills/privacy-preserving-dev/SKILL.md +442 -0
  46. package/.agent/skills/privacy-preserving-dev/scripts/pii_scanner.py +285 -0
  47. package/package.json +4 -1
@@ -0,0 +1,230 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Skill: ai-security-guardrails
4
+ Script: prompt_injection_scanner.py
5
+ Purpose: Scan code for prompt injection vulnerabilities and AI security issues
6
+ Usage: python prompt_injection_scanner.py <project_path> [--output json|summary]
7
+ Output: JSON with security findings
8
+
9
+ This script checks for:
10
+ 1. Unsafe prompt construction (string concatenation)
11
+ 2. Missing input sanitization
12
+ 3. Direct output rendering
13
+ 4. Insecure tool/function patterns
14
+ """
15
+ import os
16
+ import sys
17
+ import re
18
+ import json
19
+ import argparse
20
+ from pathlib import Path
21
+ from typing import Dict, List, Any
22
+ from datetime import datetime
23
+
24
+ # Fix console encoding
25
+ try:
26
+ sys.stdout.reconfigure(encoding='utf-8', errors='replace')
27
+ sys.stderr.reconfigure(encoding='utf-8', errors='replace')
28
+ except AttributeError:
29
+ pass
30
+
31
+ # ============================================================================
32
+ # CONFIGURATION
33
+ # ============================================================================
34
+
35
+ SKIP_DIRS = {'node_modules', '.git', 'dist', 'build', '__pycache__', '.venv', 'venv', '.next'}
36
+ CODE_EXTENSIONS = {'.js', '.ts', '.jsx', '.tsx', '.py', '.go'}
37
+
38
+ # Vulnerability patterns
39
+ INJECTION_PATTERNS = [
40
+ # Unsafe prompt construction
41
+ (r'`[^`]*\$\{[^}]*user[^}]*\}[^`]*`.*(?:openai|anthropic|llm|prompt)',
42
+ "Template literal with user input in prompt", "high", "LLM01"),
43
+ (r'f"[^"]*\{[^}]*user[^}]*\}[^"]*".*(?:prompt|message|content)',
44
+ "F-string with user input in prompt", "high", "LLM01"),
45
+ (r'prompt\s*[+=]\s*user',
46
+ "String concatenation in prompt", "high", "LLM01"),
47
+ (r'messages\.(?:push|append)\s*\([^)]*user',
48
+ "Direct user input in messages array", "medium", "LLM01"),
49
+
50
+ # Missing sanitization
51
+ (r'(?:req|request)\.(?:body|query|params)\.[a-zA-Z]+\s*(?:\)|,)',
52
+ "Direct request input usage (check for sanitization)", "medium", "LLM01"),
53
+
54
+ # Insecure output handling
55
+ (r'dangerouslySetInnerHTML.*(?:response|completion|output)',
56
+ "LLM output in dangerouslySetInnerHTML", "critical", "LLM02"),
57
+ (r'innerHTML\s*=.*(?:response|completion|output)',
58
+ "LLM output in innerHTML", "critical", "LLM02"),
59
+ (r'eval\s*\(.*(?:response|completion|output)',
60
+ "Eval on LLM output", "critical", "LLM02"),
61
+ (r'exec\s*\(.*(?:response|completion|output)',
62
+ "Exec on LLM output", "critical", "LLM02"),
63
+
64
+ # Function/tool calling risks
65
+ (r'function[_-]?call.*(?:execute|run|eval)',
66
+ "Dynamic function execution from LLM", "high", "LLM07"),
67
+ (r'tool[_-]?use.*(?:shell|exec|system)',
68
+ "Shell execution in tool", "critical", "LLM07"),
69
+
70
+ # Sensitive data in prompts
71
+ (r'(?:api[_-]?key|password|secret|token)\s*.*(?:prompt|message)',
72
+ "Potential secret in prompt construction", "high", "LLM06"),
73
+ (r'(?:system[_-]?prompt|instructions).*(?:include|contain).*(?:key|password)',
74
+ "Secret reference in system prompt", "high", "LLM06"),
75
+ ]
76
+
77
+ # Good patterns (reduce false positives)
78
+ SAFE_PATTERNS = [
79
+ r'sanitize',
80
+ r'validate',
81
+ r'escape',
82
+ r'filter',
83
+ r'clean',
84
+ ]
85
+
86
+
87
+ # ============================================================================
88
+ # SCANNING FUNCTIONS
89
+ # ============================================================================
90
+
91
+ def is_likely_safe(line: str) -> bool:
92
+ """Check if line contains safety measures."""
93
+ return any(re.search(pattern, line, re.IGNORECASE) for pattern in SAFE_PATTERNS)
94
+
95
+
96
+ def scan_file(filepath: Path, project_path: Path) -> List[Dict[str, Any]]:
97
+ """Scan a single file for injection vulnerabilities."""
98
+ findings = []
99
+
100
+ try:
101
+ with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
102
+ lines = f.readlines()
103
+
104
+ for line_num, line in enumerate(lines, 1):
105
+ # Skip comments
106
+ stripped = line.strip()
107
+ if stripped.startswith('//') or stripped.startswith('#') or stripped.startswith('*'):
108
+ continue
109
+
110
+ for pattern, desc, severity, owasp in INJECTION_PATTERNS:
111
+ if re.search(pattern, line, re.IGNORECASE):
112
+ # Check for nearby safety measures
113
+ context_start = max(0, line_num - 3)
114
+ context_end = min(len(lines), line_num + 2)
115
+ context = ''.join(lines[context_start:context_end])
116
+
117
+ if is_likely_safe(context):
118
+ severity = "low" # Downgrade if safety measures nearby
119
+
120
+ findings.append({
121
+ "file": str(filepath.relative_to(project_path)),
122
+ "line": line_num,
123
+ "issue": desc,
124
+ "severity": severity,
125
+ "owasp": owasp,
126
+ "snippet": line.strip()[:100]
127
+ })
128
+ except Exception as e:
129
+ pass
130
+
131
+ return findings
132
+
133
+
134
+ def scan_project(project_path: str) -> Dict[str, Any]:
135
+ """Scan entire project for AI security vulnerabilities."""
136
+ results = {
137
+ "project": project_path,
138
+ "timestamp": datetime.now().isoformat(),
139
+ "findings": [],
140
+ "summary": {
141
+ "total": 0,
142
+ "critical": 0,
143
+ "high": 0,
144
+ "medium": 0,
145
+ "low": 0,
146
+ "by_owasp": {}
147
+ }
148
+ }
149
+
150
+ project = Path(project_path)
151
+
152
+ for root, dirs, files in os.walk(project):
153
+ dirs[:] = [d for d in dirs if d not in SKIP_DIRS]
154
+
155
+ for file in files:
156
+ ext = Path(file).suffix.lower()
157
+ if ext not in CODE_EXTENSIONS:
158
+ continue
159
+
160
+ filepath = Path(root) / file
161
+ file_findings = scan_file(filepath, project)
162
+ results["findings"].extend(file_findings)
163
+
164
+ # Calculate summary
165
+ for finding in results["findings"]:
166
+ results["summary"]["total"] += 1
167
+ results["summary"][finding["severity"]] += 1
168
+
169
+ owasp = finding["owasp"]
170
+ results["summary"]["by_owasp"][owasp] = results["summary"]["by_owasp"].get(owasp, 0) + 1
171
+
172
+ # Determine status
173
+ if results["summary"]["critical"] > 0:
174
+ results["status"] = "[!!] CRITICAL: AI Security vulnerabilities found"
175
+ elif results["summary"]["high"] > 0:
176
+ results["status"] = "[!] HIGH: Security issues need attention"
177
+ elif results["summary"]["medium"] > 0:
178
+ results["status"] = "[?] REVIEW: Potential issues found"
179
+ else:
180
+ results["status"] = "[OK] No major AI security issues detected"
181
+
182
+ return results
183
+
184
+
185
+ # ============================================================================
186
+ # MAIN
187
+ # ============================================================================
188
+
189
+ def main():
190
+ parser = argparse.ArgumentParser(
191
+ description="Scan for AI/LLM security vulnerabilities (OWASP LLM Top 10)"
192
+ )
193
+ parser.add_argument("project_path", nargs="?", default=".", help="Project directory to scan")
194
+ parser.add_argument("--output", choices=["json", "summary"], default="json",
195
+ help="Output format")
196
+
197
+ args = parser.parse_args()
198
+
199
+ if not os.path.isdir(args.project_path):
200
+ print(json.dumps({"error": f"Directory not found: {args.project_path}"}))
201
+ sys.exit(1)
202
+
203
+ results = scan_project(args.project_path)
204
+
205
+ if args.output == "summary":
206
+ print(f"\n{'='*60}")
207
+ print(f"AI Security Scan: {results['project']}")
208
+ print(f"{'='*60}")
209
+ print(f"Status: {results['status']}")
210
+ print(f"\nFindings by Severity:")
211
+ print(f" Critical: {results['summary']['critical']}")
212
+ print(f" High: {results['summary']['high']}")
213
+ print(f" Medium: {results['summary']['medium']}")
214
+ print(f" Low: {results['summary']['low']}")
215
+ print(f"\nFindings by OWASP Category:")
216
+ for owasp, count in sorted(results['summary']['by_owasp'].items()):
217
+ print(f" {owasp}: {count}")
218
+ print(f"{'='*60}\n")
219
+
220
+ if results['findings']:
221
+ print("Top Issues:")
222
+ for finding in results['findings'][:10]:
223
+ print(f" [{finding['severity'].upper()}] {finding['file']}:{finding['line']}")
224
+ print(f" {finding['issue']}")
225
+ else:
226
+ print(json.dumps(results, indent=2))
227
+
228
+
229
+ if __name__ == "__main__":
230
+ main()
@@ -0,0 +1,411 @@
1
+ ---
2
+ name: compliance-for-ai
3
+ description: GDPR/CCPA requirements for AI systems, SOC2 controls for AI, AI Act (EU) compliance checklist, audit trail requirements, model governance framework.
4
+ allowed-tools: Read, Glob, Grep
5
+ skills:
6
+ - ai-security-guardrails
7
+ - privacy-preserving-dev
8
+ ---
9
+
10
+ # Compliance for AI
11
+
12
+ > Navigate the regulatory landscape for AI systems. Compliance by design.
13
+
14
+ ---
15
+
16
+ ## 1. Regulatory Overview
17
+
18
+ ### Key Regulations
19
+
20
+ | Regulation | Scope | AI Focus |
21
+ |------------|-------|----------|
22
+ | **GDPR** | EU data protection | Automated decision-making, profiling |
23
+ | **CCPA/CPRA** | California privacy | AI inference controls |
24
+ | **EU AI Act** | AI-specific regulation | Risk-based classification |
25
+ | **SOC2** | Trust services | AI system controls |
26
+ | **HIPAA** | Healthcare (US) | AI in medical decisions |
27
+ | **NIST AI RMF** | US AI risk management | Voluntary framework |
28
+
29
+ ---
30
+
31
+ ## 2. GDPR for AI Systems
32
+
33
+ ### Key Requirements
34
+
35
+ | Article | Requirement | AI Application |
36
+ |---------|-------------|----------------|
37
+ | **Art. 13-14** | Transparency | Disclose AI is used |
38
+ | **Art. 15** | Right to Access | Explain AI decisions |
39
+ | **Art. 22** | Automated Decision-Making | Human override option |
40
+ | **Art. 17** | Right to Erasure | Remove from training data |
41
+ | **Art. 25** | Privacy by Design | Build privacy into AI |
42
+
43
+ ### Automated Decision-Making (Art. 22)
44
+
45
+ ```
46
+ When AI makes decisions with "legal or similarly significant effects":
47
+ ├── User must be informed about automated processing
48
+ ├── User can request human review
49
+ ├── Meaningful information about logic must be provided
50
+ └── Suitable safeguards must exist
51
+ ```
52
+
53
+ ### Implementation Checklist
54
+
55
+ - [ ] Disclosure that AI is used
56
+ - [ ] "Meaningful information" about AI logic provided
57
+ - [ ] Human review mechanism for significant decisions
58
+ - [ ] Opt-out option for automated processing
59
+ - [ ] Data minimization in AI training
60
+ - [ ] Right to erasure includes training data
61
+ - [ ] DPIA (Data Protection Impact Assessment) completed
62
+
63
+ ---
64
+
65
+ ## 3. EU AI Act Compliance
66
+
67
+ ### Risk Classification
68
+
69
+ | Risk Level | Examples | Requirements |
70
+ |------------|----------|--------------|
71
+ | **Unacceptable** | Social scoring, manipulation | Prohibited |
72
+ | **High Risk** | HR AI, credit scoring, healthcare | Strict controls |
73
+ | **Limited Risk** | Chatbots, emotion recognition | Transparency |
74
+ | **Minimal Risk** | Spam filters, games | None |
75
+
76
+ ### High-Risk AI Requirements
77
+
78
+ ```
79
+ High-Risk AI Systems Must Have:
80
+ ├── Risk Management System
81
+ │ ├── Identify foreseeable risks
82
+ │ ├── Estimate risks
83
+ │ ├── Adopt mitigation measures
84
+ │ └── Monitor post-deployment
85
+ ├── Data Governance
86
+ │ ├── Training data quality
87
+ │ ├── Bias examination
88
+ │ └── Data minimization
89
+ ├── Technical Documentation
90
+ │ ├── System description
91
+ │ ├── Design specifications
92
+ │ └── Monitoring capabilities
93
+ ├── Record-Keeping
94
+ │ ├── Logs must be automatic
95
+ │ ├── Traceability ensured
96
+ │ └── Retention periods set
97
+ ├── Human Oversight
98
+ │ ├── Ability to override
99
+ │ ├── Ability to stop
100
+ │ └── Awareness of automation bias
101
+ └── Accuracy & Robustness
102
+ ├── Performance metrics defined
103
+ ├── Cybersecurity measures
104
+ └── Resilience to errors
105
+ ```
106
+
107
+ ### Limited Risk Requirements
108
+
109
+ | Requirement | Implementation |
110
+ |-------------|----------------|
111
+ | **Transparency** | "This is an AI assistant" disclosure |
112
+ | **Emotion recognition** | Inform when detecting emotions |
113
+ | **Deep fakes** | Label generated content |
114
+
115
+ ---
116
+
117
+ ## 4. SOC2 Controls for AI
118
+
119
+ ### Trust Service Criteria
120
+
121
+ | Category | AI-Specific Controls |
122
+ |----------|---------------------|
123
+ | **Security** | Model access controls, API auth |
124
+ | **Availability** | Model redundancy, fallback |
125
+ | **Processing Integrity** | Output validation, hallucination detection |
126
+ | **Confidentiality** | Training data protection, prompt security |
127
+ | **Privacy** | PII in prompts/outputs, data minimization |
128
+
129
+ ### Control Examples
130
+
131
+ ```yaml
132
+ # Example SOC2 control mapping
133
+ controls:
134
+ - id: CC6.1
135
+ title: Logical Access Controls
136
+ ai_implementation:
137
+ - API key management
138
+ - Model access by role
139
+ - Audit logging of AI usage
140
+
141
+ - id: CC7.2
142
+ title: System Monitoring
143
+ ai_implementation:
144
+ - LLM response monitoring
145
+ - Hallucination detection alerts
146
+ - Token usage tracking
147
+
148
+ - id: PI1.4
149
+ title: Personal Information Handling
150
+ ai_implementation:
151
+ - PII redaction in prompts
152
+ - Output scanning for PII
153
+ - Training data audit
154
+ ```
155
+
156
+ ---
157
+
158
+ ## 5. Audit Trail Requirements
159
+
160
+ ### What to Log
161
+
162
+ | Event | Required Data |
163
+ |-------|---------------|
164
+ | **AI Request** | Timestamp, user, input hash, model |
165
+ | **AI Response** | Output hash, latency, tokens, cost |
166
+ | **Human Override** | Who, when, original vs new decision |
167
+ | **Model Change** | Version, deployment, rollback |
168
+ | **Access** | Who accessed what, when |
169
+
170
+ ### Log Format
171
+
172
+ ```json
173
+ {
174
+ "event_type": "ai_decision",
175
+ "timestamp": "2025-01-25T10:30:00Z",
176
+ "trace_id": "abc123",
177
+ "user_id": "usr_xxx",
178
+ "model": "gpt-4",
179
+ "model_version": "0613",
180
+ "input_hash": "sha256:abc...",
181
+ "output_hash": "sha256:def...",
182
+ "decision_type": "credit_assessment",
183
+ "confidence_score": 0.85,
184
+ "human_reviewable": true,
185
+ "metadata": {
186
+ "tokens_used": 1500,
187
+ "latency_ms": 1200
188
+ }
189
+ }
190
+ ```
191
+
192
+ ### Retention Requirements
193
+
194
+ | Regulation | Minimum Retention |
195
+ |------------|-------------------|
196
+ | GDPR | "No longer than necessary" + justify |
197
+ | SOC2 | 1 year minimum |
198
+ | HIPAA | 6 years |
199
+ | Financial | 7 years (typically) |
200
+
201
+ ---
202
+
203
+ ## 6. Model Governance Framework
204
+
205
+ ### Lifecycle Governance
206
+
207
+ ```
208
+ ┌─────────────────────────────────────────────────────────────┐
209
+ │ MODEL LIFECYCLE │
210
+ ├──────────────────┬──────────────────┬───────────────────────┤
211
+ │ DEVELOPMENT │ DEPLOYMENT │ OPERATIONS │
212
+ ├──────────────────┼──────────────────┼───────────────────────┤
213
+ │ • Data sourcing │ • Model registry │ • Performance monitor │
214
+ │ • Bias testing │ • A/B testing │ • Drift detection │
215
+ │ • Documentation │ • Canary deploy │ • Incident response │
216
+ │ • Review board │ • Rollback plan │ • Retraining triggers │
217
+ └──────────────────┴──────────────────┴───────────────────────┘
218
+ ```
219
+
220
+ ### Model Card Template
221
+
222
+ ```markdown
223
+ # Model Card: [Model Name]
224
+
225
+ ## Model Details
226
+ - **Developer:** [Team/Organization]
227
+ - **Version:** [v1.2.3]
228
+ - **Type:** [Classification/Generation/etc.]
229
+ - **License:** [Commercial/Open Source]
230
+
231
+ ## Intended Use
232
+ - **Primary Use:** [What it's for]
233
+ - **Out-of-Scope:** [What it's NOT for]
234
+ - **Users:** [Who should use it]
235
+
236
+ ## Training Data
237
+ - **Sources:** [Where data came from]
238
+ - **Size:** [Dataset size]
239
+ - **Preprocessing:** [How data was cleaned]
240
+ - **Bias Mitigation:** [Steps taken]
241
+
242
+ ## Evaluation
243
+ - **Metrics:** [Accuracy, F1, etc.]
244
+ - **Datasets:** [Test datasets used]
245
+ - **Bias Testing:** [Results]
246
+
247
+ ## Limitations
248
+ - **Known Issues:** [Documented problems]
249
+ - **Failure Modes:** [When it fails]
250
+ - **Update Plan:** [How often updated]
251
+
252
+ ## Ethical Considerations
253
+ - **Potential Harms:** [Possible negative impacts]
254
+ - **Mitigations:** [Steps to reduce harm]
255
+ ```
256
+
257
+ ---
258
+
259
+ ## 7. Consent Management for AI
260
+
261
+ ### Consent Types
262
+
263
+ | Processing Activity | Consent Required? |
264
+ |--------------------|-------------------|
265
+ | AI-assisted recommendations | Legitimate interest (usually) |
266
+ | AI profiling for decisions | Yes (GDPR Art. 22) |
267
+ | Training on user data | Yes |
268
+ | Selling AI inference | Yes |
269
+
270
+ ### Implementation
271
+
272
+ ```typescript
273
+ interface AIConsentRecord {
274
+ userId: string;
275
+ consents: {
276
+ aiAssistance: boolean; // Using AI in service
277
+ aiDecisions: boolean; // AI making decisions
278
+ aiTraining: boolean; // Data used for training
279
+ profileBuilding: boolean; // AI profiling
280
+ };
281
+ version: string; // Consent form version
282
+ collectedAt: Date;
283
+ method: 'explicit' | 'banner' | 'contract';
284
+ }
285
+
286
+ // Check before AI processing
287
+ async function canProcessWithAI(userId: string, purpose: string): Promise<boolean> {
288
+ const consent = await getConsentRecord(userId);
289
+
290
+ switch (purpose) {
291
+ case 'recommendation':
292
+ return consent.consents.aiAssistance;
293
+ case 'automated_decision':
294
+ return consent.consents.aiDecisions;
295
+ case 'training':
296
+ return consent.consents.aiTraining;
297
+ default:
298
+ return false;
299
+ }
300
+ }
301
+ ```
302
+
303
+ ---
304
+
305
+ ## 8. CCPA/CPRA for AI
306
+
307
+ ### Consumer Rights
308
+
309
+ | Right | AI Application |
310
+ |-------|----------------|
311
+ | **Know** | Disclose AI categories of use |
312
+ | **Delete** | Remove from training data |
313
+ | **Opt-Out** | Stop using data for AI training |
314
+ | **Non-Discrimination** | Same service without AI consent |
315
+
316
+ ### Profiling Disclosure
317
+
318
+ ```text
319
+ NOTICE: We use automated decision-making technology for:
320
+ - Personalized recommendations
321
+ - Risk assessment
322
+ - Content moderation
323
+
324
+ You have the right to:
325
+ - Opt-out of profiling-based decisions
326
+ - Request human review of significant decisions
327
+ - Know the logic involved in automated decisions
328
+ ```
329
+
330
+ ---
331
+
332
+ ## 9. Compliance Checklist
333
+
334
+ ### Pre-Deployment
335
+
336
+ - [ ] Regulatory classification determined
337
+ - [ ] DPIA/Risk assessment completed
338
+ - [ ] Model card documented
339
+ - [ ] Bias testing performed
340
+ - [ ] Human oversight mechanism ready
341
+ - [ ] Consent flows implemented
342
+ - [ ] Disclosure text approved
343
+
344
+ ### Operations
345
+
346
+ - [ ] Audit logging enabled
347
+ - [ ] Retention policies configured
348
+ - [ ] Incident response plan ready
349
+ - [ ] Regular bias monitoring
350
+ - [ ] Quarterly compliance review
351
+ - [ ] Annual third-party audit
352
+
353
+ ### Documentation
354
+
355
+ - [ ] System architecture documented
356
+ - [ ] Data flow diagrams current
357
+ - [ ] Training data provenance recorded
358
+ - [ ] Change log maintained
359
+ - [ ] Compliance evidence collected
360
+
361
+ ---
362
+
363
+ ## 10. Vendor Assessment
364
+
365
+ ### Third-Party AI Checklist
366
+
367
+ | Category | Questions |
368
+ |----------|-----------|
369
+ | **Data Processing** | Where is data processed? Subprocessors? |
370
+ | **Model Training** | Is our data used for training? |
371
+ | **Security** | SOC2 certified? ISO 27001? |
372
+ | **Compliance** | GDPR DPA signed? AI Act ready? |
373
+ | **Transparency** | Model cards available? |
374
+
375
+ ### DPA Requirements for AI
376
+
377
+ ```markdown
378
+ ## Data Processing Agreement Addendum: AI Services
379
+
380
+ 1. **Data Use**
381
+ - Data will NOT be used for model training without explicit consent
382
+ - Data will NOT be shared with other customers
383
+ - Data will be processed only in approved regions
384
+
385
+ 2. **Model Governance**
386
+ - Vendor will provide model versioning
387
+ - Vendor will notify of significant model changes
388
+ - Vendor will provide performance metrics
389
+
390
+ 3. **Audit Rights**
391
+ - Customer may request compliance evidence
392
+ - Vendor will cooperate with regulatory audits
393
+ - Annual SOC2 report will be provided
394
+ ```
395
+
396
+ ---
397
+
398
+ ## 11. Anti-Patterns
399
+
400
+ | ❌ Don't | ✅ Do |
401
+ |----------|-------|
402
+ | Deploy without risk assessment | Complete DPIA before launch |
403
+ | Hide AI usage from users | Transparent disclosure |
404
+ | Train on all user data | Explicit consent for training |
405
+ | Log everything forever | Defined retention with justification |
406
+ | Ignore jurisdiction differences | Map requirements by region |
407
+ | One-time compliance | Continuous monitoring |
408
+
409
+ ---
410
+
411
+ > **Remember:** Compliance is not a checkbox—it's an ongoing commitment to ethical AI development.