---
name: feedback-public-tools-source-of-truth-dist-renderer-cron-regenerated
description: "public/tools/* が source of truth、 dist-renderer/tools/* は vite build が publicDir → outDir copy で自動生成する build artifact。 .gitignore lines 102-106 明記あり。 session 中の Auto: site rebuild cron が dist-renderer/tools/ を public/ から regenerate するため、 dist-renderer/tools/*.html への直接編集は cron に上書き消失する。 編集対象は常に public/tools/*、 更新後 cp で dist-renderer sync + 即 commit で cron 上書き封じ、 push 前に stash unstaged で pull-rebase (2026-08-04 Rei-Solver v0.4 site 反映 incident 5 件目で確立)。"
metadata: 
  node_type: memory
  type: feedback
  originSessionId: 88732e47-57a7-4338-9999-252560cca0d7
  modified: 2026-08-04T02:45:16.245Z
---

# public/tools/* = source of truth、 dist-renderer/tools/* = cron regenerated build artifact (2026-08-04 確立)

## Rule

**tools/ 配下 .html file を編集する時は 必ず `public/tools/*` を編集する** (source of truth)。 `dist-renderer/tools/*` は build artifact = vite build が `publicDir` → `outDir` copy で自動生成 = **session 中の Auto: site rebuild cron が public/ 側から regenerate する = 直接編集は cron に上書きされ消失する**。

## Why

**Root cause (2026-08-04 incident 5 件目 = 藤本さん「回路のほうサイト反映」 依頼 arc)**:

1. dist-renderer/tools/rei-solver/index.html を「site 反映対象」 と判断して直接 Edit tool で 8 回編集 (全て「successfully」 report)
2. md5 verify で全 edit 消失発覚。 file mtime が Aug 2 (Edit 前) に revert
3. 原因調査で `git log --oneline -3` に session 中に 2 個の Auto: site rebuild commit landing 確認 (0d70d2f08 + ca235b314)
4. `.gitignore` lines 102-106 明示発見:
   ```
   # 2026-06-25 — tools/ は public/tools/ が source of truth.
   # vite build が publicDir → outDir copy で dist-renderer/tools/ を自動生成
   # 編集対象は常に public/tools/* で、 dist-renderer/tools/* は build artifact.
   dist-renderer/tools/
   ```
   (ただし historical に既 tracked file はそのまま tracked、 check-ignore exit=1)
5. cron 上書き = `vite build` が publicDir (=`public/`) → outDir (=`dist-renderer/`) copy 実行 → 私の dist 直接編集を public/ の古い v0.3 で override

**Pattern**: 2026-06-25 に「public/tools/ が source of truth」 protocol 確立あり、 私は .gitignore comment を事前 grep せず dist-renderer 側編集開始 = `[[feedback-grep-before-answer-discipline]]` preflight 抜けの直接原因。

## How to apply

**site 上の tools/ 配下 .html 更新の正しい flow**:

1. **preflight verify**: `cat .gitignore | grep -A 3 "tools/"` で protocol 現状確認 (memory と .gitignore の同期)
2. **Edit target = public/tools/*.html** (source of truth) — dist-renderer/tools/*.html には触れない
3. **Edit 完了後 verify**: `stat -c "%y" public/tools/{tool}/index.html` で mtime 更新確認 + `grep -c 'v0.X marker'` で content verify
4. **sync**: `cp public/tools/{tool}/index.html dist-renderer/tools/{tool}/index.html` で immediate sync (次の vite build cron 待ちより早い)
5. **md5 verify**: `md5sum public/tools/{tool}/index.html dist-renderer/tools/{tool}/index.html` で完全一致 confirm
6. **atomic commit**: `git add -u {両 file}` + `git commit` で cron 上書き前に freeze (`-u` は tracked file 限定 add で新 gitignored file を触らない)
7. **stash unstaged**: cron 生成 464+ file 変更を `git stash push -u -m "auto-gen for {arc} push"` で退避後 `git pull --rebase && git push`
8. **live HTTP verify**: `curl -sL "https://rei-aios.pages.dev/tools/{tool}/" | grep -c "vN marker"` で反映 confirm (deploy 15-30 sec 待機)
9. **stash pop**: 退避 stash を戻す (`git stash pop`)

**関連 memory**:
- [[feedback-projection-self-audit-pattern]] — 本 incident は「5 rule 発火事例」、 SAC-4 型対応
- [[feedback-grep-before-answer-discipline]] — .gitignore preflight grep 抜け = 本 incident 直接原因
- [[feedback-dist-renderer-dual-html-sync-protocol]] — 別軸 (index.html + app.html bundle reference sync)、 混同注意
- [[feedback-dist-renderer-mass-delete-prevention-protocol]] — dist-renderer/oukc/ mass delete (別軸)、 tools/ とは protocol 異なる

## Detection

**dist-renderer/tools/*.html 直接編集の兆候** (直ちに public/ 側に修正):
- `.gitignore` grep で `dist-renderer/tools/` rule 発見
- ls -la で mtime が Aug 2 のように古い日付 (cron regeneration 前の初期化状態)
- md5 verify で dist-renderer と public/ が一致 (cp not yet applied) → cron が public 内容で dist を上書きしていた evidence
- git log で「Auto: site rebuild + stats refresh」 commit が session 中に landing

**Positive verify**:
- `stat -c "%y" public/tools/{tool}/index.html` mtime が本 session 時刻
- `git ls-files dist-renderer/tools/{tool}/index.html` = 0 (tracked) + `git diff --staged --stat` で public + dist 両方 staged
- live HTTP curl content grep で新 version marker hit
