# RealFailBench — Machine-Readable Agent Guide (CLI-First, Zero GUI Required)

> Platform URL: https://realfailbench.com
> Purpose: Capture real AI capability failures from local sessions (DSH Desktop/CLI, Claude Code, Codex CLI/Desktop, Antigravity, OpenCode, Pi), redact private details locally, and submit clean Twin-Bundle v3 JSON for containerized Harbor blind verification.

## 0. Fast Install (Zero-Dependency Node.js >= 20 CLI `rfb`)
```bash
curl -fsSL https://realfailbench.com/install-adapter.sh | bash -s -- --harness cli
# Or also install MCP/Skill/Extension for a specific harness:
# --harness claude-code | codex | antigravity | opencode | pi | all
```
Installs `~/.local/bin/rfb` (global CLI) and `~/.realfailbench-adapters/bin/realfailbench-mcp.js` (stdio MCP).
Every `rfb` command accepts `--json` for deterministic structured output and returns exit code 0 on success / 1 on error.

## 1. Complete Zero-GUI Workflow (Works for DSH Desktop AND All Other Harnesses)
1. **Check environment & discover sessions across all 6 harnesses**:
   ```bash
   rfb doctor --json
   ```
2. **Account (if `auth.bound === false`)**:
   - Plaintext passwords NEVER leave the local machine (`rfb` derives `rfb_pw_v1:<sha256>` locally).
   - Register open-source account: `rfb register --username <user> --password <pass> --json`
   - Register bounty account:      `rfb register --username <user> --password <pass> --bounty <passphrase> --json`
   - Login existing account:       `rfb login --username <user> --password <pass> --json`
   - Upgrade play -> bounty:       `rfb unlock-bounty --passphrase <passphrase> --json`
   - Or bind existing API token:   `rfb bind <rfb_tok_...> --json`
   - Credentials are saved to `~/realfailbench/auth.json` (mode 0600, shared with DSH Desktop plugin).
3. **Locate sessions & turns — even from a fuzzy natural description, long multi-turn chats, or across MULTIPLE sessions**:
   - **Natural-language search (recommended when user just describes the bug)**:
     ```bash
     rfb search "昨天改 Makefile 删掉 deploy 目标" --harness all --days 14 --json
     ```
     Returns ranked candidate sessions across ALL 6 harnesses, exact matching turns, snippets, and ready-to-use `suggestedSpec` (e.g. `<sid>:3-6`).
   - Or browse manually / grep inside a long multi-turn session:
     ```bash
     rfb sessions --harness all --limit 10 --json
     rfb turns <sessionId> --grep "<keyword>" --json
     ```
4. **Create pre-redacted ephemeral draft (supports single range OR stitching MULTIPLE sessions across harnesses/models)**:
   ```bash
   # Single session range:
   rfb draft create <sessionId>:<startTurn>-<endTurn> --json
   # Multi-session (even cross-harness, e.g. failed in Codex, diagnosed in DSH/Claude Code):
   rfb draft create <sid1>:2-5 <sid2>:1-3 --json
   # Or append another session later:
   rfb draft add <draftId> <sid2>:1-3 --json
   ```
   - **Model-agnostic**: each harness uses whatever model is available there (Claude, GPT/Codex, Gemini, DeepSeek, Qwen, etc. — never assumes DeepSeek Flash). `rfb` records the true `sourceModel` from the session; if the platform's active blind panel doesn't include that exact model, the platform transparently runs cross-model blind verification across its active panel.
5. **Review & redact residual sensitive context (keep code, commands, errors verbatim!)**:
   ```bash
   rfb draft view <draftId> --start-line 1 --end-line 120 --json
   rfb draft search <draftId> "<keyword>" --json
   rfb draft edit <draftId> --old "<unique verbatim snippet>" --new "<redacted snippet>" --reason "<why>" --json
   ```
6. **Set structured Twin-Bundle v3 fields (pipe via stdin to avoid shell quoting issues)**:
   ```bash
   rfb draft set <draftId> --from-json - --json <<'JSON'
   {
     "title": "简明客观的失误标题（<=120字）",
     "category": "debugging",
     "userPrompt": "脱敏后的用户原始诉求与约束",
     "observedFailure": "模型实际犯下的具体错误（不得虚构）",
     "evaluationCriteria": "客观可验证的验收标准",
     "goldenSolution": "正确解必须满足的关键特征",
     "goldenFailure": "原错解复现时的典型错误特征",
     "userNote": "可选：真实工作背景，或正当技术请求被安全策略误杀的说明"
   }
   JSON
   ```
   Allowed `category` enum: `coding | cli-ops | config | debugging | data | research | other`.
