ontoloji.orgOpen Reference Hub
Agent Governance13 min read·Updated: 2026-12-03·Türkçe sürüm →

Production Agent Engineering: Adversarial Verification, 3-Layer Permissions & Compaction

Eliminating circular provenance with three hostile review lenses, gating tools with circuit-breaker permissions, and microcompacting long-running agent context.

Executive Summary — Key Takeaways
  • 01Asking an LLM reviewer "is this finding accurate?" invites confirmation bias; commission three distinct hostile lenses—Arithmetic, Interpretive, and Provenance—defaulting to refuted under uncertainty.
  • 02Validation gates keyed only to written tokens reward omission: every compliance or citation gate requires an explicit absence mode.
  • 03Production harnesses combine O(1) static ontology rules, a circuit-broken sidecar classifier, and human write-gates—while microcompacting stale tool outputs in-place.

1. Adversarial Verification & Defeating Circular Provenance

In financial, regulatory, and operational audits, the subtler cousin of hallucination is circular provenance: an earlier export or fixture generated by your own pipeline round-trips through a collaborator’s folder under a new filename, creating the illusion of independent corroboration.

High-stakes verification splits review across three orthogonal hostile lenses rather than N redundant copies of the same prompt:

  • Arithmetic Lens: Recomputes every aggregate and implied ratio (output ÷ activity) from raw records rather than summary tables, exposing undeclared input shifts.
  • Interpretive Lens: Grants every number as true, then attacks whether the numbers actually support the causal or business claim.
  • Provenance Lens: Audits the evidential chain—checking timestamps, SHA-256 byte lineage, build-gate constraints that forced cardinality agreement, and whether a cited URL is an in-force normative act rather than a stale draft.
Token-Keyed Gates Are Blind to Absence

A checker that only flags malformed citations lets a document with zero citations pass cleanly. Pair every token-keyed validator with an absence mode that distinguishes "verified clean" from "omitted / could not parse".

2. The Three-Layer Tool Permission Model With Circuit Breakers

Prompting humans on every read kills adoption; blanket auto-approval invites disaster. Production agent harnesses layer tool authorization into three tiers:

Three-layer permission evaluation with classifier circuit breaker
evaluateToolCall(tool, input, caller):
  // Layer 1: Deterministic O(1) Ontology & Static Rules (~80% of calls)
  if matchesAllowRule(tool, caller.role): return ALLOW
  if matchesDenyRule(tool, input):        return DENY

  // Layer 2: Sidecar Policy Classifier (bounded auto-mode for novel reads)
  if autoMode and denials.consecutive < 3 and denials.total < 20:
    verdict = sidecarClassifier(tool, input, ontologyContext)
    if verdict == "ALLOW": return ALLOW
    trackDenial()

  // Layer 3: Human Write-Gate (all ERP mutations & post-circuit-breaker fallback)
  return ENQUEUE_HUMAN_APPROVAL

3. Three-Tier Context Compaction & Vectorless Hierarchical RAG

Long-running enterprise agents choke on accumulated tool payloads (SQL result sets, schema dumps) needed for a single turn. Three-tier compaction keeps reasoning sharp: Tier 1 Microcompact clears stale tool results in-place with zero LLM latency (180K -> 40K tokens); Tier 2 Full Compact forks a structured summarizer preserving user intent, errors, and active schemas; Tier 3 persists durable lessons to session memory.

For structured ERP manuals and SOPs, pairing ontology queries with a hierarchical tree index (Root -> Module -> Leaf Page summaries, zero embeddings required) lets the agent navigate exact procedural sections without mid-sentence vector chunking.

Glossary Concepts Referenced in This Guide

Open License (CC BY 4.0) · Cite This Page

Free to reference in engineering docs, ADRs, articles, and course syllabi with attribution.

[Production Agent Engineering: Adversarial Verification, 3-Layer Permissions & Compaction — Ontoloji.org](https://ontoloji.org/en/guides/ai-agent-verification-three-layer-permissions-and-context-compaction)

More Guides in This Series

Core Architecture
How AI Uses an Ontology
9 min read
Agent Engineering
Agent Harness vs. Ontology
8 min read
Data Engineering
ERP, CRM & MES Patterns
10 min read
Strategy & Governance
30-Day Ontology Strategy
7 min read
ERP Integration
ERP Ontology Integration Guide
11 min read
ERP Data Engineering
Logo Tiger, Nebim V3 & Turkish Unicode Traps
14 min read
Verification Engineering
Absence-Aware Gates & Ratio Reconstruction
13 min read
Provenance & Governance
Draft vs. Normative Provenance Hygiene
12 min read
SAP & Protocol Architecture
SAP BTP, Cloud Connector & ORD Ontology
11 min read
ERP Write-Safety
Logo REST, Nebim Integrator & UBL-TR Safety
12 min read
Platform Architecture Comparison
Cortex, Genie, dbt & Cube vs. Ontology
12 min read
Systems Engineering & Forensics
ERP Integrator Anti-Patterns & Forensics
13 min read
Platform Architecture Comparison
Fabric IQ, D365 MCP & SAP Joule vs. Ontology
12 min read
Retrieval & RAG Architecture
PageIndex Vectorless Tree RAG vs. Vector DBs
11 min read
Platform Architecture Comparison
Atlan, Stardog & Neo4j vs. Ontology
12 min read
Statutory & Financial Governance
GİB UBL-TR, VUK/TMS 29 & KVKK Ontology
13 min read
Agent Memory & Ontology Architecture
Cognee & Zep Graphiti vs. Ontology
11 min read
Protocol & Multi-Agent Architecture
MCP vs. OpenAPI & Specialist Agents
12 min read
Protocols & Standards
MCP 2026-07-28: Tasks, Events & Apps
13 min read
Agent Architecture & Governance
Agent Harness Engineering Rubric
12 min read
Agent Architecture & Governance
Multi-Agent Task Boards & Mailboxes
12 min read
Verification & Security
Generate-Evaluate-Repair & Observers
12 min read
Verification & Security
NSA MCP Security & CIMD vs. DCR
13 min read
Agent Architecture & Governance
OpenTelemetry for AI Agents & MCP
11 min read