Example 2

July 5, 2026 · View on GitHub

A full quant falsification audit. The strategy passes L2 (no obvious bugs) but fails at gate5 PBO due to universe contamination. Real x402 payment.

Inputs

strategy.py (excerpt):

import pandas as pd
from pathlib import Path

def build_universe(data_dir: str) -> list[str]:
    # BUG: glob all *_daily.csv → mixes strategies from other experiments
    return [str(p) for p in Path(data_dir).glob("*_daily.csv")]

def signal(close: pd.Series) -> pd.Series:
    return close.rolling(20).mean()  # no lookahead, no obvious bug

backtest_results.csv — 5-strategy family, 41 columns (40 contaminated + 1 target).

risk_contract.yaml:

audit_tier: quant
gates:
  gate0: { enabled: true, contract_strict: true }
  gate1: { enabled: true, source_review: true }
  gate2: { enabled: true, static_patterns: true }
  gate3: { enabled: true, numeric_recompute: true }
  gate4: { enabled: true, lookahead: true, rolling_shift: true }
  gate5:
    enabled: true
    pbo:
      n_trials_effective: max(matrix_columns, declared_trials, param_combos)
      multi_objective: true
      calmar_floor: 0.3
  gate6: { enabled: true, deployment_parity: true }
verdict_ceiling:
  on_pbo_fail: BLOCK
  on_parity_fail: BLOCK

Submit (paid, real x402)

Step 1 — get the 402 challenge

curl -i -X POST https://falsify.example.com/audit \
  -F strategy_script=@strategy.py \
  -F backtest_results=@backtest_results.csv \
  -F contract=@risk_contract.yaml

Response:

HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "accepts": [
    {
      "scheme": "exact",
      "price": "0.001",
      "asset": "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
      "network": "eip155:196",
      "pay_to": "0xFALSIFY...",
      "max_timeout_seconds": 300
    }
  ]
}

Step 2 — sign payment with Agentic Wallet

onchainos payment pay \
  --to 0xFALSIFY... \
  --amount 0.001 \
  --asset 0x779Ded0c9e1022225f8E0630b35a9b54bE713736 \
  --network eip155:196 \
  --output payment.json

Step 3 — retry with payment header

PAYMENT=$(jq -r '.header' payment.json)

curl -X POST https://falsify.example.com/audit \
  -H "X-Payment: $PAYMENT" \
  -F strategy_script=@strategy.py \
  -F backtest_results=@backtest_results.csv \
  -F contract=@risk_contract.yaml

Response

{
  "verdict": "BLOCK",
  "reason": "gate5 PBO=0.81 (multi_objective + calmar_floor 0.3); universe constructed via glob(*_daily.csv) — 40 contaminated columns vs declared 5-strategy family",
  "gates": {
    "gate0": { "verdict": "PASS", "contract_strict": true },
    "gate1": { "verdict": "PASS", "source_review": "no obvious issues" },
    "gate2": { "verdict": "PASS", "patterns_checked": 12 },
    "gate3": { "verdict": "PASS", "sharpe_recomputed": "2.41 (matches reported)" },
    "gate4": { "verdict": "PASS", "lookahead": "clean", "rolling_shift": "clean" },
    "gate5": {
      "verdict": "BLOCK",
      "pbo": 0.81,
      "n_trials_effective": 41,
      "n_trials_declared": 5,
      "calmar_median_oos": 0.42,
      "contamination": "matrix globbed from 41 *_daily.csv files, declared family has 5"
    },
    "gate6": { "verdict": "PASS", "deployment_parity": "manifest matches" }
  },
  "receipts": [
    {
      "anchor":      { "file": "strategy.py", "line": 5, "symbol": "build_universe" },
      "artifact":    { "json_path": "gates.gate5.pbo", "equals": "0.81" },
      "refutation":  "glob(*_daily.csv) includes strategies from other experiments; rebuild matrix with declared 5-strategy family only"
    },
    {
      "anchor":      { "file": "strategy.py", "line": 5, "symbol": "build_universe" },
      "artifact":    { "json_path": "gates.gate5.n_trials_effective", "equals": "41" },
      "refutation":  "n_trials_effective must equal declared family count (5), not glob result"
    }
  ],
  "receipt_hash": "sha256:c7b1a93f4d8e2c5b6a9f1e0d3c4b5a6928e7f6d5c4b3a29187e6d5c4b3a29187e",
  "onchain_tx_hash": "0xdef456abc7890123456789012345678901234567890123456789012345678901",
  "onchain_explorer": "https://www.oklink.com/xlayer/tx/0xdef456abc7890123456789012345678901234567890123456789012345678901",
  "payment": {
    "settled": true,
    "amount_usd": "0.001",
    "asset": "USD₮0",
    "network": "X Layer (eip155:196)",
    "facilitator": "OKX x402"
  }
}

What happened

  1. L1 Contextrisk_contract.yaml merged with repo defaults; quant tier active.
  2. L2 Red-Light — no shift(-N), no np.square, no obvious bugs. PASS.
  3. L3 LLM Adversarial — full gate0–gate6 run.
    • gate0 contract: PASS.
    • gate1 source review: PASS.
    • gate2 static patterns: PASS (12 patterns checked).
    • gate3 numeric recompute: PASS (Sharpe 2.41 matches).
    • gate4 lookahead: PASS.
    • gate5 PBO: BLOCK — PBO=0.81 (multi_objective + calmar_floor 0.3 fails; n_trials_effective=41 from glob contamination).
    • gate6 deployment parity: PASS.
  4. L4 Finding Ledger — 2 findings appended (PBO value + n_trials_effective contamination).
  5. L5 Output — verdict BLOCK, receipt hash anchored on X Layer via onchainos wallet contract-call.
  6. Payment — x402 exact scheme settled USD₮0 0.001 to Falsify's pay_to address on X Layer.

Total audit time: ~45 seconds (L3 LLM adversarial dominates; gate5 PBO compute ~3s).