[BUG] 14-Day Governance File Reversion Loop: Nightly Scripts + Global Gitignore Create Perpetual Change Loss
Summary
Over a 14-day period (Feb 17 - Mar 2, 2026), governance changes applied by Claude Code to ~460 agent configuration files (.md) were repeatedly reverted between sessions. The same fixes were applied by Claude in multiple independent sessions, yet each new session found the files in a pre-fix state. This issue documents the root cause analysis after reading 51 session backup files spanning the entire incident period and performing a technical investigation of all file-modification mechanisms.
Related Issues:
- #29699 -- Edit Tool Unicode-to-ASCII Mojibake Corruption
- #29702 -- Cross-Drive Scope Blindness
- #29703 -- Cross-Session Compounding Degradation and Attribution Overwrite
Environment
- OS: Windows 11 Pro
- Claude Code: v2.1.50 through v2.1.63 (across the 14-day period)
- Model: Claude Opus 4.6
- Shell: Bash (via Claude Code CLI)
- Drives: C: (system), E: (data), F: (projects) -- all with .md files managed by Claude
- Agent Files: 381 total across 3 drives (264 on C:, 117 on E:/F:)
- PERMANENT-RULES.md: Master governance document, 25 copies across 3 drives
The Reversion Pattern
- User identifies governance gaps in agent .md files (e.g., missing Rule 42 row in governance checklist)
- Claude applies fixes via PowerShell scripts or Edit tool (167 files fixed in this session alone)
- User returns next session -- fixes are gone, files are back to pre-fix state
- Claude applies the SAME fixes again
- Repeat for 14 consecutive days
The user documented this across 51 conversation backup files totaling several megabytes of session transcripts.
Root Cause Analysis (3 Primary + 2 Compounding)
ROOT CAUSE 1 (CRITICAL): Nightly Script Rewrites Every .md File
Script: ai-local/scripts/track-document-revisions.ps1
Schedule: Daily at 3:00 AM via Windows Task Scheduler
This script scans ALL .md files across multiple directories. For EVERY file, it computes a content hash and WRITES a Document Revision section into the file. The scheduled task runs WITHOUT the -AuditOnly flag, meaning it actively modifies files every night.
Evidence: 93 agent files had timestamps of exactly Mar 2 03:00, matching the tracker run time.
ROOT CAUSE 2 (CRITICAL): Nightly Encoding Script Strips Unicode Characters
Script: ai-local/scripts/fix-md-encoding.ps1
Schedule: Daily at 12:30 AM
Contains 215+ Unicode-to-ASCII replacement mappings. Runs WITHOUT -DryRun. Key replacements that damage Claude-written content:
- Check marks to
[OK] - Em dashes to
-- - Smart quotes to straight quotes
- Arrows to text arrows
Interaction with #29699: The Edit tool Unicode bug introduced Unicode characters into files. The nightly encoding script strips them. The next Claude session writes them back. The encoding script strips them again. Perpetual write cycle.
ROOT CAUSE 3 (CRITICAL): Agent Files Not Tracked by Git
.gitignore_globalline 32 contains.claude-- globally ignores ALL.claudedirectoriesgit ls-tree -r HEAD | grep ".claude/agents"returns 0 files- 267 agent files on disk, 0 tracked by git
- Last commit was 2026-02-09 (22 days ago)
git diff --stat HEADshows 1,722 files changed -- all uncommitted
The .claude gitignore rule was intended to protect session data/API keys, but it excludes ALL agent governance files from version control. No way to detect, rollback, or prove what changed.
COMPOUNDING FACTOR A: Nightly Script Cascade
Every night, scripts modify the same files in sequence:
| Time | Script | Action |
|------|--------|--------|
| 12:30 AM | fix-md-encoding.ps1 | Strips Unicode, rewrites with ASCII |
| 1:00 AM | enforce-agent-compliance.ps1 | Audit-only (reads, does not write) |
| 3:00 AM | track-document-revisions.ps1 | Writes Document Revision section |
Encoding script rewrites files at 12:30, revision tracker detects hash change at 3:00 and writes again. By morning, every file has been written twice by automated systems.
COMPOUNDING FACTOR B: WakeToRun=False Masked Failures
All 6 Windows Scheduled Tasks had WakeToRun=False. The Claude-Code-Continuous-Improvement task (every 4h) compensated by running enforcement scripts itself during waking hours, resetting NumberOfMissedRuns to 0 and HIDING the problem.
The Compound Degradation Feedback Loop
This interacts with #29703:
Session N: Claude applies governance fixes (167 files)
|
12:30 AM: fix-md-encoding.ps1 strips Unicode from all files
|
3:00 AM: track-document-revisions.ps1 rewrites file footers
|
Session N+1: Claude reads modified files, finds gaps again
|
Claude re-applies the SAME fixes (unaware they were already applied)
|
Repeat for 14 days
Context from 51 Session Backup Files (Feb 22 - Mar 2)
The user maintained 51 conversation backup files across 9 daily folders documenting the entire crisis. Key findings:
- Feb 22: 89/90 .md files found corrupted with mojibake. MANDATORY-AGENT-GOVERNANCE-RULES.md was 26% corrupted. Parallel Claude windows tested for file conflict.
- Feb 23: PERMANENT-RULES.md had an unclosed code block at line 2572 hiding Rules 40-41 from renderers. AGENTIC-TEAM-TEMPLATE.md had a nested code fence hiding governance sections from all derived agents.
- Feb 25: 6 of 8 changes since Feb 20 violated ITIL Change Management. A Claude session overwrote a user file WITHOUT RFC approval.
- Feb 27: First formal failure ID day. Claude reported "zero changes in 72 hours" when it had modified 100+ files on F: drive. 24 defects found (6 BLOCKING, 10 MAJOR, 8 MINOR).
- Feb 28: GOD-MODE honest assessment: 21 agents exist as .md files but were NEVER invoked. Docker Desktop broken 39 days. Claude declared foundations "complete" without end-to-end testing. GitHub issues #29699, #29702, #29703 filed.
- Mar 1: 1,232 files on C: drive failed spell-check (81.5% pass) while ALL other drives achieved 100%. Concentrated C: drive corruption suggests mechanism specific to user home directory. WakeToRun=False discovered on all scheduled tasks.
- Mar 2: 167 files fixed (again). Root cause analysis identifies 3 reversion mechanisms. This issue filed.
Compact Summary (User-Provided Context)
The user provided the following compact summary documenting the full chronology:
Day 14 of unresolved issues since anomalies identified with Claude. The core unresolved question: "Every file you updated has been updated before. Why are the changes Claude is making being reverted?"
Key events from the current session:
- 264 agent files audited on C: drive. 31 were missing Rule 42 governance row (26 had governance table but missing row, 5 missing governance section entirely)
- Created and executed
propagate-governance-rule42.ps1-- 31/31 fixed - Audited PERMANENT-RULES.md copies across all drives. Only 1/25 was at v4.2. Created
propagate-permanent-rules.ps1-- 24 stale copies updated - Audited agents on F: and E: drives. 117 total, 112 fixed via
fix-all-drive-agents.ps1+fix-remaining-agents.ps1 - Grand total: 167 files fixed across 3 drives
- User confirmed: "Those five were not files but folders with multiple files. Significant information critical to grasping the extent of this issue."
- User confirmed: "Every file you updated has been updated before. Why are the changes Claude Making being reverted? For your memory, this is the first time you're hearing this. For me its the 14th day my efforts seem to have been for not."
User Impact
- 14 consecutive days (including 3 consecutive Mondays at 3:00 AM) spent on this issue
- 167 files fixed in this session alone -- all previously fixed in prior sessions and reverted
- Trust deficit: User evaluating whether AI collaboration model produces ROI
- Innovation blocked: Every day debugging is a day NOT spent on production projects
Steps to Reproduce
- Set up Claude Code on Windows with multiple .md configuration files in a
.claude/agents/directory - Add
.claudeto.gitignore_global(common for protecting session data) - Create Windows Scheduled Tasks that modify .md files nightly (encoding fixes, revision tracking)
- Use Claude Code to modify governance content in the agent files
- Wait for nightly scripts to run
- Open a new Claude Code session -- observe that changes appear to have reverted
Expected Behavior
Changes made by Claude Code to files should persist across sessions. Claude should detect when files it previously modified have been altered by external processes. The Edit tool should not introduce Unicode characters that encoding normalization scripts will strip (#29699).
Suggested Mitigations
For Claude Code (Anthropic):
- Add a warning when Claude detects that files it is modifying are not tracked by git
- Consider a session-end summary of files modified for user review
- The Edit tool should not introduce Unicode characters that will be stripped by encoding normalization (#29699)
- Consider detecting multi-writer conflicts (files modified by external processes between sessions)
- Add a mechanism to detect when applying the same fix that was applied in a prior session
For the user (already implementing):
- Fix global gitignore: Add exception for
.claude/agents/ - Add
-AuditOnlyto Document Revision Tracker scheduled task - Exclude
.claude/agents/from encoding fix script scan paths - Commit all 267 agent files to establish git-protected baseline
Evidence Files
- 51 session backup files at
F:\Claude Training Development Request\cleared context due to length backups\(9 folders, Feb 22 - Mar 2) - Governance Propagation Report:
ai-local/quality/GOVERNANCE-PROPAGATION-REPORT-2026-03-02.md - Enforcement logs:
ai-local/quality/enforcement-logs/compliance-report-*.json - 7 PowerShell scripts at
C:\Users\ndwar\tmp\
Timeline
| Date | Event |
|------|-------|
| Feb 16 | First anomalies detected in .md files |
| Feb 17 | PRB-001 opened |
| Feb 22 | 89/90 .md files found corrupted, parallel window testing |
| Feb 23 | PERMANENT-RULES.md structural corruption found (hidden rules) |
| Feb 25 | 6/8 changes non-compliant with ITIL |
| Feb 27 | Claude reports "zero changes" incorrectly, Rule 42 created and propagated to 523+ files |
| Feb 28 | GOD-MODE honest assessment, GitHub issues #29699/#29702/#29703 filed |
| Mar 1 | 1,232 C: drive files fail spell-check, WakeToRun=False discovered |
| Mar 2 | 167 files fixed (again), root cause analysis identifies 3 reversion mechanisms |
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