# Quality Bar — gates before delivery (Image 2.0 FULL-GEN)

Four gates, in order. All mandatory. A beautiful full-size view passes nothing.

## Gate P — prompt encoding and transport (before generation)

Windows PowerShell:

```powershell
py -3 "$env:USERPROFILE\.codex\skills\friendly-infographic-style\scripts\build.py" `
  prompt out.prompt.txt --json --meta out.prompt.meta.json
```

macOS / Linux:

```bash
python3 "$HOME/.codex/skills/friendly-infographic-style/scripts/build.py" \
  prompt out.prompt.txt --json --meta out.prompt.meta.json
```

Require exit code 0 and `"verdict":"PASS"`. Give `image_gen` only the exact
`prompt` value parsed from this ASCII-safe JSON. This gate rejects invalid UTF-8,
replacement characters, long `??????` runs, high-specificity `縺`/`繧` mojibake
sequences, too little Japanese inside `[TEXT]`, and
missing or reordered six-block prompt sections. On Windows, never replace this
gate with default PowerShell `Get-Content` or a Unicode text pipeline.

The `.prompt.meta.json` SHA-256 identifies the exact Unicode string used for the
generation. If an output is entirely mojibake, stop: Gate P or the transport path
was bypassed. Fix transport and rerun the unchanged prompt before evaluating art.

## Gate T — text verification (the Image 2.0 make-or-break)

Windows PowerShell:
```powershell
py -3 "$env:USERPROFILE\.codex\skills\friendly-infographic-style\scripts\build.py" `
  tiles out.png "$env:TEMP\ig-tiles"
```
macOS / Linux:
```bash
python3 "$HOME/.codex/skills/friendly-infographic-style/scripts/build.py" tiles out.png /tmp/ig-tiles
```
View EVERY tile (4×3 zoom crops, 10% overlap). For each visible string, compare
against the text manifest **character by character**. FAIL on: wrong/garbled glyph,
missing string, extra text not in the manifest, clipped text, text too small to
read in the tile. One garbled 字 = regenerate; there is no "almost right" kanji.

## Gate D — density audit (mechanical tripwire)

Windows PowerShell:
```powershell
py -3 "$env:USERPROFILE\.codex\skills\friendly-infographic-style\scripts\build.py" audit out.png
```
macOS / Linux:
```bash
python3 "$HOME/.codex/skills/friendly-infographic-style/scripts/build.py" audit out.png
```
Flat-region detector (16px cells → 1-cell erosion → blobs). Hard limits: header-band
blob ≤10%, body blob ≤3.5%, total ≤45%. Calibration anchors: the reference image
PASSes (largest 0.2% / total 2.3%); the three failed samples in the handoff folder
FAIL. **Floor ≠ goal** — reference-grade targets: total ≤ ~20%, primary text ≥
~1.2% of image width, 40–90 content atoms. A PASS at 30%+ flat is still スカスカ.

## Gate V — visual checklist (compare with `assets/reference-fable5-infographic.png`)

1. 一目で「作り込まれた完成図解」に見える(テンプレ感・下書き感がない)
2. どの領域にも空洞がない/文字が小さすぎる場所がない
3. 構成文法が前回の出力と違う(カード格子/ゾーン/ジャーニー/対話/ハブ/マガジン)
4. 見出し階層(タイトル→見出し→本文→補足)がはっきり分かる
5. 箇条書きの羅列でなく、表・フロー・対比・チャート等の表現が混ざっている
6. キャラ・植物・小物が5箇所以上、文字を邪魔せず置かれている
7. 色数が豊か(6トーン前後)で、隣接パネルの色が被っていない
8. 最重要メッセージが視覚的に最も強い
9. タイトル帯に星・ハート・手描き線・キャラが散っている
10. **日本語がすべて正確**(Gate Tを通過済みであること)

## 反面教師と合格例

`<あなたの作業フォルダ>/`
- `images/original-fable5-reference.png` — 目標(これ自体がImage 2.0系の生成画像)
- `images/latest-failed-*.png` `failed-low-*.png` — スカスカ・切り抜きキャラの失敗3枚
- `samples/sample-*.png` — 密度・可読性の合格ライン(legacy HTML製だが視覚基準は同一)

## Regeneration budget

Max 3 targeted retries (one prompt change each; symptom→fix table in
prompt-recipes.md). Then stop, show the best attempt, list exactly which strings
failed, and ask the user: simplify the copy, or switch to the legacy-html fallback
(explicit approval required).

## Legacy HTML gates (fallback path only)

`build.py check page.html out.png` = layout gate (DOM clipping/overflow/font floor)
+ render + the same density audit. Diagnosis tables and grid math:
`../legacy-html/grid-recipes.md`.
