Run the labs#
| Task | Code |
|---|
| PII scrubber and audit log, lesson 25 | code/main.py |
|---|
| Control and profile map, lesson 26 | code/main.py |
|---|
| AI regulation timeline, phase 18 | python3 code/main.py |
|---|
| Webhook demo: 202, 200, 401 | go run . --mode demo |
|---|
| Build the webhook inbox | go build -o /tmp/webhook-inbox . |
|---|
Gateway pulls keys from vault#
Security numbers#
| Setting | Default | Note |
|---|
| Key rotation | ≤ 90 days | Keys, vault root tokens, CI/CD credentials |
|---|
| Token lifetime | hours | Short-lived tokens, not days |
|---|
| Audit retention, SOC 2 | 1 year | Retain per regulation |
|---|
| Audit retention, HIPAA | 6 years | Retain per regulation |
|---|
| Webhook clock skew | 5*time.Minute | Both sides of now |
|---|
| Webhook body size | 1..65536 bytes | Read before any decoding |
|---|
| Webhook secret | WEBHOOK_SECRET | At least 16 bytes |
|---|
--seconds | 60 | Receiver lifetime, 1..600 |
|---|
PII scrubbing#
- Order
- entity recognition, mask, consistent tokenization, optional reverse mapping.
- Lab patterns
SSN, EMAIL and PHONE regexes in scrubber.scrub.- Consistent tokens
- the same value maps to the same placeholder every time.
- Regex and NER
- regex catches basic patterns. NER catches more. Use both.
- When
- before the LLM call. Post-processing cleanup is not defensible.
- Storage
- only redacted prompts plus consented opt-in raw.
- Output guardrail
- regex scrub for leaked API key patterns.
Webhook receiver path#
Webhook inbox commands#
| Command | What it does |
|---|
/tmp/webhook-inbox --mode serve --dir <dir> --listen 127.0.0.1:8141 --seconds 120 | Receive deliveries for 120 seconds |
|---|
/tmp/webhook-inbox --mode sign --id delivery-1 --timestamp <unix> --body fixtures/event.json | Print the three signed headers |
|---|
/tmp/webhook-inbox --mode inspect --dir <dir> --id delivery-1 | Show the stored delivery |
|---|
/tmp/webhook-inbox --mode replay --dir <dir> --id delivery-1 --run review-1 | Process once under run ID review-1 |
|---|
Frameworks and their LLM duty#
- SOC 2 Type II
- controls operate effectively over 6-12 months.
- HIPAA
- no PHI to external AI services without a signed BAA.
- GDPR
- real-time PII redaction, data subject rights, Article 30 records.
- PCI-DSS
- configuration plus contracts for AI that touches payment.
- EU AI Act
- risk tier classification. High-risk needs conformity assessment and logging.
- Colorado AI Act
- impact assessments and right to appeal. Effective June 30, 2026.
- ISO 42001
- AI governance. It pairs with ISO 27001.