feat(wal): implement batch codec, validation, and Arena allocator

- wal/batch.go: WalBatch encode/decode with FragmentCollector state machine
- wal/validate.go: ValidateBatchLimits with checked arithmetic
- memtable/arena.go: Arena allocator with 8-byte alignment and mutex
- Comprehensive tests for all modules, all pass with -race
This commit is contained in:
dailz
2026-06-12 13:27:17 +08:00
parent cf913b1d52
commit fede839eb6
8 changed files with 1014 additions and 5 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:22:47.301Z",
"updated_at": "2026-06-12T05:26:58.955Z",
"session_ids": [
"opencode:ses_145c3bae9ffeTB2zbsTym0Cev8"
],
@@ -42,6 +42,19 @@
"status": "completed",
"ended_at": "2026-06-12T05:22:47.301Z",
"elapsed_ms": 173304
},
"todo:6": {
"task_key": "todo:6",
"task_label": "6",
"task_title": "WAL Batch encode/decode + fragment collector",
"session_id": "opencode:ses_145b65d08ffebmSv4sk5I69JXZ",
"agent": "Sisyphus-Junior",
"category": "unspecified-high",
"updated_at": "2026-06-12T05:26:58.955Z",
"started_at": "2026-06-12T05:26:43.370Z",
"status": "completed",
"ended_at": "2026-06-12T05:26:58.955Z",
"elapsed_ms": 15585
}
}
}
@@ -49,7 +62,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:22:47.301Z",
"updated_at": "2026-06-12T05:26:58.955Z",
"session_ids": [
"opencode:ses_145c3bae9ffeTB2zbsTym0Cev8"
],
@@ -83,6 +96,19 @@
"status": "completed",
"ended_at": "2026-06-12T05:22:47.301Z",
"elapsed_ms": 173304
},
"todo:6": {
"task_key": "todo:6",
"task_label": "6",
"task_title": "WAL Batch encode/decode + fragment collector",
"session_id": "opencode:ses_145b65d08ffebmSv4sk5I69JXZ",
"agent": "Sisyphus-Junior",
"category": "unspecified-high",
"updated_at": "2026-06-12T05:26:58.955Z",
"started_at": "2026-06-12T05:26:43.370Z",
"status": "completed",
"ended_at": "2026-06-12T05:26:58.955Z",
"elapsed_ms": 15585
}
},
"agent": "atlas"
+3 -3
View File
@@ -555,7 +555,7 @@ Max Concurrent: 6 (Wave 1b)
**Commit**: YES (group with Tasks 3, 4)
- [ ] 6. WAL Batch encode/decode + fragment collector
- [x] 6. WAL Batch encode/decode + fragment collector
**What to do**:
- 创建 `wal/batch.go``WalBatch` 结构体(Flags uint16, BaseSequence uint64, EntryCount uint32, EntriesSize uint32, Entries []byte
@@ -633,7 +633,7 @@ Max Concurrent: 6 (Wave 1b)
**Commit**: YES (group with Task 9)
- Message: `feat(wal): implement WAL batch codec and resource validation`
- [ ] 7. Arena allocator
- [x] 7. Arena allocator
**What to do**:
- 创建 `memtable/arena.go``Arena` 结构体
@@ -759,7 +759,7 @@ Max Concurrent: 6 (Wave 1b)
**Commit**: YES (with Task 7)
- [ ] 9. WAL Batch resource validation
- [x] 9. WAL Batch resource validation
**What to do**:
- 创建 `wal/validate.go``ValidateBatchLimits(entries []*WalEntry, cfg *config.WalConfig) error`