---
name: forecast-anything
description: Deterministic, pure-stdlib 5-domain statistical time-series forecasting, anomaly detection, and rolling backtest engine for AI agents and operations pipelines (e-commerce safety stock/EOQ/ROP/stockout date, SaaS MRR/ARR/NRR/cash runway, cloud/GPU/LLM spend P50/P90/P99 budget breach alerts, concurrent 100-SKU batch CSV Z-score/IQR/CUSUM anomaly scanning, and rolling holdout backtests with XML-valid SVG confidence charts and SHA-256 ForecastReceipts). Strict $0 billing on HTTP 422 invalid inputs, empty results, or budget skips.
---

# Forecast-Anything Agent Skill

`Forecast-Anything` (`https://forecast.fastmesh.dev`) is a flat, polymorphic, pure Python 3 standard-library statistical time-series forecasting and anomaly detection engine built for autonomous e-commerce ops agents, SaaS finance workflows, FinOps cron monitors, and inventory pipelines.

Every valid run returns a standardized, tamper-evident **`ForecastReceipt`** sealed with a deterministic **`sha256_attestation`** digest, structured **`evidence_sources`**, **`checks`**, and domain-specific actionable outputs (ROP, EOQ, stockout date, ARR/NRR/runway, budget breach date, CUSUM change-points, and valid XML `<svg>` confidence charts).

> **Software Disclaimer**: Forecast-Anything provides deterministic statistical time-series forecasting software tooling only. It is **NOT securities, financial, or investment advice**, and provides **NO return, revenue, or profit guarantee**. Do not submit equity ticker prices expecting investment recommendations.

## Hard Guarantees

1. **100% Pure Python 3 Standard Library (Zero External ML Dependencies)**: Runs additive & multiplicative Holt-Winters triple exponential smoothing, damped linear trend, classical seasonal decomposition, inverse-error rolling holdout ensemble weighting, residual Z-score/IQR/two-sided CUSUM detection, and XML-valid `<svg>` rendering with zero `numpy`, `scipy`, `pandas`, or neural GPU dependencies.
2. **Strict `$0` Billing on HTTP `422` & Errors**: Empty series, non-numeric observations, `NaN`/`Inf`, `horizon <= 0`, `seasonal_period <= 0`, sentinel placeholders (`"N/A"`, `""`, `"null"`), malformed JSON/CSV, or budget-cap refusals strictly return `HTTP 422` (or unbilled status) with `charged_micros: 0`, `billed_micros: 0`, and `zero_bill_reason: "invalid_input_422"`.
3. **Graceful Ultra-Short & Missing-Value Handling**: Missing observations (`null` gaps) are linearly interpolated, extreme promo outliers are winsorized before seasonal fitting, and ultra-short series (lengths `1..4` or all zeros) degrade safely without division-by-zero errors.
4. **Cross-Tenant Adaptive Archive Cache (7d-30d) & 10% Recheck Tier**: Verified deterministic receipts enter a SQLite WAL archive cache (`7d` initial TTL expanding `1.5x` up to `30d`). Same-tenant rechecks (`recheck: true`) bill **10%** of base domain pricing; new-tenant cache hits bill **100%**.
5. **Zero Customer Data Resale**: Customer SKU velocities, SaaS MRR/NRR cohorts, cloud/GPU spend logs, and execution traces are never sold, licensed, or reused to train third-party models.

## Supported Forecasting Domains & Micro-USD Pricing

| Domain (`domain`) | Scope & Statistical Outputs | Base Price | 10% Recheck | Key Input Fields |
| :--- | :--- | :---: | :---: | :--- |
| `ecommerce_rop` | 30-90 day SKU demand forecast, safety stock (`95%` z=1.6449 / `99%` z=2.3263), EOQ, Reorder Point (ROP), projected `stockout_date`, `order_now` alert | `$0.020` (`20000`) | `$0.0020` (`2000`) | `series`, `horizon`, `lead_time_days`, `on_hand_units`, `service_level`, `order_cost`, `holding_cost_per_unit_year` |
| `saas_mrr` | Monthly new/expansion/contraction/churned MRR or cohort CSV -> 12-month ARR trajectory, NRR trend, cash runway months, `churn_spike_alert` | `$0.020` (`20000`) | `$0.0020` (`2000`) | `monthly_mrr` or `new_mrr`/`expansion_mrr`/`contraction_mrr`/`churned_mrr`, `cash_balance_usd`, `monthly_gross_burn_usd`, `horizon` |
| `cloud_budget` | Hourly/daily cloud, GPU, or LLM token spend + monthly budget cap -> 7-day weekday/weekend decomposition, month-end P50/P90/P99 spend, projected `breach_date` & alert | `$0.020` (`20000`) | `$0.0020` (`2000`) | `daily_spend_usd` (or `series`), `monthly_budget_usd`, `day_of_month` |
| `batch_anomaly` | Concurrent multi-series CSV/JSON batch forecast + residual Z-score, Tukey IQR & two-sided CUSUM change-point scan (up to 100 series included; `+1000` micros/extra series) | `$0.060` (`60000`) | `$0.0060` (`6000`) | `csv` / `csv_text` / `items` / `series`, `horizon`, `z_threshold`, `cusum_k`, `cusum_h`, `max_budget_micros` |
| `backtest_svg` | Rolling-origin holdout backtest (MAPE, sMAPE, RMSE), inverse-error ensemble weights, valid XML `<svg>` confidence-band chart, SHA-256 receipt | `$0.040` (`40000`) | `$0.0040` (`4000`) | `series`, `horizon`, `period` / `seasonal_period`, `holdout_size` |

## Quick Invocation

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

List flat MCP tools (`forecast_series`, `forecast_batch_csv`, `forecast_verify_receipt`, `forecast_catalog`):

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

