---
name: diff-anything
description: Run deterministic structured diffs and USD overcharge recovery audits across cloud billing (AWS/GCP/Azure), freight surcharges (UPS/FedEx/DHL/ocean), contract/SLA redlines, customs tariffs & SaaS/marketplace pricing tables, and OpenAPI/HTML DOM snapshots via MCP, REST, or Treg Hub. Strictly bills $0 on errors, HTTP 422, or zero-finding diffs.
---

# Diff-Anything — AI Agent Integration Skill

Use Diff-Anything (`https://diff.fastmesh.dev`) whenever a workflow requires exact numerical variance verification, carrier or cloud invoice overcharge extraction, legal redline risk scoring, tariff/pricing cliff math, or breaking API/DOM change detection with cryptographic SHA-256 receipts.

## Core Endpoints & Channels

- **Remote MCP Server (JSON-RPC 2.0)**: `https://diff.fastmesh.dev/mcp`
- **Single Diff REST API**: `POST https://diff.fastmesh.dev/api/v1/diff`
- **Batch Diff REST API**: `POST https://diff.fastmesh.dev/api/v1/diff/batch`
- **Pricing Catalog**: `GET https://diff.fastmesh.dev/api/v1/pricing`
- **OpenAPI 3.1 Schema**: `GET https://diff.fastmesh.dev/openapi.json`
- **Treg Hub ID (0% commission)**: `singularity.diff-anything`
- **Full Machine Directory**: `https://diff.fastmesh.dev/llms.txt`

## Guarantees for Autonomous Agents

1. **Zero Charge on Misses or Malformed Payloads**: Invalid inputs return HTTP `422` with `billed_micros: 0`. Identical baseline and actual inputs return `ok: true`, `total_delta_usd: 0.0`, `billed_micros: 0`. Unverified or empty upstream payloads fail anti-fake-200 checks with `billed_micros: 0`.
2. **Exact Decimal Arithmetic**: Monetary deltas use `Decimal` precision (`<= $0.01` error tolerance), returning both `line_item_findings` and deterministic `reproducible_counterexamples`.
3. **Verifiable Proof & Archive Cache**: Every verified diff includes a 64-character hex `sha256_proof`. Repeat requests hit the 7-day to 30-day archive cache (`cache_hit: true`) with the identical proof hash and a 90% repeat-query discount.
4. **Zero Prompt & Trace Resale**: Payloads and outputs are never resold or used to train external models.

---

## Option 1: Calling via Remote MCP (`POST https://diff.fastmesh.dev/mcp`)

Add `https://diff.fastmesh.dev/mcp` to any MCP-compatible agent client. Three flat tools are exposed:

| MCP Tool | Purpose | Typical Input |
| :--- | :--- | :--- |
| `diff_anything` | Single polymorphic diff (`auto` or explicit domain) | `{ "domain": "auto", "baseline": "...", "actual": "..." }` |
| `diff_batch` | Multi-row CSV/JSON batch audit with aggregate USD delta | `{ "domain": "freight_surcharge", "items": [ ... ] }` |
| `diff_estimate_recovery` | Lightweight pre-flight recovery estimate and rate preview | `{ "domain": "cloud_billing", "monthly_spend_usd": 82000 }` |

### MCP `tools/call` Example

```bash
curl -fsSL -X POST "https://diff.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIFF_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "diff_anything",
      "arguments": {
        "domain": "cloud_billing",
        "baseline": "service,usage_qty,unit_rate_usd,discount_pct\nEC2-m6i.4xlarge,17856,0.768,18\n",
        "actual": "service,usage_qty,unit_rate_usd,discount_pct\nEC2-m6i.4xlarge,17856,0.768,0\n"
      }
    }
  }'
```

---

## Option 2: Calling via REST API (`POST /api/v1/diff` and `/api/v1/diff/batch`)

### 1. Cloud Billing Audit (`cloud_billing`)

```bash
curl -fsSL -X POST "https://diff.fastmesh.dev/api/v1/diff" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "cloud_billing",
    "baseline": "service,usage_qty,unit_rate_usd,discount_pct\nEC2-m6i.4xlarge,17856,0.768,18\nRDS-db.r6g.2xlarge,4464,1.008,18\n",
    "actual": "service,usage_qty,unit_rate_usd,discount_pct\nEC2-m6i.4xlarge,17856,0.768,0\nRDS-db.r6g.2xlarge,4464,1.008,0\n"
  }'
```

### 2. Freight Surcharge Claim Audit (`freight_surcharge`)

```bash
curl -fsSL -X POST "https://diff.fastmesh.dev/api/v1/diff" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "freight_surcharge",
    "baseline": "tracking_id,charge_type,contracted_usd\n1Z999AA101,AHS,8.93\n1Z999AA102,LARGE_PACKAGE,0.00\n",
    "actual": "tracking_id,charge_type,billed_usd\n1Z999AA101,AHS,25.50\n1Z999AA102,LARGE_PACKAGE,190.00\n"
  }'
```

