@delali/narsil 0.3.1-next.69 → 0.3.1-next.70

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.
Files changed (45) hide show
  1. package/dist/{capabilities-B1wz2Zl0.d.ts → capabilities-Dt-7B4Wz.d.ts} +2 -2
  2. package/dist/{chunk-DD5X23E6.mjs → chunk-2STVUTNA.mjs} +1 -1
  3. package/dist/chunk-3JGWULDF.mjs +256 -0
  4. package/dist/{chunk-6TGZG2TV.mjs → chunk-653BNMAF.mjs} +190 -58
  5. package/dist/{chunk-YA52AC2V.mjs → chunk-FVLQ63B7.mjs} +203 -9
  6. package/dist/{chunk-5JLSTECC.mjs → chunk-GIVAGD3Q.mjs} +1 -1
  7. package/dist/{chunk-AV4IJKD2.mjs → chunk-HWQLTLNG.mjs} +18 -1
  8. package/dist/{chunk-4VU5TWCR.mjs → chunk-LMO5TJUS.mjs} +40 -35
  9. package/dist/{chunk-BEWOA4VV.mjs → chunk-M76V3OGJ.mjs} +508 -401
  10. package/dist/{chunk-YMZCMH5M.mjs → chunk-OI42GWLR.mjs} +17 -1
  11. package/dist/{chunk-2BDG2IWP.mjs → chunk-P4DSQ6M4.mjs} +16 -6
  12. package/dist/{chunk-6IT3MH5M.mjs → chunk-VNMTB3KC.mjs} +130 -216
  13. package/dist/{chunk-THYRHHO2.mjs → chunk-YJDQ7NLA.mjs} +1 -1
  14. package/dist/{client-xVrOCYTW.d.ts → client-COek5GXK.d.ts} +3 -3
  15. package/dist/client.d.ts +8 -8
  16. package/dist/{config-CEeSV_Xo.d.ts → config-Dfanyqqt.d.ts} +2 -2
  17. package/dist/{config-CSvCVtB7.d.ts → config-rBpbgTw8.d.ts} +2 -2
  18. package/dist/direct-executor-GYJEKNV5.mjs +12 -0
  19. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  20. package/dist/distribution/coordinator/etcd.mjs +1 -1
  21. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  22. package/dist/distribution/coordinator/in-memory.mjs +1 -1
  23. package/dist/distribution.d.ts +8 -8
  24. package/dist/distribution.mjs +109 -69
  25. package/dist/{engine-77ErLy8P.d.ts → engine-CXKfmK7I.d.ts} +12 -5
  26. package/dist/index.browser.mjs +1132 -740
  27. package/dist/index.d.ts +7 -7
  28. package/dist/index.mjs +10 -10
  29. package/dist/invalidation/filesystem.mjs +1 -1
  30. package/dist/{memory-CKF-9WLP.d.ts → memory-C7UMCMH3.d.ts} +35 -17
  31. package/dist/persistence/durability/checkpoint-worker.d.ts +2 -1
  32. package/dist/persistence/durability/checkpoint-worker.mjs +10 -10
  33. package/dist/react.d.ts +6 -6
  34. package/dist/{schema-d5Afu03A.d.ts → schema-Bgzr4g7b.d.ts} +62 -10
  35. package/dist/server.d.ts +10 -10
  36. package/dist/server.mjs +11 -7
  37. package/dist/{tasks-BEiNxDRs.d.ts → tasks-BZt_zes6.d.ts} +3 -1
  38. package/dist/{thread-FLP45EUD.mjs → thread-JEVAYETR.mjs} +6 -6
  39. package/dist/{types-DAK7mnUZ.d.ts → types-gOUqhs2F.d.ts} +1 -1
  40. package/dist/vector/search-worker.d.ts +1 -1
  41. package/dist/vector/search-worker.mjs +2 -2
  42. package/dist/workers/entry.mjs +3 -3
  43. package/package.json +7 -7
  44. package/dist/chunk-VTPLKNWI.mjs +0 -135
  45. package/dist/direct-executor-3ZYXSGFX.mjs +0 -12
package/dist/client.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, N as NarsilError, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes, i as isNarsilError } from './memory-CKF-9WLP.js';
2
- export { A as ASYNC_IMPORT_CAPABILITY, E as ErrorEnvelope, I as INDEX_LIFECYCLE_CAPABILITY, R as REBUILD_ANALYSIS_CAPABILITY, S as SERVER_CAPABILITIES, T as TASK_CANCEL_CAPABILITY, a as TASK_FILTER_CAPABILITY } from './capabilities-B1wz2Zl0.js';
3
- export { C as CapabilitiesResponse, a as CreateIndexEmbedding, H as HttpIndexConfig, I as ImportError, b as ImportResult, M as MemoryStatsResponse, T as TaskListPage, c as TaskListQuery, d as TaskProgress, e as TaskRecord, f as TaskStatus, g as TaskType } from './tasks-BEiNxDRs.js';
4
- export { A as AdminOperations, B as BulkOperations, D as DocumentOperations, F as FetchFunction, I as ImportSource, a as IndexOperations, N as NarsilClient, b as NarsilClientOptions, P as PutResult, R as RequestOptions, S as SearchOperations, c as ServerOperations, d as ServerVersion, T as TaskOperations, W as WaitForTaskOptions, e as createNarsilClient } from './client-xVrOCYTW.js';
5
- import './schema-d5Afu03A.js';
1
+ export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, N as NarsilError, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes, i as isNarsilError } from './memory-C7UMCMH3.js';
2
+ export { A as ASYNC_IMPORT_CAPABILITY, E as ErrorEnvelope, I as INDEX_LIFECYCLE_CAPABILITY, R as REBUILD_ANALYSIS_CAPABILITY, S as SERVER_CAPABILITIES, T as TASK_CANCEL_CAPABILITY, a as TASK_FILTER_CAPABILITY } from './capabilities-Dt-7B4Wz.js';
3
+ export { C as CapabilitiesResponse, a as CreateIndexEmbedding, H as HttpIndexConfig, I as ImportError, b as ImportResult, M as MemoryStatsResponse, T as TaskListPage, c as TaskListQuery, d as TaskProgress, e as TaskRecord, f as TaskStatus, g as TaskType } from './tasks-BZt_zes6.js';
4
+ export { A as AdminOperations, B as BulkOperations, D as DocumentOperations, F as FetchFunction, I as ImportSource, a as IndexOperations, N as NarsilClient, b as NarsilClientOptions, P as PutResult, R as RequestOptions, S as SearchOperations, c as ServerOperations, d as ServerVersion, T as TaskOperations, W as WaitForTaskOptions, e as createNarsilClient } from './client-COek5GXK.js';
5
+ import './schema-Bgzr4g7b.js';
6
6
  import './adapters-79OIa4xm.js';
