Guardrails: Real-Time Query Policy Enforcement

Block destructive queries at the protocol layer before they hit your database

Track
Platform Fundamentals, lesson 4
Length
5 min video
Level
Intermediate
For
Platform Engineer

Tags: intermediateguardrailspolicyai-agentscompliancepostgres

All lessons

Watch this lesson

Enter your work email to open every lesson in hoop University. One email, full access. No spam.

The lesson, in writing.

What you will learn

  • Create a custom guardrail rule and assign it to one or more resources
  • Choose between preset rules and custom pattern-matching rules
  • Demonstrate that a destructive query is blocked at the protocol layer with a clear user-facing message
  • Confirm that blocked queries leave the underlying database unchanged
  • Inspect the audit trail to see the blocked query, the user, the triggered rule, and the timestamp
  • Map guardrail logs to SOC 2, HIPAA, and PCI DSS evidence requirements
  • Understand that guardrails apply equally to queries from human engineers and AI agents

Chapters

  1. Where guardrails fit

    Recap of the access-governance arc so far and intro to the three-act demo: configure, attempt, audit.

  2. Configuring a mass-deletion guardrail

    Walkthrough of the guardrails interface: name, resource assignment, preset versus custom rule, save.

  3. Inspecting the database before the attempt

    As a non-admin in the Postgres demo, viewing users, customers, and orders to set baseline state.

  4. The destructive query gets blocked

    Running the destructive query and watching it return: blocked by the following guardrail rules. User-facing message, no database impact.

  5. How protocol-layer enforcement works

    Why guardrails apply equally to humans and AI agents and how pattern matching evaluates queries before execution.

  6. Audit trail review

    Reviewing the blocked attempt in sessions: query attempted, rule triggered, user, timestamp. SOC 2, HIPAA, and PCI DSS evidence generated automatically.

Key concepts

Guardrail
A real-time execution policy that sits at the protocol layer and evaluates every query before it executes. If a query matches the rule, it is blocked instantly.
Pattern matching
A guardrail rule type that compares incoming queries against a defined pattern. Matching queries are blocked at the protocol layer before reaching the database.
Preset rules
Built-in guardrail templates available out of the box, intended to cover common destructive query patterns without requiring custom configuration.
Custom rules
User-defined guardrail rules. The host uses one to prevent mass deletion in this lesson.
Resource scoping
Each guardrail rule is assigned to one or more specific resources. The rule only enforces on those resources.
Equal coverage for humans and AI agents
Guardrails evaluate queries regardless of origin. A query from an AI agent goes through the same protocol-layer policy check as a query from a human engineer.
Block-and-log
When a guardrail blocks a query, the user receives a clear message, the database is not touched, and the attempt is logged in the session audit trail.

Check what you learned.

4 questions. No clock, no account. Each answer shows the right option and why, and you can change it any time.

Answer 4 short questions about this lesson.

  1. 1When does a guardrail evaluate a query?
  2. 2What happens to the database when a guardrail blocks a query?
  3. 3Which queries get logged in the session audit trail?
  4. 4Why do guardrails apply equally to AI agents and human engineers?