Commit dd90e6b
fix+test: close verify_grovedb cidx content-consistency gap
Was the highest-priority audit item from my earlier self-grade: the
verify_grovedb H1-A walk verifies *chain* integrity but not *content*
consistency between the primary's count_value field and what the
secondary actually contains. The nested-cidx bug found in a8bb34f
was exactly this class — stale secondary that internally hashes
correctly but reports wrong counts. H1-A passed; queries lied.
Three changes:
1. CONTENT-CONSISTENCY CHECK in verify_grovedb. After the H1-A check
on each cidx primary, walk both Merks' raw storage and assert
per-entry consistency. Mismatches are recorded in the existing
VerificationIssues HashMap with sentinel path suffixes
(__cidx_primary_orphan__, __cidx_secondary_orphan__,
__cidx_count_mismatch__, __cidx_secondary_malformed_key__) so the
public API stays unchanged.
2. db.insert() REJECTS cidx primary targets. Adding the check
revealed a real direct-path bug: db.insert(cidx_primary, ...)
wrote to the primary without mirroring to the secondary, leaving
the same kind of drift the new check catches. Route users to
insert_into_count_indexed_tree with a NotSupported error.
3. DELIBERATE-CORRUPTION TESTS. Three tests directly manipulate the
secondary's storage via Element::insert/delete to introduce each
drift class:
- verify_grovedb_catches_secondary_missing_entry_for_primary
- verify_grovedb_catches_orphan_in_secondary
- verify_grovedb_catches_count_mismatch_between_primary_and_
secondary
Plus direct_db_insert_into_cidx_primary_is_rejected covering
the rejection from item 2.
Without item 1, all three corruption tests would silently pass an
integrity check. With it, the class of bug that took an audit to
find is now CI-caught for any future regression.
All 1576 grovedb tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2498b97 commit dd90e6b
3 files changed
Lines changed: 504 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1305 | 1305 | | |
1306 | 1306 | | |
1307 | 1307 | | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
1308 | 1401 | | |
1309 | 1402 | | |
1310 | 1403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
204 | 228 | | |
205 | 229 | | |
206 | 230 | | |
| |||
0 commit comments