---
name: enterprise-trust-firewall
description: Deterministic 4-stage zero-trust AI agent tool firewall, SQLite WAL micro-USD budget circuit breaker, anti-fake-200 verifier, and schema-drift self-healing proxy at https://trustwall.fastmesh.dev. Blocks outbound SSRF/cloud metadata and OWASP LLM01 indirect prompt injection, redacts >= 15 secret and PII classes bidirectionally, enforces 4D allow/ask/deny budgets, heals schema drift with 24h SHA-256 SLA certificates, and emits tamper-evident SHA-256 TrustAuditReceipts with Zero Payload Retention and strictly $0 charged on HTTP 402/403/422 blocks, empty inputs, or errors.
---

# Enterprise-Trust-Firewall Agent Skill

`Enterprise-Trust-Firewall` (`https://trustwall.fastmesh.dev`, local port `9028`) is a deterministic, zero-dependency (Python 3 stdlib + SQLite WAL) inline trust boundary designed for autonomous coding and operations agents running in Cursor, Codex, Antigravity, whitelisted orchestrators (`gemini-4-hydrogen-medium`, `gemini-4-neon-high`, `gemini-pro-orchestrator-neon`), and custom MCP-compatible runtimes.

Route external HTTP calls, webhook dispatches, and third-party data fetches through `Enterprise-Trust-Firewall` over HTTP REST, native Streamable MCP (`POST /mcp`), `treg hub` (`0%` seller commission), or Causal Bazaar (`w4_f08_enterprise_trust_firewall_v1`).

## Hard Security, Privacy & Billing Guarantees

1. **Zero Payload Retention & Zero Training-Data Resale**: Raw payloads, prompts, headers, and credentials are processed strictly in volatile memory and never persisted to SQLite or plaintext logs. Stored `TrustAuditReceipt` records contain only redacted SHA-256 digests (`input_sha256`, `output_sha256`), category counters, and verdicts.
2. **Strict `$0` Billing on Blocked, Budget-Tripped, Invalid, Empty, or Error Calls**: Any HTTP `402` budget circuit trip, HTTP `403` SSRF/prompt-injection/policy denial, HTTP `400`/`422` invalid input, empty input, or upstream error settles with strictly `charged_micros == 0` and a non-empty `zero_bill_reason`.
3. **Comprehensive SSRF & Metadata Defense**: Unconditionally blocks `169.254.169.254`, `169.254.170.2`, `metadata.google.internal`, `127.0.0.0/8`, RFC1918 (`10/8`, `172.16/12`, `192.168/16`), `::1`, `::ffff:127.0.0.1`, `fc00::/7`, `fe80::/10`, DNS-rebinding private resolutions, and non-HTTP schemes—and re-audits every Stage 4 backup failover URL through Stage 1.
4. **Zero-Overspend SQLite WAL Escrow**: Stage 2 uses `PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000;` with transactional `BEGIN IMMEDIATE` reservation, settlement, and automatic refund across 4D policies (`max_cost_micros`, per-minute sliding-window rate limit, tenant daily budget cap, and allowed domain/tool allowlist).
5. **Zero CAPTCHA Bypasses**: Stage 3 Verify Guard classifies Cloudflare, Turnstile, reCAPTCHA, hCaptcha, SSO login walls, and empty SPA shells returning HTTP `200 OK` honestly, blocks `ArchiveCache` error poisoning, and switches to an authorized backup upstream if provided.

## Operations, Endpoints & Micro-USD Pricing

| Operation | HTTP REST Endpoint | MCP Tool (`POST /mcp`) | Unit Price | 10% Repeat Cache | Blocked / Error Billing |
| :--- | :--- | :--- | :---: | :---: | :---: |
| Stage 1 Audit Gate | `POST /v1/firewall/inspect` | `firewall_inspect` | `$0.0025` (`2500`) | `$0.00025` (`250`) | `$0` (`403`/`422`) |
| Stage 2 Escrow Policy | `POST /v1/firewall/policy-check` | `firewall_policy_check` | `$0.0010` (`1000`) | `$0.00010` (`100`) | `$0` (`402`/`403`) |
| Full 4-Stage Proxy | `POST /v1/firewall/proxy-execute` | `firewall_proxy_execute` | `$0.0100` (`10000`) | `$0.00100` (`1000`) | `$0` (`402`/`403`/err) |
| Stage 3 & 4 Heal | `POST /v1/firewall/heal-response` | `firewall_heal_response` | `$0.0150` (`15000`) | `$0.00150` (`1500`) | `$0` (`422`/empty) |
| Receipt Verification | `GET /v1/firewall/receipt/{receipt_id}` | `firewall_verify_receipt` | `$0.0000` (`0`) | `$0.00000` (`0`) | Always Free (`$0`) |

