feat(wal): implement recovery orchestrator with tail truncation

- wal/recover.go: top-level Recover() function that orchestrates scan + replay + truncation
  Reads MANIFEST/CURRENT for recovery segment ID, handles tail corruption by truncating
- Comprehensive tests for empty dir, full flow, tail corruption, and MANIFEST updates
- All tests pass with -race
This commit is contained in:
dailz
2026-06-12 14:02:19 +08:00
parent fe2d4fc5f0
commit 294ab9181f
4 changed files with 392 additions and 3 deletions
+28 -2
View File
@@ -8,7 +8,7 @@
"plan_name": "phase1-wal",
"status": "active",
"started_at": "2026-06-12T05:09:32.588Z",
"updated_at": "2026-06-12T05:57:16.412Z",
"updated_at": "2026-06-12T06:02:11.867Z",
"session_ids": [
"opencode:ses_145c3bae9ffeTB2zbsTym0Cev8"
],
@@ -107,6 +107,19 @@
"status": "completed",
"ended_at": "2026-06-12T05:57:16.412Z",
"elapsed_ms": 23149
},
"todo:17": {
"task_key": "todo:17",
"task_label": "17",
"task_title": "WAL recovery: tail truncation + main flow",
"session_id": "opencode:ses_14597418effebiQE4kDHOCEW0E",
"agent": "Sisyphus-Junior",
"category": "unspecified-high",
"updated_at": "2026-06-12T06:02:11.867Z",
"started_at": "2026-06-12T06:01:55.154Z",
"status": "completed",
"ended_at": "2026-06-12T06:02:11.867Z",
"elapsed_ms": 16713
}
}
}
@@ -114,7 +127,7 @@
"active_plan": "/home/dailz/workspace/src/go-kv/.omo/plans/phase1-wal.md",
"started_at": "2026-06-12T05:09:32.588Z",
"status": "active",
"updated_at": "2026-06-12T05:57:16.412Z",
"updated_at": "2026-06-12T06:02:11.867Z",
"session_ids": [
"opencode:ses_145c3bae9ffeTB2zbsTym0Cev8"
],
@@ -213,6 +226,19 @@
"status": "completed",
"ended_at": "2026-06-12T05:57:16.412Z",
"elapsed_ms": 23149
},
"todo:17": {
"task_key": "todo:17",
"task_label": "17",
"task_title": "WAL recovery: tail truncation + main flow",
"session_id": "opencode:ses_14597418effebiQE4kDHOCEW0E",
"agent": "Sisyphus-Junior",
"category": "unspecified-high",
"updated_at": "2026-06-12T06:02:11.867Z",
"started_at": "2026-06-12T06:01:55.154Z",
"status": "completed",
"ended_at": "2026-06-12T06:02:11.867Z",
"elapsed_ms": 16713
}
},
"agent": "atlas"
+1 -1
View File
@@ -1287,7 +1287,7 @@ Max Concurrent: 6 (Wave 1b)
**Commit**: YES (with Tasks 15, 17)
- [ ] 17. WAL recovery: tail truncation + main flow
- [x] 17. WAL recovery: tail truncation + main flow
**What to do**:
- 创建 `wal/truncation.go`:尾部截断持久化