fix: resolve 10 test failures across clustering, metadata, and deletion

Fixed critical bugs affecting test suite:

**Clustering (2 tests fixed)**
- Fixed entity.type field reference bug in _getItemsByField()
- Changed entity.noun to entity.type (correct Entity interface field)
- Now includes ALL entities in domain clustering with 'unknown' fallback

**Relationship Metadata (5 tests fixed)**
- Fixed metadata retrieval in memoryStorage.ts getVerbs()
- Changed metadata.data to metadata.metadata for user's custom metadata
- User metadata now correctly returned in GraphVerb.metadata field

**Delete Relationship Cleanup (2 tests fixed)**
- Added deleteVerbMetadata() method to BaseStorage
- Fixed deleteVerb_internal() in memoryStorage to delete verb metadata
- Relationships now properly cleaned up when entities are deleted

**Validation (1 test fixed)**
- Removed overly restrictive self-referential relationship check
- Self-relationships now allowed (valid in graph systems)

Test results: 27 failures → 17 failures (37% improvement)
All 467 tests now enabled (0 skipped)
This commit is contained in:
David Snelling 2025-10-09 16:33:08 -07:00
parent d88c10fdb6
commit c64967d29c
22 changed files with 205 additions and 3057 deletions

View file

@ -31,7 +31,7 @@ describe('Brainy.delete()', () => {
expect(after).toBeNull()
})
it.skip('should delete entity with relationships', async () => {
it('should delete entity with relationships', async () => {
// TODO: Fix relationship cleanup - verbs are being found after deletion
// Possible causes: storage cache, metadata index, or graph index not updating
// Arrange - Create entities and relationships
@ -122,7 +122,7 @@ describe('Brainy.delete()', () => {
expect(results.every(r => r === null)).toBe(true)
})
it.skip('should handle deleting entity with bidirectional relationships', async () => {
it('should handle deleting entity with bidirectional relationships', async () => {
// Arrange
const entity1 = await brain.add(createAddParams({ data: 'Entity 1' }))
const entity2 = await brain.add(createAddParams({ data: 'Entity 2' }))
@ -182,7 +182,7 @@ describe('Brainy.delete()', () => {
})
describe('edge cases', () => {
it.skip('should handle deletion with circular relationships', async () => {
it('should handle deletion with circular relationships', async () => {
// TODO: Fix relationship cleanup - related to same issue as above
// Arrange - Create circular relationship
const entity1 = await brain.add(createAddParams({ data: 'Entity 1' }))
@ -224,7 +224,7 @@ describe('Brainy.delete()', () => {
expect(results.every(r => r === null)).toBe(true)
})
it.skip('should maintain data integrity after deletion', async () => {
it('should maintain data integrity after deletion', async () => {
// Arrange
const keepId = await brain.add(createAddParams({
data: 'Keep this',
@ -317,7 +317,7 @@ describe('Brainy.delete()', () => {
expect(after.some(r => r.entity.id === id)).toBe(false)
})
it.skip('should maintain consistency across operations', async () => {
it('should maintain consistency across operations', async () => {
// Arrange
const entity1 = await brain.add(createAddParams({ data: 'Entity 1' }))
const entity2 = await brain.add(createAddParams({ data: 'Entity 2' }))