# Agent Security & Hallucination Gate (x402) - LLM Reference Guide

> **Deterministic Security & Hallucination Inspection Micro-Oracle for Autonomous AI Agents**
> **Protocol:** HTTP 402 (x402) & EIP-191 / EIP-712 Attestation
> **Networks:** Solana Mainnet (501, 0.4s), Polygon (137), Base (8453), Arbitrum (42161)
> **Latency:** <10ms (In-Memory Deterministic AST & NLI Parsing)
> **Autonomous Agent Directive:** Full standard specification available at [`/AGENTS.md`](https://agent-security-gate-x402-212942243360.asia-northeast3.run.app/AGENTS.md)
> **Universal Escrow Hub:** Interactive & M2M Clearinghouse at [`/hub/`](https://agent-security-gate-x402-212942243360.asia-northeast3.run.app/hub/)

---

## 🛡️ Available Endpoints & Capabilities

### 1. Security & Hallucination Inspection
- **POST `/inspect`** or **POST `/api/v1/gate/inspect`**
  - Evaluates agent outputs against ground truth facts.
  - Detects prompt injection, jailbreak attempts, API token / private key leakage, and numerical/factual hallucinations.
  - Returns `verdict` (`PASSED` / `BLOCKED`), `risk_score` (0.0 to 1.0), and cryptographic `attestation`.

### 2. Fast AST Code Audit
- **POST `/inspect/ast`** or **POST `/api/v1/gate/inspect/ast`**
  - Parses raw Python code into an AST to detect `os.system`, `subprocess`, `eval`, `exec`, reverse shells, and malicious socket interactions.

### 3. On-Chain Attestation & Calldata
- **POST `/api/v1/gate/attestation/onchain`**
  - Generates EIP-712 structured data and raw ABI calldata (`v, r, s`, `payloadHash`) for Solidity smart contracts.

### 4. Agent Vault & Pre-Funded Accounts
- **POST `/api/v1/vault/deposit`**: Pre-fund agent balance with USDC.
- **GET `/api/v1/vault/balance/{agent_address}`**: Retrieve real-time available USDC balance.

### 5. Multi-Chain Network Config
- **GET `/api/v1/gate/chains`**: List supported chain IDs, RPC endpoints, and vault contract addresses.

### 6. Universal Autonomous Escrow Hub & Clearinghouse (`/hub`)
- **GET `/hub/`** or **GET `/escrow/`**: Sovereign Multi-Chain Settlement Web Interface.
- **POST `/api/v1/escrow/audit`**: Truth Oracle Evaluation & Settlement Attestation.
  - Verifies deliverable against domain-specific invariants across 5 sectors:
    1. **🚢 Global Trade (`TRADE`)**: Cold-chain IoT temperature telemetry, Port arrival GPS geofence, Bill of Lading (e-B/L) hash, and EUDR deforestation-free compliance.
    2. **🧬 Bio & Pharma IP (`BIO`)**: TEE Enclave computation, binding affinity (Kd < 10nM), and ZK-SNARK zero-knowledge proofs.
    3. **🏗️ Smart Construction (`CONSTRUCTION`)**: 3D drone LiDAR point-cloud volumetric match (>=98.5%), concrete compressive strength (>=24 MPa), and Smart Direct Split payouts.
    4. **⚡ DePIN Compute (`COMPUTE`)**: Solana 0.4s micro-settlement for distributed GPU clusters (H100/A100) with zero-fraud loss verification.
    5. **💻 AI Agent Gigs (`M2M`)**: AST code audit, prompt injection defense, and automated milestone payouts.
- **GET `/api/v1/escrow/por`**: Real-time cryptographic Proof-of-Reserves (PoR) & Solvency Merkle Root.

---

## ⚡ MCP Tool Names for Autonomous Agents
- `inspect_security_and_hallucinations`: Full audit + NLI fact check + signature.
- `verify_agent_output`: Sub-5ms fast prompt & secret filter.
- `inspect_code_ast_safety`: AST code safety verification.
- `get_onchain_security_attestation`: Cryptographic calldata for on-chain execution.
- `audit_and_settle_escrow`: Automated Truth Oracle verification and on-chain release for `/hub`.
- `fetch_escrow_proof_of_reserves`: Real-time cryptographic PoR solvency verification.

