chore: recovery checkpoint - v3.0 API successfully recovered
CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB Recovery Status: - Successfully recovered brainy.ts from compiled JavaScript - All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.) - Neural subsystem intact (562KB embedded patterns, NLP working) - Augmentation pipeline operational (20+ augmentations) - HNSW clustering system complete - Triple Intelligence compiled (needs constructor fix) - Test suite validates functionality Changes preserved: - 898 files with changes from last 3 days - 144,475 insertions - All augmentation improvements - All test coverage enhancements - Complete v3.0 feature set This is a LOCAL checkpoint only - contains recovered work after corruption incident. Created backup in .backups/brainy-full-20250910-151314.tar.gz Branch: recovery-checkpoint-20250910-151433 Date: Wed Sep 10 03:18:04 PM PDT 2025
This commit is contained in:
parent
f65455fb22
commit
8ff382ca3b
895 changed files with 143654 additions and 28268 deletions
258
.recovery-workspace/dist-backup-20250910-141917/storage/adapters/opfsStorage.d.ts
vendored
Normal file
258
.recovery-workspace/dist-backup-20250910-141917/storage/adapters/opfsStorage.d.ts
vendored
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
/**
|
||||
* OPFS (Origin Private File System) Storage Adapter
|
||||
* Provides persistent storage for the vector database using the Origin Private File System API
|
||||
*/
|
||||
import { GraphVerb, HNSWNoun, HNSWVerb, StatisticsData } from '../../coreTypes.js';
|
||||
import { BaseStorage } from '../baseStorage.js';
|
||||
import '../../types/fileSystemTypes.js';
|
||||
type HNSWNode = HNSWNoun;
|
||||
/**
|
||||
* Type alias for HNSWVerb to make the code more readable
|
||||
*/
|
||||
type Edge = HNSWVerb;
|
||||
type HNSWNoun_internal = HNSWNoun;
|
||||
/**
|
||||
* OPFS storage adapter for browser environments
|
||||
* Uses the Origin Private File System API to store data persistently
|
||||
*/
|
||||
export declare class OPFSStorage extends BaseStorage {
|
||||
private rootDir;
|
||||
private nounsDir;
|
||||
private verbsDir;
|
||||
private metadataDir;
|
||||
private nounMetadataDir;
|
||||
private verbMetadataDir;
|
||||
private indexDir;
|
||||
private isAvailable;
|
||||
private isPersistentRequested;
|
||||
private isPersistentGranted;
|
||||
private statistics;
|
||||
private activeLocks;
|
||||
private lockPrefix;
|
||||
constructor();
|
||||
/**
|
||||
* Initialize the storage adapter
|
||||
*/
|
||||
init(): Promise<void>;
|
||||
/**
|
||||
* Check if OPFS is available in the current environment
|
||||
*/
|
||||
isOPFSAvailable(): boolean;
|
||||
/**
|
||||
* Request persistent storage permission from the user
|
||||
* @returns Promise that resolves to true if permission was granted, false otherwise
|
||||
*/
|
||||
requestPersistentStorage(): Promise<boolean>;
|
||||
/**
|
||||
* Check if persistent storage is granted
|
||||
* @returns Promise that resolves to true if persistent storage is granted, false otherwise
|
||||
*/
|
||||
isPersistent(): Promise<boolean>;
|
||||
/**
|
||||
* Save a noun to storage
|
||||
*/
|
||||
protected saveNoun_internal(noun: HNSWNoun_internal): Promise<void>;
|
||||
/**
|
||||
* Get a noun from storage
|
||||
*/
|
||||
protected getNoun_internal(id: string): Promise<HNSWNoun_internal | null>;
|
||||
/**
|
||||
* Get nouns by noun type (internal implementation)
|
||||
* @param nounType The noun type to filter by
|
||||
* @returns Promise that resolves to an array of nouns of the specified noun type
|
||||
*/
|
||||
protected getNounsByNounType_internal(nounType: string): Promise<HNSWNoun[]>;
|
||||
/**
|
||||
* Get nodes by noun type
|
||||
* @param nounType The noun type to filter by
|
||||
* @returns Promise that resolves to an array of nodes of the specified noun type
|
||||
*/
|
||||
protected getNodesByNounType(nounType: string): Promise<HNSWNode[]>;
|
||||
/**
|
||||
* Delete a noun from storage (internal implementation)
|
||||
*/
|
||||
protected deleteNoun_internal(id: string): Promise<void>;
|
||||
/**
|
||||
* Delete a node from storage
|
||||
*/
|
||||
protected deleteNode(id: string): Promise<void>;
|
||||
/**
|
||||
* Save a verb to storage (internal implementation)
|
||||
*/
|
||||
protected saveVerb_internal(verb: HNSWVerb): Promise<void>;
|
||||
/**
|
||||
* Save an edge to storage
|
||||
*/
|
||||
protected saveEdge(edge: Edge): Promise<void>;
|
||||
/**
|
||||
* Get a verb from storage (internal implementation)
|
||||
*/
|
||||
protected getVerb_internal(id: string): Promise<HNSWVerb | null>;
|
||||
/**
|
||||
* Get an edge from storage
|
||||
*/
|
||||
protected getEdge(id: string): Promise<Edge | null>;
|
||||
/**
|
||||
* Get all edges from storage
|
||||
*/
|
||||
protected getAllEdges(): Promise<Edge[]>;
|
||||
/**
|
||||
* Get verbs by source (internal implementation)
|
||||
*/
|
||||
protected getVerbsBySource_internal(sourceId: string): Promise<GraphVerb[]>;
|
||||
/**
|
||||
* Get edges by source
|
||||
*/
|
||||
protected getEdgesBySource(sourceId: string): Promise<GraphVerb[]>;
|
||||
/**
|
||||
* Get verbs by target (internal implementation)
|
||||
*/
|
||||
protected getVerbsByTarget_internal(targetId: string): Promise<GraphVerb[]>;
|
||||
/**
|
||||
* Get edges by target
|
||||
*/
|
||||
protected getEdgesByTarget(targetId: string): Promise<GraphVerb[]>;
|
||||
/**
|
||||
* Get verbs by type (internal implementation)
|
||||
*/
|
||||
protected getVerbsByType_internal(type: string): Promise<GraphVerb[]>;
|
||||
/**
|
||||
* Get edges by type
|
||||
*/
|
||||
protected getEdgesByType(type: string): Promise<GraphVerb[]>;
|
||||
/**
|
||||
* Delete a verb from storage (internal implementation)
|
||||
*/
|
||||
protected deleteVerb_internal(id: string): Promise<void>;
|
||||
/**
|
||||
* Delete an edge from storage
|
||||
*/
|
||||
protected deleteEdge(id: string): Promise<void>;
|
||||
/**
|
||||
* Save metadata to storage
|
||||
*/
|
||||
saveMetadata(id: string, metadata: any): Promise<void>;
|
||||
/**
|
||||
* Get metadata from storage
|
||||
*/
|
||||
getMetadata(id: string): Promise<any | null>;
|
||||
/**
|
||||
* Get multiple metadata objects in batches (CRITICAL: Prevents socket exhaustion)
|
||||
* OPFS implementation uses controlled concurrency for file operations
|
||||
*/
|
||||
getMetadataBatch(ids: string[]): Promise<Map<string, any>>;
|
||||
/**
|
||||
* Save verb metadata to storage
|
||||
*/
|
||||
protected saveVerbMetadata_internal(id: string, metadata: any): Promise<void>;
|
||||
/**
|
||||
* Get verb metadata from storage
|
||||
*/
|
||||
getVerbMetadata(id: string): Promise<any | null>;
|
||||
/**
|
||||
* Save noun metadata to storage
|
||||
*/
|
||||
protected saveNounMetadata_internal(id: string, metadata: any): Promise<void>;
|
||||
/**
|
||||
* Get noun metadata from storage
|
||||
*/
|
||||
getNounMetadata(id: string): Promise<any | null>;
|
||||
/**
|
||||
* Clear all data from storage
|
||||
*/
|
||||
clear(): Promise<void>;
|
||||
/**
|
||||
* Get information about storage usage and capacity
|
||||
*/
|
||||
getStorageStatus(): Promise<{
|
||||
type: string;
|
||||
used: number;
|
||||
quota: number | null;
|
||||
details?: Record<string, any>;
|
||||
}>;
|
||||
/**
|
||||
* Get the statistics key for a specific date
|
||||
* @param date The date to get the key for
|
||||
* @returns The statistics key for the specified date
|
||||
*/
|
||||
private getStatisticsKeyForDate;
|
||||
/**
|
||||
* Get the current statistics key
|
||||
* @returns The current statistics key
|
||||
*/
|
||||
private getCurrentStatisticsKey;
|
||||
/**
|
||||
* Get the legacy statistics key (for backward compatibility)
|
||||
* @returns The legacy statistics key
|
||||
*/
|
||||
private getLegacyStatisticsKey;
|
||||
/**
|
||||
* Acquire a browser-based lock for coordinating operations across multiple tabs
|
||||
* @param lockKey The key to lock on
|
||||
* @param ttl Time to live for the lock in milliseconds (default: 30 seconds)
|
||||
* @returns Promise that resolves to true if lock was acquired, false otherwise
|
||||
*/
|
||||
private acquireLock;
|
||||
/**
|
||||
* Release a browser-based lock
|
||||
* @param lockKey The key to unlock
|
||||
* @param lockValue The value used when acquiring the lock (for verification)
|
||||
* @returns Promise that resolves when lock is released
|
||||
*/
|
||||
private releaseLock;
|
||||
/**
|
||||
* Clean up expired locks from localStorage
|
||||
*/
|
||||
private cleanupExpiredLocks;
|
||||
/**
|
||||
* Save statistics data to storage with browser-based locking
|
||||
* @param statistics The statistics data to save
|
||||
*/
|
||||
protected saveStatisticsData(statistics: StatisticsData): Promise<void>;
|
||||
/**
|
||||
* Get statistics data from storage
|
||||
* @returns Promise that resolves to the statistics data or null if not found
|
||||
*/
|
||||
protected getStatisticsData(): Promise<StatisticsData | null>;
|
||||
/**
|
||||
* Get nouns with pagination support
|
||||
* @param options Pagination and filter options
|
||||
* @returns Promise that resolves to a paginated result of nouns
|
||||
*/
|
||||
getNounsWithPagination(options?: {
|
||||
limit?: number;
|
||||
cursor?: string;
|
||||
filter?: {
|
||||
nounType?: string | string[];
|
||||
service?: string | string[];
|
||||
metadata?: Record<string, any>;
|
||||
};
|
||||
}): Promise<{
|
||||
items: HNSWNoun[];
|
||||
totalCount?: number;
|
||||
hasMore: boolean;
|
||||
nextCursor?: string;
|
||||
}>;
|
||||
/**
|
||||
* Get verbs with pagination support
|
||||
* @param options Pagination and filter options
|
||||
* @returns Promise that resolves to a paginated result of verbs
|
||||
*/
|
||||
getVerbsWithPagination(options?: {
|
||||
limit?: number;
|
||||
cursor?: string;
|
||||
filter?: {
|
||||
verbType?: string | string[];
|
||||
sourceId?: string | string[];
|
||||
targetId?: string | string[];
|
||||
service?: string | string[];
|
||||
metadata?: Record<string, any>;
|
||||
};
|
||||
}): Promise<{
|
||||
items: GraphVerb[];
|
||||
totalCount?: number;
|
||||
hasMore: boolean;
|
||||
nextCursor?: string;
|
||||
}>;
|
||||
}
|
||||
export {};
|
||||
Loading…
Add table
Add a link
Reference in a new issue