@delali/narsil 0.3.1-next.80 → 0.3.1-next.82

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 (52) hide show
  1. package/dist/adapters/filesystem.mjs +1 -1
  2. package/dist/adapters/indexeddb.mjs +1 -1
  3. package/dist/{capabilities-CcTDWh_P.d.ts → capabilities-CAdkp2P-.d.ts} +2 -2
  4. package/dist/{chunk-HJASKX4F.mjs → chunk-2453RJYK.mjs} +2 -2
  5. package/dist/{chunk-K4FZ55Q2.mjs → chunk-4CWHWOBI.mjs} +10 -10
  6. package/dist/{chunk-4QDQEJDV.mjs → chunk-4D6OH4EF.mjs} +6 -6
  7. package/dist/{chunk-P2PYEZZE.mjs → chunk-4VBG6PEH.mjs} +3 -3
  8. package/dist/{chunk-Y3L5MDRV.mjs → chunk-5XNIRLFC.mjs} +2 -2
  9. package/dist/{chunk-2E35UM3G.mjs → chunk-B3UOQJD3.mjs} +1 -1
  10. package/dist/{chunk-MEOOYKWL.mjs → chunk-GNYXCLJS.mjs} +4 -4
  11. package/dist/{chunk-NSXQCE4K.mjs → chunk-IH3GKNDQ.mjs} +190 -40
  12. package/dist/{chunk-23HJ5QXQ.mjs → chunk-IN5CH4P2.mjs} +2 -2
  13. package/dist/{chunk-OSF3SGJV.mjs → chunk-KJ7LB3TR.mjs} +2 -2
  14. package/dist/{chunk-DQABW5UQ.mjs → chunk-LS5IRM23.mjs} +1 -1
  15. package/dist/{chunk-4MQ5F4IL.mjs → chunk-OLXM65YH.mjs} +1 -1
  16. package/dist/{chunk-R2XCJIO7.mjs → chunk-SREPGC6O.mjs} +2 -2
  17. package/dist/{chunk-I64LXKO3.mjs → chunk-TPJU7NDJ.mjs} +1 -0
  18. package/dist/{chunk-YGLSR7BC.mjs → chunk-XYDP7CCJ.mjs} +5 -5
  19. package/dist/{chunk-QPYV22XH.mjs → chunk-XZF4LZ3X.mjs} +4 -3
  20. package/dist/{chunk-GG2FBGVZ.mjs → chunk-ZCKPRCYI.mjs} +1 -1
  21. package/dist/{client-CsybN673.d.ts → client-CKUtkLz3.d.ts} +2 -2
  22. package/dist/client.d.ts +7 -7
  23. package/dist/client.mjs +1 -0
  24. package/dist/{config-CFonR_gY.d.ts → config-BuIkeM5C.d.ts} +39 -3
  25. package/dist/{config-BCNQtszf.d.ts → config-CSDEPraV.d.ts} +1 -1
  26. package/dist/direct-executor-JVXDR5Y5.mjs +19 -0
  27. package/dist/distribution/coordinator/etcd.d.ts +1 -1
  28. package/dist/distribution/coordinator/etcd.mjs +1 -1
  29. package/dist/distribution/coordinator/in-memory.d.ts +1 -1
  30. package/dist/distribution/transport/grpc.mjs +1 -1
  31. package/dist/distribution.d.ts +7 -7
  32. package/dist/distribution.mjs +756 -64
  33. package/dist/embeddings/openai.mjs +1 -1
  34. package/dist/{engine-B0oIF1_r.d.ts → engine-DMNZJAUq.d.ts} +1 -1
  35. package/dist/{types-ChrVy4lH.d.ts → index-DzONZUKE.d.ts} +79 -37
  36. package/dist/index.browser.mjs +25 -23
  37. package/dist/index.d.ts +5 -5
  38. package/dist/index.mjs +14 -14
  39. package/dist/{memory-B6SBOKlS.d.ts → memory-BPKNx9Tl.d.ts} +1 -0
  40. package/dist/partial-words.mjs +4 -4
  41. package/dist/pattern.mjs +3 -3
  42. package/dist/persistence/durability/checkpoint-worker.mjs +14 -14
  43. package/dist/react.d.ts +6 -6
  44. package/dist/react.mjs +1 -0
  45. package/dist/server.d.ts +9 -9
  46. package/dist/server.mjs +18 -13
  47. package/dist/{tasks-CYAQe6qd.d.ts → tasks-DGyz586z.d.ts} +1 -1
  48. package/dist/{thread-P6QJ2Q5O.mjs → thread-33M5AOEI.mjs} +10 -10
  49. package/dist/vector/search-worker.mjs +3 -3
  50. package/dist/workers/entry.mjs +5 -5
  51. package/package.json +11 -7
  52. package/dist/direct-executor-VNMQ6NIH.mjs +0 -19
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from '../chunk-I64LXKO3.mjs';
1
+ import { NarsilError, ErrorCodes } from '../chunk-TPJU7NDJ.mjs';
2
2
 
3
3
  // src/persistence/filesystem.ts
4
4
  var cachedFs = null;
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from '../chunk-I64LXKO3.mjs';
1
+ import { NarsilError, ErrorCodes } from '../chunk-TPJU7NDJ.mjs';
2
2
 
3
3
  // src/persistence/constants.ts
4
4
  var DEFAULT_INDEXEDDB_NAME = "narsil";
