fix: exclude __words__ keyword index from corruption detection and getStats()

The __words__ keyword index stores 50-5000 entries per entity (one per
word), which inflated avg entries/entity well above the corruption
threshold of 100. This caused:

1. validateConsistency() to falsely detect corruption on every startup,
   triggering unnecessary clearAllIndexData() + rebuild() cycles
2. getStats() to log false "Metadata index may be corrupted" warnings
   and report inflated totalEntries/totalIds stats

Both methods now skip __words__ when counting, so stats and health
checks reflect metadata fields only (noun, type, createdAt, etc.).
Keyword search is unaffected since the __words__ field index itself
is not modified.
This commit is contained in:
David Snelling 2026-01-27 15:38:21 -08:00
parent 32dbdcec61
commit 364360d447
128 changed files with 5637 additions and 5682 deletions

View file

@ -317,7 +317,7 @@ export class SemanticPathResolver {
}
/**
* Invalidate ALL caches (v6.3.0)
* Invalidate ALL caches
* Clears both traditional path cache AND semantic cache
* Call this when switching branches, clearing data, or forking
*/

View file

@ -52,7 +52,7 @@ export class AuthorProjection extends BaseProjectionStrategy {
* Resolve author to entity IDs using REAL Brainy.find()
*/
async resolve(brain: Brainy, vfs: VirtualFileSystem, authorName: string): Promise<string[]> {
// v4.7.0: VFS entities are part of the knowledge graph
// VFS entities are part of the knowledge graph
const results = await brain.find({
where: {
vfsType: 'file',

View file

@ -52,7 +52,7 @@ export class TagProjection extends BaseProjectionStrategy {
* Resolve tag to entity IDs using REAL Brainy.find()
*/
async resolve(brain: Brainy, vfs: VirtualFileSystem, tagName: string): Promise<string[]> {
// v4.7.0: VFS entities are part of the knowledge graph
// VFS entities are part of the knowledge graph
const results = await brain.find({
where: {
vfsType: 'file',

View file

@ -69,7 +69,7 @@ export class TemporalProjection extends BaseProjectionStrategy {
const endOfDay = new Date(date)
endOfDay.setHours(23, 59, 59, 999)
// v4.7.0: VFS entities are part of the knowledge graph
// VFS entities are part of the knowledge graph
const results = await brain.find({
where: {
vfsType: 'file',