Commit 6bf5343
fix(core): exclude stale entity rows from embedding coverage stats
When entities are deleted, their rows in search_index and
search_vector_chunks can remain as orphans. This caused
`bm project info` to overcount total_indexed_entities and report
false "missing embeddings" recommendations after a successful reindex.
Two-pronged fix:
1. Filter embedding status queries to only count entity_ids that
still exist in the entity table (fixes reporting)
2. Purge stale search rows during reindex (fixes root cause)
Fixes #670
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: phernandez <paul@basicmachines.co>1 parent dd91b49 commit 6bf5343
3 files changed
Lines changed: 103 additions & 3 deletions
File tree
- src/basic_memory/services
- tests/services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
1000 | 1004 | | |
1001 | 1005 | | |
1002 | | - | |
| 1006 | + | |
| 1007 | + | |
1003 | 1008 | | |
1004 | 1009 | | |
1005 | 1010 | | |
1006 | 1011 | | |
1007 | 1012 | | |
1008 | 1013 | | |
1009 | 1014 | | |
1010 | | - | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
1011 | 1019 | | |
1012 | 1020 | | |
1013 | 1021 | | |
1014 | 1022 | | |
1015 | 1023 | | |
1016 | 1024 | | |
1017 | 1025 | | |
1018 | | - | |
| 1026 | + | |
1019 | 1027 | | |
1020 | 1028 | | |
1021 | 1029 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
406 | 411 | | |
407 | 412 | | |
408 | 413 | | |
| |||
419 | 424 | | |
420 | 425 | | |
421 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
422 | 473 | | |
423 | 474 | | |
424 | 475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 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 | + | |
254 | 295 | | |
255 | 296 | | |
256 | 297 | | |
| |||
0 commit comments