@@ -1,6 +1,6 @@
1
1
  import { E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
2
- import { C as ClusterNamespace } from './config-CFonR_gY.js';
3
- import { h as TaskStore } from './tasks-CYAQe6qd.js';
2
+ import { C as ClusterNamespace } from './config-BuIkeM5C.js';
3
+ import { h as TaskStore } from './tasks-DGyz586z.js';
4
4
 
5
5
  /**
6
6
  * Context handed to {@link OnRequestHook} for every inbound request, captured
@@ -1,5 +1,5 @@
1
- import { requireDocumentWithinSizeLimit, validateRequiredFields } from './chunk-OSF3SGJV.mjs';
2
- import { ErrorCodes, NarsilError } from './chunk-I64LXKO3.mjs';
1
+ import { requireDocumentWithinSizeLimit, validateRequiredFields } from './chunk-KJ7LB3TR.mjs';
2
+ import { ErrorCodes, NarsilError } from './chunk-TPJU7NDJ.mjs';
3
3
 
4
4
  // src/narsil/internals.ts
5
5
  var engineCores = /* @__PURE__ */ new WeakMap();
@@ -1,18 +1,18 @@
1
- import { createGrowingPartialWords, requirePatternSearchFor, requirePartialWordSearchFor, buildPartialWordTableFrom, patternIndexOf, encodePartialSpellingsOf, countPartialSpelling, joinPatternWorkMeter, countsWithoutScores, fanOutMatchCount, fanOutQuery, sanitizeGlobalStats, expandPartialWords, computeFacets, cloneProjected, projectionKeepsField, setNestedValue, fnv1a, partialSpellingsOfDocuments, createFrozenPartialWords, requirePatternSearch, PATTERN_HOST, validatedFilterOf, everyValueFacetConfig, mergeFacets, kWayMerge, polygonContainment, polygonBoxes, radiusBoxes, locationCode, undeclaredFilterField, coveringRanges } from './chunk-YGLSR7BC.mjs';
2
- import { getLanguage, detectRuntime } from './chunk-4MQ5F4IL.mjs';
3
- import { MAX_DOC_ID_LENGTH } from './chunk-GG2FBGVZ.mjs';
4
- import { SCRATCH_SLOTS_PER_THREAD_POOL, osqRecordBytes, openSharedVectorField, osqBitsOf, createVectorStore, DISK_STORAGE_BLOCK_BYTES, createOsqQuantizer, magnitude, createHNSWIndex, nativeStoreScratchBytes, createOrdinalFilter, isTombstoned, addToOrdinalFilter, ordinalFilterValues, nativeScoresOf, toScore, removeFromOrdinalFilter, euclideanDistance, dotProduct, cosineSimilarityWithMagnitudes, ordinalFilterHas, STORE_CALIBRATION_GENERATION, entryForOrd, toDistance, sharedMemoryAvailable, requireWholeNeighbourLists, topLayerInParts, GRAPH_BUILD_CHUNKS_IN_FLIGHT_PER_WORKER, GRAPH_BUILD_DISPATCH_CHUNK, releaseLocksHeldBy, VECTOR_SEARCH_TIMEOUT_MS, VECTOR_SEARCH_LOAD_TIMEOUT_MS, VECTOR_INSERT_TIMEOUT_MS, VECTOR_SCRATCH_SLOTS } from './chunk-23HJ5QXQ.mjs';
5
- import { noteFallback } from './chunk-2E35UM3G.mjs';
6
- import { GrowableUint32, bitsetHas, createBitSet, bitsetSet, bitsetOrInto, bitsetAndNotInto, bitsetAndInto, bitsetFromSet, bitsetIsEmpty } from './chunk-R2XCJIO7.mjs';
1
+ import { createGrowingPartialWords, requirePatternSearchFor, requirePartialWordSearchFor, buildPartialWordTableFrom, patternIndexOf, encodePartialSpellingsOf, countPartialSpelling, joinPatternWorkMeter, countsWithoutScores, fanOutMatchCount, fanOutQuery, sanitizeGlobalStats, expandPartialWords, computeFacets, cloneProjected, projectionKeepsField, setNestedValue, fnv1a, partialSpellingsOfDocuments, createFrozenPartialWords, requirePatternSearch, PATTERN_HOST, validatedFilterOf, everyValueFacetConfig, mergeFacets, kWayMerge, polygonContainment, polygonBoxes, radiusBoxes, locationCode, undeclaredFilterField, coveringRanges } from './chunk-XYDP7CCJ.mjs';
2
+ import { getLanguage, detectRuntime } from './chunk-OLXM65YH.mjs';
3
+ import { MAX_DOC_ID_LENGTH } from './chunk-ZCKPRCYI.mjs';
4
+ import { SCRATCH_SLOTS_PER_THREAD_POOL, osqRecordBytes, openSharedVectorField, osqBitsOf, createVectorStore, DISK_STORAGE_BLOCK_BYTES, createOsqQuantizer, magnitude, createHNSWIndex, nativeStoreScratchBytes, createOrdinalFilter, isTombstoned, addToOrdinalFilter, ordinalFilterValues, nativeScoresOf, toScore, removeFromOrdinalFilter, euclideanDistance, dotProduct, cosineSimilarityWithMagnitudes, ordinalFilterHas, STORE_CALIBRATION_GENERATION, entryForOrd, toDistance, sharedMemoryAvailable, requireWholeNeighbourLists, topLayerInParts, GRAPH_BUILD_CHUNKS_IN_FLIGHT_PER_WORKER, GRAPH_BUILD_DISPATCH_CHUNK, releaseLocksHeldBy, VECTOR_SEARCH_TIMEOUT_MS, VECTOR_SEARCH_LOAD_TIMEOUT_MS, VECTOR_INSERT_TIMEOUT_MS, VECTOR_SCRATCH_SLOTS } from './chunk-IN5CH4P2.mjs';
5
+ import { noteFallback } from './chunk-B3UOQJD3.mjs';
6
+ import { GrowableUint32, bitsetHas, createBitSet, bitsetSet, bitsetOrInto, bitsetAndNotInto, bitsetAndInto, bitsetFromSet, bitsetIsEmpty } from './chunk-SREPGC6O.mjs';
7
7
  import { GEO_UNIT_METRES } from './chunk-WQBCBKY3.mjs';
8
- import { tokenizeOptions, getNestedValue, visitTokens, expandTermPrefix, suggestDisplayTerms, textFieldsChanged, sameFields, codePointOrder, encodeStringBlob, encodeLookupKey, SEGMENT_TOKEN_TABLE_START, SEGMENT_POSTING_LOG_START, SEGMENT_POSITION_POOL_START, SEGMENT_FIELD_SCRATCH_START, getFlatSchema, tokenize, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, PRUNING_REJECTION_SLACK, getOrCreateFieldNameIndex, getFieldValueByInternalId, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, TARGET_BLOCK_ENTRIES, SORT_COLUMN_REBUILD_FRACTION_SHIFT, partitionDocumentFrequency } from './chunk-P2PYEZZE.mjs';
9
- import { schemaFieldsOf, partialFieldsOf, validateDocument, validateDocumentStrict, encodeDocument, extractVectorFieldsFromSchema, VINCENTY_CONVERGENCE_THRESHOLD, EARTH_RADIUS_METERS, VINCENTY_MAX_ITERATIONS, DEG_TO_RAD } from './chunk-OSF3SGJV.mjs';
8
+ import { tokenizeOptions, getNestedValue, visitTokens, expandTermPrefix, suggestDisplayTerms, textFieldsChanged, sameFields, codePointOrder, encodeStringBlob, encodeLookupKey, SEGMENT_TOKEN_TABLE_START, SEGMENT_POSTING_LOG_START, SEGMENT_POSITION_POOL_START, SEGMENT_FIELD_SCRATCH_START, getFlatSchema, tokenize, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, PRUNING_REJECTION_SLACK, getOrCreateFieldNameIndex, getFieldValueByInternalId, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, TARGET_BLOCK_ENTRIES, SORT_COLUMN_REBUILD_FRACTION_SHIFT, partitionDocumentFrequency } from './chunk-4VBG6PEH.mjs';
9
+ import { schemaFieldsOf, partialFieldsOf, validateDocument, validateDocumentStrict, encodeDocument, extractVectorFieldsFromSchema, VINCENTY_CONVERGENCE_THRESHOLD, EARTH_RADIUS_METERS, VINCENTY_MAX_ITERATIONS, DEG_TO_RAD } from './chunk-KJ7LB3TR.mjs';
10
10
  import { MAX_M, EARLIER_RELEASE_MIN_M, MIN_M } from './chunk-KEHK2O6P.mjs';
11
11
  import { fuzzyPrefixOf, boundedLevenshtein } from './chunk-GES7U2PM.mjs';
12
- import { isWordIndexedBase, parsedTypeOf, isListBase } from './chunk-DQABW5UQ.mjs';
12
+ import { isWordIndexedBase, parsedTypeOf, isListBase } from './chunk-LS5IRM23.mjs';
13
13
  import { toReducedSortValue, readSortField, defaultSortMode, compareComparableValues, truncateSortString, SORT_VALUE_MAX_CODE_POINTS } from './chunk-R6A773WK.mjs';
14
14
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
15
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
15
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
16
16
  import { totalmem } from 'os';
17
17
  import { getHeapStatistics } from 'v8';
18
18
  import { decode } from '@msgpack/msgpack';
@@ -1,13 +1,13 @@
1
- import { clampRowCount, sortSignatureOf, requireSortableFields, decodePageCursor, requireMatchingCursor, resolveProjection, encodePageCursor, requireWithinResultWindow, normalizeSort, fanOutQuery, sortModesOf, applySorting, applyPagination, projectionKeepsField, countsWithoutScores, fanOutMatchCount, fnv1aBytes, validatedFilterOf, createPatternWorkMeter, everyValueFacetConfig, fulltextMatches, mergeFacets, pruneStatsToQueryTerms, partitionsIn, partialWordsToHighlight, partialWordHighlighter, undeclaredFieldOnStrictIndex } from './chunk-YGLSR7BC.mjs';
2
- import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, DEFAULT_LIMIT, DEFAULT_SUGGEST_LIMIT, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, DEFAULT_OFFSET } from './chunk-GG2FBGVZ.mjs';
1
+ import { clampRowCount, sortSignatureOf, requireSortableFields, decodePageCursor, requireMatchingCursor, resolveProjection, encodePageCursor, requireWithinResultWindow, normalizeSort, fanOutQuery, sortModesOf, applySorting, applyPagination, projectionKeepsField, countsWithoutScores, fanOutMatchCount, fnv1aBytes, validatedFilterOf, createPatternWorkMeter, everyValueFacetConfig, fulltextMatches, mergeFacets, pruneStatsToQueryTerms, partitionsIn, partialWordsToHighlight, partialWordHighlighter, undeclaredFieldOnStrictIndex } from './chunk-XYDP7CCJ.mjs';
2
+ import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, DEFAULT_LIMIT, DEFAULT_SUGGEST_LIMIT, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, DEFAULT_OFFSET } from './chunk-ZCKPRCYI.mjs';
3
3
  import { MIN_OVERSAMPLE } from './chunk-ZJ4CSAB2.mjs';
