---
name: heal-anything
description: Deterministic 5-class diagnostic and self-healing engine for AI agents and production pipelines (fake-200 soft-block diagnosis, JSON/OpenAPI schema drift remapping patches, HTML CSS selector rot fallback recovery, 429/5xx circuit-breaker policy generation, and dirty encoding/webhook/CSV sanitization). Emits executable patches, restored payloads, and signed 24h SHA-256 SLA Health Certificates with strict $0 billing on HTTP 422 SSRF/invalid inputs, errors, or empty results.
---

# Heal-Anything Agent Skill

`Heal-Anything` (`https://heal.fastmesh.dev`) is a flat, polymorphic, deterministic diagnostic and self-healing engine built for autonomous AI agents, scraper pipelines, webhook ingestion guards, and multi-provider API routers.

Instead of alert-only notifications, every `/heal` call returns a structured **`diagnosis`**, a deterministic executable **`patch`**, a restored **`healed_payload`**, and a tamper-evident 24-hour **`SLACertificate`** (`sla_cert`) signed with SHA-256 (`cert_sha256` / `sha256_attestation`).

## Hard Guarantees

1. **Strict `$0` Billing on 422 / Error / Empty**: Charges apply **only** on deterministic diagnostic/healing outcomes (`HEALED`, `DIAGNOSED`, `SOFT_BLOCK_DETECTED`, `ISSUED`, `VERIFIED`, `FAILED`) backed by a valid 64-hex `sha256_attestation`. Invalid/junk payloads, private/loopback/link-local SSRF URLs (`localhost`, `127.0.0.1`, `10.x`, `169.254.x`, `192.168.x`, `::1`, `file://`), upstream failures, `INCONCLUSIVE` outcomes, or empty results strictly return `HTTP 422` or `billed_micros: 0` with a non-empty `zero_bill_reason`.
2. **Zero CAPTCHA Bypasses**: `fake_200` classifies Cloudflare, Turnstile, reCAPTCHA, hCaptcha, DataDome, PerimeterX, login walls, and quota exhaustion honestly, triggers `ArchiveCache` invalidation, and recommends backup switchover—never bypassing access controls.
3. **100% Baseline Schema Restoration**: `schema_drift` emits declarative remapping patches (`rename`, `extract_path`, `coerce_type`, `derive_concat`, `derive_split`) whose deterministic `apply_patch()` restores 100% of baseline keys.
4. **Adaptive Archive Cache & 10% Repeat Tier**: Non-volatile verified healed results enter `ArchiveCache` (7d initial TTL expanding 1.5x up to 30d; error non-poisoning; explicit-empty invalidation). Same-tenant repeat hits bill 10%.
5. **Zero Conversation or Payload Resale**: Customer payloads, schemas, and healing traces are never sold, licensed, or used to train third-party models.

## Supported Healing Classes & Micro-USD Pricing

| Fault Class (`fault_class`) | Use When You Need To Heal | Unit Price | 10% Repeat | Deterministic Outputs |
| :--- | :--- | :---: | :---: | :--- |
| `fake_200` | HTTP 200 hiding CAPTCHA, SSO login wall, quota error, empty SPA shell, truncation, or filter-ignore noise | `$0.020` (`20000`) | `$0.0020` | `block_class`, honest switchover policy, `ArchiveCache` invalidation |
| `schema_drift` | Renamed keys (`user_email` -> `contact.emailAddress`), nested wrappers, type drift, missing `full_name`/`domain` | `$0.050` (`50000`) | `$0.0050` | Declarative remapping `patch` + 100% restored `healed_payload` |
| `selector_rot` | Broken CSS path (`:nth-child`, hashed CSS-in-JS classes) on changed HTML markup | `$0.040` (`40000`) | `$0.0040` | Ranked 5-tier anchor fallback chain (`data-testid`, ARIA, attrs, text, semantic) + diff patch |
| `circuit_breaker` | Upstream `429`/`5xx`/P95 spikes causing cascading retries or duplicate writes on `504` | `$0.030` (`30000`) | `$0.0030` | Exponential backoff + full jitter, `DO_NOT_REROUTE` write lock, `19.5%` share cap, failover config |
| `payload_sanitizer` | UTF-8 BOM, CP1252 mojibake, NUL bytes, trailing-comma/truncated JSON webhooks, ragged/unclosed CSVs | `$0.030` (`30000`) | `$0.0030` | Clean UTF-8 / repaired JSON / padded CSV + formula-injection neutralization + SLA cert |
| `sla_cert` (endpoint) | Standalone signed 24-hour SHA-256 SLA Health Certificate (`verify_sla_cert` is free/`$0`) | `$0.020` (`20000`) | `$0.0020` | `cert_id`, `sla_status`, `health_score`, `issued_at_utc`, `expires_at_utc`, `cert_sha256` |
| `diagnose` (endpoint) | Non-mutating fault diagnosis across any of the 5 degradation classes (`POST /diagnose`) | `$0.015` (`15000`) | `$0.0015` | `diagnosis`, `checks`, `cache_invalidation`, `sha256_attestation` |

