chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase

This commit is contained in:
David Snelling 2026-06-11 14:51:00 -07:00
parent 970e08c466
commit 1f7e365a4e
237 changed files with 1951 additions and 49413 deletions

View file

@ -123,7 +123,7 @@ export class BackgroundDeduplicator {
try {
// Get all entities from this import using brain.find()
const results = await this.brain.find({
where: { importId } as any,
where: { importId },
limit: 100000 // Large limit to get all entities from import
})
@ -298,7 +298,7 @@ export class BackgroundDeduplicator {
return this.brain.find({
query,
limit: 5,
where: { type: entity.type } as any // Type-aware search
where: { type: entity.type } // Type-aware search
})
})
@ -318,8 +318,11 @@ export class BackgroundDeduplicator {
// Check if not already merged
const stillExists = await this.brain.get(entity.id)
if (stillExists) {
// Cast match.entity to HNSWNounWithMetadata (it comes from brain.find results)
const matchEntity = match.entity as any as HNSWNounWithMetadata
// Typed boundary: bridge the public Entity<T> result shape from
// brain.find() to the storage-layer HNSWNounWithMetadata record
// (same structural bridge as the results.map above). The merge
// path only reads id/type/metadata, present in both shapes.
const matchEntity = match.entity as unknown as HNSWNounWithMetadata
await this.mergeEntities([entity, matchEntity], 'Similarity')
merged++
break // Only merge with first high-similarity match
@ -388,7 +391,7 @@ export class BackgroundDeduplicator {
for (const entity of entities) {
if (entity.id !== primary.id) {
try {
await this.brain.delete(entity.id)
await this.brain.remove(entity.id)
} catch (error) {
// Entity might already be deleted, continue
prodLog.debug(`[BackgroundDedup] Could not delete ${entity.id}:`, error)