4
- import { tokenize } from './chunk-P2PYEZZE.mjs';
5
- import { partialFieldsOf, DEFAULT_MAX_PER_GROUP, flattenSchema, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_FUZZY_PREFIX_LENGTH, RESULT_WINDOW, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-OSF3SGJV.mjs';
4
+ import { tokenize } from './chunk-4VBG6PEH.mjs';
5
+ import { partialFieldsOf, DEFAULT_MAX_PER_GROUP, flattenSchema, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_FUZZY_PREFIX_LENGTH, RESULT_WINDOW, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-KJ7LB3TR.mjs';
6
6
  import { fuzzyTermMatches } from './chunk-GES7U2PM.mjs';
7
- import { MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, isWordIndexedFieldType, isGeopointOrVectorType } from './chunk-DQABW5UQ.mjs';
7
+ import { MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, isWordIndexedFieldType, isGeopointOrVectorType } from './chunk-LS5IRM23.mjs';
8
8
  import { compareComparableKeys } from './chunk-R6A773WK.mjs';
9
9
  import { holdsUnpairedSurrogate, compareCodePoints } from './chunk-YTJCGKM4.mjs';
10
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
10
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
11
11
 
12
12
  // src/search/cursor-binding.ts
13
13
  var ABSENT_TAG = 0;
@@ -1,8 +1,8 @@
1
- import { flattenSchema, PARTIAL_WORD_MIN_CODE_POINTS, PARTIAL_WORDS_ADDED_PER_QUERY, DEFAULT_FUZZY_PREFIX_LENGTH } from './chunk-OSF3SGJV.mjs';
1
+ import { flattenSchema, PARTIAL_WORD_MIN_CODE_POINTS, PARTIAL_WORDS_ADDED_PER_QUERY, DEFAULT_FUZZY_PREFIX_LENGTH } from './chunk-KJ7LB3TR.mjs';
2
2
  import { fuzzyTermMatches } from './chunk-GES7U2PM.mjs';
3
- import { isWordIndexedBase } from './chunk-DQABW5UQ.mjs';
3
+ import { isWordIndexedBase } from './chunk-LS5IRM23.mjs';
4
4
  import { compareCodePoints, codePointCount } from './chunk-YTJCGKM4.mjs';
5
- import { createNarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
5
+ import { createNarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
6
6
 
7
7
  // src/core/tokenizer/constants.ts
8
8
  var TOKEN_CACHE_SIZE_FLOOR = 5e4;
@@ -1,5 +1,5 @@
1
1
  import { performance } from 'perf_hooks';
2
- import { getHeapStatistics, setFlagsFromString } from 'v8';
2
+ import { setFlagsFromString, getHeapStatistics } from 'v8';
3
3
  import { runInNewContext } from 'vm';
4
4
 
5
5
  // src/runtime/idle-heap-cleanup.ts
@@ -93,4 +93,4 @@ function startIdleHeapCleanup() {
93
93
  return () => clearInterval(timer);
94
94
  }
95
95
 
96
- export { startIdleHeapCleanup };
96
+ export { collectAndReturnPages, startIdleHeapCleanup };
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
1
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
2
2
  import { existsSync } from 'fs';
3
3
  import { createRequire } from 'module';
4
4
  import { join, dirname } from 'path';
@@ -1,8 +1,8 @@
1
- import { readSharedConfigFields, restoredEmbedding, restoredPartitionConfig, MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR } from './chunk-HJASKX4F.mjs';
2
- import { getLanguage } from './chunk-4MQ5F4IL.mjs';
3
- import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN } from './chunk-GG2FBGVZ.mjs';
1
+ import { readSharedConfigFields, restoredEmbedding, restoredPartitionConfig, MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR } from './chunk-2453RJYK.mjs';
2
+ import { getLanguage } from './chunk-OLXM65YH.mjs';
3
+ import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN } from './chunk-ZCKPRCYI.mjs';
4
4
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
5
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
5
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
6
6
  import { encode, decode } from '@msgpack/msgpack';
7
7
 
8
8
  // src/distribution/cluster/index-settings.ts
@@ -1,20 +1,24 @@
1
- import { validateWorkerConfig, validateIndexName, validatePatternValueLimit, requireSurfaceFormsForPartialFields, validateBM25Params, validatePartitionConfig, executeQuery, queryBindingOf, executePreflight, executeSuggest, executeListDocuments, validateDocId } from './chunk-4QDQEJDV.mjs';
1
+ import { validateWorkerConfig, validateIndexName, validatePatternValueLimit, requireSurfaceFormsForPartialFields, validateBM25Params, validatePartitionConfig, executeQuery, queryBindingOf, executePreflight, executeSuggest, executeListDocuments, validateDocId } from './chunk-4D6OH4EF.mjs';
2
2
  import { ReplicationMessageTypes } from './chunk-GCM3JFVA.mjs';
3
- import { WIRE_BATCH_BUDGET, resolveVectorText, bindEngineCore, restoredConfigFields, restoredEmbedding, collectRequiredFieldFailures, embedChunkDocuments, providedDocId, requireDocumentObject, admitInsert, asBatchInsertError, requireMatchingDocId, embedDocumentFields, assertDocumentCarriesMappedVectors, admitBufferedUpsert, createPendingAdmissions, recordPendingAdmission } from './chunk-HJASKX4F.mjs';
4
- import { NATIVE_CRC32_MIN_BYTES, generateId, decodeEveryStoredDocument, createSharedFrozenSegment, shareSegmentArrays, splitWorkerBudget, resolveWorkerCount, createDirectExecutor, createPartitionRouter, MAX_FILE_BYTES, resolveWorkerEntry, missingWorkerEntry, readHeapStatistics, nodeThreadId, CHECKSUM_YIELD_CHUNK_BYTES, resolvePartitionInsertOptions, resolveIndexAnalysis, createPartitionManager, buildSegmentPayload, createFrozenSegment, resolveRequestThreadCount, vectorsPerFile, vectorsToBytes, VECTOR_FILE_PAYLOAD_VERSION, deadBitsWhere, NO_LIVE_VECTOR_AT_POSITION, createPartitionIndex, selectionKeeps, decodeMapWithoutFields, isCompositePartition, segmentArraysOf, mergeSegmentContents, survivorDocumentsOf, partitionStateOf, VECTOR_FILE_MAX_VECTORS, deadBytesFor, mergeFrozenSegments, workerResourceLimits, decodeVectorIndexParts, bytesToVectors, freezeSegmentShared, DEFAULT_BACKPRESSURE_LIMIT, DEFAULT_REQUEST_TIMEOUT_MS, SHUTDOWN_TIMEOUT_MS, decodeVectorFilePayload, decodeVectorGraphPartPayload, assembleGraphParts, countDead, encodeSegmentState, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH, VALID_HNSW_METRICS, spawnNodeWorker, decodeVectorGraphPayload, graphPartsOfEarlierPayload, decodeStoredDocument, isDead } from './chunk-K4FZ55Q2.mjs';
5
- import { requirePatternSearchFor, requirePartialWordSearchFor, collectQueryTermStats, mergePartitionStats, oversampledFacetConfig, fnv1a, availablePatternSearch, PATTERN_HOST, kWayMerge, mergeFacets, setNestedValue } from './chunk-YGLSR7BC.mjs';
6
- import { detectRuntime, getLanguage } from './chunk-4MQ5F4IL.mjs';
7
- import { MAX_INDEX_CONFIGURATION_BYTES, STATISTICS_BROADCAST_INTERVAL_MS, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, HEAP_PRESSURE_WARNING_FRACTION, MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, FOREIGN_STATS_TTL_MS, MAX_IMPORT_REFUSALS_REPORTED, BATCH_CHUNK_SIZE, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION, EXPORT_CHUNK_BYTES } from './chunk-GG2FBGVZ.mjs';
8
- import { releaseLocksHeldBy } from './chunk-23HJ5QXQ.mjs';
9
- import { requireSearchBackendSettings } from './chunk-2E35UM3G.mjs';
10
- import { DEFAULT_PATTERN_WORK_CAP, MATCHER_STATE_BUDGET_BYTES } from './chunk-R2XCJIO7.mjs';
11
- import { getNestedValue, parseVectorDimension } from './chunk-P2PYEZZE.mjs';
12
- import { extractVectorFieldsFromSchema, messagePackUpperBoundBytes, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, raiseEarlierReleaseGraphSetting, partialFieldsOf, flattenSchema, requireValidFieldTypes, encodeDocument, schemaFieldsOf, isQuantizationMode, isStorageMode, validateRequiredFields, requireDocumentWithinSizeLimit, validateDocument, validateDocumentStrict } from './chunk-OSF3SGJV.mjs';
3
+ import { WIRE_BATCH_BUDGET, resolveVectorText, bindEngineCore, restoredConfigFields, restoredEmbedding, collectRequiredFieldFailures, embedChunkDocuments, providedDocId, requireDocumentObject, admitInsert, asBatchInsertError, requireMatchingDocId, embedDocumentFields, assertDocumentCarriesMappedVectors, admitBufferedUpsert, createPendingAdmissions, recordPendingAdmission } from './chunk-2453RJYK.mjs';
4
+ import { NATIVE_CRC32_MIN_BYTES, generateId, decodeEveryStoredDocument, createSharedFrozenSegment, shareSegmentArrays, splitWorkerBudget, resolveWorkerCount, createDirectExecutor, createPartitionRouter, MAX_FILE_BYTES, resolveWorkerEntry, missingWorkerEntry, readHeapStatistics, nodeThreadId, CHECKSUM_YIELD_CHUNK_BYTES, resolvePartitionInsertOptions, resolveIndexAnalysis, createPartitionManager, buildSegmentPayload, createFrozenSegment, resolveRequestThreadCount, vectorsPerFile, vectorsToBytes, VECTOR_FILE_PAYLOAD_VERSION, deadBitsWhere, NO_LIVE_VECTOR_AT_POSITION, createPartitionIndex, selectionKeeps, decodeMapWithoutFields, isCompositePartition, segmentArraysOf, mergeSegmentContents, survivorDocumentsOf, partitionStateOf, VECTOR_FILE_MAX_VECTORS, deadBytesFor, mergeFrozenSegments, workerResourceLimits, decodeVectorIndexParts, bytesToVectors, freezeSegmentShared, DEFAULT_BACKPRESSURE_LIMIT, DEFAULT_REQUEST_TIMEOUT_MS, SHUTDOWN_TIMEOUT_MS, decodeVectorFilePayload, decodeVectorGraphPartPayload, assembleGraphParts, countDead, encodeSegmentState, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH, VALID_HNSW_METRICS, spawnNodeWorker, decodeVectorGraphPayload, graphPartsOfEarlierPayload, decodeStoredDocument, isDead } from './chunk-4CWHWOBI.mjs';
5
+ import { requirePatternSearchFor, requirePartialWordSearchFor, collectQueryTermStats, mergePartitionStats, oversampledFacetConfig, fnv1a, availablePatternSearch, PATTERN_HOST, kWayMerge, mergeFacets, setNestedValue } from './chunk-XYDP7CCJ.mjs';
6
+ import { detectRuntime, getLanguage } from './chunk-OLXM65YH.mjs';
7
+ import { MAX_INDEX_CONFIGURATION_BYTES, STATISTICS_BROADCAST_INTERVAL_MS, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, HEAP_PRESSURE_WARNING_FRACTION, MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, FOREIGN_STATS_TTL_MS, MAX_IMPORT_REFUSALS_REPORTED, BATCH_CHUNK_SIZE, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION, EXPORT_CHUNK_BYTES } from './chunk-ZCKPRCYI.mjs';
8
+ import { releaseLocksHeldBy } from './chunk-IN5CH4P2.mjs';
9
+ import { requireSearchBackendSettings } from './chunk-B3UOQJD3.mjs';
10
+ import { DEFAULT_PATTERN_WORK_CAP, MATCHER_STATE_BUDGET_BYTES } from './chunk-SREPGC6O.mjs';
11
+ import { getNestedValue, parseVectorDimension } from './chunk-4VBG6PEH.mjs';
12
+ import { extractVectorFieldsFromSchema, messagePackUpperBoundBytes, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, raiseEarlierReleaseGraphSetting, partialFieldsOf, flattenSchema, requireValidFieldTypes, encodeDocument, schemaFieldsOf, isQuantizationMode, isStorageMode, validateRequiredFields, requireDocumentWithinSizeLimit, validateDocument, validateDocumentStrict } from './chunk-KJ7LB3TR.mjs';
13
13
  import { MIN_M } from './chunk-KEHK2O6P.mjs';
14
- import { isSingleStringFieldType, VECTOR_PATTERN, MAX_DOCUMENT_NESTING_DEPTH } from './chunk-DQABW5UQ.mjs';
14
+ import { isSingleStringFieldType, VECTOR_PATTERN, MAX_DOCUMENT_NESTING_DEPTH } from './chunk-LS5IRM23.mjs';
15
15
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
16
16
  import { createRequestId, isValidWorkerResponse, threadSlotOfWorker } from './chunk-POWOTUKJ.mjs';
17
- import { ErrorCodes, NarsilError } from './chunk-I64LXKO3.mjs';
17
+ import { ErrorCodes, NarsilError } from './chunk-TPJU7NDJ.mjs';
18
+ import { openSync, close, readFileSync } from 'fs';
19
+ import { rename, readFile, writeFile, unlink, realpath, readdir, readlink } from 'fs/promises';
20
+ import { endianness } from 'os';
21
+ import { dirname } from 'path';
18
22
  import { encode, decode } from '@msgpack/msgpack';
19
23
  import * as zlib from 'zlib';
20
24
 
@@ -728,15 +732,48 @@ async function getPath() {
728
732
  }
729
733
  return cachedPath;
730
734
  }
731
-
732
- // src/persistence/durability/directory-lock.ts
733
- var LOCK_FILE_NAME = ".narsil.lock";
734
- var HARD_LINK_UNSUPPORTED_CODES = /* @__PURE__ */ new Set(["EPERM", "ENOTSUP", "EOPNOTSUPP", "ENOSYS"]);
735
- var lockedDirectories = /* @__PURE__ */ new Set();
735
+ var AUXV_CLOCK_TICKS_TYPE = 17n;
736
+ var AUXV_END_TYPE = 0n;
737
+ var THIRTY_TWO_BIT_ARCHITECTURES = /* @__PURE__ */ new Set(["arm", "ia32", "mips", "mipsel", "ppc"]);
738
+ var FIRST_STAT_FIELD_AFTER_COMMAND = 3;
739
+ var STAT_STATE_FIELD = 3;
740
+ var STAT_START_TIME_FIELD = 22;
741
+ var EXITED_STATES = /* @__PURE__ */ new Set(["Z", "X", "x"]);
742
+ var UNKNOWN = { kind: "unknown" };
743
+ var clockTicksPerSecond = null;
736
744
  function errnoOf(err) {
737
745
  return err?.code;
738
746
  }
739
- function processIsRunning(pid) {
747
+ function readWord(bytes, offset, wordBytes, littleEndian) {
748
+ if (wordBytes === 8) return littleEndian ? bytes.readBigUInt64LE(offset) : bytes.readBigUInt64BE(offset);
749
+ return BigInt(littleEndian ? bytes.readUInt32LE(offset) : bytes.readUInt32BE(offset));
750
+ }
751
+ async function readClockTicksPerSecond() {
752
+ const auxv = await readFile("/proc/self/auxv");
753
+ const wordBytes = THIRTY_TWO_BIT_ARCHITECTURES.has(process.arch) ? 4 : 8;
754
+ const littleEndian = endianness() === "LE";
755
+ for (let offset = 0; offset + 2 * wordBytes <= auxv.length; offset += 2 * wordBytes) {
756
+ const type = readWord(auxv, offset, wordBytes, littleEndian);
757
+ if (type === AUXV_END_TYPE) return null;
758
+ if (type === AUXV_CLOCK_TICKS_TYPE) {
759
+ const ticks = Number(readWord(auxv, offset + wordBytes, wordBytes, littleEndian));
760
+ return ticks > 0 ? ticks : null;
761
+ }
762
+ }
763
+ return null;
764
+ }
765
+ function clockTicks() {
766
+ clockTicksPerSecond ??= readClockTicksPerSecond().catch(() => null);
767
+ return clockTicksPerSecond;
768
+ }
769
+ function threadGroupOf(status) {
770
+ const leader = /^Tgid:\s*(\d+)\s*$/m.exec(status)?.[1];
771
+ return leader === void 0 ? null : Number(leader);
772
+ }
773
+ function statField(fieldsAfterCommand, field) {
774
+ return fieldsAfterCommand[field - FIRST_STAT_FIELD_AFTER_COMMAND];
775
+ }
776
+ function signalReaches(pid) {
740
777
  try {
741
778
  process.kill(pid, 0);
742
779
  return true;
@@ -744,6 +781,101 @@ function processIsRunning(pid) {
744
781
  return errnoOf(err) === "EPERM";
745
782
  }
746
783
  }
784
+ async function identifyProcess(pid) {
785
+ try {
786
+ const [status, stat, ticksPerSecond] = await Promise.all([
787
+ readFile(`/proc/${pid}/status`, "utf8"),
788
+ readFile(`/proc/${pid}/stat`, "utf8"),
789
+ clockTicks()
790
+ ]);
791
+ const leader = threadGroupOf(status);
792
+ if (leader === null) return UNKNOWN;
793
+ if (leader !== pid) return { kind: "thread" };
794
+ const commandEnd = stat.lastIndexOf(")");
795
+ if (commandEnd < 0) return UNKNOWN;
796
+ const fieldsAfterCommand = stat.slice(commandEnd + 1).trim().split(/\s+/);
797
+ const state = statField(fieldsAfterCommand, STAT_STATE_FIELD);
798
+ if (state !== void 0 && EXITED_STATES.has(state)) return { kind: "exited" };
799
+ const startTicks = Number(statField(fieldsAfterCommand, STAT_START_TIME_FIELD));
800
+ const uptimeSeconds = Number.parseFloat(readFileSync("/proc/uptime", "utf8"));
801
+ const nowMs = Date.now();
802
+ if (ticksPerSecond === null || !Number.isFinite(startTicks) || !Number.isFinite(uptimeSeconds)) return UNKNOWN;
803
+ return { kind: "process", startMs: Math.round(nowMs - (uptimeSeconds - startTicks / ticksPerSecond) * 1e3) };
804
+ } catch {
805
+ return UNKNOWN;
806
+ }
807
+ }
808
+ async function descriptorTargets(pid) {
809
+ const descriptorDirectory = `/proc/${pid}/fd`;
810
+ let descriptors;
811
+ try {
812
+ descriptors = await readdir(descriptorDirectory);
813
+ } catch {
814
+ return null;
815
+ }
816
+ const targets = [];
817
+ for (const descriptor of descriptors) {
818
+ try {
819
+ targets.push(await readlink(`${descriptorDirectory}/${descriptor}`));
820
+ } catch (err) {
821
+ if (errnoOf(err) !== "ENOENT") return null;
822
+ }
823
+ }
824
+ return targets;
825
+ }
826
+ async function holdsFileInDirectoryOf(pid, lockPath) {
827
+ const targets = await descriptorTargets(pid);
828
+ if (targets === null) return false;
829
+ const directory = await realpath(dirname(lockPath)).catch(() => null);
830
+ if (directory === null) return false;
831
+ const inside = directory.endsWith("/") ? directory : `${directory}/`;
832
+ return targets.some((target) => target === directory || target.startsWith(inside));
833
+ }
834
+ async function holderIsLive(holder, self, lockPath) {
835
+ if (holder.pid === self.pid) {
836
+ if (holder.processStartMs === null || self.processStartMs === null) return false;
837
+ if (Math.abs(holder.processStartMs - self.processStartMs) <= DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS) return true;
838
+ return holdsFileInDirectoryOf(holder.pid, lockPath);
839
+ }
840
+ if (!signalReaches(holder.pid)) return false;
841
+ const found = await identifyProcess(holder.pid);
842
+ if (found.kind === "thread" || found.kind === "exited") return false;
843
+ if (found.kind === "unknown") return signalReaches(holder.pid);
844
+ if (holder.processStartMs === null) return true;
845
+ if (found.startMs - holder.processStartMs <= DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS) return true;
846
+ return holdsFileInDirectoryOf(holder.pid, lockPath);
847
+ }
848
+ function holdDirectoryOpen(directory) {
849
+ if (process.platform !== "linux") return () => void 0;
850
+ const descriptor = openSync(directory, "r");
851
+ return () => close(descriptor, () => void 0);
852
+ }
853
+ async function removeStaleLock(lockPath, asidePath, isStale) {
854
+ try {
855
+ await rename(lockPath, asidePath);
856
+ } catch (err) {
857
+ if (errnoOf(err) === "ENOENT") return;
858
+ throw err;
859
+ }
860
+ try {
861
+ const moved = await readFile(asidePath, "utf8");
862
+ if (!isStale(moved)) {
863
+ await writeFile(lockPath, moved, { flag: "wx" }).catch((err) => {
864
+ if (errnoOf(err) !== "EEXIST") throw err;
865
+ });
866
+ }
867
+ } finally {
868
+ await unlink(asidePath).catch(() => void 0);
869
+ }
870
+ }
871
+
872
+ // src/persistence/durability/directory-lock.ts
873
+ var LOCK_FILE_NAME = ".narsil.lock";
874
+ var HARD_LINK_UNSUPPORTED_CODES = /* @__PURE__ */ new Set(["EPERM", "ENOTSUP", "EOPNOTSUPP", "ENOSYS"]);
875
+ var lockedDirectories = /* @__PURE__ */ new Set();
876
+ function errnoOf2(err) {
877
+ return err?.code;
878
+ }
747
879
  function integerOrNull(text) {
748
880
  const value = Number.parseInt(text ?? "", 10);
749
881
  return Number.isSafeInteger(value) ? value : null;
@@ -771,7 +903,7 @@ async function readHolder(fs, lockPath) {
771
903
  try {
772
904
  return parseHolder(await fs.readFile(lockPath, "utf8")) ?? "unreadable";
773
905
  } catch (err) {
774
- if (errnoOf(err) === "ENOENT") return "absent";
906
+ if (errnoOf2(err) === "ENOENT") return "absent";
775
907
  throw err;
776
908
  }
777
909
  }
@@ -781,10 +913,9 @@ async function settledHolder(fs, lockPath) {
781
913
  await new Promise((resolve) => setTimeout(resolve, DIRECTORY_LOCK_SETTLE_MS));
782
914
  return readHolder(fs, lockPath);
783
915
  }
784
- function holderIsLive(holder, self) {
785
- if (holder.pid !== self.pid) return processIsRunning(holder.pid);
786
- if (holder.processStartMs === null || self.processStartMs === null) return false;
787
- return Math.abs(holder.processStartMs - self.processStartMs) <= DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS;
916
+ function sameReading(first, second) {
917
+ if (typeof first !== "object" || typeof second !== "object") return first === second;
918
+ return formatHolder(first) === formatHolder(second);
788
919
  }
789
920
  function heldElsewhere(root, holder, lockPath) {
790
921
  return new NarsilError(
@@ -802,7 +933,7 @@ async function createLockFileExclusively(fs, lockPath, content) {
802
933
  await fs.writeFile(lockPath, content, { flag: "wx" });
803
934
  return true;
804
935
  } catch (err) {
805
- if (errnoOf(err) === "EEXIST") return false;
936
+ if (errnoOf2(err) === "EEXIST") return false;
806
937
  throw err;
807
938
  }
808
939
  }
@@ -812,7 +943,7 @@ async function createLockFile(fs, lockPath, draftPath, content) {
812
943
  await fs.link(draftPath, lockPath);
813
944
  return true;
814
945
  } catch (err) {
815
- const code = errnoOf(err);
946
+ const code = errnoOf2(err);
816
947
  if (code === "EEXIST") return false;
817
948
  if (code !== void 0 && HARD_LINK_UNSUPPORTED_CODES.has(code)) {
818
949
  return createLockFileExclusively(fs, lockPath, content);
@@ -828,12 +959,14 @@ async function acquire(fs, root, lockPath, self) {
828
959
  for (let attempt = 0; attempt < DIRECTORY_LOCK_ATTEMPTS; attempt++) {
829
960
  if (await createLockFile(fs, lockPath, draftPath, content)) return;
830
961
  const holder = await settledHolder(fs, lockPath);
831
- if (typeof holder === "object" && holderIsLive(holder, self)) {
962
+ if (typeof holder === "object" && await holderIsLive(holder, self, lockPath)) {
832
963
  throw heldElsewhere(root, holderLabel(holder, self), lockPath);
833
964
  }
834
- await fs.unlink(lockPath).catch((err) => {
835
- if (errnoOf(err) !== "ENOENT") throw err;
836
- });
965
+ await removeStaleLock(
966
+ lockPath,
967
+ `${draftPath}.aside`,
968
+ (text) => sameReading(holder, parseHolder(text) ?? "unreadable")
969
+ );
837
970
  }
838
971
  throw heldElsewhere(root, "another process", lockPath);
839
972
  }
@@ -851,7 +984,15 @@ async function lockDirectory(root) {
851
984
  const resolvedRoot = pathMod.resolve(root);
852
985
  const lockPath = pathMod.join(resolvedRoot, LOCK_FILE_NAME);
853
986
  const self = await describeSelf();
987
+ async function holds() {
988
+ const holder = await readHolder(fs, lockPath);
989
+ return typeof holder === "object" && holder.nonce === self.nonce;
990
+ }
991
+ async function removeOwnLockFile() {
992
+ if (await holds().catch(() => false)) await fs.unlink(lockPath).catch(() => void 0);
993
+ }
854
994
  let directoryKey = null;
995
+ let closeDirectory = () => void 0;
855
996
  try {
856
997
  await fs.mkdir(resolvedRoot, { recursive: true });
857
998
  const stat = await fs.stat(resolvedRoot, { bigint: true });
@@ -860,8 +1001,10 @@ async function lockDirectory(root) {
860
1001
  lockedDirectories.add(key);
861
1002
  directoryKey = key;
862
1003
  await acquire(fs, root, lockPath, self);
1004
+ closeDirectory = holdDirectoryOpen(resolvedRoot);
863
1005
  } catch (err) {
864
1006
  if (directoryKey !== null) lockedDirectories.delete(directoryKey);
1007
+ await removeOwnLockFile();
865
1008
  if (err instanceof NarsilError) throw err;
866
1009
  throw new NarsilError(
867
1010
  ErrorCodes.PERSISTENCE_SAVE_FAILED,
@@ -871,17 +1014,14 @@ async function lockDirectory(root) {
871
1014
  }
872
1015
  const heldKey = directoryKey;
873
1016
  let released = false;
874
- async function holds() {
875
- const holder = await readHolder(fs, lockPath);
876
- return typeof holder === "object" && holder.nonce === self.nonce;
877
- }
878
1017
  return {
879
1018
  holds,
880
1019
  async release() {
881
1020
  if (released) return;
882
1021
  released = true;
883
1022
  lockedDirectories.delete(heldKey);
884
- if (await holds().catch(() => false)) await fs.unlink(lockPath).catch(() => void 0);
1023
+ await removeOwnLockFile();
1024
+ closeDirectory();
885
1025
  }
886
1026
  };
887
1027
  }
@@ -2989,6 +3129,13 @@ function createInsyncConfirmMessage(payload, sourceId, requestId) {
2989
3129
  function isRecord2(value) {
2990
3130
  return value !== null && typeof value === "object" && !Array.isArray(value);
2991
3131
  }
3132
+ function isPlainObject(value) {
3133
+ if (!isRecord2(value)) {
3134
+ return false;
3135
+ }
3136
+ const prototype = Object.getPrototypeOf(value);
3137
+ return prototype === Object.prototype || prototype === null;
3138
+ }
2992
3139
  function validateEntryPayload(decoded) {
2993
3140
  if (!isRecord2(decoded) || !isRecord2(decoded.entry)) {
2994
3141
  throw new Error('Invalid EntryPayload: missing or invalid "entry" field');
@@ -3110,6 +3257,9 @@ function validateForwardBatchResultPayload(decoded) {
3110
3257
  if (result.errorMessage !== null && typeof result.errorMessage !== "string") {
3111
3258
  throw new Error(`Invalid ForwardBatchResultPayload: "results[${index}].errorMessage" must be a string or null`);
3112
3259
  }
3260
+ if (result.errorDetails !== void 0 && result.errorDetails !== null && !isPlainObject(result.errorDetails)) {
3261
+ throw new Error(`Invalid ForwardBatchResultPayload: "results[${index}].errorDetails" must be an object or absent`);
3262
+ }
3113
3263
  }
3114
3264
  return decoded;
3115
3265
  }
@@ -7366,7 +7516,7 @@ function createDurabilityManager(config, hooks, directoryOverride) {
7366
7516
  if (indexState === void 0) {
7367
7517
  return;
7368
7518
  }
7369
- await drainIndexStateForUnload(indexState, metadataWrites.get(indexName), (close) => close);
7519
+ await drainIndexStateForUnload(indexState, metadataWrites.get(indexName), (close2) => close2);
7370
7520
  indexes.delete(indexName);
7371
7521
  metadataWrites.delete(indexName);
7372
7522
  },
@@ -14068,17 +14218,17 @@ function rejectConfiguration(message) {
14068
14218
  throw new NarsilError(ErrorCodes.CONFIG_INVALID, `Invalid index configuration: ${message}`);
14069
14219
  }
14070
14220
  function renamed(manifest, sourceName, indexName) {
14071
- const rename = (key) => `${indexName}/${key.slice(sourceName.length + 1)}`;
14221
+ const rename2 = (key) => `${indexName}/${key.slice(sourceName.length + 1)}`;
14072
14222
  return {
14073
14223
  ...manifest,
14074
14224
  partitions: manifest.partitions.map((partition) => ({
14075
14225
  ...partition,
14076
- segments: partition.segments.map((segment) => ({ ...segment, key: rename(segment.key) }))
14226
+ segments: partition.segments.map((segment) => ({ ...segment, key: rename2(segment.key) }))
14077
14227
  })),
14078
14228
  vectors: manifest.vectors.map((field) => ({
14079
14229
  ...field,
14080
- files: field.files.map((file) => ({ ...file, key: rename(file.key) })),
14081
- graphParts: field.graphParts.map((part) => ({ ...part, key: rename(part.key) }))
14230
+ files: field.files.map((file) => ({ ...file, key: rename2(file.key) })),
14231
+ graphParts: field.graphParts.map((part) => ({ ...part, key: rename2(part.key) }))
14082
14232
  }))
14083
14233
  };
14084
14234
  }
@@ -1,8 +1,8 @@
1
1
  import { OSQ_STEPS, OSQ_GRID, OSQ_REFINE_ROUNDS, OSQ_REFINE_TOLERANCE, OSQ4_NARROW_DIMENSION_LIMIT, DEFAULT_OSQ4_NARROW_OVERSAMPLE, DEFAULT_OVERSAMPLE_BY_BITS, OSQ_QUERY_BITS, OSQ_LAMBDA } from './chunk-ZJ4CSAB2.mjs';
2
- import { nativeSearchCoreIsEnabled, loadNativeCore, stopUsingTheNativeSearchCore, noteFallback } from './chunk-2E35UM3G.mjs';
2
+ import { nativeSearchCoreIsEnabled, loadNativeCore, stopUsingTheNativeSearchCore, noteFallback } from './chunk-B3UOQJD3.mjs';
3
3
  import { COMPACTION_TOMBSTONE_RATIO, COMPACTION_ABSOLUTE_THRESHOLD, MAX_LAYER_CAP, PLACEMENT_ROOM_REQUESTS, INITIAL_LIST_CAPACITY, DEFAULT_EF_SEARCH, INITIAL_UPPER_SLOTS } from './chunk-KEHK2O6P.mjs';
4
4
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
5
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
5
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
6
6
  import { readSync, closeSync, openSync } from 'fs';
7
7
 
8
8
  // src/vector/constants.ts
@@ -1,7 +1,7 @@
1
1
  import { EARLIER_RELEASE_MIN_M, MIN_M, MAX_M } from './chunk-KEHK2O6P.mjs';
2
- import { DEFAULT_PATTERN_VALUE_LIMIT, isPlainObject, isWordIndexedBase, MAX_TEXT_FIELDS, MAX_VECTOR_DIMENSION, parseFieldType, MAX_DOCUMENT_BYTES, MAX_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, FIELD_NAME_PATTERN, RESERVED_ROOT_FIELDS, MAX_DOCUMENT_NESTING_DEPTH, VECTOR_PATTERN } from './chunk-DQABW5UQ.mjs';
2
+ import { DEFAULT_PATTERN_VALUE_LIMIT, isPlainObject, isWordIndexedBase, MAX_TEXT_FIELDS, MAX_VECTOR_DIMENSION, parseFieldType, MAX_DOCUMENT_BYTES, MAX_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, FIELD_NAME_PATTERN, RESERVED_ROOT_FIELDS, MAX_DOCUMENT_NESTING_DEPTH, VECTOR_PATTERN } from './chunk-LS5IRM23.mjs';
3
3
  import { compareCodePoints, holdsUnpairedSurrogate, exceedsCodePoints } from './chunk-YTJCGKM4.mjs';
4
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
4
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
5
5
  import { encode } from '@msgpack/msgpack';
6
6
 
7
7
  // src/schema/validator/schema.ts
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
1
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
2
2
 
3
3
  // src/schema/constants.ts
4
4
  var MAX_NESTING_DEPTH = 4;
@@ -1,5 +1,5 @@
1
1
  import { english } from './chunk-TGP5M5R7.mjs';
2
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
3
3
 
4
4
  // src/languages/registry.ts
5
5
  var languages = /* @__PURE__ */ new Map();
@@ -1,8 +1,8 @@
1
1
  import { MAX_FILTER_ARRAY_SIZE } from './chunk-WQBCBKY3.mjs';
2
2
  import { tabulatedLevenshtein } from './chunk-GES7U2PM.mjs';
3
- import { parsedTypeOf } from './chunk-DQABW5UQ.mjs';
3
+ import { parsedTypeOf } from './chunk-LS5IRM23.mjs';
4
4
  import { codePointCount, exceedsCodePoints } from './chunk-YTJCGKM4.mjs';
5
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
5
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
6
6
 
7
7
  // src/core/bitset.ts
8
8
  function createBitSet(capacity) {
@@ -47,6 +47,7 @@ var ErrorCodes = {
47
47
  QUERY_NODE_TIMEOUT: "QUERY_NODE_TIMEOUT",
48
48
  QUERY_NO_ACTIVE_REPLICA: "QUERY_NO_ACTIVE_REPLICA",
49
49
  CLUSTER_OPERATION_UNSUPPORTED: "CLUSTER_OPERATION_UNSUPPORTED",
50
+ CLUSTER_WRITE_BLOCKED: "CLUSTER_WRITE_BLOCKED",
50
51
  ALLOCATION_NO_DATA_NODES: "ALLOCATION_NO_DATA_NODES",
51
52
  ALLOCATION_INVALID_CONFIG: "ALLOCATION_INVALID_CONFIG",
52
53
  ALLOCATION_FAILED: "ALLOCATION_FAILED",
@@ -1,12 +1,12 @@
1
- import { PATTERN_EXPRESSION_OPERATORS, PATTERN_TEST_OPERATORS, PATTERN_ELEMENT_OPERATORS, requireTextRangeField, isFiniteNumber, invalid, requireFieldKind, kindOfValue, requireListLength, isObjectRecord, patternSearchModule, DEFAULT_PATTERN_WORK_CAP, bitsetIsEmpty, createBitSet, bitsetSet, PATTERN_WORK_FLUSH_UNITS, MATCHER_STATE_BUDGET_BYTES } from './chunk-R2XCJIO7.mjs';
1
+ import { PATTERN_EXPRESSION_OPERATORS, PATTERN_TEST_OPERATORS, PATTERN_ELEMENT_OPERATORS, requireTextRangeField, isFiniteNumber, invalid, requireFieldKind, kindOfValue, requireListLength, isObjectRecord, patternSearchModule, DEFAULT_PATTERN_WORK_CAP, bitsetIsEmpty, createBitSet, bitsetSet, PATTERN_WORK_FLUSH_UNITS, MATCHER_STATE_BUDGET_BYTES } from './chunk-SREPGC6O.mjs';
2
2
  import { GEO_UNIT_METRES, MAX_FILTER_DEPTH, MAX_FILTER_TESTS, FILTER_OPERAND_COPY_DEPTH } from './chunk-WQBCBKY3.mjs';
3
- import { getFlatSchema, tokenize, partialWordSearchModule, getFieldValueByInternalId, getFieldValueForDoc } from './chunk-P2PYEZZE.mjs';
4
- import { isLatitude, MAX_LATITUDE_DEGREES, isLongitude, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, partialFieldsOf, schemaFieldsOf, flattenSchema, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, RESULT_WINDOW, DEFAULT_FUZZY_PREFIX_LENGTH, EARTH_RADIUS_METERS, RADIUS_BOX_MARGIN_RATIO, RADIUS_BOX_MARGIN_RADIANS, FULL_TURN_DEGREES, ANTIMERIDIAN_SPAN_DEGREES, DEFAULT_PAGE_SIZE, DEG_TO_RAD, LOCATION_CODE_BITS_PER_AXIS, PREFIX_MAX_EXPANSIONS, MAX_COVERING_CELLS } from './chunk-OSF3SGJV.mjs';
3
+ import { getFlatSchema, tokenize, partialWordSearchModule, getFieldValueByInternalId, getFieldValueForDoc } from './chunk-4VBG6PEH.mjs';
4
+ import { isLatitude, MAX_LATITUDE_DEGREES, isLongitude, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, partialFieldsOf, schemaFieldsOf, flattenSchema, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, RESULT_WINDOW, DEFAULT_FUZZY_PREFIX_LENGTH, EARTH_RADIUS_METERS, RADIUS_BOX_MARGIN_RATIO, RADIUS_BOX_MARGIN_RADIANS, FULL_TURN_DEGREES, ANTIMERIDIAN_SPAN_DEGREES, DEFAULT_PAGE_SIZE, DEG_TO_RAD, LOCATION_CODE_BITS_PER_AXIS, PREFIX_MAX_EXPANSIONS, MAX_COVERING_CELLS } from './chunk-KJ7LB3TR.mjs';
5
5
  import { fuzzyTermMatches } from './chunk-GES7U2PM.mjs';
6
- import { parsedTypeOf, isStringValuedBase, withSortableOption, isGeopointOrVectorType, PROTOTYPE_POLLUTION_KEYS, isWordIndexedFieldType } from './chunk-DQABW5UQ.mjs';
6
+ import { parsedTypeOf, isStringValuedBase, withSortableOption, isGeopointOrVectorType, PROTOTYPE_POLLUTION_KEYS, isWordIndexedFieldType } from './chunk-LS5IRM23.mjs';
7
7
  import { singleFoldTable, appendFoldedCodePoint, sortModeOf, defaultSortMode, SORT_VALUE_MAX_CODE_POINTS, toReducedSortValue, readSortField, compareComparableKeys, toComparableSortValue, isSortMode, SORT_MODES, compareSortValues } from './chunk-R6A773WK.mjs';
8
8
  import { compareCodePoints, exceedsCodePoints, codePointCount, holdsUnpairedSurrogate } from './chunk-YTJCGKM4.mjs';
9
- import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
9
+ import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
10
10
 
11
11
  // src/core/partition/partial-words/platform.ts
12
12
  function platformPartialWordSearch() {
@@ -1,7 +1,7 @@
1
- import { nativeSearchCoreIsEnabled, loadNativeCore } from './chunk-2E35UM3G.mjs';
1
+ import { nativeSearchCoreIsEnabled, loadNativeCore } from './chunk-B3UOQJD3.mjs';
2
2
  import { MAX_FILTER_DEPTH } from './chunk-WQBCBKY3.mjs';
3
- import { MAX_SORT_FIELDS } from './chunk-OSF3SGJV.mjs';
4
- import { NarsilError, ServerErrorCodes, ErrorCodes } from './chunk-I64LXKO3.mjs';
3
+ import { MAX_SORT_FIELDS } from './chunk-KJ7LB3TR.mjs';
4
+ import { NarsilError, ServerErrorCodes, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
5
5
  import { mkdtemp, open, rm } from 'fs/promises';
6
6
  import { tmpdir } from 'os';
7
7
  import path from 'path';
@@ -151,6 +151,7 @@ var STATUS_BY_CODE = {
151
151
  QUERY_NODE_TIMEOUT: 503,
152
152
  QUERY_NO_ACTIVE_REPLICA: 503,
153
153
  CLUSTER_OPERATION_UNSUPPORTED: 501,
154
+ CLUSTER_WRITE_BLOCKED: 429,
154
155
  REPLICATION_ENTRY_INVALID: 503,
155
156
  REPLICATION_INSYNC_REMOVAL_FAILED: 503,
156
157
  REPLICATION_ROLLBACK_FAILED: 503,
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PAGE_SIZE } from './chunk-OSF3SGJV.mjs';
1
+ import { DEFAULT_PAGE_SIZE } from './chunk-KJ7LB3TR.mjs';
2
2
 
3
3
  // src/engine/constants.ts
4
4
  var MIN_DOCUMENTS_FOR_SEGMENTS = 64;
@@ -1,6 +1,6 @@
1
1
  import { P as PartitionConfig, A as AnyDocument, a as InsertOptions, W as WriteOptions } from './schema-DgyDijhf.js';
2
- import { V as VectorMaintenanceResult, B as BatchResult, L as ListParams, h as ListResult, I as IndexInfo, g as IndexStats, P as PartitionStatsResult, Q as QueryParams, e as QueryResult, j as PreflightResult, k as SuggestParams, l as SuggestResult } from './memory-B6SBOKlS.js';
3
- import { e as TaskRecord, M as MemoryStatsResponse, b as ImportResult, H as HttpIndexConfig, c as TaskListQuery, T as TaskListPage } from './tasks-CYAQe6qd.js';
2
+ import { V as VectorMaintenanceResult, B as BatchResult, L as ListParams, h as ListResult, I as IndexInfo, g as IndexStats, P as PartitionStatsResult, Q as QueryParams, e as QueryResult, j as PreflightResult, k as SuggestParams, l as SuggestResult } from './memory-BPKNx9Tl.js';
3
+ import { e as TaskRecord, M as MemoryStatsResponse, b as ImportResult, H as HttpIndexConfig, c as TaskListQuery, T as TaskListPage } from './tasks-DGyz586z.js';
4
4
 
5
5
  /**
6
6
  * This is the `fetch` implementation the client sends every request through.