# 03 · Trust Model & Anti-Sybil Scoring Specification

> **SSOT Status**: Authoritative Specification  
> **Machine Source**: [`spec/fiderail.manifest.json`](../spec/fiderail.manifest.json) (`schemaVersion: 1.0.0`)  
> **Release**: `v2.3.5` | **Active Model**: `trust-v2`

---

## 1. Design Principle: Decoupled Enforcement and Intelligence

FideRail strictly separates deterministic policy enforcement from pluggable reputation scoring:

1. **Deterministic Policy Execution Layer**: Enforces spending caps, rate limits, asset allowlists, Ed25519 mandate chains, outbound secret/PII scrubbing, Quote-to-Pay digest binding, and idempotency. Zero probabilistic overrides.
2. **Pluggable Risk Intelligence Layer (`TrustScorer`)**: Computes reproducible 0-100 credit profiles from indexed stablecoin flows, graph topology, L1 liveness, and verified L2 delivery receipts. Every output binds `modelVersion`, `modelHash` (RFC 8785 JCS SHA-256 of active parameters), and an Ed25519-signed per-epoch Merkle `stateRoot`.

---

## 2. Active Scoring Model: `trust-v2`

Implemented in [`packages/core/src/scoring.ts`](../packages/core/src/scoring.ts) (`createTrustScorerV2()`).

### 2.1 Positive Signals (Max 100 Points)
All activity and volume signals apply **14-day exponential half-life decay** (`weight = 0.5^(ageSec / 1209600)`):

- **Cross-Ecosystem Payer Diversity (max 40 pts)**: `min(40, log2(effectiveUniquePayers + 1) * 10.5)`. Payers that have paid `>= 2` distinct payees receive weight `1.0`; single-target isolated payers receive weight `0.2`.
- **Time-Decayed Organic Volume (max 30 pts)**: `min(30, log10(decayedUsd * 20 + 1) * 8.5)`.
- **Multi-Day Activity (max 20 pts)**: `min(20, log2(decayedTxCount + 1) * 2.8 + min(6, log2(activeUtcDays + 1) * 2))`.
- **Dual HHI Dispersion (max 10 pts)**: `round((1 - max(txHhi, volumeHhi)) * 10)`.

### 2.2 Time Maturity Hard Caps
- Active observation span `< 24h`: capped at **`65`** (`NEW_WALLET_MATURITY_CAP`, ineligible for `HIGH_TRUST`).
- Active observation span `< 3d`: capped at **`80`**.
- Active observation span `< 7d`: capped at **`90`**.

### 2.3 Deterministic Anti-Sybil Penalties

| Risk Flag | Penalty | Score Cap | Resulting Tier / Pre-Flight Effect | Trigger Rule |
|---|---|---|---|---|
| `RECIPROCAL_LOOP` | `-30` | `10` | `FLAGGED_LOOP` (`CRITICAL`, `< 40`), `BLOCK` unconditionally | Self-transfers, 2-hop (`A <-> B`), or 3-hop (`A -> B -> C -> A`) directed wash cycles |
| `SINGLE_PAYER_CONCENTRATED` | `-25` | `29` | `FLAGGED_CONCENTRATED` (`HIGH`, `< 40`), `BLOCK` above micro cap | `txCount >= 5` and `max(txHhi, volumeHhi) > 0.8` or top-1 tx/volume share `> 80%` |
| `ISOLATED_PAYER_FARM` | `-25` | `25` | `FLAGGED_FARM` (`HIGH`, `< 40`), `BLOCK` above micro cap | `>= 10` unique payers and `>= 15` txs with `> 95%` single-target isolated payers |
| `BEHAVIOR_DRIFT` | `-20` | `69` | Ineligible for `HIGH_TRUST` (`MODERATE_TRUST` cap), `riskLevel: HIGH`, pre-flight `WARN` | `>= 10` txs across `>= 24h` where recent 20% median ticket `>= 10x` baseline median and `>= $10 USD` |
| `MICRO_PING_ONLY` | `-10` | — | `riskLevel: MEDIUM` | Median ticket `< $0.005 USD` |
| `NON_X402_WHALE_FLOW` | `-35` | `65` | Ineligible for `HIGH_TRUST`, pre-flight `WARN` | Generic EIP-3009 wallet with median ticket `> $100 USD` and no verified x402 facilitator channel |

### 2.4 Tier Classification (`deriveTrustTier`)
- `FLAGGED_LOOP`: has `RECIPROCAL_LOOP` (score capped `<= 10`, strictly `< 40`)
- `FLAGGED_CONCENTRATED`: has `SINGLE_PAYER_CONCENTRATED` (score capped `<= 29`, strictly `< 40`)
- `FLAGGED_FARM`: has `ISOLATED_PAYER_FARM` (score capped `<= 25`, strictly `< 40`)
- `HIGH_TRUST`: `creditScore >= 70` and no `NON_X402_WHALE_FLOW`, `BEHAVIOR_DRIFT`, or flagged tiers
- `MODERATE_TRUST`: `creditScore >= 40` and not flagged
- `LOW_HISTORY`: `creditScore < 40` and not flagged
- `UNVERIFIED`: no indexed payment history

### 2.5 Explainability, Delta History, and Isolated `ASSOCIATED_CREDIT`
- **Independent `confidence` (`0–1` + `LOW` / `MEDIUM` / `HIGH`)**: Computed from active span hours, effective cross-ecosystem payers, and sample count (penalized `0.4x` for farms and non-x402 whale flows).
- **Delta Audit Trail (`GET /v1/history/{chain}/{address}`)**: Persists score transitions on initial scoring, `>= 5` point shifts, or risk flag changes, paired with the chain's latest Ed25519-signed Merkle `stateRoot`.
- **Isolated `ASSOCIATED_CREDIT`**: Parent-to-child cold-start endorsements stay strictly isolated in `associatedCredit` (never mutating `creditScore`) and automatically slash/revoke on child sybil flags.

---

## 3. Reproducible Benchmark Suite

[`test/trust-v2-benchmark.test.mjs`](../test/trust-v2-benchmark.test.mjs) and [`scripts/generate-audit-report.mjs`](../scripts/generate-audit-report.mjs) preserve `createTrustScorerV1()` strictly as an offline A/B comparison baseline and verify 6 adversarial vectors (flash-100 isolated farm, 3-hop wash triangle, volume-HHI whale dilution, micro-ping spam, 60-day dormancy decay, and exit-scam `BEHAVIOR_DRIFT`) plus a 50,000-payment performance benchmark.

---

## 4. Risk Disclosure

FideRail provides reproducible on-chain risk intelligence—not financial guarantees or manual dispute arbitration. Final allow/block enforcement executes deterministically according to caller policy.
