@soulcraft/brainy 0.54.1 → 0.54.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -788,8 +788,9 @@ export class BrainyData {
788
788
  catch (e) {
789
789
  // Ignore errors loading existing statistics
790
790
  }
791
- // Initialize metadata index if not in write-only mode
792
- if (!this.writeOnly) {
791
+ // Initialize metadata index unless in read-only mode
792
+ // Write-only mode NEEDS metadata indexing for search capability!
793
+ if (!this.readOnly) {
793
794
  this.metadataIndex = new MetadataIndexManager(this.storage, this.config.metadataIndex);
794
795
  // Check if we need to rebuild the index (for existing data)
795
796
  // Skip rebuild for memory storage (starts empty) or when in read-only mode
@@ -1186,8 +1187,8 @@ export class BrainyData {
1186
1187
  }
1187
1188
  }
1188
1189
  await this.storage.saveMetadata(id, metadataToSave);
1189
- // Update metadata index
1190
- if (this.metadataIndex && !this.readOnly && !this.frozen) {
1190
+ // Update metadata index (write-only mode should build indices!)
1191
+ if (this.metadataIndex && !this.frozen) {
1191
1192
  await this.metadataIndex.addToIndex(id, metadataToSave);
1192
1193
  }
1193
1194
  // Track metadata statistics
@@ -2288,8 +2289,8 @@ export class BrainyData {
2288
2289
  try {
2289
2290
  // Get metadata before removing for index cleanup
2290
2291
  const existingMetadata = await this.storage.getMetadata(actualId);
2291
- // Remove from metadata index
2292
- if (this.metadataIndex && existingMetadata && !this.readOnly && !this.frozen) {
2292
+ // Remove from metadata index (write-only mode should update indices!)
2293
+ if (this.metadataIndex && existingMetadata && !this.frozen) {
2293
2294
  await this.metadataIndex.removeFromIndex(actualId, existingMetadata);
2294
2295
  }
2295
2296
  await this.storage.saveMetadata(actualId, null);
@@ -2377,8 +2378,8 @@ export class BrainyData {
2377
2378
  }
2378
2379
  // Update metadata
2379
2380
  await this.storage.saveMetadata(id, metadata);
2380
- // Update metadata index
2381
- if (this.metadataIndex && !this.readOnly && !this.frozen) {
2381
+ // Update metadata index (write-only mode should build indices!)
2382
+ if (this.metadataIndex && !this.frozen) {
2382
2383
  // Remove old metadata from index if it exists
2383
2384
  const oldMetadata = await this.storage.getMetadata(id);
2384
2385
  if (oldMetadata) {