Execute an e-commerce safety stock, EOQ, and Reorder Point forecast via MCP:

```json
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "forecast_series",
    "arguments": {
      "domain": "ecommerce_rop",
      "target": "SKU-TOP-101",
      "series": [42, 48, 51, 44, 63, 71, 55, 46, 50, 53, 47, 68, 74, 59],
      "horizon": 30,
      "lead_time_days": 14,
      "on_hand_units": 650,
      "service_level": 0.95,
      "order_cost": 85.0,
      "holding_cost_per_unit_year": 4.2
    }
  }
}
```

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

Single Cloud/GPU/LLM spend P50/P90/P99 month-end budget breach forecast:

```bash
curl -sS -X POST https://forecast.fastmesh.dev/forecast \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ${FORECAST_API_KEY}" \
  -d '{
    "domain": "cloud_budget",
    "target": "gpu-cluster-us",
    "daily_spend_usd": [410, 435, 450, 440, 460, 290, 275, 430, 470, 495, 485, 510, 310, 295],
    "monthly_budget_usd": 14000,
    "day_of_month": 14
  }'
```

Concurrent multi-series batch CSV anomaly scan with hard budget cap (`POST /forecast/batch`):

```bash
curl -sS -X POST https://forecast.fastmesh.dev/forecast/batch \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ${FORECAST_API_KEY}" \
  -d '{
    "domain": "batch_anomaly",
    "max_budget_micros": 120000,
    "horizon": 14,
    "csv": "series_id,t,value\nSKU_A,1,40\nSKU_A,2,42\nSKU_A,3,98\nSKU_B,1,15\nSKU_B,2,16\nSKU_B,3,14"
  }'
```

Retrieve a stored receipt by ID:

```bash
curl -sS https://forecast.fastmesh.dev/receipt/fr_example_receipt_id
```

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

```bash
treg call forecast-anything \
  --data '{"domain":"backtest_svg","target":"weekly-orders","payload":"{\"series\":[112,118,132,129,121,135,148,148,136,119,104,118,115,126,141,135,125,149,170,170,158,133,114,140],\"horizon\":6,\"period\":12}"}'
```

## Example `ForecastReceipt` Response

```json
{
  "ok": true,
  "http_status": 200,
  "receipt_id": "fr_ecom_rop_01",
  "domain": "ecommerce_rop",
  "target": "SKU-TOP-101",
  "verdict": "ALERT",
  "confidence": "0.9500",
  "disclaimer": "Deterministic statistical time-series forecasting tool only; not securities, financial, or investment advice and not a return guarantee.",
  "evidence_sources": [
    {
      "source": "holt_winters_damped_ensemble",
      "url": "https://forecast.fastmesh.dev/guides/ecommerce-safety-stock-reorder-point-rop-api",
      "status": "applied",
      "observed_at_utc": "2026-12-02T19:20:00Z",
      "summary": "Pure-stdlib Holt-Winters + damped trend + 95% service-level ROP/EOQ calculation"
    }
  ],
  "checks": [
    {"name": "series_validation", "passed": true, "detail": "14 finite observations validated"},
    {"name": "safety_stock_rop", "passed": true, "detail": "SS=62.5 units, ROP=841.3 units, order_now=true"}
  ],
  "payload_sha256": "6e4c1d9e8a2f7b12f3a8c9b0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0",
  "sha256_attestation": "a1b2c3d4e5f60718293a4b5c6d7e8f90112233445566778899aabbccddeeff00",
  "charged_micros": 20000,
  "billed_micros": 20000,
  "base_price_micros": 20000,
  "cache_hit": false,
  "cache_tier": "live",
  "timestamp_utc": "2026-12-02T19:20:00Z",
  "zero_bill_reason": "",
  "details": {
    "forecast_p50": [58.4, 59.1, 60.2],
    "safety_stock_units": 62.5,
    "reorder_point_units": 841.3,
    "eoq_units": 982.4,
    "order_now": true
  }
}
```

## Local Tamper-Evident Receipt Verification (Python 3 Stdlib)

Any downstream auditor or agent can verify offline that a `ForecastReceipt` has not been altered:

```python
import hashlib
import hmac
import json

def verify_receipt(receipt: dict) -> bool:
    """Recompute deterministic SHA-256 attestation over all fields except sha256_attestation, ok, http_status."""
    expected = str(receipt.get("sha256_attestation") or "").strip().lower()
    if len(expected) != 64:
        return False
    unsigned = {
        k: v
        for k, v in receipt.items()
        if k not in ("sha256_attestation", "ok", "http_status")
    }
    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 `forecast_verify_receipt` directly with the full receipt JSON object.

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

- **Starter (`$19.00`)**: `sku_forecast_starter_19` — `1,000` credits (`$20.00` value, `20,000,000` micros, never expires) — `https://www.creem.io/product/prod_forecast_anything_starter_19`
- **Growth (`$79.00`, Recommended)**: `sku_forecast_growth_79` — `10,000` credits (`$200.00` value, `200,000,000` micros, never expires) — `https://www.creem.io/product/prod_forecast_anything_growth_79`
- **Scale (`$199.00`)**: `sku_forecast_scale_199` — `40,000` credits (`$800.00` value, `800,000,000` micros, never expires) — `https://www.creem.io/product/prod_forecast_anything_scale_199`

## Support & Discovery

- Service URL: `https://forecast.fastmesh.dev/`
- Machine Index: `https://forecast.fastmesh.dev/llms.txt`
- OpenAPI 3.1.0 Spec: `https://forecast.fastmesh.dev/openapi.json`
- Technical Guides (26 pages): `https://forecast.fastmesh.dev/guides`
- Contact: `ops@fastmesh.dev`