7
- import './config-CSvCVtB7.js';
8
- import './config-CEeSV_Xo.js';
9
- import './types-DAK7mnUZ.js';
7
+ import './config-rBpbgTw8.js';
8
+ import './config-Dfanyqqt.js';
9
+ import './types-gOUqhs2F.js';
10
10
  import './types-D5OwhtsQ.js';
@@ -1,6 +1,6 @@
1
1
  import { P as PersistenceAdapter, I as InvalidationAdapter, E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
2
- import { Q as QueryParams, e as QueryResult } from './memory-CKF-9WLP.js';
3
- import { I as IndexConfig, A as AnyDocument } from './schema-d5Afu03A.js';
2
+ import { Q as QueryParams, e as QueryResult } from './memory-C7UMCMH3.js';
3
+ import { I as IndexConfig, A as AnyDocument } from './schema-Bgzr4g7b.js';
4
4
 
5
5
  /**
6
6
  * Hooks that the engine calls alongside its own work, so that an application
@@ -1,5 +1,5 @@
1
- import { N as NarsilConfig } from './config-CEeSV_Xo.js';
2
- import { A as AllocationTable, N as NodeRole, a as NodeRegistration, C as ClusterCoordinator, b as NodeCapacity } from './types-DAK7mnUZ.js';
1
+ import { N as NarsilConfig } from './config-Dfanyqqt.js';
2
+ import { A as AllocationTable, N as NodeRole, a as NodeRegistration, C as ClusterCoordinator, b as NodeCapacity } from './types-gOUqhs2F.js';
3
3
  import { N as NodeTransport } from './types-D5OwhtsQ.js';
4
4
 
5
5
  /**
@@ -0,0 +1,12 @@
1
+ export { createDirectExecutor } from './chunk-M76V3OGJ.mjs';
2
+ import './chunk-HWQLTLNG.mjs';
3
+ import './chunk-LMO5TJUS.mjs';
4
+ import './chunk-653BNMAF.mjs';
5
+ import './chunk-TGP5M5R7.mjs';
6
+ import './chunk-YJDQ7NLA.mjs';
7
+ import './chunk-ZJ4CSAB2.mjs';
8
+ import './chunk-YNVIUGF5.mjs';
9
+ import './chunk-IFBKLBGB.mjs';
10
+ import './chunk-U2BKYEC7.mjs';
11
+ import './chunk-OI42GWLR.mjs';
12
+ import './chunk-USKFU7J5.mjs';
@@ -1,5 +1,5 @@
1
- import { C as ClusterCoordinator } from '../../types-DAK7mnUZ.js';
2
- import '../../schema-d5Afu03A.js';
1
+ import { C as ClusterCoordinator } from '../../types-gOUqhs2F.js';
2
+ import '../../schema-Bgzr4g7b.js';
3
3
  import '../../adapters-79OIa4xm.js';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { MAX_NODE_ID_LENGTH, MAX_WATCHERS } from '../../chunk-ORBLD3EL.mjs';
2
- import { compareCodePoints } from '../../chunk-YMZCMH5M.mjs';
2
+ import { compareCodePoints } from '../../chunk-OI42GWLR.mjs';
3
3
  import { NarsilError, ErrorCodes } from '../../chunk-USKFU7J5.mjs';
4
4
  import { decode, encode } from '@msgpack/msgpack';
5
5
 
@@ -1,5 +1,5 @@
1
- import { C as ClusterCoordinator } from '../../types-DAK7mnUZ.js';
2
- import '../../schema-d5Afu03A.js';
1
+ import { C as ClusterCoordinator } from '../../types-gOUqhs2F.js';
2
+ import '../../schema-Bgzr4g7b.js';
3
3
  import '../../adapters-79OIa4xm.js';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { NODE_HEARTBEAT_TTL_MS } from '../../chunk-ORBLD3EL.mjs';
2
- import { compareCodePoints } from '../../chunk-YMZCMH5M.mjs';
2
+ import { compareCodePoints } from '../../chunk-OI42GWLR.mjs';
3
3
 
4
4
  // src/distribution/coordinator/in-memory.ts
5
5
  var NODE_HEARTBEAT_PREFIX = "_narsil/node/";
@@ -1,12 +1,12 @@
1
- import { a as CreateIndexOptions, C as ClusterNamespace, b as ClusterNodeConfig } from './config-CSvCVtB7.js';
2
- export { c as ClusterControllerConfig, d as ClusterNodeInfo, e as ClusterQueryConfig, N as NodeReadiness, R as ReplicationConfig } from './config-CSvCVtB7.js';
3
- import { N as NarsilEventMap, a as Narsil } from './engine-77ErLy8P.js';
4
- import { B as BatchResult, L as ListParams, g as ListResult, j as SuggestParams, k as SuggestResult, Q as QueryParams, h as PreflightResult, f as IndexStats, P as PartitionStatsResult, M as MemoryStats, e as QueryResult } from './memory-CKF-9WLP.js';
5
- import { I as IndexConfig, A as AnyDocument, a as InsertOptions } from './schema-d5Afu03A.js';
6
- import { b as NodeCapacity, N as NodeRole } from './types-DAK7mnUZ.js';
7
- export { c as AllocationConstraints, d as AllocationEvent, A as AllocationTable, C as ClusterCoordinator, e as NodeEvent, a as NodeRegistration, P as PartitionAssignment, f as PartitionState, S as SchemaEvent, U as UnassignedReason } from './types-DAK7mnUZ.js';
1
+ import { a as CreateIndexOptions, C as ClusterNamespace, b as ClusterNodeConfig } from './config-rBpbgTw8.js';
2
+ export { c as ClusterControllerConfig, d as ClusterNodeInfo, e as ClusterQueryConfig, N as NodeReadiness, R as ReplicationConfig } from './config-rBpbgTw8.js';
3
+ import { N as NarsilEventMap, a as Narsil } from './engine-CXKfmK7I.js';
4
+ import { B as BatchResult, L as ListParams, g as ListResult, j as SuggestParams, k as SuggestResult, Q as QueryParams, h as PreflightResult, f as IndexStats, P as PartitionStatsResult, M as MemoryStats, e as QueryResult } from './memory-C7UMCMH3.js';
5
+ import { I as IndexConfig, A as AnyDocument, a as InsertOptions } from './schema-Bgzr4g7b.js';
6
+ import { b as NodeCapacity, N as NodeRole } from './types-gOUqhs2F.js';
7
+ export { c as AllocationConstraints, d as AllocationEvent, A as AllocationTable, C as ClusterCoordinator, e as NodeEvent, a as NodeRegistration, P as PartitionAssignment, f as PartitionState, S as SchemaEvent, U as UnassignedReason } from './types-gOUqhs2F.js';
8
8
  export { L as ListenHandler, N as NodeTransport, R as RespondFn, T as TransportConfig, a as TransportMessage } from './types-D5OwhtsQ.js';
9
- import './config-CEeSV_Xo.js';
9
+ import './config-Dfanyqqt.js';
10
10
  import './adapters-79OIa4xm.js';
11
11
 
12
12
  /**
@@ -1,22 +1,22 @@
1
1
  import { MAX_MESSAGE_SIZE_BYTES } from './chunk-UNEEFTEU.mjs';
2
- import { validateIndexName, indexConfigKey, putIndexMetadata, getIndexMetadata } from './chunk-VTPLKNWI.mjs';
3
- import { requireKnownConfig, resolveRunnableConfig, createEngineCore, startEngineCore, createNarsilFromCore, runEngineQueryStats, runEngineListDocuments, runEngineSuggest, runEnginePreflight, runEngineQuery, createEngineIndex, applyIndexEntry, applyDeleteEntry, validateEntryBatchPayload, createAckMessage, validateEntryPayload, validateForwardBatchPayload, createForwardBatchResultMessage, createForwardBatchMessage, validateForwardBatchResultPayload, createForwardMessage, validateReplicationEntry, computeEntryChecksum, createEntryMessage, createEntryBatchMessage, createInsyncConfirmMessage, validateAckPayload, createInsyncRemoveMessage, validateInsyncConfirmPayload, createInsyncAddMessage } from './chunk-6IT3MH5M.mjs';
2
+ import { validateIndexName, indexConfigKey, indexSettingsOf, putIndexMetadata, withPartitionCount, getIndexMetadata, getClusterIndexConfig } from './chunk-3JGWULDF.mjs';
3
+ import { requireKnownConfig, resolveRunnableConfig, createEngineCore, startEngineCore, createNarsilFromCore, runEngineQueryStats, runEngineListDocuments, runEngineSuggest, runEnginePreflight, runEngineQuery, createEngineIndex, applyIndexEntry, applyDeleteEntry, validateEntryBatchPayload, createAckMessage, validateEntryPayload, validateForwardBatchPayload, createForwardBatchResultMessage, createForwardBatchMessage, validateForwardBatchResultPayload, createForwardMessage, validateReplicationEntry, computeEntryChecksum, createEntryMessage, createEntryBatchMessage, createInsyncConfirmMessage, validateAckPayload, createInsyncRemoveMessage, validateInsyncConfirmPayload, createInsyncAddMessage } from './chunk-VNMTB3KC.mjs';
4
4
  import { ReplicationMessageTypes, TransportErrorCodes, ClusterMessageTypes, QueryMessageTypes, TransportError } from './chunk-GCM3JFVA.mjs';
5
- import { providedDocId, MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR, WIRE_BATCH_BUDGET } from './chunk-YA52AC2V.mjs';
6
- import { generateId, deserializePayloadV2, createPartitionIndex, getLanguage, FILTER_EXPRESSION_KEYS, FIELD_FILTER_OPERATORS } from './chunk-BEWOA4VV.mjs';
7
- import './chunk-AV4IJKD2.mjs';
8
- import { now, listBindingOf, queryBindingOf, hitsKeptPerGroup, clampLimit, resolveHybridFusion, dedupePinnedEntries, foldGroupReducer } from './chunk-2BDG2IWP.mjs';
9
- import { DEFAULT_SUGGEST_LIMIT, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, MAX_INDEX_NAME_LENGTH, MAX_DOC_ID_LENGTH, SUGGEST_OVERSAMPLE_FACTOR, SUGGEST_OVERSAMPLE_PADDING, INDEX_NAME_PATTERN } from './chunk-5JLSTECC.mjs';
10
- import { oversampledShardSize, resolveProjection, clampRowCount, sortSignatureOf, requireMatchingCursor, decodePageCursor, normalizeSort, sortModesOf, encodePageCursor, applyProjection, readSortValues, requireWithinResultWindow, fnv1a, sortSignatureEntry, MAX_FILTER_DEPTH, fnv1aUint32s, mergePartitionStats, MIN_POLYGON_POINTS } from './chunk-4VU5TWCR.mjs';
11
- import { DEFAULT_PAGE_SIZE, MAX_SORT_FIELDS, MAX_CURSOR_LENGTH, MAX_TOLERANCE, MAX_PREFIX_LENGTH, RESULT_WINDOW, MAX_NESTING_DEPTH } from './chunk-6TGZG2TV.mjs';
5
+ import { providedDocId, MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR, WIRE_BATCH_BUDGET } from './chunk-FVLQ63B7.mjs';
6
+ import { generateId, deserializePayloadV2, createPartitionIndex, FILTER_EXPRESSION_KEYS, FIELD_FILTER_OPERATORS } from './chunk-M76V3OGJ.mjs';
7
+ import { getLanguage } from './chunk-HWQLTLNG.mjs';
8
+ import { now, listBindingOf, queryBindingOf, hitsKeptPerGroup, clampLimit, resolveHybridFusion, dedupePinnedEntries, foldGroupReducer } from './chunk-P4DSQ6M4.mjs';
9
+ import { DEFAULT_SUGGEST_LIMIT, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, MAX_INDEX_NAME_LENGTH, MAX_DOC_ID_LENGTH, SUGGEST_OVERSAMPLE_FACTOR, SUGGEST_OVERSAMPLE_PADDING, INDEX_NAME_PATTERN } from './chunk-GIVAGD3Q.mjs';
10
+ import { oversampledShardSize, resolveProjection, clampRowCount, sortSignatureOf, requireMatchingCursor, decodePageCursor, normalizeSort, sortModesOf, encodePageCursor, applyProjection, readSortValues, requireWithinResultWindow, fnv1a, sortSignatureEntry, MAX_FILTER_DEPTH, fnv1aUint32s, mergePartitionStats, MIN_POLYGON_POINTS } from './chunk-LMO5TJUS.mjs';
11
+ import { validateSchema, DEFAULT_PAGE_SIZE, MAX_SORT_FIELDS, MAX_CURSOR_LENGTH, MAX_TOLERANCE, MAX_PREFIX_LENGTH, RESULT_WINDOW, MAX_NESTING_DEPTH } from './chunk-653BNMAF.mjs';
12
12
  import './chunk-TGP5M5R7.mjs';
13
- import './chunk-THYRHHO2.mjs';
13
+ import './chunk-YJDQ7NLA.mjs';
14
14
  import { MIN_OVERSAMPLE } from './chunk-ZJ4CSAB2.mjs';
15
15
  import './chunk-YNVIUGF5.mjs';
16
16
  import { crc32 } from './chunk-3L4U6EJQ.mjs';
17
17
  import './chunk-IFBKLBGB.mjs';
18
18
  import './chunk-U2BKYEC7.mjs';
19
- import { compareCodePoints, toComparableSortValue, compareComparableKeys, isSortMode, SORT_MODES, compareSortValues } from './chunk-YMZCMH5M.mjs';
19
+ import { compareCodePoints, toComparableSortValue, compareComparableKeys, isSortMode, SORT_MODES, compareSortValues } from './chunk-OI42GWLR.mjs';
20
20
  import './chunk-POWOTUKJ.mjs';
21
21
  import { ErrorCodes, NarsilError, describeError } from './chunk-USKFU7J5.mjs';
22
22
  import { encode, decode } from '@msgpack/msgpack';
@@ -3332,7 +3332,7 @@ async function dropRestoredIndexQuietly(engine, indexName, deps = {}) {
3332
3332
  );
3333
3333
  }
3334
3334
  }
3335
- async function loadCoordinatorSchema(coordinator, indexName, primaryNodeId, abortPromise) {
3335
+ async function loadCoordinatorIndexConfig(coordinator, indexName, primaryNodeId, abortPromise) {
3336
3336
  let schema;
3337
3337
  try {
3338
3338
  const winner = await Promise.race([coordinator.getSchema(indexName), abortPromise]);
@@ -3359,7 +3359,35 @@ async function loadCoordinatorSchema(coordinator, indexName, primaryNodeId, abor
3359
3359
  )
3360
3360
  };
3361
3361
  }
3362
- return { schema };
3362
+ let validSchema;
3363
+ try {
3364
+ validSchema = validateSchema(schema);
3365
+ } catch (err) {
3366
+ if (!(err instanceof NarsilError)) throw err;
3367
+ return {
3368
+ error: new NarsilError(err.code, `coordinator schema for index '${indexName}' is invalid: ${err.message}`, {
3369
+ ...err.details,
3370
+ indexName,
3371
+ primaryNodeId
3372
+ })
3373
+ };
3374
+ }
3375
+ try {
3376
+ const winner = await Promise.race([getClusterIndexConfig(coordinator, indexName, validSchema), abortPromise]);
3377
+ if (winner === ABORT_SENTINEL) {
3378
+ return "aborted";
3379
+ }
3380
+ return { config: winner };
3381
+ } catch (err) {
3382
+ const cause = err instanceof Error ? err.message : String(err);
3383
+ return {
3384
+ error: new NarsilError(
3385
+ err instanceof NarsilError ? err.code : ErrorCodes.SNAPSHOT_SYNC_SCHEMA_UNAVAILABLE,
3386
+ `failed to read the coordinator index metadata for '${indexName}': ${cause}`,
3387
+ { indexName, primaryNodeId, cause }
3388
+ )
3389
+ };
3390
+ }
3363
3391
  }
3364
3392
  async function dropExistingIndex(engine, indexName, primaryNodeId) {
3365
3393
  try {
@@ -3602,8 +3630,8 @@ function streamFailureToError(failure) {
3602
3630
  }
3603
3631
 
3604
3632
  // src/distribution/cluster-node/bootstrap-sync/apply.ts
3605
- async function applyLiveIncrementalSync(indexName, partitionId, target, entriesPayloads, expectedFirstSeqNo, localPrimaryTerm, coordinatorSchema, partitionCount, deps) {
3606
- const ensureResult = await ensureLocalIndexForIncremental(indexName, target, coordinatorSchema, partitionCount, deps);
3633
+ async function applyLiveIncrementalSync(indexName, partitionId, target, entriesPayloads, expectedFirstSeqNo, localPrimaryTerm, coordinatorConfig, partitionCount, deps) {
3634
+ const ensureResult = await ensureLocalIndexForIncremental(indexName, target, coordinatorConfig, partitionCount, deps);
3607
3635
  if (ensureResult instanceof NarsilError) {
3608
3636
  return { ok: false, error: ensureResult };
3609
3637
  }
@@ -3626,7 +3654,7 @@ async function applyLiveIncrementalSync(indexName, partitionId, target, entriesP
3626
3654
  snapshotHeader: null
3627
3655
  };
3628
3656
  }
3629
- async function applyLiveSnapshotSync(state, entry, indexName, partitionId, target, frameState, coordinatorSchema, partitionCount, deadline, deps) {
3657
+ async function applyLiveSnapshotSync(state, entry, indexName, partitionId, target, frameState, coordinatorConfig, partitionCount, deadline, deps) {
3630
3658
  const finalized = finalizeSnapshotStream(frameState.snapshotState);
3631
3659
  if (!finalized.ok) {
3632
3660
  return { ok: false, error: streamFailureToError(finalized) };
@@ -3653,7 +3681,7 @@ async function applyLiveSnapshotSync(state, entry, indexName, partitionId, targe
3653
3681
  partitionId,
3654
3682
  target,
3655
3683
  finalized.bytes,
3656
- coordinatorSchema,
3684
+ coordinatorConfig,
3657
3685
  partitionCount,
3658
3686
  deadline,
3659
3687
  deps
@@ -3681,7 +3709,7 @@ async function applyLiveSnapshotSync(state, entry, indexName, partitionId, targe
3681
3709
  snapshotHeader: finalized.header
3682
3710
  };
3683
3711
  }
3684
- async function restoreLiveSnapshotPartition(state, entry, indexName, partitionId, primaryNodeId, bytes, coordinatorSchema, partitionCount, deadline, deps) {
3712
+ async function restoreLiveSnapshotPartition(state, entry, indexName, partitionId, primaryNodeId, bytes, coordinatorConfig, partitionCount, deadline, deps) {
3685
3713
  const remainingMs = deadline - Date.now();
3686
3714
  if (remainingMs <= 0) {
3687
3715
  return new NarsilError(
@@ -3705,7 +3733,7 @@ async function restoreLiveSnapshotPartition(state, entry, indexName, partitionId
3705
3733
  }
3706
3734
  try {
3707
3735
  await withDeadline(
3708
- deps.restoreReplicationPartition(indexName, partitionId, bytes, coordinatorSchema, partitionCount),
3736
+ deps.restoreReplicationPartition(indexName, partitionId, bytes, coordinatorConfig, partitionCount),
3709
3737
  remainingMs,
3710
3738
  indexName,
3711
3739
  "partition-restore"
@@ -3730,29 +3758,26 @@ async function restoreLiveSnapshotPartition(state, entry, indexName, partitionId
3730
3758
  primaryNodeId
3731
3759
  });
3732
3760
  }
3733
- const schemaError = validateRestoredSchema(deps.engine, indexName, primaryNodeId, coordinatorSchema);
3761
+ const schemaError = validateRestoredSchema(deps.engine, indexName, primaryNodeId, coordinatorConfig.schema);
3734
3762
  if (schemaError !== null) {
3735
3763
  return schemaError;
3736
3764
  }
3737
3765
  return null;
3738
3766
  }
3739
- async function ensureLocalIndexForIncremental(indexName, primaryNodeId, coordinatorSchema, partitionCount, deps) {
3767
+ async function ensureLocalIndexForIncremental(indexName, primaryNodeId, coordinatorConfig, partitionCount, deps) {
3740
3768
  const existing = deps.engine.listIndexes().find((idx) => idx.name === indexName);
3741
3769
  if (existing !== void 0) {
3742
- const validation = validateLocalSchema(deps.engine, indexName, primaryNodeId, coordinatorSchema);
3770
+ const validation = validateLocalSchema(deps.engine, indexName, primaryNodeId, coordinatorConfig.schema);
3743
3771
  if (validation instanceof NarsilError) {
3744
3772
  return validation;
3745
3773
  }
3746
3774
  return validateLocalPartitionCount(deps.engine, indexName, primaryNodeId, partitionCount);
3747
3775
  }
3748
3776
  try {
3749
- await deps.engine.createIndex(indexName, {
3750
- schema: coordinatorSchema,
3751
- partitions: { maxPartitions: partitionCount }
3752
- });
3777
+ await deps.engine.createIndex(indexName, withPartitionCount(coordinatorConfig, partitionCount));
3753
3778
  } catch (err) {
3754
3779
  if (err instanceof NarsilError && err.code === ErrorCodes.INDEX_ALREADY_EXISTS) {
3755
- const validation = validateLocalSchema(deps.engine, indexName, primaryNodeId, coordinatorSchema);
3780
+ const validation = validateLocalSchema(deps.engine, indexName, primaryNodeId, coordinatorConfig.schema);
3756
3781
  if (validation instanceof NarsilError) {
3757
3782
  return validation;
3758
3783
  }
@@ -3839,7 +3864,7 @@ async function reportSyncedPosition(indexName, partitionId, target, knownSeqNo,
3839
3864
  }
3840
3865
  }
3841
3866
  }
3842
- async function syncFromAnyTarget(state, entry, indexName, partitionId, primaryNodeId, targets, coordinatorSchema, partitionCount, deadline, deps, abortCheck) {
3867
+ async function syncFromAnyTarget(state, entry, indexName, partitionId, primaryNodeId, targets, coordinatorConfig, partitionCount, deadline, deps, abortCheck) {
3843
3868
  let lastError = new NarsilError(ErrorCodes.SNAPSHOT_SYNC_TRANSPORT_FAILED, "no live sync attempts were made", {
3844
3869
  indexName,
3845
3870
  partitionId,
@@ -3879,7 +3904,7 @@ async function syncFromAnyTarget(state, entry, indexName, partitionId, primaryNo
3879
3904
  indexName,
3880
3905
  partitionId,
3881
3906
  target,
3882
- coordinatorSchema,
3907
+ coordinatorConfig,
3883
3908
  partitionCount,
3884
3909
  deadline,
3885
3910
  deps,
@@ -3899,7 +3924,7 @@ async function syncFromAnyTarget(state, entry, indexName, partitionId, primaryNo
3899
3924
  }
3900
3925
  return { ok: false, error: lastError };
3901
3926
  }
3902
- async function syncFromTarget(state, entry, indexName, partitionId, target, coordinatorSchema, partitionCount, deadline, deps, abortCheck) {
3927
+ async function syncFromTarget(state, entry, indexName, partitionId, target, coordinatorConfig, partitionCount, deadline, deps, abortCheck) {
3903
3928
  const logState = readLocalLogState(indexName, partitionId, deps);
3904
3929
  const requestPayload = {
3905
3930
  indexName,
@@ -3963,7 +3988,7 @@ async function syncFromTarget(state, entry, indexName, partitionId, target, coor
3963
3988
  partitionId,
3964
3989
  target,
3965
3990
  frameState,
3966
- coordinatorSchema,
3991
+ coordinatorConfig,
3967
3992
  partitionCount,
3968
3993
  deadline,
3969
3994
  deps
@@ -3977,7 +4002,7 @@ async function syncFromTarget(state, entry, indexName, partitionId, target, coor
3977
4002
  frameState.syncEntries,
3978
4003
  logState.lastSeqNo + 1,
3979
4004
  logState.lastPrimaryTerm,
3980
- coordinatorSchema,
4005
+ coordinatorConfig,
3981
4006
  partitionCount,
3982
4007
  deps
3983
4008
  );
@@ -4046,13 +4071,13 @@ async function resolveLivePartitionCount(coordinator, indexName, partitionId, pr
4046
4071
  }
4047
4072
  }
4048
4073
  async function executeLiveBootstrapSync(state, entry, indexName, partitionId, primaryNodeId, deps, deadlineMs, deadline, abortCheck) {
4049
- const schemaResult = await loadCoordinatorSchema(deps.coordinator, indexName, primaryNodeId, entry.abortPromise);
4050
- if (schemaResult === "aborted") {
4074
+ const configResult = await loadCoordinatorIndexConfig(deps.coordinator, indexName, primaryNodeId, entry.abortPromise);
4075
+ if (configResult === "aborted") {
4051
4076
  surfaceAborted(deps, indexName, primaryNodeId);
4052
4077
  return false;
4053
4078
  }
4054
- if ("error" in schemaResult) {
4055
- surfaceError(deps, indexName, primaryNodeId, schemaResult.error);
4079
+ if ("error" in configResult) {
4080
+ surfaceError(deps, indexName, primaryNodeId, configResult.error);
4056
4081
  return false;
4057
4082
  }
4058
4083
  if (abortCheck()) {
@@ -4098,7 +4123,7 @@ async function executeLiveBootstrapSync(state, entry, indexName, partitionId, pr
4098
4123
  partitionId,
4099
4124
  primaryNodeId,
4100
4125
  targetsResult,
4101
- schemaResult.schema,
4126
+ configResult.config,
4102
4127
  allocationResult.partitionCount,
4103
4128
  deadline,
4104
4129
  deps,
@@ -4135,15 +4160,15 @@ async function fetchSchemaAndPrepare(entry, indexName, primaryNodeId, deps) {
4135
4160
  if (entry.aborted) {
4136
4161
  return "aborted";
4137
4162
  }
4138
- const schemaResult = await loadCoordinatorSchema(deps.coordinator, indexName, primaryNodeId, entry.abortPromise);
4139
- if (schemaResult === "aborted") {
4163
+ const configResult = await loadCoordinatorIndexConfig(deps.coordinator, indexName, primaryNodeId, entry.abortPromise);
4164
+ if (configResult === "aborted") {
4140
4165
  return "aborted";
4141
4166
  }
4142
- if ("error" in schemaResult) {
4143
- surfaceError(deps, indexName, primaryNodeId, schemaResult.error);
4167
+ if ("error" in configResult) {
4168
+ surfaceError(deps, indexName, primaryNodeId, configResult.error);
4144
4169
  return null;
4145
4170
  }
4146
- return schemaResult.schema;
4171
+ return configResult.config.schema;
4147
4172
  }
4148
4173
  async function applyRestore(state, entry, indexName, primaryNodeId, bytes, coordinatorSchema, deadline, deps) {
4149
4174
  const remainingMs = deadline - Date.now();
@@ -5193,13 +5218,14 @@ async function applyLocalReplicationEntry(core, entry) {
5193
5218
  async function createClusterLocalEngine(config, hooks) {
5194
5219
  requireKnownConfig(config);
5195
5220
  const runnableConfig = await resolveRunnableConfig(config);
5196
- const core = createEngineCore(runnableConfig, hooks);
5221
+ const core = createEngineCore(runnableConfig, hooks, "partition");
5197
5222
  await startEngineCore(core, runnableConfig);
5198
5223
  core.orchestrator.shareMainThread();
5199
5224
  const engine = createNarsilFromCore(core, runnableConfig);
5200
5225
  const heldPartitions = createHeldPartitionRecord(core);
5201
5226
  return Object.assign(engine, {
5202
- createIndexWithUuid: (name, indexConfig, indexUuid) => createEngineIndex(core, runnableConfig, name, indexConfig, indexUuid),
5227
+ createIndex: (name, indexConfig) => createEngineIndex(core, runnableConfig, name, indexConfig, { adapterBinding: "deferred" }),
5228
+ createIndexWithUuid: (name, indexConfig, indexUuid) => createEngineIndex(core, runnableConfig, name, indexConfig, { indexUuid }),
5203
5229
  acquireIndexForReplication: (indexName) => core.indexState.acquire(indexName, false),
5204
5230
  indexUuidOf: (indexName) => core.indexRegistry.get(indexName)?.indexUuid,
5205
5231
  stampIndexUuid: (indexName, indexUuid) => stampIndexUuid(core, indexName, indexUuid),
@@ -5209,7 +5235,7 @@ async function createClusterLocalEngine(config, hooks) {
5209
5235
  forgetHeldPartition: (indexName, partitionId) => heldPartitions.forget(indexName, partitionId),
5210
5236
  applyReplicationEntry: (entry) => applyLocalReplicationEntry(core, entry),
5211
5237
  serializeReplicationPartition: (indexName, partitionId) => serializeReplicationPartition(core, indexName, partitionId),
5212
- restoreReplicationPartition: (indexName, partitionId, bytes, schema, partitionCount) => restoreReplicationPartition(core, engine, indexName, partitionId, bytes, schema, partitionCount),
5238
+ restoreReplicationPartition: (indexName, partitionId, bytes, indexConfig, partitionCount) => restoreReplicationPartition(core, engine, indexName, partitionId, bytes, indexConfig, partitionCount),
5213
5239
  queryPartitions: (indexName, params, partitionIds, globalStats) => runEngineQuery(core, indexName, params, { partitionIds, globalStats }),
5214
5240
  preflightPartitions: (indexName, params, partitionIds) => runEnginePreflight(core, indexName, params, { partitionIds }),
5215
5241
  suggestPartitions: (indexName, params, partitionIds) => runEngineSuggest(core, indexName, params, partitionIds),
@@ -5244,9 +5270,10 @@ async function serializeReplicationPartition(core, indexName, partitionId) {
5244
5270
  release();
5245
5271
  }
5246
5272
  }
5247
- async function restoreReplicationPartition(core, engine, indexName, partitionId, bytes, schema, partitionCount) {
5273
+ async function restoreReplicationPartition(core, engine, indexName, partitionId, bytes, indexConfig, partitionCount) {
5248
5274
  core.guardShutdown();
5249
5275
  validatePartitionRestoreTarget(indexName, partitionId, partitionCount);
5276
+ const schema = indexConfig.schema;
5250
5277
  let partition;
5251
5278
  try {
5252
5279
  partition = deserializePayloadV2(bytes);
@@ -5267,7 +5294,7 @@ async function restoreReplicationPartition(core, engine, indexName, partitionId,
5267
5294
  core,
5268
5295
  engine,
5269
5296
  indexName,
5270
- schema,
5297
+ indexConfig,
5271
5298
  partition.language,
5272
5299
  partitionCount
5273
5300
  );
@@ -5359,16 +5386,15 @@ function validatePartitionSnapshotPayload(indexName, partitionId, partitionCount
5359
5386
  }
5360
5387
  }
5361
5388
  }
5362
- async function ensureReplicationIndex(core, engine, indexName, schema, languageName, partitionCount) {
5389
+ async function ensureReplicationIndex(core, engine, indexName, coordinatorConfig, languageName, partitionCount) {
5363
5390
  const language = getLanguage(languageName);
5364
5391
  const existing = core.indexRegistry.get(indexName);
5365
5392
  let created = false;
5366
5393
  if (existing === void 0) {
5367
- const indexConfig = {
5368
- schema,
5369
- language: language.name,
5370
- partitions: { maxPartitions: partitionCount }
5371
- };
5394
+ const indexConfig = withPartitionCount(
5395
+ { ...coordinatorConfig, language: coordinatorConfig.language ?? language.name },
5396
+ partitionCount
5397
+ );
5372
5398
  try {
5373
5399
  await engine.createIndex(indexName, indexConfig);
5374
5400
  created = true;
@@ -5386,7 +5412,7 @@ async function ensureReplicationIndex(core, engine, indexName, schema, languageN
5386
5412
  receivedLanguage: language.name
5387
5413
  });
5388
5414
  }
5389
- validateExistingSchema(indexName, schema, entry.config.schema);
5415
+ validateExistingSchema(indexName, coordinatorConfig.schema, entry.config.schema);
5390
5416
  const manager = core.requireManager(indexName);
5391
5417
  if (manager.partitionCount > partitionCount) {
5392
5418
  throw new NarsilError(ErrorCodes.SNAPSHOT_SYNC_RESTORE_FAILED, "local index has more partitions than allocation", {
@@ -6388,10 +6414,22 @@ function validateStringList(value, fieldLabel, errorCode) {
6388
6414
  validateBoundedString(value[i], `${fieldLabel}[${i}]`, errorCode);
6389
6415
  }
6390
6416
  }
6417
+ function validateRangeOperand(value, fieldLabel, errorCode) {
6418
+ if (typeof value === "string") {
6419
+ validateBoundedString(value, fieldLabel, errorCode);
6420
+ return;
6421
+ }
6422
+ validateNumericOperand(value, fieldLabel, errorCode);
6423
+ }
6391
6424
  function validateBetween(value, fieldLabel, errorCode) {
6392
6425
  if (!Array.isArray(value) || value.length !== 2) {
6393
6426
  throwInvalid(errorCode, `Invalid payload: "${fieldLabel}" must be a two-element array`);
6394
6427
  }
6428
+ if (typeof value[0] === "string" && typeof value[1] === "string") {
6429
+ validateBoundedString(value[0], `${fieldLabel}[0]`, errorCode);
6430
+ validateBoundedString(value[1], `${fieldLabel}[1]`, errorCode);
6431
+ return;
6432
+ }
6395
6433
  validateNumericOperand(value[0], `${fieldLabel}[0]`, errorCode);
6396
6434
  validateNumericOperand(value[1], `${fieldLabel}[1]`, errorCode);
6397
6435
  }
@@ -6455,7 +6493,7 @@ function validateGeoPolygon(value, fieldLabel, errorCode) {
6455
6493
  function validateLeafOperator(opKey, opValue, leafLabel, errorCode) {
6456
6494
  const opLabel = `${leafLabel}.${opKey}`;
6457
6495
  if (opKey === "gt" || opKey === "lt" || opKey === "gte" || opKey === "lte") {
6458
- validateNumericOperand(opValue, opLabel, errorCode);
6496
+ validateRangeOperand(opValue, opLabel, errorCode);
6459
6497
  return;
6460
6498
  }
6461
6499
  if (opKey === "eq" || opKey === "ne") {
@@ -9228,8 +9266,9 @@ function validateCreateIndexOptions(partitionCount, replicationFactor) {
9228
9266
  );
9229
9267
  }
9230
9268
  }
9231
- async function routeCreateIndex(name, config, options, coordinator, engine) {
9269
+ async function routeCreateIndex(name, requestedConfig, options, coordinator, engine) {
9232
9270
  validateIndexName(name);
9271
+ const config = { ...requestedConfig, schema: validateSchema(requestedConfig.schema) };
9233
9272
  const partitionCount = options?.partitionCount ?? DEFAULT_PARTITION_COUNT;
9234
9273
  const replicationFactor = options?.replicationFactor ?? DEFAULT_REPLICATION_FACTOR;
9235
9274
  validateCreateIndexOptions(partitionCount, replicationFactor);
@@ -9243,7 +9282,8 @@ async function routeCreateIndex(name, config, options, coordinator, engine) {
9243
9282
  indexName: name,
9244
9283
  partitionCount,
9245
9284
  replicationFactor,
9246
- constraints
9285
+ constraints,
9286
+ settings: indexSettingsOf(config)
9247
9287
  };
9248
9288
  const stored = await putIndexMetadata(coordinator, metadata);
9249
9289
  if (!stored) {
@@ -9254,11 +9294,7 @@ async function routeCreateIndex(name, config, options, coordinator, engine) {
9254
9294
  );
9255
9295
  }
9256
9296
  try {
9257
- await engine.createIndexWithUuid(
9258
- name,
9259
- { ...config, partitions: { ...config.partitions, maxPartitions: partitionCount } },
9260
- metadata.indexUuid
9261
- );
9297
+ await engine.createIndexWithUuid(name, withPartitionCount(config, partitionCount), metadata.indexUuid);
9262
9298
  await coordinator.putSchema(name, config.schema);
9263
9299
  } catch (createErr) {
9264
9300
  const cleanupError = await withdrawPartialIndex(name, coordinator, engine);
@@ -11236,8 +11272,15 @@ function createClusterOperationTracker(config) {
11236
11272
 
11237
11273
  // src/distribution/cluster-node/primary-partition.ts
11238
11274
  async function preparePrimaryPartition(indexName, partitionId, deps) {
11239
- const schema = await deps.coordinator.getSchema(indexName);
11240
- if (schema === null) {
11275
+ const storedSchema = await deps.coordinator.getSchema(indexName);
11276
+ if (storedSchema === null) {
11277
+ return false;
11278
+ }
11279
+ let config;
11280
+ try {
11281
+ config = await getClusterIndexConfig(deps.coordinator, indexName, validateSchema(storedSchema));
11282
+ } catch (error) {
11283
+ deps.onError(error);
11241
11284
  return false;
11242
11285
  }
11243
11286
  const allocation = await deps.coordinator.getAllocation(indexName);
@@ -11247,10 +11290,7 @@ async function preparePrimaryPartition(indexName, partitionId, deps) {
11247
11290
  const existing = deps.engine.listIndexes().find((index) => index.name === indexName);
11248
11291
  if (existing === void 0) {
11249
11292
  try {
11250
- await deps.engine.createIndex(indexName, {
11251
- schema,
11252
- partitions: { maxPartitions: allocation.assignments.size }
11253
- });
11293
+ await deps.engine.createIndex(indexName, withPartitionCount(config, allocation.assignments.size));
11254
11294
  } catch (error) {
11255
11295
  if (!(error instanceof NarsilError) || error.code !== ErrorCodes.INDEX_ALREADY_EXISTS) {
11256
11296
  deps.onError(error);
@@ -11258,7 +11298,7 @@ async function preparePrimaryPartition(indexName, partitionId, deps) {
11258
11298
  }
11259
11299
  }
11260
11300
  } else {
11261
- const schemaError = validateRestoredSchema(deps.engine, indexName, deps.nodeId, schema);
11301
+ const schemaError = validateRestoredSchema(deps.engine, indexName, deps.nodeId, config.schema);
11262
11302
  if (schemaError !== null) {
11263
11303
  deps.onError(schemaError);
11264
11304
  return false;
@@ -1,6 +1,6 @@
1
1
  import { E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
2
- import { B as BatchResult, I as IndexInfo, f as IndexStats, P as PartitionStatsResult, L as ListParams, g as ListResult, Q as QueryParams, e as QueryResult, h as PreflightResult, j as SuggestParams, k as SuggestResult, M as MemoryStats, V as VectorMaintenanceResult } from './memory-CKF-9WLP.js';
3
- import { A as AnyDocument, a as InsertOptions, W as WriteOptions, I as IndexConfig, P as PartitionConfig } from './schema-d5Afu03A.js';
2
+ import { B as BatchResult, I as IndexInfo, f as IndexStats, P as PartitionStatsResult, L as ListParams, g as ListResult, Q as QueryParams, e as QueryResult, h as PreflightResult, j as SuggestParams, k as SuggestResult, M as MemoryStats, V as VectorMaintenanceResult } from './memory-C7UMCMH3.js';
3
+ import { A as AnyDocument, a as InsertOptions, W as WriteOptions, I as IndexConfig, P as PartitionConfig } from './schema-Bgzr4g7b.js';
4
4
 
5
5
  /**
6
6
  * Every event the engine emits, with the payload each one carries.
@@ -58,16 +58,23 @@ type NarsilEventMap = {
58
58
  /** The index holds this many partitions now. */
59
59
  newCount: number;
60
60
  };
61
- /** A partition passed its watermark, so the index is close to needing another one. */
61
+ /**
62
+ * An index passed its watermark, so its partitions are close to their
63
+ * capacity. On a cluster node, the engine reports the document count and the
64
+ * capacity of the one partition that `partitionId` names, which is a
65
+ * partition that this node leads.
66
+ */
62
67
  partitionWatermark: {
63
68
  /** This index crossed the mark. */
64
69
  indexName: string;
65
- /** The index holds this many documents. */
70
+ /** The index holds this many documents, or the partition does on a cluster node. */
66
71
  documentCount: number;
67
- /** The index can hold this many across its current partitions. */
72
+ /** The index can hold this many across its current partitions, or the partition can on a cluster node. */
68
73
  capacity: number;
69
74
  /** The index holds this many partitions. */
70
75
  partitionCount: number;
76
+ /** On a cluster node, this partition crossed the mark. The field is absent outside a cluster. */
77
+ partitionId?: number;
71
78
  };
72
79
  /**
73
80
  * The process uses nine tenths of its heap, measured during a write or a