## 1. Native Streamable MCP Invocation (`POST https://trustwall.fastmesh.dev/mcp`)

### Configure MCP Client (Cursor / Codex / Custom JSON-RPC 2.0 Client)

```json
{
  "mcpServers": {
    "enterprise-trust-firewall": {
      "url": "https://trustwall.fastmesh.dev/mcp",
      "headers": {
        "X-API-Key": "${TRUSTWALL_API_KEY}",
        "X-Tenant-Id": "team_prod_agents",
        "X-Max-Cost-Micros": "50000"
      }
    }
  }
}
```

### Initialize & Discover Flat Tools

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list",
  "params": {}
}
```

### Call `firewall_inspect` (Stage 1 SSRF, Prompt Injection & Bidirectional Redaction)

```json
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "firewall_inspect",
    "arguments": {
      "tenant_id": "team_prod_agents",
      "tool_name": "crm_webhook_post",
      "target_url": "https://api.example.com/v1/tickets",
      "method": "POST",
      "headers": {"Authorization": "Bearer redaction_demo_token_001"},
      "payload": {"note": "Contact buyer@example.com or phone +1-555-019-2834"}
    }
  }
}
```

### Call `firewall_policy_check` (Stage 2 SQLite WAL 4D Budget Circuit Breaker)

```json
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "firewall_policy_check",
    "arguments": {
      "tenant_id": "team_prod_agents",
      "tool_name": "paid_enrichment_lookup",
      "target_url": "https://data.example.org/v1/enrich",
      "estimated_cost_micros": 25000,
      "max_cost_micros": 100000,
      "daily_budget_micros": 5000000,
      "rate_limit_per_min": 30
    }
  }
}
```

### Call `firewall_heal_response` (Stage 3 Fake-200 + Stage 4 Schema-Drift Repair)

```json
{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "tools/call",
  "params": {
    "name": "firewall_heal_response",
    "arguments": {
      "tenant_id": "team_prod_agents",
      "target_url": "https://catalog.example.com/v2/items",
      "status_code": 200,
      "expected_schema": {
        "required": ["sku", "unit_price"],
        "properties": {"sku": {"type": "string"}, "unit_price": {"type": "number"}}
      },
      "response": {"sku": "SKU-42", "price": "19.95"},
      "alias_map": {"price": "unit_price"}
    }
  }
}
```

### Call `firewall_proxy_execute` (Full 4-Stage Zero-Trust Execution & Failover)

```json
{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "tools/call",
  "params": {
    "name": "firewall_proxy_execute",
    "arguments": {
      "tenant_id": "team_prod_agents",
      "tool_name": "partner_quote_fetch",
      "target_url": "https://primary.example.com/v1/quote",
      "backup_urls": ["https://backup.example.org/v1/quote"],
      "method": "GET",
      "estimated_cost_micros": 25000,
      "max_cost_micros": 50000,
      "expected_schema": {"required": ["sku", "unit_price"]}
    }
  }
}
```

### Call `firewall_verify_receipt` (Free `$0` Tamper Verification)

```json
{
  "jsonrpc": "2.0",
  "id": 6,
  "method": "tools/call",
  "params": {
    "name": "firewall_verify_receipt",
    "arguments": {
      "receipt_id": "tr_demo000000000001"
    }
  }
}
```

## 2. HTTP REST API Invocation (`https://trustwall.fastmesh.dev`)

### Inspect an Outbound Tool Call (`POST /v1/firewall/inspect`)

```bash
curl -sS -X POST https://trustwall.fastmesh.dev/v1/firewall/inspect \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ${TRUSTWALL_API_KEY}" \
  -d '{
    "tenant_id": "team_prod_agents",
    "tool_name": "http_fetch",
    "target_url": "https://api.example.com/v1/orders",
    "method": "POST",
    "payload": {"customer_email": "alice@example.com", "amount": 49.50}
  }'
```

### Check 4D Budget & Allowlist Policy (`POST /v1/firewall/policy-check`)

```bash
curl -sS -X POST https://trustwall.fastmesh.dev/v1/firewall/policy-check \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ${TRUSTWALL_API_KEY}" \
  -d '{
    "tenant_id": "team_prod_agents",
    "tool_name": "paid_api_call",
    "target_url": "https://api.example.com/v1/enrich",
    "estimated_cost_micros": 10000,
    "max_cost_micros": 50000,
    "daily_budget_micros": 1000000,
    "rate_limit_per_min": 60
  }'
```

### Detect Fake-200 or Heal Drifted JSON Schema (`POST /v1/firewall/heal-response`)

