refactor(8.0): rename HNSWIndex class → JsHnswVectorIndex (scaffold step 3)
Step 3 of the brainy 8.0 rename scaffolding. The class name now matches its role: the JS HNSW implementation of the VectorIndexProvider contract. Per planning § 2.3: this is NOT cosmetic — leaving HNSWIndex when the public contract is VectorIndexProvider creates a confusing read at the implementation layer. CHANGES Repo-wide mechanical rename: HNSWIndex → JsHnswVectorIndex across 52 references in src/ + 5 references in tests/ via sed. Class declaration, imports, JSDoc, comments, and identifiers all updated. src/index.ts - Primary public export: JsHnswVectorIndex (the new name). - Backwards-compat alias: `export const HNSWIndex = JsHnswVectorIndex` with @deprecated note. Removed in the final 8.0 cleanup commit. NO-OP scope No behavioural change. The class is exactly the same; only the name moved. Tests + build green. VERIFICATION - npx tsc --noEmit: clean - npm test: 1468 / 1468 unit
This commit is contained in:
parent
8f87b35614
commit
f39d420cb4
11 changed files with 80 additions and 70 deletions
|
|
@ -31,10 +31,10 @@ const DEFAULT_CONFIG: HNSWConfig = {
|
|||
|
||||
/**
|
||||
* Implements {@link VectorIndexProvider}: the vector-index surface Brainy calls
|
||||
* on whatever the `'vector'` factory returns (its own `HNSWIndex`, or a native
|
||||
* on whatever the `'vector'` factory returns (its own `JsHnswVectorIndex`, or a native
|
||||
* acceleration provider).
|
||||
*/
|
||||
export class HNSWIndex implements VectorIndexProvider {
|
||||
export class JsHnswVectorIndex implements VectorIndexProvider {
|
||||
private nouns: Map<string, HNSWNoun> = new Map()
|
||||
private entryPointId: string | null = null
|
||||
private maxLevel = 0
|
||||
|
|
@ -71,7 +71,7 @@ export class HNSWIndex implements VectorIndexProvider {
|
|||
// COW (Copy-on-Write) support
|
||||
private cowEnabled: boolean = false
|
||||
private cowModifiedNodes: Set<string> = new Set()
|
||||
private cowParent: HNSWIndex | null = null
|
||||
private cowParent: JsHnswVectorIndex | null = null
|
||||
|
||||
// Deferred HNSW persistence for cloud storage performance
|
||||
// In deferred mode, HNSW connections are only persisted on flush/close
|
||||
|
|
@ -130,7 +130,7 @@ export class HNSWIndex implements VectorIndexProvider {
|
|||
* Lifecycle: brainy.ts wires this after plugin activation when (a) the
|
||||
* `vectorStore:mmap` provider is registered AND (b) the storage adapter
|
||||
* resolves a real local path via `getBinaryBlobPath()`. Cloud adapters
|
||||
* leave it null; HNSWIndex's behaviour is then identical to pre-2.4.0.
|
||||
* leave it null; JsHnswVectorIndex's behaviour is then identical to pre-2.4.0.
|
||||
*/
|
||||
public setVectorBackend(backend: MmapVectorBackend | null): void {
|
||||
this.vectorBackend = backend
|
||||
|
|
@ -340,10 +340,10 @@ export class HNSWIndex implements VectorIndexProvider {
|
|||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const parent = new HNSWIndex(config)
|
||||
* const parent = new JsHnswVectorIndex(config)
|
||||
* // ... parent has 1M nodes ...
|
||||
*
|
||||
* const fork = new HNSWIndex(config)
|
||||
* const fork = new JsHnswVectorIndex(config)
|
||||
* fork.enableCOW(parent) // <10ms - instant!
|
||||
*
|
||||
* // Reads share data
|
||||
|
|
@ -353,7 +353,7 @@ export class HNSWIndex implements VectorIndexProvider {
|
|||
* await fork.addItem(newItem) // Deep copies only modified nodes
|
||||
* ```
|
||||
*/
|
||||
public enableCOW(parent: HNSWIndex): void {
|
||||
public enableCOW(parent: JsHnswVectorIndex): void {
|
||||
this.cowEnabled = true
|
||||
this.cowParent = parent
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue