/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { DataPortSchemaObject, FromSchema, TypedArray, TypedArrayConstructor, TypedArraySchemaOptions } from "@workglow/util/schema"; import { InMemoryTabularStorage } from "../tabular/InMemoryTabularStorage"; import type { AutoGeneratedKeys, InsertEntity } from "../tabular/ITabularStorage"; import type { IVectorStorage, VectorSearchOptions } from "./IVectorStorage"; /** In-memory {@link IVectorStorage} on top of {@link InMemoryTabularStorage}. */ export declare class InMemoryVectorStorage, Metadata extends Record = Record, Entity = FromSchema, InsertType extends InsertEntity> = InsertEntity>> extends InMemoryTabularStorage implements IVectorStorage { private vectorDimensions; private vectorPropertyName; private metadataPropertyName; constructor(schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes: readonly (keyof NoInfer | readonly (keyof NoInfer)[])[] | undefined, dimensions: number, _vectorCtor?: TypedArrayConstructor); getVectorDimensions(): number; /** * Per-instance promise-chain mutex. Serializes `put` and `putBulk` so a * concurrent single-row `put` cannot slip rows into the live Map while a * `putBulk` is mid-flight — otherwise the snapshot/restore on failure would * wipe the interleaved row along with the failed batch. */ private mutexChain; private mutex; /** * Fail-fast vector validation. We mirror the cloud backends here so an * in-memory test fixture catches the same shape mismatches a Postgres / * SQLite store would reject — otherwise tests pass and the deployment * silently breaks on garbage rows. Routed through the same mutex as * `putBulk` so concurrent writes serialize and a `put` cannot land in the * Map mid-batch only to be wiped by a rollback snapshot. */ put(value: InsertType): Promise; /** * Validate the whole batch up front, then perform an atomic batch put: * snapshot mutable state, write rows one at a time, and roll back to the * snapshot if any single `put` throws. The inherited default `putBulk` * runs writes through `Promise.all`, which can leave the Map (and * autoincrement counter) in a half-applied state when the second or later * `put` rejects after earlier ones already mutated the Map. This override * guarantees either every row in the batch is visible after a successful * return, or none of the batch's rows are visible after a thrown error — * matching the contract the vector overlay relies on for RAG ingestion * replays. */ putBulk(values: InsertType[]): Promise; similaritySearch(query: TypedArray, options?: VectorSearchOptions>): Promise<(Entity & { score: number; })[]>; } //# sourceMappingURL=InMemoryVectorStorage.d.ts.map