@delali/narsil 0.4.1-next.215 → 0.4.2-next.271

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 (157) hide show
  1. package/README.md +1 -1
  2. package/dist/adapters/filesystem.d.ts +1 -1
  3. package/dist/adapters/filesystem.mjs +9 -3
  4. package/dist/adapters/gcs.d.ts +1 -1
  5. package/dist/adapters/indexeddb.d.ts +6 -1
  6. package/dist/adapters/indexeddb.mjs +20 -26
  7. package/dist/adapters/memory.d.ts +1 -1
  8. package/dist/adapters/s3.d.ts +1 -1
  9. package/dist/{adapters-pljAqmrC.d.ts → adapters-8LcdNB77.d.ts} +18 -1
  10. package/dist/browser/{chunk-GBJSEHVJ.mjs → chunk-DPRCAVC2.mjs} +14 -8
  11. package/dist/browser/{chunk-YINZFPLT.mjs → chunk-WRRXR57N.mjs} +1 -1
  12. package/dist/browser/{chunk-QAOVAYAG.mjs → chunk-XBWABEL3.mjs} +1 -1
  13. package/dist/browser/{chunk-4E5APHTM.mjs → chunk-Y5CSZDOH.mjs} +1 -1
  14. package/dist/browser/{durability-config-75NSFCQN.mjs → durability-config-UP3OTUMB.mjs} +34 -2
  15. package/dist/browser/{msgpack-leaf-44XNWSSY.mjs → msgpack-leaf-FEPCLXXY.mjs} +7 -1
  16. package/dist/browser/{optional-reads-6LN3HMUH.mjs → optional-reads-NQO5DKM4.mjs} +18 -16
  17. package/dist/browser/{optional-writes-76DWMRQH.mjs → optional-writes-HVPPDHSY.mjs} +259 -104
  18. package/dist/browser/{storage-leaf-5UTR5K7J.mjs → storage-leaf-42IZEOJJ.mjs} +1473 -305
  19. package/dist/{capabilities-BOFFMx84.d.ts → capabilities-BoWiLNv7.d.ts} +76 -61
  20. package/dist/{chunk-DBC4EJWB.mjs → chunk-33ZMFOAR.mjs} +1 -1
  21. package/dist/{chunk-NCIGNQJE.mjs → chunk-4GCHJ3XD.mjs} +930 -387
  22. package/dist/{chunk-7P5YWDRQ.mjs → chunk-4WQNWAQE.mjs} +1 -1
  23. package/dist/{chunk-357KIU5E.mjs → chunk-5E3TJ4P3.mjs} +5 -5
  24. package/dist/{chunk-GXCDWLQI.mjs → chunk-5GYGHPCH.mjs} +7 -1
  25. package/dist/{chunk-SMQPZHPS.mjs → chunk-ATQ6JR3I.mjs} +1 -1
  26. package/dist/{chunk-2K24MEYV.mjs → chunk-BBIAUHAB.mjs} +3 -3
  27. package/dist/{react-native/chunks/chunk-MMPBO4WR.mjs → chunk-DA32WXBT.mjs} +2 -2
  28. package/dist/{chunk-MSJD74GN.mjs → chunk-EALKCTWH.mjs} +5 -5
  29. package/dist/{chunk-755NM4PL.mjs → chunk-FOGTBAYN.mjs} +183 -21
  30. package/dist/{chunk-6GHX35ZM.mjs → chunk-GTBJSNN2.mjs} +1 -1
  31. package/dist/{chunk-DDUXEJXW.mjs → chunk-H6LWGMPQ.mjs} +45 -22
  32. package/dist/{chunk-UNEEFTEU.mjs → chunk-HZ3OAUTL.mjs} +2 -1
  33. package/dist/{chunk-M3B7SGJB.mjs → chunk-KL4ORYJW.mjs} +6 -6
  34. package/dist/{chunk-IL5DRCNU.mjs → chunk-KQWTS7AM.mjs} +1 -1
  35. package/dist/{chunk-DKIMHIBC.mjs → chunk-KX3OP6VP.mjs} +2 -2
  36. package/dist/{chunk-D456ZFPQ.mjs → chunk-MIIJ5O3O.mjs} +2 -2
  37. package/dist/{chunk-PP3W5PQQ.mjs → chunk-MS746XNY.mjs} +285 -118
  38. package/dist/{chunk-WM5KJSQV.mjs → chunk-NFA3WHJU.mjs} +1 -1
  39. package/dist/{react-native/chunks/chunk-ZUJCUPVS.mjs → chunk-OETLM4EH.mjs} +1 -1
  40. package/dist/{chunk-MYN4K5IS.mjs → chunk-OLXFIUIZ.mjs} +1 -1
  41. package/dist/{chunk-P4F4UWLC.mjs → chunk-PSO7V7VW.mjs} +17 -3
  42. package/dist/{chunk-X3EQCQLP.mjs → chunk-Q4NLL66U.mjs} +2 -2
  43. package/dist/{chunk-WC5KAWXQ.mjs → chunk-QJFKL4NK.mjs} +4 -4
  44. package/dist/{chunk-MSIN4NM3.mjs → chunk-S3JHYPH7.mjs} +6 -1
  45. package/dist/{chunk-3IE3A74H.mjs → chunk-SSITKQU6.mjs} +3 -3
  46. package/dist/{chunk-B3MO37YF.mjs → chunk-TANKI7TG.mjs} +1 -1
  47. package/dist/{chunk-Z7XSHKOF.mjs → chunk-TI4G3SIG.mjs} +63 -144
  48. package/dist/{chunk-OGYSPNL2.mjs → chunk-TT3UDDL3.mjs} +7 -7
  49. package/dist/{react-native/chunks/chunk-4FUCRLSA.mjs → chunk-VHIOGDVD.mjs} +1 -1
  50. package/dist/{chunk-AXDB6KUQ.mjs → chunk-W3JH2IK6.mjs} +4 -4
  51. package/dist/{chunk-CERPUGRK.mjs → chunk-WIT6B5OB.mjs} +2 -2
  52. package/dist/{chunk-MI6UZGUR.mjs → chunk-XGVSG6ZU.mjs} +3 -3
  53. package/dist/{chunk-6I6OO6B2.mjs → chunk-XWPNRHTG.mjs} +4 -4
  54. package/dist/{chunk-WTMCGZ74.mjs → chunk-YHZSSPG3.mjs} +2 -2
  55. package/dist/chunk-ZYEEOZTT.mjs +52 -0
  56. package/dist/{client-BhNxHtcZ.d.ts → client-B0NPZSKY.d.ts} +4 -4
  57. package/dist/client.d.ts +9 -9
  58. package/dist/client.mjs +2 -2
  59. package/dist/{config-P9zW3Zz7.d.ts → config-B3-sw887.d.ts} +3 -3
  60. package/dist/{config-BJSL7piq.d.ts → config-DL_nkguq.d.ts} +4 -4
  61. package/dist/{direct-executor-GWJXDFLD.mjs → direct-executor-PCBB6FCO.mjs} +4 -4
  62. package/dist/distribution/coordinator/etcd.d.ts +3 -3
  63. package/dist/distribution/coordinator/etcd.mjs +33 -3
  64. package/dist/distribution/coordinator/in-memory.d.ts +3 -3
  65. package/dist/distribution/transport/grpc.mjs +4 -4
  66. package/dist/distribution/transport/in-memory.mjs +1 -1
  67. package/dist/distribution/transport/tcp.mjs +12 -7
  68. package/dist/distribution.d.ts +8 -8
  69. package/dist/distribution.mjs +167 -91
  70. package/dist/{durability-config-VWS2K24E.mjs → durability-config-HWKWP35M.mjs} +34 -2
  71. package/dist/embeddings/openai.d.ts +7 -3
  72. package/dist/embeddings/openai.mjs +37 -31
  73. package/dist/{engine-DoFnkRoF.d.ts → engine-DGG_yX0p.d.ts} +3 -3
  74. package/dist/{index-B_vmxpgW.d.ts → index-fX_FbuRT.d.ts} +1 -1
  75. package/dist/index.browser.mjs +3 -3
  76. package/dist/index.d.ts +7 -7
  77. package/dist/index.mjs +4 -4
  78. package/dist/index.react-native.mjs +4 -4
  79. package/dist/invalidation/broadcast-channel.d.ts +1 -1
  80. package/dist/invalidation/filesystem.d.ts +1 -1
  81. package/dist/invalidation/noop.d.ts +1 -1
  82. package/dist/{long-query-thread-GNTDYDOZ.mjs → long-query-thread-4ALYIIC4.mjs} +14 -14
  83. package/dist/msgpack-leaf-6ZBZWFRD.mjs +9 -0
  84. package/dist/{optional-reads-UCS23AWP.mjs → optional-reads-ESDVS225.mjs} +18 -16
  85. package/dist/{optional-writes-2AHJCGTY.mjs → optional-writes-2OK4TOLY.mjs} +9 -8
  86. package/dist/{paged-partition-archive-GBAHDT55.mjs → paged-partition-archive-Y5OAKNRB.mjs} +13 -13
  87. package/dist/partial-words.browser.mjs +3 -3
  88. package/dist/partial-words.mjs +4 -4
  89. package/dist/pattern.browser.mjs +2 -2
  90. package/dist/pattern.mjs +2 -2
  91. package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
  92. package/dist/persistence/durability/checkpoint-worker.mjs +14 -14
  93. package/dist/{query-actions-IDCUA7UV.mjs → query-actions-UQVQZFIJ.mjs} +4 -4
  94. package/dist/query-suggestions/merge-worker.mjs +7 -7
  95. package/dist/query-suggestions.browser.mjs +3 -3
  96. package/dist/query-suggestions.d.ts +3 -3
  97. package/dist/query-suggestions.mjs +5 -5
  98. package/dist/{chunk-F26DOOUH.mjs → react-native/chunks/chunk-4OOUY2K7.mjs} +1 -1
  99. package/dist/react-native/chunks/{chunk-LPX26NNL.mjs → chunk-5MYHYBET.mjs} +286 -118
  100. package/dist/react-native/chunks/{chunk-MRH36RN3.mjs → chunk-AVCMTWET.mjs} +1 -1
  101. package/dist/react-native/chunks/{chunk-HTBY4GON.mjs → chunk-GS6LGXY3.mjs} +1 -1
  102. package/dist/{chunk-UHLFCGZ3.mjs → react-native/chunks/chunk-LE4DTMDL.mjs} +2 -2
  103. package/dist/react-native/chunks/{chunk-TG56N5JC.mjs → chunk-VIO5IPF7.mjs} +2 -2
  104. package/dist/react-native/chunks/{chunk-UO44MA5M.mjs → chunk-VRI5XH2M.mjs} +7 -1
  105. package/dist/{chunk-R2PJKSNL.mjs → react-native/chunks/chunk-XGS2UYVI.mjs} +1 -1
  106. package/dist/react-native/chunks/{chunk-AJAH6X7W.mjs → chunk-XW6GZQWP.mjs} +4 -4
  107. package/dist/react-native/chunks/{chunk-SCGBU47K.mjs → chunk-Z44S6WW5.mjs} +2 -2
  108. package/dist/react-native/chunks/{durability-config-FCSD4MXY.mjs → durability-config-HJETGZVB.mjs} +34 -2
  109. package/dist/react-native/chunks/msgpack-leaf-4MIGXWZT.mjs +7 -0
  110. package/dist/react-native/chunks/{optional-reads-4XCJ34QG.mjs → optional-reads-TN3PT6M4.mjs} +18 -16
  111. package/dist/react-native/chunks/{optional-writes-XYZVTBFB.mjs → optional-writes-LZDHB7FX.mjs} +8 -7
  112. package/dist/react-native/chunks/{restore-queue-NOKQZJ2Z.mjs → restore-queue-J7SB263E.mjs} +7 -7
  113. package/dist/react-native/chunks/{segment-codec-leaf-3ZXBJVKH.mjs → segment-codec-leaf-PEKX7TBL.mjs} +5 -5
  114. package/dist/react-native/chunks/{segment-merge-leaf-3Z7MMPWE.mjs → segment-merge-leaf-I2EC7H6R.mjs} +6 -6
  115. package/dist/react-native/chunks/{storage-leaf-KJOX3MMW.mjs → storage-leaf-RQXM7HBO.mjs} +1481 -314
  116. package/dist/react-native/chunks/{store-leaf-QGLVSO5X.mjs → store-leaf-EZGCLSLM.mjs} +6 -6
  117. package/dist/react-native/chunks/{suggestions-leaf-6GI5ZSW6.mjs → suggestions-leaf-JNGH2JYC.mjs} +6 -6
  118. package/dist/react-native/chunks/{worker-copies-ALOD7TSP.mjs → worker-copies-2OWLLBCV.mjs} +5 -5
  119. package/dist/react-native/partial-words.mjs +4 -4
  120. package/dist/react-native/pattern.mjs +2 -2
  121. package/dist/react-native/query-suggestions.mjs +4 -4
  122. package/dist/react-native/sync.mjs +4 -4
  123. package/dist/react-native/synonyms.mjs +4 -4
  124. package/dist/react.d.ts +10 -10
  125. package/dist/react.mjs +0 -2
  126. package/dist/{rerank-HB6DU6GS.mjs → rerank-TQ4SU76L.mjs} +4 -4
  127. package/dist/rerankers/http.d.ts +1 -1
  128. package/dist/rerankers/http.mjs +19 -15
  129. package/dist/{restore-queue-VUQHGCXE.mjs → restore-queue-W7U2X6V3.mjs} +7 -7
  130. package/dist/{schema-CzG9OUw5.d.ts → schema-CFnQ-WI3.d.ts} +1 -1
  131. package/dist/{segment-codec-leaf-TW2FPAAT.mjs → segment-codec-leaf-WGP4FBXF.mjs} +5 -5
  132. package/dist/{segment-merge-leaf-BS3QV5PZ.mjs → segment-merge-leaf-FYWJQSPL.mjs} +5 -5
  133. package/dist/server.d.ts +86 -12
  134. package/dist/server.mjs +2243 -1918
  135. package/dist/{storage-leaf-5IG2HPNY.mjs → storage-leaf-GRG44RQA.mjs} +1193 -219
  136. package/dist/{store-leaf-ZWSOK2DV.mjs → store-leaf-YDJVH73G.mjs} +6 -6
  137. package/dist/{suggestions-leaf-MUZNKQVF.mjs → suggestions-leaf-5UFJV7SC.mjs} +8 -8
  138. package/dist/sync/filesystem.d.ts +4 -4
  139. package/dist/sync/filesystem.mjs +12 -12
  140. package/dist/sync/indexeddb.browser.mjs +1 -1
  141. package/dist/sync/indexeddb.d.ts +4 -4
  142. package/dist/sync/indexeddb.mjs +2 -2
  143. package/dist/sync.browser.mjs +4 -4
  144. package/dist/sync.d.ts +5 -5
  145. package/dist/sync.mjs +4 -4
  146. package/dist/synonyms.browser.mjs +3 -3
  147. package/dist/synonyms.mjs +4 -4
  148. package/dist/{tasks-DrLiolTG.d.ts → tasks-B2MDjPL0.d.ts} +4 -4
  149. package/dist/{thread-6ZBCENAP.mjs → thread-6YLVL2NC.mjs} +13 -13
  150. package/dist/{types-pS-mAJmX.d.ts → types-DGjk684l.d.ts} +2 -2
  151. package/dist/vector/search-worker.d.ts +2 -2
  152. package/dist/{worker-copies-32HWFUH7.mjs → worker-copies-IP4L7KEW.mjs} +7 -7
  153. package/dist/workers/entry.mjs +16 -16
  154. package/package.json +12 -10
  155. package/dist/chunk-HLPRHOSO.mjs +0 -17
  156. package/dist/msgpack-leaf-H5ZYW7S7.mjs +0 -9
  157. package/dist/react-native/chunks/msgpack-leaf-JMNGSTRW.mjs +0 -7