7. **Inspect exact diff & full cleartext JSON, get `bundleSha8`, confirm with user**:
   ```bash
   rfb draft diff <draftId> --json
   rfb draft bundle <draftId> --json
   ```
   Show the user the diff/redactions and summary. NEVER upload unreviewed private data without user consent.
8. **Submit (hash-gated pure CLI, or optional `--review-ui` local browser page)**:
   ```bash
   rfb submit <draftId> --confirm-reviewed <bundleSha8> --json
   # Optional local 127.0.0.1 review page if user prefers GUI:
   # rfb submit <draftId> --review-ui
   ```
   - Any edit invalidates `bundleSha8`, guaranteeing the exact reviewed bytes are uploaded.
   - If the verification host is temporarily offline (network error or HTTP 502/503/504/520-530), `rfb submit` queues the already-sanitized bundle to `~/realfailbench/outbox.json` (0600) instead of failing; flush later with `rfb flush --json`.
   - The local draft file is burned immediately upon acceptance or offline queueing.
9. **Track 7-step verification & wallet/admin via CLI**:
   ```bash
   rfb status <submissionId> --json
   rfb watch <submissionId> --interval 5 --json
   rfb submissions --mine --json
   rfb whoami --json
   rfb bind-payout --channel wechat|alipay [--target <收款账号>] [--qr <收款码图片.png>] [--name <实名末字>] --json
   rfb withdraw --wait --json   # 发起提现并实时等待管理员确认到账
   rfb withdraw [--amount <yuan>] --json
   # Admin only:
   rfb admin profiles --json
   rfb admin overview --json
   ```

## 2. Eligibility & Valuation Rules
- **Valid cases**: Real capability failures encountered in real user tasks.
- **Safety refusal rule**: Provider safety/policy refusal on genuinely unsafe/sensitive requests is NOT a valid capability failure (platform will reject). ONLY benign over-refusal (false positive blocking normal legitimate work) is valid — state why it is a false positive in `observedFailure` and `userNote`.
- **Stamina system**: Every non-admin account has 100 max stamina; each submission costs `-1` stamina, regenerates `+1/hour`, and awards `+10` stamina (capped at 100) per verified task; `infra_error` refunds `+1`.
- **Hard quality & anti-trap gate**: Tasks with `avgQuality < 65` or `fairnessTier === "gotcha_trap"` (ambiguous/misleading traps) are **hard-rejected (¥0, not admitted)**.
- **Reward formula (bounty accounts, passing tasks only)**: Base ¥20 (1st verified) / ¥10 (2nd-5th) / ¥5 (6th+) × 5-factor multiplicative score [0.25x..5.0x]:
  - Real work/research workflow: `2.0x` (mixed `1.2x`, contrived `0.6x`)
  - Fairness / anti-gotcha: `direct_capability 1.0x` (subtle_intent `0.5x`; `gotcha_trap` is rejected with ¥0)
  - Frontier/specialized domain (systems, kernel, research, CAD/Blender, etc.): `2.0x` (engineering `1.2x`, general `1.0x`)
  - Quality base `0.85-1.15x` (for `>= 65`, `<65` is rejected) × Blind difficulty `1.00-1.25x`, clamped to `[0.25x..5.0x]` (1st task up to ¥100).

## 3. Direct HTTP API Reference (if running without `rfb`)
- `GET  https://realfailbench.com/health` — platform status, active blind solvers, queue depth
- `POST https://realfailbench.com/api/v1/auth/register` — `{ username, password: "rfb_pw_v1:<sha256>", accountType: "play"|"bounty", passphrase? }`
- `POST https://realfailbench.com/api/v1/auth/login` — `{ username, password: "rfb_pw_v1:<sha256>" }`
- `GET  https://realfailbench.com/api/v1/auth/me` — Bearer token check & wallet balance
- `POST https://realfailbench.com/api/v1/submissions` — submit cleartext Twin-Bundle v3 JSON (returns 202 + `submissionId`)
- `GET  https://realfailbench.com/api/v1/submissions/:id` — 7-step pipeline status, blind matrix, valuation, payout
- `GET  https://realfailbench.com/api/v1/open-dataset.json` — public CC-BY-4.0 verified open-track dataset
- `GET  https://realfailbench.com/api/v1/admin/users/profiles` — admin-only per-user analytics & risk profile
