Skip to main content
Glama

Explain why a Rego query is undefined

rego_explain_undefined

Diagnose why a Rego query returns undefined or a default value by tracing evaluation and analyzing rule conditions to pinpoint the exact blocking expression.

Instructions

Diagnose why a fully-qualified Rego query (e.g. "data.authz.allow") produces no value, or falls back to its default. Combines a plain eval, a full-trace eval, and per-condition AST analysis to identify the exact body expression blocking each rule. Handles both runtime failures (trace-based) and indexer elimination (standalone condition eval). A rule written with default allow := false always has a value, so queryResult reports default for it and the same per-rule breakdown follows: the question "why is allow false" is the question this answers. Returns a structured breakdown of which conditions blocked each rule plus a human-readable summary.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputNoInput document (JSON value) for the query.
pathsNoPolicy .rego file paths to load. Mutually exclusive with source.
queryYesFully-qualified rule reference to explain, e.g. "data.authz.allow". Must match the path you would pass to rego_eval.
sourceNoInline Rego source to analyse. Mutually exclusive with paths.
inputPathNoPath to an input JSON file.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.14

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses meaningful behavior beyond the annotations: it combines plain eval, full-trace eval, and per-condition AST analysis; it distinguishes runtime failures from indexer elimination; and it explains the default rule semantics and the 'queryResult' default reporting. This gives the agent a clear model of how the tool works.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The first sentence front-loads the core purpose, and the rest of the description earns its place by explaining edge cases and the internal approach. It is somewhat dense and uses technical terms like 'indexer elimination', but it remains structured and free of filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity and the absence of an output schema, the description provides a solid picture: it covers the input expected, the failure modes handled, the default-rule special case, and what the return value contains. It does not enumerate exact output fields, but 'structured breakdown' plus the queryResult mention is adequate for an agent to infer the result shape.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds value by clarifying the 'query' parameter: it must be a fully-qualified rule reference, matches what would be passed to rego_eval, and defaults are handled specially. This is useful guidance beyond the schema's simple descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a precise verb-resource pairing: 'Diagnose why a fully-qualified Rego query ... produces no value, or falls back to its default.' It gives a concrete example (data.authz.allow) and a clear scope that distinguishes it from eval and decision-explaining siblings by focusing on undefined/default diagnosis.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description clearly states when to use the tool: when a fully-qualified query is undefined or falls back to a default. It also explains how default rules are treated, giving the agent actionable context. It does not explicitly name alternative tools or say when not to use it, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.