@@ -1,10 +1,10 @@
1
1
  import { encodeDocument } from './chunk-2CKDCC65.mjs';
2
2
  import { workerResourceLimits, admittedHeapBytes, collectYoungGenerationBeforeRefusal, collectGarbageBeforeRefusal } from './chunk-2AFZE7Y3.mjs';
3
- import { headerAt, MAP_TAGS, decode, Decoder } from './chunk-GXCDWLQI.mjs';
3
+ import { headerAt, MAP_TAGS, decode, Decoder } from './chunk-5GYGHPCH.mjs';
4
4
  import { newSyncEpoch, isSyncEpoch } from './chunk-BUMREPLU.mjs';
5
5
  import { english } from './chunk-7T4LAYT4.mjs';
6
- import { patternSearchModule, PATTERN_EXPRESSION_OPERATORS, PATTERN_TEST_OPERATORS, PATTERN_ELEMENT_OPERATORS, requireTextRangeField, isFiniteNumber, invalid, requireFieldKind, kindOfValue, requireListLength, isObjectRecord, GEO_UNIT_METRES, matchPattern, claimsTypoPreparation, DEFAULT_PATTERN_WORK_CAP, bitsetHas, bitsetClear, storedText, cachedStoredFields, storedValuesOf, bitsetSet, discardStoredValues, MAX_FILTER_DEPTH, createBitSet, installStoredFields, storedValueBytes, bitsetIterator, bitsetIsEmpty, prepareStoredValues, fuzzyTermMatches, MATCHER_STATE_BUDGET_BYTES, GrowableUint32, checkedSize, buildStoredValues, bitsetFromSet, MAX_FILTER_TESTS, TYPO_CLAIM_SLOTS_PER_WORD, fuzzyPrefixOf, boundedLevenshtein, bitsetAndNotInto, bitsetAndInto, bitsetOrInto, FILTER_OPERAND_COPY_DEPTH, PATTERN_WORK_FLUSH_UNITS } from './chunk-IL5DRCNU.mjs';
7
- import { parsedTypeOf, isLatitude, MAX_LATITUDE_DEGREES, isLongitude, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, isStringValuedBase, flattenSchema, schemaFieldsOf, getNestedValue, partialFieldsOf, MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, requireLoadedMessagePack, vectorDimensionOf, isSingleStringFieldType, messagePackUpperBoundBytes, extractVectorFieldsFromSchema, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, validateTextStorage, loadMessagePack, validateRequiredFields, requireDocumentWithinSizeLimit, raiseEarlierReleaseGraphSetting, isWordIndexedBase, PROTOTYPE_POLLUTION_KEYS, tokenizeOptions, isPlainObject, isWordIndexedFieldType, loadedMessagePack, validateDocument, validateDocumentStrict, textFieldsChanged, getFlatSchema, getOrCreateFieldNameIndex, MAX_NESTING_DEPTH, requireValidFieldTypes, parseVectorDimension, isStorageMode, isQuantizationMode, MAX_DOCUMENT_NESTING_DEPTH, withSortableOption, VECTOR_PATTERN, isListBase, isGeopointOrVectorType, MAX_COVERING_CELLS, LOCATION_CODE_BITS_PER_AXIS, LOCATION_CELLS_PER_AXIS, FULL_TURN_DEGREES, EARTH_RADIUS_METERS, DEG_TO_RAD, ANTIMERIDIAN_SPAN_DEGREES } from './chunk-7P5YWDRQ.mjs';
6
+ import { patternSearchModule, PATTERN_EXPRESSION_OPERATORS, PATTERN_TEST_OPERATORS, PATTERN_ELEMENT_OPERATORS, requireTextRangeField, isFiniteNumber, invalid, requireFieldKind, kindOfValue, requireListLength, isObjectRecord, GEO_UNIT_METRES, matchPattern, claimsTypoPreparation, DEFAULT_PATTERN_WORK_CAP, bitsetHas, bitsetClear, storedText, cachedStoredFields, storedValuesOf, bitsetSet, discardStoredValues, MAX_FILTER_DEPTH, createBitSet, installStoredFields, storedValueBytes, bitsetIterator, bitsetIsEmpty, prepareStoredValues, fuzzyTermMatches, MATCHER_STATE_BUDGET_BYTES, GrowableUint32, checkedSize, buildStoredValues, bitsetFromSet, MAX_FILTER_TESTS, TYPO_CLAIM_SLOTS_PER_WORD, fuzzyPrefixOf, boundedLevenshtein, bitsetAndNotInto, bitsetAndInto, bitsetOrInto, FILTER_OPERAND_COPY_DEPTH, PATTERN_WORK_FLUSH_UNITS } from './chunk-KQWTS7AM.mjs';
7
+ import { parsedTypeOf, isLatitude, MAX_LATITUDE_DEGREES, isLongitude, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, isStringValuedBase, flattenSchema, schemaFieldsOf, getNestedValue, partialFieldsOf, MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, requireLoadedMessagePack, vectorDimensionOf, isSingleStringFieldType, messagePackUpperBoundBytes, extractVectorFieldsFromSchema, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, validateTextStorage, loadMessagePack, validateRequiredFields, requireDocumentWithinSizeLimit, raiseEarlierReleaseGraphSetting, isWordIndexedBase, PROTOTYPE_POLLUTION_KEYS, tokenizeOptions, isPlainObject, isWordIndexedFieldType, loadedMessagePack, validateDocument, validateDocumentStrict, textFieldsChanged, getFlatSchema, getOrCreateFieldNameIndex, MAX_NESTING_DEPTH, requireValidFieldTypes, parseVectorDimension, isStorageMode, isQuantizationMode, MAX_DOCUMENT_NESTING_DEPTH, withSortableOption, VECTOR_PATTERN, isListBase, isGeopointOrVectorType, MAX_COVERING_CELLS, LOCATION_CODE_BITS_PER_AXIS, LOCATION_CELLS_PER_AXIS, FULL_TURN_DEGREES, EARTH_RADIUS_METERS, DEG_TO_RAD, ANTIMERIDIAN_SPAN_DEGREES } from './chunk-4WQNWAQE.mjs';
8
8
  import { detectRuntime, splitWorkerBudget, resolveWorkerCount, DEFAULT_BACKPRESSURE_LIMIT, DEFAULT_REQUEST_TIMEOUT_MS, countEngineThread, requirePinnedState, createDocIdMap, SHUTDOWN_TIMEOUT_MS, stopOfSignal, requireSearchActive, resolveWorkerEntry, missingWorkerEntry, signalOfSearch, answerFromOneState, sharedStopOfSignal, engineThreadYoungGenerationBytes, resolveRequestThreadCount, spawnNodeWorker, bindSearchSignal, WORKER_YOUNG_GENERATION_MB, nodeThreadId, youngGenerationBytesOfThisV8 } from './chunk-FJXJZUWF.mjs';
