Learning: Security + Guardrails¶
How to Use This Page¶
- Think in defense-in-depth layers.
- Test guardrails with realistic adversarial prompts.
- Track both block quality and usability impact.
Lesson 1: Fundamentals¶
Learn prompt injection basics, redaction, and action allowlisting.
What You Learn¶
- How common injection patterns attempt instruction override
- Why sensitive-data redaction must happen before logging
- How allowlists limit unsafe action surface area
Walkthrough¶
- Build basic input checks for injection indicators.
- Add redaction to logs and telemetry fields.
- Enforce allowlist checks before risky tool calls.
Try It Yourself¶
- Run benign and malicious inputs and compare outcomes.
- Verify secrets never appear in stored logs.
- Add one new risky action and ensure policy blocks it.
Lesson 2: Intermediate Patterns¶
Learn layered guardrail pipelines and explainable deny decisions.
What You Learn¶
- How input, context, output, and tool checks work together
- Why deterministic deny rules simplify operations
- How audit metadata supports investigations
Walkthrough¶
- Chain multiple guardrail checks into one policy pipeline.
- Standardize deny reasons and response format.
- Emit safe audit records for blocked events.
Try It Yourself¶
- Create a case that passes input checks but fails tool checks.
- Validate that deny reasons are consistent and actionable.
- Add a safe fallback message for blocked requests.
Lesson 3: Production Patterns¶
Learn red-team regression testing and policy rollout control.
What You Learn¶
- How to measure false-positive and false-negative rates
- Why policy versioning enables safe incremental rollout
- How security regressions should gate releases
Walkthrough¶
- Run a red-team dataset against current policy.
- Analyze misses and over-blocking by category.
- Roll out policy updates gradually with monitoring.
Try It Yourself¶
- Compare two policy versions on the same adversarial set.
- Define one hard block metric for release gating.
- Draft a rollback criterion for policy regressions.
Code Examples¶
- Starter script:
docs/starter/stage10_security_guardrails.py - Stage architecture notes:
docs/roadmap/stage-10-injection-defense-and-guardrails/architecture.md