### 3. Contract & SLA Redline Diff (`contract_redline`)

```bash
curl -fsSL -X POST "https://diff.fastmesh.dev/api/v1/diff" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "contract_redline",
    "baseline": "Liability cap is 12 months fees ($240,000). Auto-renewal requires 30 days notice with 3% annual price cap.",
    "actual": "Liability cap is $25,000. Auto-renewal requires 90 days notice for 24 months with 12% annual uplift."
  }'
```

### 4. Tariff & Pricing Table Cliff Diff (`tariff_pricing`)

```bash
curl -fsSL -X POST "https://diff.fastmesh.dev/api/v1/diff" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "tariff_pricing",
    "baseline": "hs_code,fob_value_usd,duty_rate_pct\n8507.60.0020,504000,7.5\n8541.43.0010,306000,25.0\n",
    "actual": "hs_code,fob_value_usd,duty_rate_pct\n8507.60.0020,504000,25.0\n8541.43.0010,306000,50.0\n"
  }'
```

### 5. OpenAPI Spec & Webpage DOM Diff (`openapi_dom`)

```bash
curl -fsSL -X POST "https://diff.fastmesh.dev/api/v1/diff" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "openapi_dom",
    "baseline": "<div class=\"tier\"><h3>Growth</h3><span class=\"price\">$79/mo</span><p>Min 5 seats</p></div>",
    "actual": "<div class=\"tier\"><h3>Growth</h3><span class=\"price\">$119/mo</span><p>Min 15 seats</p><small>$1,500 mandatory setup fee</small></div>"
  }'
```

### Batch CSV / Multi-Item Diff (`POST /api/v1/diff/batch`)

```bash
curl -fsSL -X POST "https://diff.fastmesh.dev/api/v1/diff/batch" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "freight_surcharge",
    "items": [
      {
        "id": "week_44_ups",
        "baseline": "tracking_id,charge_type,contracted_usd\n1Z100,AHS,8.93\n",
        "actual": "tracking_id,charge_type,billed_usd\n1Z100,AHS,25.50\n"
      },
      {
        "id": "week_44_fedex",
        "baseline": "tracking_id,charge_type,contracted_usd\n7946001,RESIDENTIAL,0.00\n",
        "actual": "tracking_id,charge_type,billed_usd\n7946001,RESIDENTIAL,5.95\n"
      }
    ]
  }'
```

---

## Option 3: Calling via Treg Hub (0% Commission)

```bash
treg call singularity.diff-anything --data '{
  "domain": "auto",
  "baseline": "service,usage_qty,unit_rate_usd,discount_pct\nS3-Standard,480000,0.023,18\n",
  "actual": "service,usage_qty,unit_rate_usd,discount_pct\nS3-Standard,480000,0.023,0\n"
}'
```

---

## Standardized `DiffProofReport` Response Contract

Every successful call returns:

- `ok` (`boolean`): `true` when verification passes; `false` on HTTP `422` or anti-fake-200 rejection.
- `domain` (`string`): Resolved domain (`cloud_billing`, `freight_surcharge`, `contract_redline`, `tariff_pricing`, `openapi_dom`).
- `total_delta_usd` (`number`): Signed or absolute aggregate financial variance rounded to 2 decimals.
- `recoverable_overcharge_usd` (`number`): Direct claimable refund or avoidable billing amount rounded to 2 decimals.
- `severity` (`string`): One of `none`, `low`, `medium`, `high`, `critical`.
- `line_item_findings` (`array`): Structured items containing `id`, `category`, `item`, `baseline_value`, `actual_value`, `delta_usd`, `severity`, `evidence`, and `claim_action`.
- `reproducible_counterexamples` (`array`): Exact arithmetic or structural proof tuples (`formula`, `expected`, `observed`, `delta`).
- `sha256_proof` (`string`): Deterministic 64-hex proof digest suitable for vendor dispute tickets and audit logs.
- `cache_hit` (`boolean`): Indicates archive cache reuse.
- `billed_micros` (`integer`): Exact micro-USD billed (`0` on error, HTTP `422`, or zero-finding diff).

## Error Recovery Rules for Agents

- On HTTP `422`: Inspect `summary` for missing `baseline` or `actual` fields; fix input formatting before retrying (cost was `$0`).
- On `billed_micros == 0` with `ok == true`: Baseline and actual are mathematically equivalent; do not re-call with identical payloads.
- For high-volume audits (>50 rows): Use `/api/v1/diff/batch` rather than single-row HTTP loops to minimize latency and round-trips.
