Commit 894d2f9
committed
fix(raftengine): PR783 r3 claude — reorder scanner guards to honor empty-range contract
Claude r3 on PR #783 flagged a contract violation in
HasEncryptionRelevantEntryInRange's guard ordering:
The EncryptionRelevantScanner interface (audit.go) requires the
empty-range case (startExclusive >= endInclusive) to return
(false, nil) UNCONDITIONALLY. The previous implementation
checked s.storage == nil FIRST, so a nil-storage scanner called
with an empty range would return the nil-storage error instead
of the contract-required (false, nil).
GuardSidecarBehindRaftLog in audit.go pre-filters the empty-gap
case (`if sidecarAppliedIdx >= engineAppliedIdx { return nil }`)
so this branch is unreachable in production today. But future
callers (6C-2d main.go phase, 6D capability fan-out) might
defensively call scan with a same-index range on a maybe-nil
engine. Pinning the order now avoids reintroducing the surprise
later.
Fix: reorder so empty-range short-circuits before nil-storage.
New TestEncryptionScanner_NilStorageEmptyRange pins the order
against regressions; the existing
TestEncryptionScanner_NilStorageError still passes because it
uses a non-empty range (0, 5), so the empty-range short-circuit
doesn't fire first.
## Verification
- go test -race -timeout=60s ./internal/raftengine/etcd/... — PASS
- golangci-lint run ./internal/raftengine/etcd/... — 0 issues1 parent 644e428 commit 894d2f9
2 files changed
Lines changed: 35 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
64 | 74 | | |
65 | 75 | | |
66 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
| 242 | + | |
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
246 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
247 | 267 | | |
248 | 268 | | |
249 | 269 | | |
| |||
0 commit comments