fix(counts): counts.byType({ excludeVFS: true }) now returns correct type counts
Root cause: lazyLoadCounts() was reading from stats.nounCount (SERVICE-keyed)
instead of the sparse index (TYPE-keyed), and had a race condition (not awaited).
Changes:
- Fix lazyLoadCounts() to compute counts from 'noun' sparse index
- Move lazyLoadCounts() call from constructor to init() (properly awaited)
- Add getNounCountsByType()/getVerbCountsByType() getters to BaseStorage
- Add regression tests (7 tests)
Fixes Workshop bug where counts.byType({ excludeVFS: true }) returned {}
even when 48 entities existed in the database.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
e4ca3839e0
commit
9b2ff2d4ae
3 changed files with 229 additions and 15 deletions
|
|
@ -2439,6 +2439,24 @@ export abstract class BaseStorage extends BaseStorageAdapter {
|
|||
await this.writeObjectToPath(`${SYSTEM_DIR}/type-statistics.json`, stats)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get noun counts by type (O(1) access to type statistics)
|
||||
* v6.2.2: Exposed for MetadataIndexManager to use as single source of truth
|
||||
* @returns Uint32Array indexed by NounType enum value (42 types)
|
||||
*/
|
||||
public getNounCountsByType(): Uint32Array {
|
||||
return this.nounCountsByType
|
||||
}
|
||||
|
||||
/**
|
||||
* Get verb counts by type (O(1) access to type statistics)
|
||||
* v6.2.2: Exposed for MetadataIndexManager to use as single source of truth
|
||||
* @returns Uint32Array indexed by VerbType enum value (127 types)
|
||||
*/
|
||||
public getVerbCountsByType(): Uint32Array {
|
||||
return this.verbCountsByType
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild type counts from actual storage (v5.5.0)
|
||||
* Called when statistics are missing or inconsistent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue