@ruvector/rvf 0.1.2 → 0.1.4

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.
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Distance metric for vector similarity search.
3
+ *
4
+ * - `l2` Squared Euclidean distance.
5
+ * - `cosine` Cosine distance (1 - cosine_similarity).
6
+ * - `dotproduct` Negated inner (dot) product.
7
+ */
8
+ export type DistanceMetric = 'l2' | 'cosine' | 'dotproduct';
9
+ /**
10
+ * Compression profile for stored vectors.
11
+ *
12
+ * - `none` Raw fp32 vectors.
13
+ * - `scalar` Scalar quantization (int8).
14
+ * - `product` Product quantization.
15
+ */
16
+ export type CompressionProfile = 'none' | 'scalar' | 'product';
17
+ /**
18
+ * Hardware profile selector.
19
+ *
20
+ * 0 = Generic, 1 = Core, 2 = Hot, 3 = Full.
21
+ */
22
+ export type HardwareProfile = 0 | 1 | 2 | 3;
23
+ /** Options for creating a new RVF store. */
24
+ export interface RvfOptions {
25
+ /** Vector dimensionality (required, must be > 0). */
26
+ dimensions: number;
27
+ /** Distance metric for similarity search. Default: `'l2'`. */
28
+ metric?: DistanceMetric;
29
+ /** Hardware profile identifier. Default: `0` (Generic). */
30
+ profile?: HardwareProfile;
31
+ /** Compression profile. Default: `'none'`. */
32
+ compression?: CompressionProfile;
33
+ /** Enable segment signing. Default: `false`. */
34
+ signing?: boolean;
35
+ /** HNSW M parameter: max edges per node per layer. Default: `16`. */
36
+ m?: number;
37
+ /** HNSW ef_construction: beam width during index build. Default: `200`. */
38
+ efConstruction?: number;
39
+ }
40
+ /** Primitive value types usable in filter expressions. */
41
+ export type RvfFilterValue = number | string | boolean;
42
+ /**
43
+ * A filter expression for metadata-based vector filtering.
44
+ *
45
+ * Leaf operators compare a `fieldId` against a literal `value`.
46
+ * Composite operators combine sub-expressions with boolean logic.
47
+ */
48
+ export type RvfFilterExpr = {
49
+ op: 'eq';
50
+ fieldId: number;
51
+ value: RvfFilterValue;
52
+ } | {
53
+ op: 'ne';
54
+ fieldId: number;
55
+ value: RvfFilterValue;
56
+ } | {
57
+ op: 'lt';
58
+ fieldId: number;
59
+ value: RvfFilterValue;
60
+ } | {
61
+ op: 'le';
62
+ fieldId: number;
63
+ value: RvfFilterValue;
64
+ } | {
65
+ op: 'gt';
66
+ fieldId: number;
67
+ value: RvfFilterValue;
68
+ } | {
69
+ op: 'ge';
70
+ fieldId: number;
71
+ value: RvfFilterValue;
72
+ } | {
73
+ op: 'in';
74
+ fieldId: number;
75
+ values: RvfFilterValue[];
76
+ } | {
77
+ op: 'range';
78
+ fieldId: number;
79
+ low: RvfFilterValue;
80
+ high: RvfFilterValue;
81
+ } | {
82
+ op: 'and';
83
+ exprs: RvfFilterExpr[];
84
+ } | {
85
+ op: 'or';
86
+ exprs: RvfFilterExpr[];
87
+ } | {
88
+ op: 'not';
89
+ expr: RvfFilterExpr;
90
+ };
91
+ /** Options controlling a query operation. */
92
+ export interface RvfQueryOptions {
93
+ /** HNSW ef_search parameter (beam width during search). Default: `100`. */
94
+ efSearch?: number;
95
+ /** Optional metadata filter expression. */
96
+ filter?: RvfFilterExpr;
97
+ /** Query timeout in milliseconds (0 = no timeout). Default: `0`. */
98
+ timeoutMs?: number;
99
+ }
100
+ /** A single search result: vector ID and distance. */
101
+ export interface RvfSearchResult {
102
+ /** The vector's unique identifier (string-encoded u64). */
103
+ id: string;
104
+ /** Distance from the query vector (lower = more similar). */
105
+ distance: number;
106
+ }
107
+ /** Result of a batch ingest operation. */
108
+ export interface RvfIngestResult {
109
+ /** Number of vectors successfully ingested. */
110
+ accepted: number;
111
+ /** Number of vectors rejected. */
112
+ rejected: number;
113
+ /** Manifest epoch after the ingest commit. */
114
+ epoch: number;
115
+ }
116
+ /** Result of a delete operation. */
117
+ export interface RvfDeleteResult {
118
+ /** Number of vectors soft-deleted. */
119
+ deleted: number;
120
+ /** Manifest epoch after the delete commit. */
121
+ epoch: number;
122
+ }
123
+ /** Result of a compaction operation. */
124
+ export interface RvfCompactionResult {
125
+ /** Number of segments compacted. */
126
+ segmentsCompacted: number;
127
+ /** Bytes of dead space reclaimed. */
128
+ bytesReclaimed: number;
129
+ /** Manifest epoch after compaction commit. */
130
+ epoch: number;
131
+ }
132
+ /** Compaction state as reported in store status. */
133
+ export type CompactionState = 'idle' | 'running' | 'emergency';
134
+ /** A snapshot of the store's current state. */
135
+ export interface RvfStatus {
136
+ /** Total number of live (non-deleted) vectors. */
137
+ totalVectors: number;
138
+ /** Total number of segments in the file. */
139
+ totalSegments: number;
140
+ /** Total file size in bytes. */
141
+ fileSizeBytes: number;
142
+ /** Current manifest epoch. */
143
+ epoch: number;
144
+ /** Hardware profile identifier. */
145
+ profileId: number;
146
+ /** Current compaction state. */
147
+ compactionState: CompactionState;
148
+ /** Ratio of dead space to total (0.0 - 1.0). */
149
+ deadSpaceRatio: number;
150
+ /** Whether the store is open in read-only mode. */
151
+ readOnly: boolean;
152
+ }
153
+ /** A single entry for batch ingestion. */
154
+ export interface RvfIngestEntry {
155
+ /** Unique vector identifier. */
156
+ id: string;
157
+ /** The embedding vector (must match store dimensions). */
158
+ vector: Float32Array | number[];
159
+ /** Optional per-vector metadata fields. */
160
+ metadata?: Record<string, RvfFilterValue>;
161
+ }
162
+ /** Derivation type for creating derived stores. */
163
+ export type DerivationType = 'filter' | 'merge' | 'snapshot' | 'transform';
164
+ /** Data returned from kernel extraction. */
165
+ export interface RvfKernelData {
166
+ /** Serialized KernelHeader bytes. */
167
+ header: Uint8Array;
168
+ /** Raw kernel image bytes. */
169
+ image: Uint8Array;
170
+ }
171
+ /** Data returned from eBPF extraction. */
172
+ export interface RvfEbpfData {
173
+ /** Serialized EbpfHeader bytes. */
174
+ header: Uint8Array;
175
+ /** Program bytecode + optional BTF. */
176
+ payload: Uint8Array;
177
+ }
178
+ /** Information about a segment in the store. */
179
+ export interface RvfSegmentInfo {
180
+ /** Segment ID. */
181
+ id: number;
182
+ /** File offset of the segment. */
183
+ offset: number;
184
+ /** Payload length in bytes. */
185
+ payloadLength: number;
186
+ /** Segment type name (e.g. "vec", "manifest", "kernel"). */
187
+ segType: string;
188
+ }
189
+ /** Identifies which backend implementation to use. */
190
+ export type BackendType = 'node' | 'wasm' | 'auto';
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruvector/rvf",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "RuVector Format — unified TypeScript SDK for vector intelligence",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -12,24 +12,14 @@
12
12
  "require": "./dist/index.js"
13
13
  }
14
14
  },
15
- "files": [
16
- "dist/",
17
- "package.json"
18
- ],
15
+ "files": ["dist/", "package.json"],
19
16
  "scripts": {
20
17
  "build": "tsc",
21
18
  "test": "jest",
22
19
  "bench": "tsx bench/index.ts",
23
20
  "typecheck": "tsc --noEmit"
24
21
  },
25
- "keywords": [
26
- "vector",
27
- "database",
28
- "binary-format",
29
- "hnsw",
30
- "simd",
31
- "rvf"
32
- ],
22
+ "keywords": ["vector", "database", "binary-format", "hnsw", "simd", "rvf"],
33
23
  "license": "MIT",
34
24
  "repository": "https://github.com/ruvnet/ruvector",
35
25
  "dependencies": {