---
name: feedback-index-html-commit-required-protocol
description: "vite build + sync-index-html-bundle.ts 走らせた後、 dist-renderer/index.html を必ず commit に含める永続 protocol。 2026-06-14 incident: commit 8306612a (magnetometer fix) + fff2fe16 (ZCSG glyph) で sync 走らせたが output tail -2 で truncate して update 行を見落とし + index.html を stage 忘れ → CF Pages が git HEAD の stale 版 (1298214b voyage 時代) を deploy し続け、 magnetometer null fix + ZCSG glyph いずれも live 反映されず藤本さん再報告。 commit c3fb4b48 で 1 line 修正で解消。"
metadata: 
  node_type: memory
  type: feedback
  originSessionId: aa726e4e-dc7f-4186-9a6b-85fef55d19a0
---

# index.html commit 必須 protocol (永続原則)

**Date 確立**: 2026-06-14
**Incident source**: commit 8306612a → fff2fe16 → 藤本さん 「未だ反映されません」 報告 × 2 → commit c3fb4b48 で 1 line fix

## 規則

vite build 後 deploy する commit には **必ず** `dist-renderer/index.html` を含める。

## Why

CF Pages `_redirects` は `/* → /index.html 200` で **全 path が index.html を経由**。 `dist-renderer/index.html` の bundle 参照が古いと、 新 bundle が live にあっても **browser は古い bundle を読み込み続ける**。

vite build は `dist-renderer/` を空にして `app.html` だけを生成する (vite.config.ts input: 'app.html')。 `dist-renderer/index.html` は **git tracked separate file** で、 build のたびに削除 → `sync-index-html-bundle.ts` が git HEAD から restore + bundle 参照を `app.html` と一致させる。

問題: `sync` 走らせて update しても、 commit に含め忘れると **CF Pages は git HEAD の古い index.html を deploy** し続ける。

## How to apply (確実な 4 step protocol)

vite build 後 deploy commit を作る際:

```bash
# 1. build + sync を必ず両方走らせる
npx vite build && npx tsx scripts/sync-index-html-bundle.ts

# 2. ★ sync output を tail で truncate せず確認 (∵ data restore 行多数で末尾が見えにくい)
#    成功 line を grep で明示確認:
#    「✓ dist-renderer/index.html synced to app.html bundle」
#    または「✓ dist-renderer/index.html already in sync (no change)」

# 3. ★ git status で dist-renderer/index.html が staged or modified か必ず確認
git status -s dist-renderer/index.html

# 4. commit 前に明示 stage (忘れ防止)
git add dist-renderer/index.html dist-renderer/app.html dist-renderer/assets/app-*.js
git commit -m "..."
```

## Detection (commit 後 verify)

push 後 deploy verify 時:

```bash
# 最新 bundle hash を local app.html から取得
BUNDLE=$(grep -oE "app-[A-Za-z0-9_-]+\.js" dist-renderer/app.html | head -1)

# live root が同 bundle を参照しているか check
curl -s "https://rei-aios.pages.dev/?v=$(date +%s)" | grep -oE "app-[A-Za-z0-9_-]+\.js" | head -1
# → $BUNDLE と一致すれば OK
```

## Antipattern record (2026-06-14 incident)

- **NG**: `npx vite build && npx tsx scripts/sync-index-html-bundle.ts 2>&1 | tail -2`
  - tail -2 で sync 末尾 line を truncate
  - sync 「✓ index.html synced」 line を見落とし
  - git status での index.html 確認も skip
  - commit に index.html 不在 → CF Pages が stale 版 deploy

- **OK**: 上記 4 step protocol 通り

## 関連

- [[feedback-deploy-verify-http-200-plus-content-grep-required]] (HTTP 200 + content grep 二重 check)
- [[feedback-index-html-bundle-sync]] (dist-renderer bundle sync 必須)
- [[feedback-stop-hook-source-not-committed]] (Stop hook は data+bundle のみ commit、 src 手動必須 — 本 protocol は src + index.html の手動必須を追加)
- [[feedback-deploy-verify-violation-same-day-2026-06-05]] (deploy verify 違反 1 例目)
