Commit df2407a
committed
backup: reject Add after WriteTo on snapshotBuilder (claude review)
claude review on PR #825 found a silent-data-loss footgun: after
WriteTo set b.written, Add still passed its checks and appended to
b.entries, but those records could never be flushed (the second
WriteTo fails closed before re-sorting). For the M2-M5 adapter feed
loops this would silently drop records on builder reuse.
Add now guards on b.written at the top and returns the same
ErrSnapshotBuilderReused sentinel WriteTo uses, so a caller reusing an
exhausted builder gets one consistent signal regardless of method.
Caller audit: the only Add callers are tests; the production callers
(per-adapter encoders) land in M2-M5, so no existing call site relies
on post-WriteTo Add.
Test: TestSnapshotBuilderRejectsAddAfterWriteTo.1 parent d83d398 commit df2407a
2 files changed
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
153 | 163 | | |
154 | 164 | | |
155 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
272 | 292 | | |
273 | 293 | | |
274 | 294 | | |
| |||
0 commit comments