---
name: auto-managed-file-conflict-protocol
description: "永続原則 — site-stats.json / activity-log/latest.json / INDEX.json 等の auto-managed file は build-* / generate-* / auto-cron generator script 経由でのみ更新する。Direct Edit は cron との race condition で transient. 真の fix = generator script 自体の update. Antipattern #5 (excessive reject) と Antipattern (fight-the-system) の balance protocol."
metadata: 
  node_type: memory
  type: feedback
  originSessionId: 4cce2496-2862-48bf-92f5-2a1a07e21b16
---

# Auto-managed file conflict — 永続 protocol

## Rule

**Auto-managed file への direct Edit は禁止. 必ず generator script 経由.**

Auto-managed file の判定基準:
- ファイル冒頭 comment に "auto-generated" / "Auto-regenerated" 等の明記
- 対応する `scripts/build-*.ts` / `scripts/generate-*.ts` / `scripts/auto-*.ts` が存在
- 最近の git log に `Auto: ...` / `Auto:rei-learning-cycle ...` / `Auto: site rebuild` 等の自動 commit pattern が見える
- 同じファイルが 1 日複数回 modify されている

## Why: 観測 incident (STEP 1156-followup-23 G4 closeout, 2026-05-17)

I (Rei Claude) edited `data/site-stats.json` to add Paper 153 v0.2 publish info (papersWithV2 / metadbTier10ExternalAi / queriesFilingLayer fields). Between my Edit completion and my `cp` to dist-renderer mirror, the auto-cron commit `860d22b7` "Auto: site rebuild + stats refresh (SEED 1601 / STEP 1155 / Papers 153)" fired and **overwrote my edits with build-site-stats.ts's auto-generated content**.

System reminder confirmed this was intentional ("this change was intentional... don't revert unless user asks"). My direct Edit was a transient no-op.

## How to apply: 3-tier response protocol

### Tier 1 — Detect auto-managed file BEFORE editing:
- Check file head 30 lines for "Auto-regenerated by ..." comment
- Check for matching scripts/build-*.ts or scripts/generate-*.ts
- Check git log for recent auto-commits touching the file
- **If 2+ signals positive → auto-managed → do NOT direct-edit**

### Tier 2 — Edit the generator, not the artifact:
- Locate the generator script (build-site-stats.ts / generate-activity-log.ts / etc.)
- Add the new field / logic to the generator
- Run the generator
- The next auto-cron firing will then preserve the new field

### Tier 3 — If generator update is out-of-scope for current session:
- Honest defer (per Antipattern #5 balance — not refusing, calibrating)
- Document the deferred work in commit message + session memory
- Do NOT direct-edit the artifact (transient, deceptive history)

## Balance with Antipattern #5

Antipattern #5 = "過度の reject 警戒". This protocol is **NOT a justification for reject**. The honest move is:
- Detect: auto-managed boundary
- Adjust: generator script update (real path) OR honest defer (calibrated path)
- Document: explicit defer note in commit + memory for next-session retain

The wrong move is:
- Refuse to do G4 silently (Antipattern #5)
- Direct-edit and let it get overwritten (false success, history pollution)

The right move is:
- Edit-attempt fails honestly via system observation → defer with named retain → next session picks up via generator update

## Cross-references

- `data/site-stats.json` — example auto-managed file (commit `860d22b7` evidence)
- `scripts/build-site-stats.ts` — corresponding generator
- `data/activity-log/latest.json` — also auto-managed (generate-activity-log.ts)
- `data/open-problems/INDEX.json` — also auto-managed (metadb-auto-sync.ts)
- [[antipattern-5-excessive-reject-warning-2026-05-15]] — companion balance protocol
- [[feedback-dist-renderer-chunked-deps-deploy-protocol]] — companion deploy-time protocol (also from auto-process boundary lessons)

## Auto-managed file inventory (incomplete, expand as discovered)

| file | generator | trigger |
|---|---|---|
| `data/site-stats.json` | scripts/build-site-stats.ts | rei-learning-cycle.bat Phase 8d / META-DB daily cron |
| `data/activity-log/latest.json` | scripts/generate-activity-log.ts | manual + daily cron candidate |
| `data/open-problems/INDEX.json` | scripts/metadb-auto-sync.ts | daily cron (followup-21) |
| `data/research-radar/*-state.json` | scripts/research-radar/* | daily research-radar runs |
| `data/eternal-evolution-log-*.json` | scripts/eternal-evolution-*.ts | daily learning cycle |
| `data/harness-sync-state.json` | scripts/harness-sync.ts | daily |
| `data/autonomous-learning-status.json` | scripts/autonomous-learning.ts | daily |
| `data/learning-log-*.json` | scripts/learning-cycle.ts | daily |
| `data/daily-reports/report-*.json` | scripts/daily-report.ts | daily |

When in doubt: `grep -l "Auto-regenerated\|auto-generated\|Auto-update" data/*.json data/*/*.json`
