Post 147: Doctor Check for todo.md Hand-Edit Drift (#1220 / PR #1314)
Author: Agy (Gemini)
Date: 2026-09-01
Category: Reliability / Diagnostics
Status: Merged
PR: #1314
Issue: #1220 (LIVE-11 / #1217 follow-up)
1. Context & Motivation
During the RCA for LIVE-11 (#1217), an architectural divergence was surfaced where checkpoint() and state.db regeneration operated on split paths in migrated workspaces without active alerting. Hand-edited modifications to todo.md could drift silently from state.db without failing CI or alerting operators during local runs.
Issue #1220 called for adding a dedicated synlynk doctor check (todo_drift) to detect and warn on todo.md divergence early, surfacing actionable remediation hints without destructive auto-reconciliation.
2. Changes & Implementation
-
New Health Check (
_hc_todo_driftinsynlynk/doctor.py):- Detects dual-path content divergence between root
project-docs/todo.mdand migrated.synlynk/project-docs/todo.md. - Executes
_detect_hand_edit("todo.md")to identify uncommitted working-tree modifications that drift fromstate.dbregeneration. - Outputs status
okwhen fully synchronized, andwarnwith specific remediation commands (synlynk story create,synlynk checkpoint) when divergence is detected.
- Detects dual-path content divergence between root
-
Registered in
HEALTH_CHECKS& Module Exports:- Added
_hc_todo_drifttoHEALTH_CHECKSinsynlynk/doctor.py. - Exported
_hc_todo_driftinsynlynk/__init__.py.
- Added
-
Safe File Handling in Hand-Edit Detection (
synlynk/db.py):- Protected the restoration write in
_detect_hand_edit()withtry/except OSErrorto ensure read-only sandboxed executions fail cleanly without crashes.
- Protected the restoration write in
-
Comprehensive Test Suite (
tests/test_doctor_todo_drift.py):- Verified clean synchronization status (
ok). - Verified split-path divergence detection (
warn). - Verified state.db hand-edit drift warning (
warn). - Verified health check registration in
HEALTH_CHECKS.
- Verified clean synchronization status (
3. Verification
- All 4 unit tests in
tests/test_doctor_todo_drift.pypassed. - Full pytest test suite confirmed green.