9
9
  import { changeIndexOutsideExternalWaits, turnsAreBudgeted, turnIsSpent, yieldTurn, HEAP_RESUME_FRACTION_BELOW_V8_INEFFECTIVE_MARK_COMPACT_LINE, HEAP_BLOCK_FRACTION_BELOW_V8_INEFFECTIVE_MARK_COMPACT_LINE, noteThreadSlotLive, threadSlotOfWorker, indexChangeOutsideExternalWaits, PROCESS_LIMIT_REFRESH_INTERVAL_MS, countWrite, PROCESS_STATUS_READ_BYTES, PROCESS_STATUS_READ_CEILING_BYTES, threadSlotGone, noteThreadSlotGone, adoptSharedTurns, WASM_PAGE_BYTES, VECTOR_STORE_INITIAL_CAPACITY, VECTOR_SEARCH_TIMEOUT_MS, VECTOR_SEARCH_LOAD_TIMEOUT_MS, VECTOR_SCRATCH_SLOTS, VECTOR_INSERT_TIMEOUT_MS, VECTOR_BLOCK_MAX_BYTES, VECTOR_BLOCK_INITIAL_SLOTS, UNPLACED_FLAG_CHUNK_ORDINALS, NATIVE_THREAD_SEARCH_SLOTS, NATIVE_THREAD_SCAN_CHUNK_ORDINALS, NATIVE_ATTACH_RETRY_MS, MAX_WASM_PAGES, MAX_VECTOR_ORDINALS, MAX_RENUMBERED_SEARCH_ATTEMPTS, MAX_DOC_ID_TABLE_BYTES, LOCK_WAIT_SLICE_MS, LOCK_SPIN_ITERATIONS, GRAPH_LOCK_WAIT_SLICE_MS, GRAPH_LOCK_WAIT_DEADLINE_MS, GRAPH_BUILD_DISPATCH_CHUNK, GRAPH_BUILD_CHUNKS_IN_FLIGHT_PER_WORKER, DISK_STORAGE_BLOCK_BYTES, waitOutsideCountedWrite, collectAndReturnPages } from './chunk-5EI5CXO6.mjs';
