Commit 67d8678
tak: Persist Lamport timestamps across command runs
Bug fix:
- Lamport timestamps were resetting to 1 on each command run
- This caused all events to have ts=1, breaking proper claim resolution
- When multiple status changes occurred, the reducer couldn't determine which was latest
Solution:
- Store Lamport counter in database metadata table
- Increment and persist counter on each event creation
- Load counter from DB instead of using global variable
Changes:
- Add DB.GetNextLamportTS() method to get/increment persisted counter
- Remove global lamportCounter variable from ulid.go
- Update all event creation in main.go to use DB method
- Counter now properly increments: 1, 2, 3, 4, 5...
Result:
- Status updates now have increasing timestamps
- Latest status correctly becomes effective
- Older statuses marked as tentative
- Proper conflict resolution based on both authority and timestamp
Co-authored-by: neongreen <1523306+neongreen@users.noreply.github.com>1 parent 1650169 commit 67d8678
4 files changed
Lines changed: 58 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
259 | 296 | | |
260 | 297 | | |
261 | 298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
| |||
106 | 112 | | |
107 | 113 | | |
108 | 114 | | |
109 | | - | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
| |||
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
168 | 180 | | |
169 | 181 | | |
170 | 182 | | |
| |||
179 | 191 | | |
180 | 192 | | |
181 | 193 | | |
182 | | - | |
| 194 | + | |
183 | 195 | | |
184 | 196 | | |
185 | 197 | | |
| |||
223 | 235 | | |
224 | 236 | | |
225 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
226 | 244 | | |
227 | 245 | | |
228 | 246 | | |
| |||
235 | 253 | | |
236 | 254 | | |
237 | 255 | | |
238 | | - | |
| 256 | + | |
239 | 257 | | |
240 | 258 | | |
241 | 259 | | |
| |||
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
0 commit comments