Repository navigation
Commit 9b089a2
committed
fix(config): keep the settings cache honest across batched same-key writes
CodeRabbit review comment 4452829726 (Data Integrity & Integration, Minor). The rollback
added in 6536617 captured `previousValue` per call, but `Memento.update` batches:
two writes to the same key issued before the scheduled flush share one pending promise,
so a rejected batch rejects both callers and the second one rolls the key back to the
first one's unflushed value - a value storage never held. Writes are now numbered per
key and the newest value that actually persisted is remembered: only the newest write
may touch the cache, and it restores what is persisted. `resetAllState` clears the
bookkeeping along with the cache so it cannot remember values storage dropped.
Tests: 4 new in `core/config/__tests__/ContextProxy.spec.ts` (42/42) - a batched
rejection restores the startup value, a superseded write that fails late leaves the
newer persisted value alone, an older failure cannot roll back a write that is still in
flight, and the first write of a key read from storage at startup rolls back to it.
Evidence: eight hand-written mutants are killed (drop the sequence guard, stop advancing
the persisted value on success, stop tracking the sequence, seed the persisted value from
the incoming value, never seed it, swallow the rejection, skip the cache write, restore
undefined). Full unit suite: 58 failed / 12003 passed before and after this commit, the
same 15 pre-existing Windows failures, no new ones (`core/webview/__tests__/ClineProvider
.spec.ts` is 2 failed / 314 passed both with and without this change). `pnpm --dir src run
check-types`: 114 pre-existing errors, none in a file this PR touches. ESLint exits 0
with `no-explicit-any` counts unchanged (1 and 5).1 parent faa9c0b commit 9b089a2
2 files changed
Lines changed: 108 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
| |||
365 | 372 | | |
366 | 373 | | |
367 | 374 | | |
368 | | - | |
369 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
370 | 380 | | |
371 | 381 | | |
372 | 382 | | |
373 | 383 | | |
374 | 384 | | |
375 | | - | |
376 | | - | |
| 385 | + | |
| 386 | + | |
377 | 387 | | |
378 | 388 | | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
383 | 404 | | |
384 | 405 | | |
385 | 406 | | |
| |||
603 | 624 | | |
604 | 625 | | |
605 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
606 | 631 | | |
607 | 632 | | |
608 | 633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
198 | 212 | | |
199 | 213 | | |
200 | 214 | | |
| |||
218 | 232 | | |
219 | 233 | | |
220 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 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 | + | |
221 | 296 | | |
222 | 297 | | |
223 | 298 | | |
| |||
0 commit comments