10
10
  import { MIN_DOCUMENTS_FOR_SEGMENTS, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, RESULT_WINDOW, PARTIAL_WORD_MIN_CODE_POINTS, PARTIAL_WORDS_ADDED_PER_QUERY, MAX_PARTITIONS, DEFAULT_LIMIT, MAX_INDEX_CONFIGURATION_BYTES, BATCH_CHUNK_SIZE, DEFAULT_FUZZY_PREFIX_LENGTH, BM25_DISPLAYED_NAME_LENGTH, MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, MAX_CALLS_ACROSS_INDEX_CHANGES, DEFAULT_PAGE_SIZE, CURSOR_BINDING_BUFFER_BYTES, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, MAX_SWEEP_INTERVAL_MS, DEFAULT_OFFSET, MIN_SWEEP_INTERVAL_MS, MIN_RANK_CONSTANT, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, FUSION_TIE_INSERTION_LIMIT, DEFAULT_RANK_CONSTANT, DEFAULT_LINEAR_ALPHA, STATISTICS_BROADCAST_INTERVAL_MS, MAX_IMPORT_REFUSALS_REPORTED, MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, FOREIGN_STATS_TTL_MS, EXPORT_CHUNK_BYTES, DEFAULT_MAX_PARTITIONS, ANALYSIS_HOLD_APPLY_INTERVAL_MS, ANALYSIS_CHANGE_MEMBERS, MIN_HYBRID_DEPTH, MAX_SUGGEST_SCATTER_LIMIT, MAX_SUGGEST_LIMIT, MAX_QUERY_PHRASES, MAX_PHRASE_WORDS, MAX_HYBRID_DEPTH, HYBRID_RESCORE_WINDOW, DEFAULT_SUGGEST_LIMIT, DEFAULT_MAX_PER_GROUP, HEAP_PRESSURE_WARNING_FRACTION, PREFIX_MAX_EXPANSIONS, HEAP_PRESSURE_REARM_FRACTION, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-3ECIRFS5.mjs';
@@ -993,7 +993,7 @@ var loaded = null;
993
993
  var loading = null;
994
994
  function importOptionalReads() {
995
995
  if (loaded !== null) return Promise.resolve(loaded);
996
- loading ??= import('./optional-reads-UCS23AWP.mjs').then(
996
+ loading ??= import('./optional-reads-ESDVS225.mjs').then(
997
997
  (code7) => {
998
998
  code7.bindOptionalReadsHost(optionalCodeHost());
999
999
  loaded = code7;
@@ -12686,7 +12686,7 @@ function resolvePartitionInsertOptions(config, analysis, options) {
12686
12686
 
12687
12687
  // src/core/segment-codec-code.ts
12688
12688
  var segmentCodec = codeLoader(async () => {
12689
- const [msgpack, code7] = await Promise.all([loadMessagePack(), import('./segment-codec-leaf-TW2FPAAT.mjs')]);
12689
+ const [msgpack, code7] = await Promise.all([loadMessagePack(), import('./segment-codec-leaf-WGP4FBXF.mjs')]);
12690
12690
  code7.bindSegmentCodecHost(optionalCodeHost(), msgpack);
12691
12691
  return code7;
12692
12692
  }, "segment codec");
@@ -12694,7 +12694,7 @@ var loadSegmentCodec = segmentCodec.load;
12694
12694
 
12695
12695
  // src/query-suggestions/store-code.ts
12696
12696
  var suggestionStore = codeLoader(async () => {
12697
- const [msgpack, code7] = await Promise.all([loadMessagePack(), import('./store-leaf-ZWSOK2DV.mjs')]);
12697
+ const [msgpack, code7] = await Promise.all([loadMessagePack(), import('./store-leaf-YDJVH73G.mjs')]);
12698
12698
  code7.bindSuggestionStoreHost(optionalCodeHost(), msgpack);
12699
12699
  return code7;
12700
12700
  }, "query suggestions store");
@@ -12775,7 +12775,7 @@ var storageCode = codeLoader(async () => {
12775
12775
  loadSegmentMerge(),
12776
12776
  loadSuggestionStore(),
12777
12777
  loadVectorCore(),
12778
- import('./storage-leaf-5IG2HPNY.mjs')
12778
+ import('./storage-leaf-GRG44RQA.mjs')
12779
12779
  ]);
12780
12780
  code7.bindStorageHost(optionalCodeHost(), digest2, msgpack, segmentCodec2, segmentMerge2, suggestionStore2, vectorCore2);
12781
12781
  return code7;
@@ -21549,7 +21549,7 @@ function hasLanguage(name) {
21549
21549
 
21550
21550
  // src/narsil/restore-queue-code.ts
21551
21551
  var restoreQueue = codeLoader(async () => {
21552
- const [suggestionStore2, code7] = await Promise.all([loadSuggestionStore(), import('./restore-queue-VUQHGCXE.mjs')]);
21552
+ const [suggestionStore2, code7] = await Promise.all([loadSuggestionStore(), import('./restore-queue-W7U2X6V3.mjs')]);
21553
21553
  code7.bindRestoreQueueHost(optionalCodeHost(), suggestionStore2);
21554
21554
  return code7;
21555
21555
  }, "restore");
@@ -22126,7 +22126,7 @@ var loadEmbedCode = embedCode.load;
22126
22126
 
22127
22127
  // src/engine/optional-writes-code.ts
22128
22128
  var optionalWrites = codeLoader(async () => {
22129
- const [segmentCodec2, code7] = await Promise.all([loadSegmentCodec(), import('./optional-writes-2AHJCGTY.mjs')]);
22129
+ const [segmentCodec2, code7] = await Promise.all([loadSegmentCodec(), import('./optional-writes-2OK4TOLY.mjs')]);
22130
22130
  code7.bindOptionalWritesHost(optionalCodeHost(), segmentCodec2);
22131
22131
  return code7;
22132
22132
  }, "write");
@@ -22561,6 +22561,51 @@ function reconstructSchemaFromMetadata(metadata) {
22561
22561
  function bindOptionalWritesHost(_host, _segmentCodec) {
22562
22562
  }
22563
22563
 
22564
+ // src/engine/mutations/batch-shutdown.ts
22565
+ function isFailureThatShutdownCauses(code7) {
22566
+ return code7 === ErrorCodes.INSTANCE_SHUT_DOWN || code7 === ErrorCodes.INDEX_NOT_FOUND || code7 === ErrorCodes.EMBEDDING_FAILED;
22567
+ }
22568
+ function shutDownStarted(ctx) {
22569
+ return ctx.abortController.signal.aborted;
22570
+ }
22571
+ function shutDownError() {
22572
+ return new NarsilError(ErrorCodes.INSTANCE_SHUT_DOWN, "This Narsil instance has been shut down");
22573
+ }
22574
+ function causedByShutdown(ctx, err) {
22575
+ const { signal } = ctx.abortController;
22576
+ if (!signal.aborted) return false;
22577
+ if (err === signal.reason) return true;
22578
+ if (err instanceof NarsilError) return isFailureThatShutdownCauses(err.code);
22579
+ return err instanceof Error && err.name === "AbortError";
22580
+ }
22581
+ function batchFailureOf(ctx, err, fallbackCode) {
22582
+ if (causedByShutdown(ctx, err)) {
22583
+ return err instanceof NarsilError && err.code === ErrorCodes.INSTANCE_SHUT_DOWN ? err : shutDownError();
22584
+ }
22585
+ return err instanceof NarsilError ? err : new NarsilError(fallbackCode, String(err));
22586
+ }
22587
+ function docIdOf(entry) {
22588
+ return entry.docId;
22589
+ }
22590
+ function failAsShutDown(failed, entries, reportedDocIdOf2, start = 0, end = entries.length) {
22591
+ if (start >= end) return;
22592
+ const error = shutDownError();
22593
+ for (let i = start; i < end; i++) failed.push({ docId: reportedDocIdOf2(entries[i]), error });
22594
+ }
22595
+ function applyUnlessShutDown(ctx, apply) {
22596
+ return () => {
22597
+ if (shutDownStarted(ctx)) throw shutDownError();
22598
+ return apply();
22599
+ };
22600
+ }
22601
+ async function unlessShutDown(ctx, work) {
22602
+ try {
22603
+ await work();
22604
+ } catch (err) {
22605
+ if (!shutDownStarted(ctx)) throw err;
22606
+ }
22607
+ }
22608
+
22564
22609
  // src/engine/mutations/batch-admissions.ts
22565
22610
  function createPendingAdmissions() {
22566
22611
  return { total: 0, byPartition: /* @__PURE__ */ new Map() };
@@ -22571,8 +22616,11 @@ function recordPendingAdmission(ctx, pending, manager, docId) {
22571
22616
  const partitionId = manager.routePartition(docId);
22572
22617
  pending.byPartition.set(partitionId, (pending.byPartition.get(partitionId) ?? 0) + 1);
22573
22618
  }
22574
- function asBatchInsertError(err) {
22575
- return err instanceof NarsilError ? err : new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, String(err));
22619
+ function asBatchInsertError(ctx, err) {
22620
+ return batchFailureOf(ctx, err, ErrorCodes.DOC_VALIDATION_FAILED);
22621
+ }
22622
+ function providedDocIdOrEmpty(document) {
22623
+ return providedDocId(document) ?? "";
22576
22624
  }
22577
22625
 
22578
22626
  // src/engine/mutations/outside-hold.ts
@@ -22802,7 +22850,11 @@ async function prepareInsertDocuments(ctx, indexName, documents2, start, end, ho
22802
22850
  const pending = [];
22803
22851
  for (let i = start; i < end; i++) {
22804
22852
  if (turnsAreBudgeted && turnIsSpent()) await yieldTurn();
22805
- if (ctx.abortController.signal.aborted) break;
22853
+ if (shutDownStarted(ctx)) {
22854
+ failAsShutDown(failed, pending, docIdOf);
22855
+ failAsShutDown(failed, documents2, providedDocIdOrEmpty, i, end);
22856
+ return null;
22857
+ }
22806
22858
  const document = documents2[i];
22807
22859
  const docId = providedDocId(document) ?? ctx.idGenerator();
22808
22860
  try {
@@ -22811,17 +22863,26 @@ async function prepareInsertDocuments(ctx, indexName, documents2, start, end, ho
22811
22863
  validateDocId(docId);
22812
22864
  pending.push(pendingInsertOf(ctx, indexName, docId, document, hooked));
22813
22865
  } catch (err) {
22814
- failed.push({ docId, error: asBatchInsertError(err) });
22866
+ failed.push({ docId, error: asBatchInsertError(ctx, err) });
22815
22867
  }
22816
22868
  }
22817
- const { entry, embedding } = await prepareDocumentWrites(
22818
- ctx,
22819
- indexName,
22820
- pending.map((item) => item.preparation),
22821
- hold,
22822
- true,
22823
- earlier
22824
- );
22869
+ let prepared;
22870
+ try {
22871
+ if (shutDownStarted(ctx)) throw shutDownError();
22872
+ prepared = await prepareDocumentWrites(
22873
+ ctx,
22874
+ indexName,
22875
+ pending.map((item) => item.preparation),
22876
+ hold,
22877
+ true,
22878
+ earlier
22879
+ );
22880
+ } catch (err) {
22881
+ if (!causedByShutdown(ctx, err)) throw err;
22882
+ failAsShutDown(failed, pending, docIdOf);
22883
+ return null;
22884
+ }
22885
+ const { entry, embedding } = prepared;
22825
22886
  const candidates2 = [];
22826
22887
  for (const item of pending) {
22827
22888
  const { document, failure } = item.preparation;
@@ -22829,22 +22890,19 @@ async function prepareInsertDocuments(ctx, indexName, documents2, start, end, ho
22829
22890
  candidates2.push({ docId: item.docId, document });
22830
22891
  continue;
22831
22892
  }
22832
- const docId = item.refusedByHook ? item.docId : providedDocId(document) ?? "";
22833
- failed.push({ docId, error: asBatchInsertError(failure) });
22893
+ const docId = item.refusedByHook ? item.docId : providedDocIdOrEmpty(document);
22894
+ failed.push({ docId, error: asBatchInsertError(ctx, failure) });
22834
22895
  }
22835
22896
  return { entry, candidates: candidates2, embedding };
22836
22897
  }
22837
22898
  async function admitBatchDocuments(ctx, indexName, documents2, failed, hold) {
22838
- const { entry, candidates: candidates2, embedding } = await prepareInsertDocuments(
22839
- ctx,
22840
- indexName,
22841
- documents2,
22842
- 0,
22843
- documents2.length,
22844
- hold,
22845
- true,
22846
- failed
22847
- );
22899
+ const prepared = await prepareInsertDocuments(ctx, indexName, documents2, 0, documents2.length, hold, true, failed);
22900
+ if (prepared === null) return { admitted: [], embedding: null };
22901
+ const { entry, candidates: candidates2, embedding } = prepared;
22902
+ if (shutDownStarted(ctx)) {
22903
+ failAsShutDown(failed, candidates2, docIdOf);
22904
+ return { admitted: [], embedding };
22905
+ }
22848
22906
  const manager = ctx.requireManager(indexName);
22849
22907
  const vecIndexes = manager.getVectorIndexes();
22850
22908
  const vectorFieldPaths = vecIndexes.size > 0 ? entry.vectorFieldPaths : /* @__PURE__ */ new Set();
@@ -22854,7 +22912,11 @@ async function admitBatchDocuments(ctx, indexName, documents2, failed, hold) {
22854
22912
  const pending = createPendingAdmissions();
22855
22913
  for (let position = 0; position < candidates2.length; position++) {
22856
22914
  if (position > 0 && position % BATCH_CHUNK_SIZE === 0) await new Promise((r) => setTimeout(r, 0));
22857
- if (ctx.abortController.signal.aborted) break;
22915
+ if (shutDownStarted(ctx)) {
22916
+ failAsShutDown(failed, admitted, docIdOf);
22917
+ failAsShutDown(failed, candidates2, docIdOf, position);
22918
+ return { admitted: [], embedding };
22919
+ }
22858
22920
  const { docId, document } = candidates2[position];
22859
22921
  try {
22860
22922
  const { partitionDoc, extractedVectors } = prepareDocumentVectors(
@@ -22876,7 +22938,7 @@ async function admitBatchDocuments(ctx, indexName, documents2, failed, hold) {
22876
22938
  recordPendingAdmission(ctx, pending, manager, docId);
22877
22939
  admitted.push({ docId, document, partitionDoc, extractedVectors });
22878
22940
  } catch (err) {
22879
- failed.push({ docId, error: asBatchInsertError(err) });
22941
+ failed.push({ docId, error: asBatchInsertError(ctx, err) });
22880
22942
  }
22881
22943
  }
22882
22944
  return { admitted, embedding };
@@ -23026,9 +23088,9 @@ async function recordChunk(ctx, indexName, mutations, applies) {
23026
23088
  function applyInsertDocument(ctx, indexName, doc, options, progress) {
23027
23089
  const manager = ctx.requireManager(indexName);
23028
23090
  const insertIntoIndex = () => {
23029
- if (ctx.abortController.signal.aborted) {
23091
+ if (shutDownStarted(ctx)) {
23030
23092
  progress.skipped = true;
23031
- throw ctx.abortController.signal.reason;
23093
+ throw shutDownError();
23032
23094
  }
23033
23095
  admitInsert(ctx, indexName, manager, doc.docId);
23034
23096
  const queued = ctx.bufferIfRebalancing(indexName, {
@@ -23084,11 +23146,11 @@ async function applyInsertChunk(ctx, indexName, docs, options) {
23084
23146
  const progress = docs.map(() => ({ inserted: false, buffered: false, skipped: false }));
23085
23147
  const applies = docs.map((doc, i) => applyInsertDocument(ctx, indexName, doc, options, progress[i]));
23086
23148
  const failures = await recordChunk(ctx, indexName, docs, applies);
23087
- await ctx.orchestrator.settlePublications(indexName);
23149
+ await unlessShutDown(ctx, () => ctx.orchestrator.settlePublications(indexName));
23088
23150
  const applications = [];
23089
23151
  for (let i = 0; i < docs.length; i++) {
23090
23152
  if (progress[i].skipped) {
23091
- applications.push({ status: "skipped" });
23153
+ applications.push({ status: "failed", error: shutDownError() });
23092
23154
  continue;
23093
23155
  }
23094
23156
  const failure = failures[i];
@@ -23121,27 +23183,33 @@ async function applyInsertChunk(ctx, indexName, docs, options) {
23121
23183
  async function runAfterInsertHooks(ctx, indexName, inserted, hold) {
23122
23184
  if (inserted.length === 0 || !ctx.pluginRegistry.hasHooks("afterInsert")) return false;
23123
23185
  const manager = ctx.executor.getManager(indexName);
23124
- await runOutside(hold, async () => {
23125
- for (const doc of inserted) {
23126
- try {
23127
- await ctx.pluginRegistry.runHook("afterInsert", { indexName, docId: doc.docId, document: doc.document });
23128
- } catch (err) {
23129
- console.warn("afterInsert plugin hook error:", err instanceof Error ? err.message : String(err));
23186
+ await unlessShutDown(
23187
+ ctx,
23188
+ () => runOutside(hold, async () => {
23189
+ for (const doc of inserted) {
23190
+ try {
23191
+ await ctx.pluginRegistry.runHook("afterInsert", { indexName, docId: doc.docId, document: doc.document });
23192
+ } catch (err) {
23193
+ console.warn("afterInsert plugin hook error:", err instanceof Error ? err.message : String(err));
23194
+ }
23130
23195
  }
23131
- }
23132
- });
23133
- return ctx.executor.getManager(indexName) !== manager;
23196
+ })
23197
+ );
23198
+ return shutDownStarted(ctx) || ctx.executor.getManager(indexName) !== manager;
23134
23199
  }
23135
23200
  async function applyAdmittedDocuments(ctx, indexName, admitted, options, hold, failed) {
23136
23201
  const succeeded = [];
23137
23202
  const touchedVectorFields = /* @__PURE__ */ new Set();
23138
23203
  for (let chunkStart = 0; chunkStart < admitted.length; chunkStart += BATCH_CHUNK_SIZE) {
23139
- if (ctx.abortController.signal.aborted) break;
23204
+ if (shutDownStarted(ctx)) {
23205
+ failAsShutDown(failed, admitted, docIdOf, chunkStart);
23206
+ break;
23207
+ }
23140
23208
  const chunk = admitted.slice(chunkStart, chunkStart + BATCH_CHUNK_SIZE);
23141
23209
  try {
23142
23210
  ctx.memoryWriteBlock?.refuseWhileFull(indexName);
23143
23211
  } catch (err) {
23144
- const error = asBatchInsertError(err);
23212
+ const error = asBatchInsertError(ctx, err);
23145
23213
  for (let i = chunkStart; i < admitted.length; i++) failed.push({ docId: admitted[i].docId, error });
23146
23214
  break;
23147
23215
  }
@@ -23150,9 +23218,8 @@ async function applyAdmittedDocuments(ctx, indexName, admitted, options, hold, f
23150
23218
  for (let i = 0; i < chunk.length; i++) {
23151
23219
  const doc = chunk[i];
23152
23220
  const application = applications[i];
23153
- if (application.status === "skipped") continue;
23154
23221
  if (application.status === "failed") {
23155
- failed.push({ docId: doc.docId, error: asBatchInsertError(application.error) });
23222
+ failed.push({ docId: doc.docId, error: asBatchInsertError(ctx, application.error) });
23156
23223
  continue;
23157
23224
  }
23158
23225
  succeeded.push(doc.docId);
@@ -23167,7 +23234,7 @@ async function applyAdmittedDocuments(ctx, indexName, admitted, options, hold, f
23167
23234
  return { succeeded, touchedVectorFields, unrecorded: admitted.slice(applied) };
23168
23235
  }
23169
23236
  if (applied < admitted.length) {
23170
- ctx.checkHeapPressure(indexName);
23237
+ if (!shutDownStarted(ctx)) ctx.checkHeapPressure(indexName);
23171
23238
  await new Promise((r) => setTimeout(r, 0));
23172
23239
  }
23173
23240
  }
@@ -23176,7 +23243,7 @@ async function applyAdmittedDocuments(ctx, indexName, admitted, options, hold, f
23176
23243
 
23177
23244
  // src/engine/mutations/insert-batch-chunks.ts
23178
23245
  async function admitChunk(ctx, indexName, documents2, chunkStart, chunkEnd, hold, hooked, failed, earlier) {
23179
- const { entry, candidates: candidates2 } = await prepareInsertDocuments(
23246
+ const prepared = await prepareInsertDocuments(
23180
23247
  ctx,
23181
23248
  indexName,
23182
23249
  documents2,
@@ -23187,13 +23254,24 @@ async function admitChunk(ctx, indexName, documents2, chunkStart, chunkEnd, hold
23187
23254
  failed,
23188
23255
  earlier
23189
23256
  );
23257
+ if (prepared === null) return [];
23258
+ const { entry, candidates: candidates2 } = prepared;
23259
+ const admitted = [];
23260
+ if (shutDownStarted(ctx)) {
23261
+ failAsShutDown(failed, candidates2, docIdOf);
23262
+ return admitted;
23263
+ }
23190
23264
  const manager = ctx.requireManager(indexName);
23191
23265
  const vecIndexes = manager.getVectorIndexes();
23192
23266
  const vectorFieldPaths = vecIndexes.size > 0 ? entry.vectorFieldPaths : /* @__PURE__ */ new Set();
23193
- const admitted = [];
23194
- for (const { docId, document } of candidates2) {
23267
+ for (let position = 0; position < candidates2.length; position++) {
23195
23268
  if (turnsAreBudgeted && turnIsSpent()) await yieldTurn();
23196
- if (ctx.abortController.signal.aborted) break;
23269
+ if (shutDownStarted(ctx)) {
23270
+ failAsShutDown(failed, admitted, docIdOf);
23271
+ failAsShutDown(failed, candidates2, docIdOf, position);
23272
+ return [];
23273
+ }
23274
+ const { docId, document } = candidates2[position];
23197
23275
  try {
23198
23276
  const { partitionDoc, extractedVectors } = prepareDocumentVectors(
23199
23277
  document,
@@ -23205,7 +23283,7 @@ async function admitChunk(ctx, indexName, documents2, chunkStart, chunkEnd, hold
23205
23283
  admitInsert(ctx, indexName, manager, docId);
23206
23284
  admitted.push({ docId, document, partitionDoc, extractedVectors });
23207
23285
  } catch (err) {
23208
- failed.push({ docId, error: asBatchInsertError(err) });
23286
+ failed.push({ docId, error: asBatchInsertError(ctx, err) });
23209
23287
  }
23210
23288
  }
23211
23289
  return admitted;
@@ -23214,17 +23292,25 @@ async function insertInChunks(ctx, indexName, documents2, options, hold, hooked,
23214
23292
  const succeeded = [];
23215
23293
  const touchedVectorFields = /* @__PURE__ */ new Set();
23216
23294
  for (let chunkStart = 0; chunkStart < documents2.length; chunkStart += BATCH_CHUNK_SIZE) {
23217
- if (ctx.abortController.signal.aborted) break;
23295
+ if (shutDownStarted(ctx)) {
23296
+ failAsShutDown(failed, documents2, providedDocIdOrEmpty, chunkStart);
23297
+ break;
23298
+ }
23218
23299
  const chunkEnd = Math.min(chunkStart + BATCH_CHUNK_SIZE, documents2.length);
23219
23300
  const earlier = embeddingOfDocuments(embedded2, documents2.slice(chunkStart, chunkEnd));
23220
23301
  const prepared = await admitChunk(ctx, indexName, documents2, chunkStart, chunkEnd, hold, hooked, failed, earlier);
23302
+ if (shutDownStarted(ctx)) {
23303
+ failAsShutDown(failed, prepared, docIdOf);
23304
+ failAsShutDown(failed, documents2, providedDocIdOrEmpty, chunkEnd);
23305
+ break;
23306
+ }
23221
23307
  try {
23222
23308
  if (prepared.length > 0) ctx.memoryWriteBlock?.refuseWhileFull(indexName);
23223
23309
  } catch (err) {
23224
- const error = asBatchInsertError(err);
23310
+ const error = asBatchInsertError(ctx, err);
23225
23311
  for (const doc of prepared) failed.push({ docId: doc.docId, error });
23226
23312
  for (let i = chunkEnd; i < documents2.length; i++) {
23227
- failed.push({ docId: providedDocId(documents2[i]) ?? "", error });
23313
+ failed.push({ docId: providedDocIdOrEmpty(documents2[i]), error });
23228
23314
  }
23229
23315
  break;
23230
23316
  }
@@ -23234,9 +23320,8 @@ async function insertInChunks(ctx, indexName, documents2, options, hold, hooked,
23234
23320
  for (let i = 0; i < prepared.length; i++) {
23235
23321
  const doc = prepared[i];
23236
23322
  const application = applications[i];
23237
- if (application.status === "skipped") continue;
23238
23323
  if (application.status === "failed") {
23239
- failed.push({ docId: doc.docId, error: asBatchInsertError(application.error) });
23324
+ failed.push({ docId: doc.docId, error: asBatchInsertError(ctx, application.error) });
23240
23325
  continue;
23241
23326
  }
23242
23327
  succeeded.push(doc.docId);
@@ -23247,21 +23332,24 @@ async function insertInChunks(ctx, indexName, documents2, options, hold, hooked,
23247
23332
  await runAfterInsertHooks(ctx, indexName, inserted, hold);
23248
23333
  }
23249
23334
  if (chunkEnd < documents2.length) {
23250
- ctx.checkHeapPressure(indexName);
23335
+ if (!shutDownStarted(ctx)) ctx.checkHeapPressure(indexName);
23251
23336
  await new Promise((r) => setTimeout(r, 0));
23252
23337
  }
23253
23338
  }
23254
23339
  return { succeeded, touchedVectorFields };
23255
23340
  }
23256
23341
  async function finishInsertBatch(ctx, indexName, inserts, options) {
23342
+ if (shutDownStarted(ctx)) return;
23257
23343
  const vecIndexes = ctx.executor.getManager(indexName)?.getVectorIndexes();
23258
23344
  for (const fieldPath of inserts.touchedVectorFields) {
23259
23345
  vecIndexes?.get(fieldPath)?.scheduleBuild();
23260
23346
  }
23261
23347
  ctx.checkWatermark(indexName, inserts.succeeded);
23262
23348
  ctx.checkHeapPressure(indexName);
23263
- await ctx.orchestrator.scaleOutReadyIndexes();
23264
- if (options?.wait === true) await awaitWriteVisibility(ctx, indexName);
23349
+ await unlessShutDown(ctx, async () => {
23350
+ await ctx.orchestrator.scaleOutReadyIndexes();
23351
+ if (options?.wait === true && !shutDownStarted(ctx)) await awaitWriteVisibility(ctx, indexName);
23352
+ });
23265
23353
  }
23266
23354
 
23267
23355
  // src/engine/mutations/segment-publication.ts
@@ -23270,7 +23358,7 @@ function applySegment(ctx, indexName, attachment, doc, options) {
23270
23358
  const publish2 = async () => {
23271
23359
  if (attachment.failure !== void 0) throw attachment.failure;
23272
23360
  if (attachment.attached) return;
23273
- if (ctx.abortController.signal.aborted) throw ctx.abortController.signal.reason;
23361
+ if (shutDownStarted(ctx)) throw shutDownError();
23274
23362
  if (ctx.isRebalancing(indexName) || manager.partitionCount !== attachment.partitionCount) {
23275
23363
  attachment.individual = true;
23276
23364
  }
@@ -23424,6 +23512,7 @@ async function recordMergedDocuments(ctx, indexName, partitionCount, built2, fro
23424
23512
  for (let index = 0; index < chunks.length; index++) {
23425
23513
  const { docs, attachmentOf } = chunks[index];
23426
23514
  try {
23515
+ if (shutDownStarted(ctx)) throw shutDownError();
23427
23516
  ctx.memoryWriteBlock?.refuseWhileFull(indexName);
23428
23517
  } catch (error) {
23429
23518
  for (const later of chunks.slice(index)) {
@@ -23437,7 +23526,7 @@ async function recordMergedDocuments(ctx, indexName, partitionCount, built2, fro
23437
23526
  return applySegment(ctx, indexName, attachment, doc, options);
23438
23527
  });
23439
23528
  const failures = await recordChunk(ctx, indexName, docs, applies);
23440
- await ctx.orchestrator.settlePublications(indexName, "segments");
23529
+ await unlessShutDown(ctx, () => ctx.orchestrator.settlePublications(indexName, "segments"));
23441
23530
  const inserted = [];
23442
23531
  for (let i = 0; i < docs.length; i++) {
23443
23532
  const doc = docs[i];
@@ -23478,7 +23567,7 @@ async function recordMergedDocuments(ctx, indexName, partitionCount, built2, fro
23478
23567
  break;
23479
23568
  }
23480
23569
  if (index + 1 < chunks.length) {
23481
- ctx.checkHeapPressure(indexName);
23570
+ if (!shutDownStarted(ctx)) ctx.checkHeapPressure(indexName);
23482
23571
  await new Promise((r) => setTimeout(r, 0));
23483
23572
  }
23484
23573
  }
@@ -23489,7 +23578,7 @@ async function recordMergedDocuments(ctx, indexName, partitionCount, built2, fro
23489
23578
  continue;
23490
23579
  }
23491
23580
  if (!errorOf.has(doc.docId)) continue;
23492
- failed.push({ docId: doc.docId, error: asBatchInsertError(errorOf.get(doc.docId)) });
23581
+ failed.push({ docId: doc.docId, error: asBatchInsertError(ctx, errorOf.get(doc.docId)) });
23493
23582
  }
23494
23583
  return { succeeded, touchedVectorFields, unrecorded };
23495
23584
  }
@@ -23503,8 +23592,11 @@ function frozenSegmentOf(segment, members, options) {
23503
23592
  );
23504
23593
  }
23505
23594
  async function ingestAdmitted(ctx, indexName, admitted, options, hold, failed) {
23506
- if (admitted.length === 0) {
23507
- return { succeeded: [], touchedVectorFields: /* @__PURE__ */ new Set(), unrecorded: [] };
23595
+ const nothingIngested = () => ({ succeeded: [], touchedVectorFields: /* @__PURE__ */ new Set(), unrecorded: [] });
23596
+ if (admitted.length === 0) return nothingIngested();
23597
+ if (shutDownStarted(ctx)) {
23598
+ failAsShutDown(failed, admitted, docIdOf);
23599
+ return nothingIngested();
23508
23600
  }
23509
23601
  const applyIndividually = () => applyAdmittedDocuments(ctx, indexName, admitted, options, hold, failed);
23510
23602
  const manager = ctx.requireManager(indexName);
@@ -23522,6 +23614,10 @@ async function ingestAdmitted(ctx, indexName, admitted, options, hold, failed) {
23522
23614
  } catch {
23523
23615
  built2 = null;
23524
23616
  }
23617
+ if (shutDownStarted(ctx)) {
23618
+ failAsShutDown(failed, admitted, docIdOf);
23619
+ return nothingIngested();
23620
+ }
23525
23621
  if (built2 === null) {
23526
23622
  return applyIndividually();
23527
23623
  }
@@ -23572,7 +23668,9 @@ async function insertBatchViaSegments(ctx, indexName, documents2, options, hold)
23572
23668
  const failed = [];
23573
23669
  const { admitted, embedding } = await admitBatchDocuments(ctx, indexName, documents2, failed, hold);
23574
23670
  const outcome = await ingestAdmitted(ctx, indexName, admitted, options, hold, failed);
23575
- if (outcome.unrecorded.length > 0) {
23671
+ if (shutDownStarted(ctx)) {
23672
+ failAsShutDown(failed, outcome.unrecorded, docIdOf);
23673
+ } else if (outcome.unrecorded.length > 0) {
23576
23674
  const unrecorded = outcome.unrecorded.map((doc) => doc.document);
23577
23675
  const rest = await insertInChunks(ctx, indexName, unrecorded, options, hold, false, failed, embedding);
23578
23676
  outcome.succeeded.push(...rest.succeeded);
@@ -23587,20 +23685,24 @@ async function insertDocumentBatch(ctx, indexName, documents2, options, hold) {
23587
23685
  ctx.guardShutdown();
23588
23686
  ctx.requireIndex(indexName);
23589
23687
  validateBatchList(documents2, "documents");
23590
- await ctx.orchestrator.scaleOutBeforeBatch(indexName, documents2.length);
23688
+ const failed = [];
23689
+ await unlessShutDown(ctx, () => ctx.orchestrator.scaleOutBeforeBatch(indexName, documents2.length));
23690
+ if (shutDownStarted(ctx)) {
23691
+ failAsShutDown(failed, documents2, providedDocIdOrEmpty);
23692
+ return { succeeded: [], failed };
23693
+ }
23591
23694
  const copiesBuildSegments = ctx.orchestrator.segmentBuildConcurrency(indexName) > 0;
23592
23695
  if (documents2.length >= MIN_DOCUMENTS_FOR_SEGMENTS && !ctx.isRebalancing(indexName) && copiesBuildSegments) {
23593
23696
  return insertBatchViaSegments(ctx, indexName, documents2, options, hold);
23594
23697
  }
23595
- const failed = [];
23596
23698
  const inserts = await insertInChunks(ctx, indexName, documents2, options, hold, true, failed);
23597
23699
  await finishInsertBatch(ctx, indexName, inserts, options);
23598
23700
  return { succeeded: inserts.succeeded, failed };
23599
23701
  }
23600
23702
 
23601
23703
  // src/engine/mutations/remove.ts
23602
- function asRemoveError(err) {
23603
- return err instanceof NarsilError ? err : new NarsilError(ErrorCodes.DOC_NOT_FOUND, String(err));
23704
+ function asRemoveError(ctx, err) {
23705
+ return batchFailureOf(ctx, err, ErrorCodes.DOC_NOT_FOUND);
23604
23706
  }
23605
23707
  function validateRemoval(ctx, docId) {
23606
23708
  ctx.guardShutdown();
@@ -23708,18 +23810,31 @@ async function refusedRemovalsOf(ctx, indexName, docIds, chunkStart, chunkEnd, h
23708
23810
  }
23709
23811
  }
23710
23812
  if (!ctx.pluginRegistry.hasHooks("beforeRemove")) return refused;
23711
- await runOutside(hold, async () => {
23712
- for (let i = chunkStart; i < chunkEnd; i++) {
23713
- if (refused.has(i)) continue;
23714
- try {
23715
- await ctx.pluginRegistry.runHook("beforeRemove", { indexName, docId: docIds[i] });
23716
- } catch (err) {
23717
- refused.set(i, err);
23813
+ await unlessShutDown(
23814
+ ctx,
23815
+ () => runOutside(hold, async () => {
23816
+ for (let i = chunkStart; i < chunkEnd; i++) {
23817
+ if (refused.has(i)) continue;
23818
+ try {
23819
+ await ctx.pluginRegistry.runHook("beforeRemove", { indexName, docId: docIds[i] });
23820
+ } catch (err) {
23821
+ refused.set(i, err);
23822
+ }
23718
23823
  }
23719
- }
23720
- });
23824
+ })
23825
+ );
23721
23826
  return refused;
23722
23827
  }
23828
+ function failChunkAsShutDown(ctx, failed, docIds, chunkStart, chunkEnd, refused) {
23829
+ const error = shutDownError();
23830
+ for (let i = chunkStart; i < chunkEnd; i++) {
23831
+ failed.push({ docId: docIds[i], error: refused.has(i) ? asRemoveError(ctx, refused.get(i)) : error });
23832
+ }
23833
+ failAsShutDown(failed, docIds, removalDocIdOf, chunkEnd);
23834
+ }
23835
+ function removalDocIdOf(docId) {
23836
+ return docId;
23837
+ }
23723
23838
  async function removeDocumentBatch(ctx, indexName, docIds, options, hold) {
23724
23839
  ctx.guardShutdown();
23725
23840
  ctx.requireIndex(indexName);
@@ -23731,8 +23846,16 @@ async function removeDocumentBatch(ctx, indexName, docIds, options, hold) {
23731
23846
  let manager = first;
23732
23847
  try {
23733
23848
  for (let chunkStart = 0; chunkStart < docIds.length; chunkStart += BATCH_CHUNK_SIZE) {
23849
+ if (shutDownStarted(ctx)) {
23850
+ failAsShutDown(failed, docIds, removalDocIdOf, chunkStart);
23851
+ break;
23852
+ }
23734
23853
  const chunkEnd = Math.min(chunkStart + BATCH_CHUNK_SIZE, docIds.length);
23735
23854
  const refused = await refusedRemovalsOf(ctx, indexName, docIds, chunkStart, chunkEnd, hold);
23855
+ if (shutDownStarted(ctx)) {
23856
+ failChunkAsShutDown(ctx, failed, docIds, chunkStart, chunkEnd, refused);
23857
+ break;
23858
+ }
23736
23859
  manager = await batchManagerAfterHooks(ctx, indexName, manager);
23737
23860
  const removed = [];
23738
23861
  const prepared = [];
@@ -23742,10 +23865,15 @@ async function removeDocumentBatch(ctx, indexName, docIds, options, hold) {
23742
23865
  if (refused.has(i)) throw refused.get(i);
23743
23866
  prepared.push(prepareRemoval(ctx, indexName, docIds[i]));
23744
23867
  } catch (err) {
23745
- failed.push({ docId: docIds[i], error: asRemoveError(err) });
23868
+ failed.push({ docId: docIds[i], error: asRemoveError(ctx, err) });
23746
23869
  }
23747
23870
  }
23748
- const applies = prepared.map((removal) => applyOfRemoval(ctx, indexName, removal));
23871
+ if (shutDownStarted(ctx)) {
23872
+ failAsShutDown(failed, prepared, docIdOf);
23873
+ failAsShutDown(failed, docIds, removalDocIdOf, chunkEnd);
23874
+ break;
23875
+ }
23876
+ const applies = prepared.map((removal) => applyUnlessShutDown(ctx, applyOfRemoval(ctx, indexName, removal)));
23749
23877
  try {
23750
23878
  const failures = await recordChunk(ctx, indexName, prepared, applies);
23751
23879
  for (let i = 0; i < prepared.length; i++) {
@@ -23766,7 +23894,7 @@ async function removeDocumentBatch(ctx, indexName, docIds, options, hold) {
23766
23894
  error = rollbackError;
23767
23895
  }
23768
23896
  removal.releaseVectorHolds?.();
23769
- failed.push({ docId: removal.docId, error: asRemoveError(error) });
23897
+ failed.push({ docId: removal.docId, error: asRemoveError(ctx, error) });
23770
23898
  continue;
23771
23899
  }
23772
23900
  removal.releaseVectorHolds?.();
@@ -23776,18 +23904,19 @@ async function removeDocumentBatch(ctx, indexName, docIds, options, hold) {
23776
23904
  } finally {
23777
23905
  for (const removal of prepared) removal.releaseVectorHolds?.();
23778
23906
  }
23779
- await settleRemovals(ctx, indexName, removed, hold);
23780
- manager = await batchManagerAfterHooks(ctx, indexName, manager);
23907
+ await unlessShutDown(ctx, () => settleRemovals(ctx, indexName, removed, hold));
23908
+ if (!shutDownStarted(ctx)) manager = await batchManagerAfterHooks(ctx, indexName, manager);
23781
23909
  if (chunkEnd < docIds.length) {
23782
23910
  await new Promise((r) => setTimeout(r, 0));
23783
23911
  }
23784
23912
  }
23785
23913
  } finally {
23786
23914
  const ending = manager;
23787
- await ending?.publication.write(() => ending.endBatchRemove());
23915
+ await unlessShutDown(ctx, () => ending?.publication.write(() => ending.endBatchRemove()));
23788
23916
  }
23917
+ if (shutDownStarted(ctx)) return { succeeded, failed };
23789
23918
  ctx.checkHeapPressure(indexName);
23790
- if (options?.wait === true) await awaitWriteVisibility(ctx, indexName);
23919
+ if (options?.wait === true) await unlessShutDown(ctx, () => awaitWriteVisibility(ctx, indexName));
23791
23920
  return { succeeded, failed };
23792
23921
  }
23793
23922
  async function batchManagerAfterHooks(ctx, indexName, batchManager) {
@@ -23827,8 +23956,8 @@ function prepareUpdatePartitionDoc(document, extractedVectors) {
23827
23956
  }
23828
23957
  return { partitionDoc };
23829
23958
  }
23830
- function asUpdateError(err) {
23831
- return err instanceof NarsilError ? err : new NarsilError(ErrorCodes.DOC_NOT_FOUND, String(err));
23959
+ function asUpdateError(ctx, err) {
23960
+ return batchFailureOf(ctx, err, ErrorCodes.DOC_NOT_FOUND);
23832
23961
  }
23833
23962
  async function runAfterUpdateHooks(ctx, indexName, updates) {
23834
23963
  for (const update of updates) {
@@ -24025,24 +24154,39 @@ async function prepareChunk(ctx, indexName, updates, chunkStart, chunkEnd, hold,
24025
24154
  const { document } = requireUpdateEntry(update);
24026
24155
  preparations.push({ docId, preparation: updatePreparationOf(ctx, indexName, docId, document) });
24027
24156
  } catch (err) {
24028
- failed.push({ docId, error: asUpdateError(err) });
24157
+ failed.push({ docId, error: asUpdateError(ctx, err) });
24029
24158
  }
24030
24159
  }
24031
- const { entry } = await prepareDocumentWrites(
24032
- ctx,
24033
- indexName,
24034
- preparations.map((pending) => pending.preparation),
24035
- hold,
24036
- false
24037
- );
24160
+ let entry;
24161
+ try {
24162
+ if (shutDownStarted(ctx)) throw shutDownError();
24163
+ const writes = await prepareDocumentWrites(
24164
+ ctx,
24165
+ indexName,
24166
+ preparations.map((pending) => pending.preparation),
24167
+ hold,
24168
+ false
24169
+ );
24170
+ entry = writes.entry;
24171
+ } catch (err) {
24172
+ if (!causedByShutdown(ctx, err)) throw err;
24173
+ failAsShutDown(failed, preparations, docIdOf);
24174
+ return [];
24175
+ }
24038
24176
  const prepared = [];
24039
- for (const { docId, preparation } of preparations) {
24177
+ for (let position = 0; position < preparations.length; position++) {
24040
24178
  if (turnsAreBudgeted && turnIsSpent()) await yieldTurn();
24179
+ if (shutDownStarted(ctx)) {
24180
+ failAsShutDown(failed, prepared, docIdOf);
24181
+ failAsShutDown(failed, preparations, docIdOf, position);
24182
+ return [];
24183
+ }
24184
+ const { docId, preparation } = preparations[position];
24041
24185
  try {
24042
24186
  if (preparation.failure !== void 0) throw preparation.failure;
24043
24187
  prepared.push(await finishUpdate(ctx, indexName, entry, docId, preparation.document));
24044
24188
  } catch (err) {
24045
- failed.push({ docId, error: asUpdateError(err) });
24189
+ failed.push({ docId, error: asUpdateError(ctx, err) });
24046
24190
  }
24047
24191
  }
24048
24192
  return prepared;
@@ -24055,17 +24199,26 @@ async function updateDocumentBatch(ctx, indexName, updates, options, hold) {
24055
24199
  const failed = [];
24056
24200
  const touchedVectorFields = /* @__PURE__ */ new Set();
24057
24201
  for (let chunkStart = 0; chunkStart < updates.length; chunkStart += BATCH_CHUNK_SIZE) {
24202
+ if (shutDownStarted(ctx)) {
24203
+ failAsShutDown(failed, updates, reportedDocIdOf, chunkStart);
24204
+ break;
24205
+ }
24058
24206
  const chunkEnd = Math.min(chunkStart + BATCH_CHUNK_SIZE, updates.length);
24059
24207
  const prepared = await prepareChunk(ctx, indexName, updates, chunkStart, chunkEnd, hold, failed);
24208
+ if (shutDownStarted(ctx)) {
24209
+ failAsShutDown(failed, prepared, docIdOf);
24210
+ failAsShutDown(failed, updates, reportedDocIdOf, chunkEnd);
24211
+ break;
24212
+ }
24060
24213
  try {
24061
24214
  ctx.memoryWriteBlock?.refuseWhileFull(indexName);
24062
24215
  } catch (err) {
24063
- const error = asUpdateError(err);
24216
+ const error = asUpdateError(ctx, err);
24064
24217
  for (const update of prepared) failed.push({ docId: update.docId, error });
24065
24218
  for (let i = chunkEnd; i < updates.length; i++) failed.push({ docId: reportedDocIdOf(updates[i]), error });
24066
24219
  break;
24067
24220
  }
24068
- const applies = prepared.map((update) => applyOfUpdate(ctx, indexName, update));
24221
+ const applies = prepared.map((update) => applyUnlessShutDown(ctx, applyOfUpdate(ctx, indexName, update)));
24069
24222
  let failures;
24070
24223
  try {
24071
24224
  failures = await recordChunk(ctx, indexName, prepared, applies);
@@ -24096,7 +24249,7 @@ async function updateDocumentBatch(ctx, indexName, updates, options, hold) {
24096
24249
  const update = prepared[i];
24097
24250
  const failure = failures[i];
24098
24251
  if (failure !== null) {
24099
- failed.push({ docId: update.docId, error: asUpdateError(failure.error) });
24252
+ failed.push({ docId: update.docId, error: asUpdateError(ctx, failure.error) });
24100
24253
  continue;
24101
24254
  }
24102
24255
  if (!update.buffered) settled.push(update);
@@ -24105,18 +24258,19 @@ async function updateDocumentBatch(ctx, indexName, updates, options, hold) {
24105
24258
  }
24106
24259
  succeeded.push(update.docId);
24107
24260
  }
24108
- await settleUpdates(ctx, indexName, settled, hold);
24261
+ await unlessShutDown(ctx, () => settleUpdates(ctx, indexName, settled, hold));
24109
24262
  if (chunkEnd < updates.length) {
24110
- ctx.checkHeapPressure(indexName);
24263
+ if (!shutDownStarted(ctx)) ctx.checkHeapPressure(indexName);
24111
24264
  await new Promise((r) => setTimeout(r, 0));
24112
24265
  }
24113
24266
  }
24267
+ if (shutDownStarted(ctx)) return { succeeded, failed };
24114
24268
  const vectorIndexes = ctx.executor.getManager(indexName)?.getVectorIndexes();
24115
24269
  for (const fieldPath of touchedVectorFields) {
24116
24270
  vectorIndexes?.get(fieldPath)?.scheduleBuild();
24117
24271
  }
24118
24272
  ctx.checkHeapPressure(indexName);
24119
- if (options?.wait === true) await awaitWriteVisibility(ctx, indexName);
24273
+ if (options?.wait === true) await unlessShutDown(ctx, () => awaitWriteVisibility(ctx, indexName));
24120
24274
  return { succeeded, failed };
24121
24275
  }
24122
24276
 
@@ -24162,12 +24316,17 @@ async function withReservation(grouping, indexName, document, write) {
24162
24316
  reservation.release();
24163
24317
  }
24164
24318
  }
24165
- async function writeInGroups(grouping, indexName, items, write) {
24319
+ async function writeInGroups(ctx, grouping, indexName, items, write) {
24166
24320
  const succeeded = [];
24167
24321
  const failed = [];
24168
24322
  await grouping.applyInGroups(indexName, {
24169
24323
  items,
24170
24324
  failed,
24325
+ refuseFrom: (start) => {
24326
+ if (!shutDownStarted(ctx)) return false;
24327
+ failAsShutDown(failed, items, docIdOf, start);
24328
+ return true;
24329
+ },
24171
24330
  apply: async (group) => {
24172
24331
  const result = await write(group);
24173
24332
  for (const docId of result.succeeded) succeeded.push(docId);
@@ -24205,6 +24364,7 @@ async function insertDocumentBatch2(ctx, indexName, documents2, options, hold) {
24205
24364
  }
24206
24365
  const items = documents2.map((document) => ({ docId: providedDocId(document) ?? "", document }));
24207
24366
  return writeInGroups(
24367
+ ctx,
24208
24368
  grouping,
24209
24369
  indexName,
24210
24370
  items,
@@ -24237,6 +24397,7 @@ async function updateDocumentBatch2(ctx, indexName, updates, options, hold) {
24237
24397
  }
24238
24398
  noteGroupedChurn(ctx, indexName, updates.length);
24239
24399
  return writeInGroups(
24400
+ ctx,
24240
24401
  grouping,
24241
24402
  indexName,
24242
24403
  updates.map(updateItemOf),
@@ -25055,7 +25216,7 @@ function createAnalysisRebuildCoordinator(config, deps) {
25055
25216
 
25056
25217
  // src/engine/durability-config-code.ts
25057
25218
  var durabilityConfig = codeLoader(
25058
- () => import('./durability-config-VWS2K24E.mjs').then((code7) => {
25219
+ () => import('./durability-config-HWKWP35M.mjs').then((code7) => {
25059
25220
  code7.bindDurabilityConfigHost(optionalCodeHost());
25060
25221
  return code7;
25061
25222
  }),
@@ -25628,7 +25789,7 @@ var workerCopies = codeLoader(async () => {
25628
25789
  const [segmentCodec2, segmentMerge2, code7] = await Promise.all([
25629
25790
  loadSegmentCodec(),
25630
25791
  loadSegmentMerge(),
25631
- import('./worker-copies-32HWFUH7.mjs')
25792
+ import('./worker-copies-IP4L7KEW.mjs')
25632
25793
  ]);
25633
25794
  code7.bindWorkerCopiesHost(optionalCodeHost(), segmentCodec2, segmentMerge2);
25634
25795
  return code7;
@@ -25753,7 +25914,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
25753
25914
  throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Index lifecycle settings require durability");
25754
25915
  }
25755
25916
  const durabilityWiring = durabilityTier === null ? null : (await Promise.all([loadStorageCode(), loadOptionalWrites()]))[0];
25756
- const filesystemDurability = durabilityTier?.kind === "wal";
25917
+ const filesystemDurability = durabilityTier?.kind === "wal" && durabilityTier.indexedDB === void 0;
25757
25918
  const executor = createDirectExecutor({
25758
25919
  vectorWorkerCopies: vectorCopyPolicy,
25759
25920
  vectorStorage: filesystemDurability ? "disk" : "memory",
@@ -26029,8 +26190,13 @@ async function shutdownEngine(core2) {
26029
26190
  await core2.analysisRebuild.shutdown();
26030
26191
  await core2.querySuggestionHooks?.shutdown();
26031
26192
  core2.indexState.dispose();
26193
+ let durabilityFailure = null;
26032
26194
  if (durability) {
26033
- await durability.manager.shutdown();
26195
+ try {
26196
+ await durability.manager.shutdown();
26197
+ } catch (error) {
26198
+ durabilityFailure = { error };
26199
+ }
26034
26200
  }
26035
26201
  const vectorDisposals = [];
26036
26202
  for (const [name] of indexRegistry) {
@@ -26064,6 +26230,7 @@ async function shutdownEngine(core2) {
26064
26230
  await Promise.all(vectorDisposals);
26065
26231
  eventHandlers.clear();
26066
26232
  indexRegistry.clear();
26233
+ if (durabilityFailure !== null) throw durabilityFailure.error;
26067
26234
  }
26068
26235
 
26069
26236
  // src/core/keyword-score/layout.ts
@@ -30126,7 +30293,7 @@ var suggestionsCode = codeLoader(async () => {
30126
30293
  const [msgpack, suggestionStore2, code7] = await Promise.all([
30127
30294
  loadMessagePack(),
30128
30295
  loadSuggestionStore(),
30129
- import('./suggestions-leaf-MUZNKQVF.mjs')
30296
+ import('./suggestions-leaf-5UFJV7SC.mjs')
30130
30297
  ]);
30131
30298
  code7.bindSuggestionsHost(optionalCodeHost(), msgpack, suggestionStore2);
30132
30299
  return code7;
@@ -31287,7 +31454,7 @@ var segmentMerge = codeLoader(async () => {
31287
31454
  const [msgpack, codec, code7] = await Promise.all([
31288
31455
  loadMessagePack(),
31289
31456
  loadSegmentCodec(),
31290
- import('./segment-merge-leaf-BS3QV5PZ.mjs')
31457
+ import('./segment-merge-leaf-FYWJQSPL.mjs')
31291
31458
  ]);
31292
31459
  code7.bindSegmentMergeHost(optionalCodeHost(), msgpack, codec);
31293
31460
  return code7;