## Quick Invocation

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

Discover available flat tools (`diagnose_fault`, `heal_anything`, `issue_sla_cert`, `verify_sla_cert`):

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

Execute a schema drift self-healing call via MCP:

```json
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "heal_anything",
    "arguments": {
      "fault_class": "schema_drift",
      "target": "https://api.partner.example/v2/users",
      "baseline_schema": {"user_email": "string", "account_id": "string", "plan_tier": "string"},
      "payload": {"contact": {"emailAddress": "ops@fastmesh.dev"}, "acctId": "acc_9042", "tier": "pro"}
    }
  }
}
```

### 2. HTTP REST API (`POST https://heal.fastmesh.dev/heal`)

Heal a drifted JSON payload and receive an executable patch + restored payload + 24h SLA certificate:

```bash
curl -sS -X POST https://heal.fastmesh.dev/heal \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ${HEAL_API_KEY}" \
  -d '{
    "fault_class": "schema_drift",
    "target": "https://api.partner.example/v2/users",
    "baseline_schema": {"user_email": "string", "account_id": "string", "plan_tier": "string"},
    "payload": {"contact": {"emailAddress": "ops@fastmesh.dev"}, "acctId": "acc_9042", "tier": "pro"}
  }'
```

Diagnose a fake-200 CAPTCHA wall honestly without bypassing (`POST /diagnose`, `$0.015` or `$0` on `422`):

```bash
curl -sS -X POST https://heal.fastmesh.dev/diagnose \
  -H "Content-Type: application/json" \
  -d '{
    "fault_class": "fake_200",
    "target": "https://api.example.com/v1/feed",
    "status_code": 200,
    "headers": {"Content-Type": "text/html"},
    "expected_content_type": "application/json",
    "body": "<html><title>Just a moment...</title><div>Verify you are human</div></html>"
  }'
```

Issue or verify a 24h SHA-256 SLA Health Certificate (`POST /sla-cert` or `GET /sla-cert/{cert_id}`):

```bash
curl -sS https://heal.fastmesh.dev/sla-cert/sla_example_cert_id
```

### 3. Via `treg hub` (0% Seller Commission, `$0` on 422/Error/Empty)

```bash
treg call heal-anything \
  --data '{"fault_class":"schema_drift","target":"https://api.partner.example/v2/users","options":"{\"baseline_schema\":{\"user_email\":\"string\"},\"payload\":{\"contact\":{\"emailAddress\":\"ops@fastmesh.dev\"}}}"}'
```

## Offline Tamper-Evident SLA Certificate Verification (Python 3 Stdlib)

Any auditor or downstream pipeline can verify an `SLACertificate` offline with zero network calls:

```python
import hashlib
import hmac
import json

def verify_sla_certificate(cert: dict) -> bool:
    """Recompute deterministic SHA-256 over all certificate fields except signature aliases."""
    expected = str(cert.get("cert_sha256") or cert.get("sha256_attestation") or "").strip().lower()
    if len(expected) != 64:
        return False
    unsigned = {
        k: v
        for k, v in cert.items()
        if k not in ("cert_sha256", "sha256_attestation", "fault_class")
    }
    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)
```

Or invoke the MCP tool `verify_sla_cert` at `https://heal.fastmesh.dev/mcp` (free / `$0`).

## Prepaid Credit Packs (Creem.io, Non-Expiring, One-Time)

- **Starter (`$9.00`)**: `sku_heal_starter_9` — `$9.00` credits (`9,000,000` micros, `0` bonus) — `https://www.creem.io/product/prod_heal_anything_starter_9`
- **Growth (`$29.00`, Recommended)**: `sku_heal_growth_29` — `$32.00` credits (`32,000,000` micros, `+$3.00` bonus) — `https://www.creem.io/product/prod_heal_anything_growth_29`
- **Pro (`$99.00`)**: `sku_heal_pro_99` — `$115.00` credits (`115,000,000` micros, `+$16.00` bonus) — `https://www.creem.io/product/prod_heal_anything_pro_99`
- **Scale (`$249.00`)**: `sku_heal_scale_249` — `$310.00` credits (`310,000,000` micros, `+$61.00` bonus) — `https://www.creem.io/product/prod_heal_anything_scale_249`

## Support & Discovery

- Public Service URL: `https://heal.fastmesh.dev/`
- Local Runtime URL: `http://127.0.0.1:8808/`
- Machine Index: `https://heal.fastmesh.dev/llms.txt`
- OpenAPI 3.1.0 Spec: `https://heal.fastmesh.dev/openapi.json`
- Technical Guides (25 pages): `https://heal.fastmesh.dev/guides`
- Contact: `ops@fastmesh.dev`
