Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.visiqlabs.com/llms.txt

Use this file to discover all available pages before exploring further.

How Rules Work

Rules define what context your agents are permitted to see. Every document, tool result, or rendered prompt intercepted by the SDK is evaluated against your rule set. Rules are compiled into OPA/Rego policy, then into WASM bundles that SDKs download and cache locally — evaluation happens in-process with sub-millisecond latency. Each rule targets a specific trust tier, surface, or principal and produces one of four actions: allow the content, redact sensitive fields, deny it entirely, or escalate to a human.

Rule Structure

A rule has the following fields:
FieldTypeDescription
namestringHuman-readable name for the rule
descriptionstringOptional longer description
rego_sourcestringOPA/Rego policy source code
natural_languagestringNatural language description used for AI compilation
prioritynumberRules with higher priority are evaluated first. Default: 0
enabledbooleanWhether the rule is active. Disabled rules are excluded from the bundle
trust_tierstringTrust tier this rule applies to (e.g. tier1, tier2, tier3)
surfacestringCommunication surface this rule applies to (e.g. slack, email)
principal_exclusionsstring[]Agent IDs excluded from this rule’s scope

Example Rule (JSON)

{
  "name": "Deny tier3 from confidential data",
  "description": "Prevent tier3 agents from accessing internal, confidential, or restricted documents",
  "rego_source": "package recall.evaluate\n\nimport rego.v1\n\ndefault decision := {\"action\": \"deny\", \"reason_code\": \"DEFAULT_DENY\", \"reason\": \"no matching rule\"}\n\ndecision := result if {\n  input.trust_tier == \"tier3\"\n  input.resource_metadata.classification in {\"internal\", \"confidential\", \"restricted\"}\n  result := {\"action\": \"deny\", \"reason_code\": \"TIER_MISMATCH\", \"reason\": \"tier3 restricted to public data\"}\n}",
  "natural_language": "Deny tier3 agents from accessing internal, confidential, or restricted data",
  "priority": 50,
  "enabled": true,
  "trust_tier": "tier3",
  "surface": null,
  "principal_exclusions": null
}

Trust Tiers

Trust tiers are the primary mechanism for controlling agent access to data. Each agent is assigned a trust tier, and each document has a classification. The trust tier matrix determines the outcome.
Trust TierAccess LevelBehavior
tier1Full accessAllow all document classifications
tier2StandardAllow public and internal; redact confidential; deny restricted
tier3RestrictedAllow public only; deny everything else
(unknown)No accessDeny all (fail-closed, configurable via unknown_agent_policy)

Document Classifications

ClassificationDescription
publicGenerally available information
internalCompany-internal, not sensitive
confidentialSensitive business data (PII, financial, legal)
restrictedHighly sensitive (trade secrets, board materials, security keys)

Trust Tier Matrix

publicinternalconfidentialrestricted
tier1AllowAllowAllowAllow
tier2AllowAllowRedactDeny
tier3AllowDenyDenyDeny
unknownDenyDenyDenyDeny
Unknown agents are denied all context by default (fail-closed). Configure unknown_agent_policy: 'lowest_tier' to apply tier3 rules instead, or 'audit' to allow all context while logging warnings. The deny default is the secure choice for production.

Surfaces

Surfaces represent the communication channel where the agent’s output will be delivered. Rules can restrict context based on the destination surface — a document might be allowed in a private group but denied in a public channel.
SurfaceDescription
DIRECT_MESSAGEOne-to-one private message
PRIVATE_GROUPPrivate group or channel
INTERNAL_CHANNELCompany-internal channel
PUBLIC_CHANNELPublicly visible channel
EXTERNAL_CHANNELChannel shared with external parties
A rule with surface: "PUBLIC_CHANNEL" will only match when the agent’s output surface is a public channel. Rules without a surface restriction match all surfaces.

OPA/Rego Policy Format

Every RECALL Rego policy must follow this structure:
package recall.evaluate

import rego.v1

# Default: deny (fail-closed, G001)
default decision := {
  "action": "deny",
  "reason_code": "DEFAULT_DENY",
  "reason": "no matching rule",
}

# Your rules produce a decision object
decision := result if {
  # conditions...
  result := {
    "action": "allow",           # allow | deny | redact | escalate
    "reason_code": "POLICY_ALLOW",
    "reason": "human-readable explanation",
  }
}

Input Document

