# Tutorial: AI Guardrails (Phase 2)

Detect and engage rogue or compromised enterprise LLM agents using decoy MCP
tool traps, canary RAG docs, CI/developer exclusion, and progressive lures.

**Time:** ~30-45 minutes  
**Plane:** sensor/decoy (+ optional PLG `chn-ai` / `chn-canary`)

## Prerequisites

- Phase 1 Living Sensor path available (engine-only is fine; Ops not required)
- `go test` for engine packages; optional Python 3.10+ for `chn-ai`

## 1. Decoy MCP traps + canary RAG (TDD-350)

```bash
cd engine
go test ./internal/protocol/mcpdecoy/ -run TDD350 -count=1
go test ./internal/aileval/ -run TDD350 -count=1
```

Decoy traffic is tagged `chn.decoy_traffic=true` and **never** enters production
LLM evaluation metrics.

Arm the built-in Phase 2 trap tool set when no custom MCP tools file is used:

```bash
export CYBERHALLUCINET_MCP_PHASE2_TRAPS=1
```

## 2. CI/localhost exclusion (TDD-351)

Signed allowlists route developer/CI hits to the Developer Sandbox Log.
Source-IP-only rules cannot silently suppress SOC without `suppress_soc: true`.

```bash
go test ./internal/ciexclusion/ -run TDD351 -count=1
```

## 3. AI Risk Governance Pack + Article 15 (TDD-352)

```bash
go test ./internal/aigov/ -run TDD352 -count=1
```

Ops HTTP export (when Ops is running): `GET /api/export/aigov`: see
[ops-exports.md](../how-to/ops-exports.md).

See [AI Risk Governance README](../governance/ai-risk-governance/README.md).
Mapping/evidence only: **not** an EU AI Act conformity claim.

## 4. `chn-ai` inject (TDD-353)

```bash
cd ../satellites/chn-ai
python3 -m pytest tests/ -k tdd353 -q
```

Import canary IDs into Ops inventory via `export_canary_ids_for_ops`.

## 5. Counter-agentic probes + progressive lures (TDD-354 / TDD-356)

```bash
cd ../../engine
go test ./internal/agentprobe/ -run TDD354 -count=1
go test ./internal/progressivelure/ -run TDD356 -count=1
```

Wire bytes are score-independent (SEC-AI-001). Sensor progressive lures refuse
outbound callbacks.

Arm on a live sensor (default off):

```bash
export CYBERHALLUCINET_COUNTER_AGENTIC_PACK=1
export CYBERHALLUCINET_PROGRESSIVE_LURE=1
```

How-to: [counter-agentic-pack.md](../how-to/counter-agentic-pack.md).

## 6. Healthcare / Retail packs (TDD-355)

```bash
go test ./tests/deploy/ -run TDD355 -count=1
```

Synthetic PHI / payment lures only; HIPAA/PCI language is **mapping only**.

## Ops AI Findings (stub)

Ops AI Findings UX consumes Class B progressive-lure / MCP assessment events.
Documented stub: `progressivelure.OpsAIFindingsStub`.
