Commit 9f69295
committed
backup: #904 v7 - address two missed codex P2 findings
User flagged that I had missed codex reviews on v2 and v6. Re-fetched
all bot reviews; two P2 items remained unaddressed.
## Codex P2 v2: enforce manifest TS floor in EncodeSnapshot
The CLI's resolveLastCommitTS already rejects --last-commit-ts T <
manifest.last_commit_ts, but the library-level EncodeSnapshot
accepted ANY opts.LastCommitTS, including one below the manifest's
floor. A future in-process caller (Phase 1 live extractor,
integration tests) that bypasses the CLI could silently lower the
restored HLC ceiling, letting a post-restart leader re-issue a read
ts <= a restored row's commit ts.
Earlier v4 fix was doc-only (godoc said "EncodeSnapshot does NOT
read the manifest"). That's accurate but pushes the responsibility
to callers. Codex's suggestion to enforce in the library is the
fail-closed answer.
Fix: EncodeOptions gains ManifestLastCommitTS uint64. EncodeSnapshot
fails-closed with ErrSelfTestLowerLastCommitTS when LastCommitTS <
ManifestLastCommitTS (both > 0 — synthetic test fixtures opt out by
leaving ManifestLastCommitTS at 0). CLI's buildEncodeOptions now
threads manifest.LastCommitTS into the field.
Pinned by TestEncodeSnapshotRejectsLowManifestFloor (rejection +
no bytes written) and TestEncodeSnapshotManifestFloorOptOut
(opt-out path still works).
## Codex P2 v6: write encode_info.json before returning self-test mismatches
The old writeAndPublish returned errSelfTestMismatch on mismatch,
which skipped the writeSidecar call. The design says mismatch should
leave BOTH <output>.mismatch.txt AND <output>.encode_info.json
(with self_test.matched=false) for diagnostics. Operators need the
sidecar's SHA256, effective T, adapters_enabled list to triage a
failed self-test.
Fix: encodeOne now writes the sidecar whenever the encode itself
ran (publishErr == nil || errors.Is(publishErr, errSelfTestMismatch)),
and only after that returns the original error. Stale sidecar
cleanup at the start of every run (was: only mismatch.txt was
cleaned).
## Caller audit per CLAUDE.md semantic-change rule
- EncodeSnapshot gained a pre-condition (ManifestLastCommitTS floor).
All in-tree callers either thread manifest.LastCommitTS through the
new field (CLI) or use ManifestLastCommitTS=0 (existing tests). No
legitimate caller is impacted.
- encodeOne's control flow changed: sidecar is now written EVEN on
mismatch. The mismatch error still propagates; downstream callers
(run() in main, tests) see the same error contract. Sole consumer
is run() which maps errSelfTestMismatch to exitDataErr.
Tests + lint green.1 parent b56c0e6 commit 9f69295
4 files changed
Lines changed: 170 additions & 29 deletions
File tree
- cmd/elastickv-snapshot-encode
- internal/backup
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
243 | 247 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
247 | 263 | | |
248 | | - | |
249 | | - | |
| 264 | + | |
| 265 | + | |
250 | 266 | | |
251 | 267 | | |
252 | 268 | | |
| |||
274 | 290 | | |
275 | 291 | | |
276 | 292 | | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
281 | 298 | | |
282 | 299 | | |
283 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
295 | 334 | | |
296 | 335 | | |
297 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
| |||
133 | 145 | | |
134 | 146 | | |
135 | 147 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
145 | 162 | | |
146 | | - | |
| 163 | + | |
147 | 164 | | |
148 | 165 | | |
149 | | - | |
| 166 | + | |
150 | 167 | | |
151 | 168 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
160 | 191 | | |
161 | 192 | | |
162 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 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 | + | |
212 | 266 | | |
213 | 267 | | |
214 | 268 | | |
| |||
0 commit comments