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

@ -82,7 +82,7 @@ describe('Brainy.relate()', () => {
expect(relation!.weight).toBe(0.8)
})
it.skip('should create relationship with metadata - BUG: metadata not stored', async () => {
it('should create relationship with metadata', async () => {
// Arrange
const metadata = {
since: '2024-01-01',
@ -165,7 +165,7 @@ describe('Brainy.relate()', () => {
expect(toEntity2.some(r => r.type === 'reportsTo')).toBe(true)
})
it.skip('should handle self-relationships - BUG: metadata not stored', async () => {
it('should handle self-relationships', async () => {
// Act
await brain.relate({
from: entity1Id,
@ -245,7 +245,7 @@ describe('Brainy.relate()', () => {
expect(matches.length).toBe(2)
})
it.skip('should handle very long metadata - BUG: metadata not stored', async () => {
it('should handle very long metadata', async () => {
// Arrange
const largeMetadata = {
bigArray: new Array(100).fill('item'),
@ -270,7 +270,7 @@ describe('Brainy.relate()', () => {
expect(relation!.metadata?.bigArray).toHaveLength(100)
})
it.skip('should handle special characters in metadata - BUG: metadata not stored', async () => {
it('should handle special characters in metadata', async () => {
// Arrange
const specialMetadata = {
emoji: '🚀🎉💻',
@ -361,7 +361,7 @@ describe('Brainy.relate()', () => {
})
describe('consistency', () => {
it.skip('should maintain relationship consistency - BUG: metadata not stored', async () => {
it('should maintain relationship consistency', async () => {
// Act
await brain.relate({
from: entity1Id,