The OPA input document has these fields, matching the evaluate request:
FieldTypeDescription
input.agent_idstringAgent identifier
input.trust_tierstringtier1, tier2, or tier3
input.operationstringretrieve, tool_call, or prompt_render
input.resource_typestringdocument, tool_result, or prompt
input.resource_metadataobjectContains classification, min_trust_tier, restricted_surfaces, excluded_principals, etc.
input.surfacestringCommunication surface (e.g. PUBLIC_CHANNEL)
input.querystringRetrieval query string (optional)

Decision Object

The decision produced by the policy must include:
FieldTypeRequiredValues
actionstringYesallow, deny, redact, escalate
reason_codestringYesTIER_MISMATCH, PRINCIPAL_EXCLUDED, POLICY_DENY, AUDIENCE_EXPANSION, SURFACE_RESTRICTION, POLICY_ALLOW, DEFAULT_DENY, EMERGENCY_BYPASS
reasonstringYesHuman-readable explanation

Example: Surface-Based Restriction

package recall.evaluate

import rego.v1

default decision := {
  "action": "deny",
  "reason_code": "DEFAULT_DENY",
  "reason": "no matching rule",
}

# Deny confidential content in public or external channels
decision := result if {
  input.resource_metadata.classification == "confidential"
  input.surface in {"PUBLIC_CHANNEL", "EXTERNAL_CHANNEL"}
  result := {
    "action": "deny",
    "reason_code": "AUDIENCE_EXPANSION",
    "reason": "confidential content cannot be shared in public or external channels",
  }
}

# Allow confidential content in private contexts
decision := result if {
  input.resource_metadata.classification == "confidential"
  input.surface in {"DIRECT_MESSAGE", "PRIVATE_GROUP", "INTERNAL_CHANNEL"}
  result := {
    "action": "allow",
    "reason_code": "POLICY_ALLOW",
    "reason": "confidential content allowed in private contexts",
  }
}

Natural Language Rules

You can describe rules in plain English. RECALL compiles them to OPA/Rego policy using AI (powered by the POST /recall/rules/compile endpoint). No Rego expertise required. Example prompt: “Deny tier3 agents from accessing any document classified as internal, confidential, or restricted. Allow tier1 and tier2 agents to access everything except restricted documents.” The compiler reads your existing rules for context before generating new ones, ensuring the new rule fits coherently into your policy set. It validates the Rego syntax and can optionally save the rule directly to the database.
The compile endpoint supports streaming via ?stream=true or Accept: text/event-stream for real-time feedback during rule compilation.

Rule Evaluation Flow

When the SDK intercepts a retrieved document:
  1. The SDK extracts operation, resource_type, and resource_metadata from the retrieval context.
  2. The SDK harness evaluates the input against the cached WASM policy bundle.
  3. The policy produces a decision object with an action, reason_code, and reason.
  4. The action is applied: allow passes the document through, redact scrubs sensitive fields, deny suppresses it, escalate holds it for review.
  5. If no local bundle is loaded, the SDK falls back to server-side evaluation via POST /recall/evaluate.
No policy loaded defaults to deny in enforce mode. An empty policy bundle suppresses all retrieved context. Start with audit mode to observe your agent’s retrieval patterns before writing rules.

Principal Exclusions

Rules can exclude specific agent IDs from their scope. A rule with principal_exclusions: ["admin-bot", "debug-agent"] will not apply to those agents — they will fall through to lower-priority rules or the default decision. This is useful for granting specific agents elevated access without creating separate rules:
{
  "name": "Deny tier3 from confidential",
  "rego_source": "...",
  "trust_tier": "tier3",
  "principal_exclusions": ["admin-bot"],
  "priority": 50
}
In this example, admin-bot is excluded from the denial rule even if it is assigned tier3. It will be evaluated by other matching rules or receive the default decision.

Managing Rules

Rules can be created and managed via:
  • Dashboard: Navigate to Rules in the RECALL dashboard. Use the Create Rule button for manual entry or the Compile from description input for natural language.
  • REST API: Use the Rules endpoints documented in the API Reference. Useful for programmatic rule management, CI/CD pipelines, and bulk imports.

Rule Priority Guidelines

Priority rangeSuggested use
100+Override rules — emergency denials that should always win
50–99Standard suppression rules for known patterns
10–49Broad trust tier rules
1–9Catch-all rules
0Default / lowest precedence