feat: US-009 - Add state save atomicity with SetLastChannel

- Create pkg/state package with State and Manager structs
- Implement SetLastChannel with atomic save using temp file + rename
- Implement SetLastChatID with same atomic save pattern
- Add GetLastChannel, GetLastChatID, and GetTimestamp getters
- Use sync.RWMutex for thread-safe concurrent access
- Add comprehensive tests for atomic save, concurrent access, and persistence
- Cleanup temp file if rename fails

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yinwm
2026-02-12 19:46:10 +08:00
parent 4c4c10c915
commit b94941da4a
4 changed files with 405 additions and 3 deletions

View File

@@ -137,7 +137,7 @@
"go test ./pkg/state -run TestAtomicSave passes"
],
"priority": 9,
"passes": false,
"passes": true,
"notes": ""
},
{