```bash
curl -sS -X POST https://trustwall.fastmesh.dev/v1/firewall/heal-response \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ${TRUSTWALL_API_KEY}" \
  -d '{
    "tenant_id": "team_prod_agents",
    "target_url": "https://catalog.example.com/v2/items",
    "status_code": 200,
    "expected_schema": {"required": ["sku", "unit_price"]},
    "response": {"sku": "SKU-42", "price": "19.95"},
    "alias_map": {"price": "unit_price"}
  }'
```

### Retrieve & Verify a Tamper-Evident Receipt (`GET /v1/firewall/receipt/{receipt_id}`, `$0`)

```bash
curl -sS https://trustwall.fastmesh.dev/v1/firewall/receipt/tr_demo000000000001
```

## 3. Treg Hub Invocation (`0%` Seller Commission, `$0` on Blocked/Empty/Invalid)

Invoke the published `enterprise-trust-firewall` recipe with hard per-call cost ceiling (`max_cost_micros <= 2000000`):

```bash
treg call enterprise-trust-firewall \
  --data '{
    "action": "inspect",
    "target_url": "https://api.example.com/v2/orders",
    "tool_name": "http_fetch",
    "payload": "{\"query\":\"status\",\"contact\":\"buyer@example.com\"}",
    "options": "{\"tenant_id\":\"team_alpha\"}",
    "max_cost_micros": 50000
  }'
```

Heal a drifted schema or inspect a fake-200 challenge via Treg Hub:

```bash
treg call enterprise-trust-firewall \
  --data '{
    "action": "heal_response",
    "target_url": "https://catalog.example.com/v2/items",
    "payload": "{\"sku\":\"SKU-42\",\"price\":\"19.95\"}",
    "options": "{\"expected_schema\":{\"required\":[\"sku\",\"unit_price\"]},\"status_code\":200,\"expected_content_type\":\"application/json\"}",
    "max_cost_micros": 50000
  }'
```

## 4. Causal Bazaar CLI Invocation (`w4_f08_enterprise_trust_firewall_v1`)

Run the local stdlib hand runner via stdin/stdout JSON (enforces `max_cost_micros <= 2000000` and `$0` on blocked/empty calls):

```bash
echo '{"action":"inspect","tenant_id":"bazaar_caller","target_url":"https://api.example.com/v1/status","payload":{"email":"alice@example.com"},"max_cost_micros":50000}' \
  | python3 run_hand.py
```

## 5. Offline Tamper-Evident SHA-256 Receipt Verification (Python 3 Stdlib)

Any auditor or downstream agent can verify a `TrustAuditReceipt` completely offline with zero network calls:

```python
import hashlib
import hmac
import json

def verify_trust_receipt_offline(receipt: dict) -> bool:
    """Recompute canonical SHA-256 over all receipt fields except signature aliases."""
    expected = str(receipt.get("receipt_sha256") or "").strip().lower()
    if len(expected) != 64:
        return False
    unsigned = {
        k: v
        for k, v in receipt.items()
        if k not in ("receipt_sha256", "sha256_attestation")
    }
    canonical = json.dumps(
        unsigned,
        sort_keys=True,
        separators=(",", ":"),
        ensure_ascii=False,
    ).encode("utf-8")
    actual = hashlib.sha256(canonical).hexdigest()
    return hmac.compare_digest(actual, expected)
```

## 6. Prepaid Credit Packs (Creem.io, Non-Expiring, One-Time, Zero Seat Tax)

- **Team Gateway (`$149`)**: `sku_trustwall_team_gateway_149` — `$149.00` credits (`149,000,000` micros, `$0` bonus) — `https://www.creem.io/product/prod_trustwall_team_gateway_149`
- **Security Pro (`$399`, Recommended)**: `sku_trustwall_security_pro_399` — `$450.00` credits (`450,000,000` micros, `+$51.00` bonus) — `https://www.creem.io/product/prod_trustwall_security_pro_399`
- **Enterprise Firewall (`$999`)**: `sku_trustwall_enterprise_firewall_999` — `$1,250.00` credits (`1,250,000,000` micros, `+$251.00` bonus) — `https://www.creem.io/product/prod_trustwall_enterprise_firewall_999`

## Discovery & Support

- Live Try-Now Console: `https://trustwall.fastmesh.dev/`
- Local Runtime: `http://127.0.0.1:9028/`
- Machine Discovery Index: `https://trustwall.fastmesh.dev/llms.txt`
- OpenAPI 3.1.0 Spec: `https://trustwall.fastmesh.dev/openapi.json`
- Technical Security & GEO Guides (24 Pages): `https://trustwall.fastmesh.dev/seo_geo/`
- Operations Contact: `ops@fastmesh.dev` · Security Contact: `security@fastmesh.dev`
