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:
parent
32dbdcec61
commit
364360d447
128 changed files with 5637 additions and 5682 deletions
|
|
@ -388,7 +388,7 @@ export class FieldTypeInference {
|
|||
const data = await this.storage.getMetadata(cacheKey)
|
||||
|
||||
if (data) {
|
||||
// v4.0.0: Double cast for type boundary crossing
|
||||
// Double cast for type boundary crossing
|
||||
return data as unknown as FieldTypeInfo
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -406,7 +406,7 @@ export class FieldTypeInference {
|
|||
this.typeCache.set(field, typeInfo)
|
||||
|
||||
// Save to persistent storage (async, non-blocking)
|
||||
// v4.0.0: Add required 'noun' property for NounMetadata
|
||||
// Add required 'noun' property for NounMetadata
|
||||
const cacheKey = `${this.CACHE_STORAGE_PREFIX}${field}`
|
||||
const metadataObj = {
|
||||
noun: 'FieldTypeCache',
|
||||
|
|
@ -487,7 +487,7 @@ export class FieldTypeInference {
|
|||
if (field) {
|
||||
this.typeCache.delete(field)
|
||||
const cacheKey = `${this.CACHE_STORAGE_PREFIX}${field}`
|
||||
// v4.0.0: null signals deletion to storage adapter
|
||||
// null signals deletion to storage adapter
|
||||
await this.storage.saveMetadata(cacheKey, null as any)
|
||||
} else {
|
||||
this.typeCache.clear()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue