Lesson Learned #112: Self-Healing Data Integrity System Required
Date: January 8, 2026
Severity: HIGH
Category: System Architecture
Incident Summary
CEO identified multiple data integrity issues that have been recurring daily:
-
system_state.jsonshowed Jan 7 instead of Jan 8 - Challenge day counter showed 70 instead of 72 (calculated from start date)
-
docs/index.mdshowed "Day 70/90" and "Wednesday, January 7, 2026" - GitHub Wiki dashboard showed old $117K paper account instead of post-reset $5K
-
docs/progress_dashboard.mdhad wrong day counter
CEO Quote: "Why isn't our system self healing? Why do I have to bring out these issues everyday?"
Root Cause Analysis
-
No automated date updates:
current_datein system_state.json required manual updates -
Day counter not calculated dynamically: Was stored as static value instead of computed from
start_date - Multiple sources of truth: system_state.json, index.md, wiki, progress_dashboard all needed separate updates
- No staleness detection with auto-fix: Hook detected staleness but didn't fix it
- Dashboard not auto-regenerated: When CEO reset paper to $5K, wiki dashboard never updated
Solution Implemented
1. Created scripts/self_heal_data.py
Auto-fixes:
-
current_datein system_state.json (always today) -
current_daycounter (calculated from start_date: Oct 29, 2025) -
days_remainingcounter -
docs/index.mddate and day references - "Last updated" timestamps
2. Added Self-Healing to CI Workflow
In .github/workflows/daily-trading.yml:
- Runs before trading execution every day
- Auto-commits fixes if any changes detected
- Non-blocking (doesn't fail the workflow)
3. Correct Calculation
from datetime import date
start = date(2025, 10, 29)
today = date.today()
current_day = (today - start).days + 1
For Jan 8, 2026: Day 72 (not 70 or 71)
Prevention Measures
- Calculate, don't store: Day counter should be COMPUTED from start_date, not stored
- Single source of truth: All displays should read from system_state.json
- Auto-regenerate dashboards: After any data change, regenerate all views
- Self-healing CI step: Every workflow should fix data drift before execution
Files Changed
-
scripts/self_heal_data.py(NEW) .github/workflows/daily-trading.ymldata/system_state.jsondocs/index.mddocs/progress_dashboard.md
Verification
Run self-healing manually:
python3 scripts/self_heal_data.py
Expected output when data is current:
SELF-HEALING COMPLETE: All data is current
Tags
data-integrity #self-healing #automation #ci-cd #staleness
This lesson was auto-published from our AI Trading repository.
More lessons: rag_knowledge/lessons_learned
Top comments (0)