@delali/narsil 0.3.1-next.128 → 0.3.1-next.130

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 (108) hide show
  1. package/dist/adapters/filesystem.mjs +1 -1
  2. package/dist/adapters/indexeddb.mjs +1 -1
  3. package/dist/browser/chunk-26A5JFT2.mjs +89 -0
  4. package/dist/browser/{chunk-4Y2EGA3U.mjs → chunk-2Y3CO4EQ.mjs} +878 -310
  5. package/dist/browser/{chunk-2CBQ2PCC.mjs → chunk-AIIJDWMG.mjs} +1 -1
  6. package/dist/browser/{chunk-P7C2S5JX.mjs → chunk-D7WQF6DV.mjs} +2 -2
  7. package/dist/browser/{chunk-V5DCQIOT.mjs → chunk-M5UAAXGU.mjs} +2 -2
  8. package/dist/browser/{chunk-B65QVTST.mjs → chunk-NSCSR6MA.mjs} +24 -9
  9. package/dist/browser/{chunk-LJS6PREA.mjs → chunk-UDGB2MWT.mjs} +7 -28
  10. package/dist/browser/{chunk-6POI2KNI.mjs → chunk-VBBLTD7O.mjs} +4 -3
  11. package/dist/browser/chunk-VEGHFP2P.mjs +30 -0
  12. package/dist/browser/{durability-wiring-PUC4QSCR.mjs → durability-wiring-FNZSRH4N.mjs} +8 -6
  13. package/dist/browser/{module-ACWDC7YI.mjs → module-4HIMOQM5.mjs} +6 -5
  14. package/dist/browser/phrase-module-WESYVU7K.mjs +327 -0
  15. package/dist/browser/{restore-queue-MLUEUEAN.mjs → restore-queue-GEZ54CA5.mjs} +1 -1
  16. package/dist/browser/{runtime-BX6XRFYR.mjs → runtime-3X7ZJ5T3.mjs} +2 -1
  17. package/dist/browser/{snapshot-U5Y346XG.mjs → snapshot-V7VF6BN6.mjs} +25 -10
  18. package/dist/browser/{write-GZHR6AVG.mjs → write-YIC2MKRY.mjs} +7 -5
  19. package/dist/{capabilities-9YwwCcqP.d.ts → capabilities-Bl8G9taj.d.ts} +10 -3
  20. package/dist/{chunk-VK45J47R.mjs → chunk-2C3WXBQS.mjs} +1 -1
  21. package/dist/{chunk-QSCVJJW5.mjs → chunk-2JWNJSNE.mjs} +8 -8
  22. package/dist/{chunk-IBGMFR5Y.mjs → chunk-2MKX2SCO.mjs} +481 -121
  23. package/dist/{chunk-P34VZEXB.mjs → chunk-2SEL6SBS.mjs} +4 -95
  24. package/dist/{chunk-7ZZQNOIY.mjs → chunk-2WBY4Y4M.mjs} +1 -1
  25. package/dist/{chunk-HFJXEFFV.mjs → chunk-4GDLFDPZ.mjs} +3 -3
  26. package/dist/chunk-4UMZ7KQL.mjs +17 -0
  27. package/dist/{chunk-ZR63OGT2.mjs → chunk-5LX6MOIB.mjs} +2 -2
  28. package/dist/{chunk-UKXMSO5H.mjs → chunk-6M6SDH3S.mjs} +189 -45
  29. package/dist/{chunk-IR4KQ4WB.mjs → chunk-6SSVIW7Y.mjs} +49 -31
  30. package/dist/{chunk-4IHMMDRF.mjs → chunk-7OIQ2SIO.mjs} +4 -4
  31. package/dist/{chunk-6ODIY6ZB.mjs → chunk-7XY6VD7B.mjs} +1 -1
  32. package/dist/{chunk-OBWUWZRA.mjs → chunk-CZ7ISLXA.mjs} +3 -0
  33. package/dist/{chunk-OFYKBKKV.mjs → chunk-D5TFRB5G.mjs} +3 -15
  34. package/dist/{chunk-KCQG2PJT.mjs → chunk-EUCX5K74.mjs} +4 -4
  35. package/dist/{chunk-HWQDZB2U.mjs → chunk-F6AAXI7T.mjs} +3 -3
  36. package/dist/{chunk-E74YLAIG.mjs → chunk-FQBFZAWG.mjs} +4 -1
  37. package/dist/{chunk-U6NGTWI3.mjs → chunk-HCGJKDZV.mjs} +1 -1
  38. package/dist/{chunk-SJEIIR56.mjs → chunk-JJ6EUMXB.mjs} +2 -2
  39. package/dist/{chunk-N57XXGPG.mjs → chunk-JT3YZGCE.mjs} +23 -4
  40. package/dist/chunk-JUKYYXSP.mjs +93 -0
  41. package/dist/{chunk-JIXO442E.mjs → chunk-K77FJXKS.mjs} +26 -10
  42. package/dist/{chunk-4PQNDHSA.mjs → chunk-NMXRXFGZ.mjs} +2 -2
  43. package/dist/{chunk-6PN3U6XW.mjs → chunk-NNO7CO3A.mjs} +1 -1
  44. package/dist/{chunk-542TD4BL.mjs → chunk-PATMDIMN.mjs} +1 -1
  45. package/dist/{chunk-DG62H7OD.mjs → chunk-PU6SKH7O.mjs} +2 -2
  46. package/dist/chunk-Q2AP2FSN.mjs +15 -0
  47. package/dist/{chunk-22CK2LQO.mjs → chunk-QQTXT65X.mjs} +6 -5
  48. package/dist/{chunk-LXWDQLTW.mjs → chunk-RNSC4NFI.mjs} +1 -1
  49. package/dist/{chunk-JEXJDCQH.mjs → chunk-RWESFSJI.mjs} +28 -13
  50. package/dist/{chunk-SEG4CL6W.mjs → chunk-SOHMMNCH.mjs} +4 -4
  51. package/dist/{chunk-OGFSUXYY.mjs → chunk-SZGRYEIC.mjs} +4 -4
  52. package/dist/{chunk-LOBYK2FG.mjs → chunk-T4OFG4IQ.mjs} +20 -9
  53. package/dist/{chunk-ENBN5VQ6.mjs → chunk-TGHNXN7W.mjs} +150 -52
  54. package/dist/{chunk-Z4DZ4KK2.mjs → chunk-UJWGQIXU.mjs} +1 -0
  55. package/dist/{chunk-ANFNYCQG.mjs → chunk-WVRDRLIC.mjs} +6 -6
  56. package/dist/{chunk-62IPM62F.mjs → chunk-X5CNUKD5.mjs} +2 -2
  57. package/dist/{chunk-IE43SRL3.mjs → chunk-XABMCBHA.mjs} +12 -6
  58. package/dist/{chunk-OCB7TMUQ.mjs → chunk-Y2U5VVWX.mjs} +1 -1
  59. package/dist/{chunk-MFPJVITN.mjs → chunk-Y4BVTQ53.mjs} +2 -2
  60. package/dist/{chunk-N6J6EJW3.mjs → chunk-YBWSV5DV.mjs} +2 -2
  61. package/dist/{chunk-FUUP45IS.mjs → chunk-ZR4VM4A6.mjs} +1 -1
  62. package/dist/{client-CsuhZ13c.d.ts → client-Cx-TiqPE.d.ts} +19 -3
  63. package/dist/client.d.ts +8 -8
  64. package/dist/client.mjs +10 -2
  65. package/dist/{config-CtTfxbpV.d.ts → config-CzB9YvF_.d.ts} +2 -2
  66. package/dist/{config-DLVnlByZ.d.ts → config-hOWGBeC6.d.ts} +7 -5
  67. package/dist/direct-executor-HQ4QVDX7.mjs +28 -0
  68. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  69. package/dist/distribution/coordinator/etcd.mjs +18 -1
  70. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  71. package/dist/distribution/coordinator/in-memory.mjs +33 -1
  72. package/dist/distribution/transport/grpc.mjs +1 -1
  73. package/dist/distribution.d.ts +71 -43
  74. package/dist/distribution.mjs +411 -127
  75. package/dist/{durability-wiring-UGGUNATA.mjs → durability-wiring-S7OX2MAI.mjs} +28 -26
  76. package/dist/embeddings/openai.mjs +2 -2
  77. package/dist/{engine-Bq5wz6c1.d.ts → engine-B_W9sdZK.d.ts} +38 -8
  78. package/dist/{events-x2aVu0_o.d.ts → events-DErop1LM.d.ts} +23 -2
  79. package/dist/{index-Cl5qQauj.d.ts → index-CKI1fDEl.d.ts} +37 -3
  80. package/dist/index.browser.mjs +5 -3
  81. package/dist/index.d.ts +7 -7
  82. package/dist/index.mjs +21 -19
  83. package/dist/{long-query-thread-5BIPZVS6.mjs → long-query-thread-WVSMIBYP.mjs} +17 -15
  84. package/dist/{module-7OHZ2OPI.mjs → module-2E4XYSGT.mjs} +11 -11
  85. package/dist/partial-words.mjs +7 -6
  86. package/dist/pattern.mjs +4 -3
  87. package/dist/persistence/durability/checkpoint-worker.d.ts +3 -1
  88. package/dist/persistence/durability/checkpoint-worker.mjs +24 -22
  89. package/dist/phrase-module-JERF2IDG.mjs +329 -0
  90. package/dist/react.d.ts +7 -7
  91. package/dist/react.mjs +3 -0
  92. package/dist/{rerank-NYX5S7OG.mjs → rerank-DMMT4FZA.mjs} +6 -6
  93. package/dist/rerankers/http.mjs +2 -2
  94. package/dist/{restore-queue-NVMWJMHI.mjs → restore-queue-JAMNRC6T.mjs} +1 -1
  95. package/dist/{runtime-XNYW6AWX.mjs → runtime-7MLQ7J64.mjs} +7 -7
  96. package/dist/{schema-4W_7tk1f.d.ts → schema-CS-clLun.d.ts} +54 -28
  97. package/dist/server.d.ts +10 -10
  98. package/dist/server.mjs +27 -15
  99. package/dist/{snapshot-P7IQGNNQ.mjs → snapshot-DOQLGGEX.mjs} +45 -30
  100. package/dist/synonyms.mjs +4 -3
  101. package/dist/{tasks-DLQIfXqy.d.ts → tasks-BfF-VRhm.d.ts} +4 -6
  102. package/dist/{thread-QPETQEPK.mjs → thread-DNK5XWXG.mjs} +16 -14
  103. package/dist/vector/search-worker.d.ts +1 -1
  104. package/dist/vector/search-worker.mjs +4 -4
  105. package/dist/workers/entry.mjs +8 -8
  106. package/dist/{write-WZVM7ZL6.mjs → write-ZKR7SNRT.mjs} +23 -21
  107. package/package.json +7 -7
  108. package/dist/direct-executor-6KCVVHYT.mjs +0 -26
@@ -1,26 +1,27 @@
1
- import { validateWorkerConfig, validateIndexName, validatePatternValueLimit, requireSurfaceFormsForPartialFields, validateBM25Params, validatePartitionConfig, lazyQueryBinding, executeQuery, executePreflight, executeSuggest, executeListDocuments, validateDocId } from './chunk-UKXMSO5H.mjs';
2
- import { resolveVectorText, bindEngineCore, restoredConfigFields, restoredEmbedding, collectRequiredFieldFailures, embedChunkDocuments, providedDocId, requireDocumentObject, admitInsert, asBatchInsertError, requireMatchingDocId, embedDocumentFields, assertDocumentCarriesMappedVectors, admitBufferedUpsert, createPendingAdmissions, recordPendingAdmission } from './chunk-N57XXGPG.mjs';
3
- import { splitWorkerBudget, resolveWorkerCount, resolveWorkerEntry, missingWorkerEntry, DEFAULT_REQUEST_TIMEOUT_MS, resolveRequestThreadCount, workerResourceLimits, DEFAULT_BACKPRESSURE_LIMIT, SHUTDOWN_TIMEOUT_MS, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH } from './chunk-6PN3U6XW.mjs';
1
+ import { validateWorkerConfig, validateIndexName, validatePatternValueLimit, requireSurfaceFormsForPartialFields, validateBM25Params, validatePartitionConfig, lazyQueryBinding, executeQuery, executePreflight, executeSuggest, executeListDocuments, storedBM25Params, validateDocId } from './chunk-6M6SDH3S.mjs';
2
+ import { resolveVectorText, bindEngineCore, restoredConfigFields, restoredEmbedding, collectRequiredFieldFailures, embedChunkDocuments, providedDocId, requireDocumentObject, admitInsert, asBatchInsertError, requireMatchingDocId, embedDocumentFields, assertDocumentCarriesMappedVectors, admitBufferedUpsert, createPendingAdmissions, recordPendingAdmission } from './chunk-JT3YZGCE.mjs';
3
+ import { splitWorkerBudget, resolveWorkerCount, resolveWorkerEntry, missingWorkerEntry, DEFAULT_REQUEST_TIMEOUT_MS, resolveRequestThreadCount, workerResourceLimits, DEFAULT_BACKPRESSURE_LIMIT, SHUTDOWN_TIMEOUT_MS, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH } from './chunk-NNO7CO3A.mjs';
4
4
  import { detectRuntime } from './chunk-AV4IJKD2.mjs';
5
- import { isEmptySynonymSet, synonymModule, createDirectExecutor, createPartitionRouter, availableSynonymModule, mergeFrozenSegments, createSharedFrozenSegment, freezeSegmentShared, resolvePartitionInsertOptions, createFrozenSegment } from './chunk-JEXJDCQH.mjs';
6
- import { requirePatternSearchFor, requirePartialWordSearchFor, collectQueryTermStats, mergePartitionStats, createPartitionIndex, oversampledFacetConfig, availablePatternSearch, PATTERN_HOST, kWayMerge, mergeFacets, isCompositePartition, fnv1a, encodeSegmentState } from './chunk-IBGMFR5Y.mjs';
7
- import { generateId, getLanguage } from './chunk-FUUP45IS.mjs';
5
+ import { isEmptySynonymSet, synonymModule, createDirectExecutor, createPartitionRouter, availableSynonymModule, mergeFrozenSegments, createSharedFrozenSegment, freezeSegmentShared, resolvePartitionInsertOptions, createFrozenSegment } from './chunk-RWESFSJI.mjs';
6
+ import { ARRAY_POSITION_GAP, requirePatternSearchFor, requirePartialWordSearchFor, loadPhraseCodeFor, collectQueryTermStats, requireLoadedPhraseCode, mergePartitionStats, createPartitionIndex, oversampledFacetConfig, availablePatternSearch, PATTERN_HOST, kWayMerge, mergeFacets, isCompositePartition, fnv1a, encodeSegmentState } from './chunk-2MKX2SCO.mjs';
7
+ import { generateId, getLanguage } from './chunk-ZR4VM4A6.mjs';
8
8
  import { readHeapStatistics } from './chunk-ZATRDAYU.mjs';
9
9
  import { countEngineThread } from './chunk-EBIHRL7B.mjs';
10
10
  import { DEFAULT_MAX_RERANK_WINDOW, DEFAULT_RERANK_TIMEOUT_MS } from './chunk-HJSN7UYG.mjs';
11
- import { MAX_INDEX_CONFIGURATION_BYTES, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, STATISTICS_BROADCAST_INTERVAL_MS, MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, HEAP_PRESSURE_WARNING_FRACTION, FOREIGN_STATS_TTL_MS, MAX_IMPORT_REFUSALS_REPORTED, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION, BATCH_CHUNK_SIZE } from './chunk-LXWDQLTW.mjs';
12
- import { requireSearchBackendSettings } from './chunk-VK45J47R.mjs';
13
- import { DEFAULT_PATTERN_WORK_CAP, MATCHER_STATE_BUDGET_BYTES } from './chunk-P34VZEXB.mjs';
14
- import { getNestedValue } from './chunk-KCQG2PJT.mjs';
15
- import { flattenSchema, raiseEarlierReleaseGraphSetting, messagePackUpperBoundBytes, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, extractVectorFieldsFromSchema, schemaFieldsOf, validateRequiredFields, requireDocumentWithinSizeLimit, validateDocument, validateDocumentStrict } from './chunk-DG62H7OD.mjs';
11
+ import { MAX_INDEX_CONFIGURATION_BYTES, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, STATISTICS_BROADCAST_INTERVAL_MS, MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, HEAP_PRESSURE_WARNING_FRACTION, FOREIGN_STATS_TTL_MS, MAX_IMPORT_REFUSALS_REPORTED, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION, BATCH_CHUNK_SIZE } from './chunk-RNSC4NFI.mjs';
12
+ import { requireSearchBackendSettings } from './chunk-2C3WXBQS.mjs';
13
+ import { DEFAULT_PATTERN_WORK_CAP, MATCHER_STATE_BUDGET_BYTES } from './chunk-2SEL6SBS.mjs';
14
+ import { getNestedValue } from './chunk-EUCX5K74.mjs';
15
+ import { flattenSchema, raiseEarlierReleaseGraphSetting, messagePackUpperBoundBytes, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, schemaFieldsOf, extractVectorFieldsFromSchema, validateRequiredFields, requireDocumentWithinSizeLimit, validateDocument, validateDocumentStrict } from './chunk-PU6SKH7O.mjs';
16
16
  import { NATIVE_CRC32_MIN_BYTES, MAX_FILE_BYTES, CHECKSUM_YIELD_CHUNK_BYTES } from './chunk-U476IXKQ.mjs';
17
- import { isSingleStringFieldType } from './chunk-6ODIY6ZB.mjs';
17
+ import { isSingleStringFieldType } from './chunk-7XY6VD7B.mjs';
18
+ import { withOpenIndex, oneAtATime } from './chunk-6SSVIW7Y.mjs';
18
19
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
19
- import { createRequestId, isValidWorkerResponse } from './chunk-Z4DZ4KK2.mjs';
20
- import { loadVectorCodeFor, requireLoadedVectorCode } from './chunk-U6NGTWI3.mjs';
20
+ import { createRequestId, isValidWorkerResponse } from './chunk-UJWGQIXU.mjs';
21
+ import { loadVectorCodeFor, requireLoadedVectorCode } from './chunk-HCGJKDZV.mjs';
21
22
  import { noteThreadSlotLive, threadSlotOfWorker, noteThreadSlotGone } from './chunk-RFBLQLLZ.mjs';
22
23
  import { MAX_DOCUMENT_NESTING_DEPTH } from './chunk-L5ORED7V.mjs';
23
- import { ErrorCodes, NarsilError } from './chunk-OBWUWZRA.mjs';
24
+ import { ErrorCodes, NarsilError } from './chunk-CZ7ISLXA.mjs';
24
25
  import { encode, decode } from '@msgpack/msgpack';
25
26
  import * as zlib from 'zlib';
26
27
 
@@ -685,6 +686,7 @@ function createAnalysisRebuildCoordinator(config, deps) {
685
686
  }
686
687
  }
687
688
  return {
689
+ rebuildMode,
688
690
  markStale(index) {
689
691
  const existing = stale.get(index.indexName);
690
692
  if (existing !== void 0 && existing.run !== null) {
@@ -813,6 +815,17 @@ function resolveDurabilityTier(config) {
813
815
  return { kind: "snapshot", config: {}, adapter: config.persistence };
814
816
  }
815
817
 
818
+ // src/engine/array-positions.ts
819
+ function holdsStringArrayField(schema) {
820
+ return schemaFieldsOf(schema).some((field) => field.base === "string[]");
821
+ }
822
+ function arrayPositionsAreStale(config, storedGap) {
823
+ return storedGap !== ARRAY_POSITION_GAP && config.trackPositions !== false && holdsStringArrayField(config.schema);
824
+ }
825
+ function storedArrayPositionGap(value) {
826
+ return typeof value === "number" ? value : null;
827
+ }
828
+
816
829
  // src/engine/recovery-schema.ts
817
830
  function unflattenSchema(flat) {
818
831
  const root = {};
@@ -839,7 +852,11 @@ function reconstructSchemaFromMetadata(metadata) {
839
852
  const config = {
840
853
  schema: unflattenSchema(metadata.schema),
841
854
  language: metadata.language,
842
- bm25: { k1: metadata.bm25Params.k1, b: metadata.bm25Params.b }
855
+ bm25: {
856
+ k1: metadata.bm25Params.k1,
857
+ b: metadata.bm25Params.b,
858
+ ...metadata.bm25Params.fields !== void 0 ? { fields: metadata.bm25Params.fields } : {}
859
+ }
843
860
  };
844
861
  if (metadata.embedding) {
845
862
  config.embedding = metadata.embedding.adapter !== void 0 ? { adapter: metadata.embedding.adapter, fields: metadata.embedding.fields } : { fields: metadata.embedding.fields };
@@ -988,11 +1005,12 @@ async function createIndexFromMetadata(deps, metadata, loadData) {
988
1005
  documentCount: metadata.documentCount ?? 0,
989
1006
  partitionCount: metadata.partitionCount,
990
1007
  analysisRevision: metadata.analysisRevision ?? null,
1008
+ arrayPositionGap: metadata.arrayPositionGap ?? null,
991
1009
  synonyms
992
1010
  });
993
1011
  if (loadData) await deps.indexState().registerOpen(metadata.indexName);
994
1012
  else deps.indexState().registerClosed(metadata.indexName);
995
- if (metadata.analysisRevision !== language.revision) {
1013
+ if (metadata.analysisRevision !== language.revision || arrayPositionsAreStale(indexConfig, metadata.arrayPositionGap ?? null)) {
996
1014
  deps.analysisRebuild().markStale({
997
1015
  indexName: metadata.indexName,
998
1016
  language: language.name,
@@ -3643,23 +3661,24 @@ function scoresPerPartition(state, indexName, params, globalStats) {
3643
3661
  if (mode === "local") return true;
3644
3662
  return mode === "broadcast" && globalStats !== void 0;
3645
3663
  }
3646
- function queryAction(indexName, params, globalStats, partitionIds, patternWork) {
3664
+ function queryAction(indexName, params, globalStats, partitionIds, patternWork, bm25) {
3647
3665
  return {
3648
3666
  type: "query",
3649
3667
  indexName,
3650
3668
  params,
3651
3669
  requestId: createRequestId(),
3652
3670
  patternWork,
3671
+ bm25: bm25 ?? null,
3653
3672
  ...partitionIds !== void 0 ? { partitionIds } : {},
3654
3673
  ...globalStats !== void 0 ? { globalStats } : {}
3655
3674
  };
3656
3675
  }
3657
- async function runSplit(leases, scope, indexName, params, globalStats, patternWork) {
3676
+ async function runSplit(leases, scope, indexName, params, globalStats, patternWork, bm25) {
3658
3677
  const assignments = partitionsPerLease(scope, leases.length);
3659
3678
  const workerParams = params.facets !== void 0 ? { ...params, facets: oversampledFacetConfig(params.facets) } : params;
3660
3679
  const outcomes = await Promise.allSettled(
3661
3680
  assignments.map(
3662
- (partitionIds, at) => leases[at].executor.execute(queryAction(indexName, workerParams, globalStats, partitionIds, patternWork)).finally(() => leases[at].release())
3681
+ (partitionIds, at) => leases[at].executor.execute(queryAction(indexName, workerParams, globalStats, partitionIds, patternWork, bm25)).finally(() => leases[at].release())
3663
3682
  )
3664
3683
  );
3665
3684
  const results = [];
@@ -3695,7 +3714,7 @@ function answersFasterOnMainCopy(state, pool, manager) {
3695
3714
  if (manager.countDocuments() > MAIN_COPY_LONE_QUERY_DOCUMENTS) return false;
3696
3715
  return takeMainCopyTurn(state);
3697
3716
  }
3698
- async function searchViaWorker(state, indexName, params, globalStats, partitionIds, patternWork) {
3717
+ async function searchViaWorker(state, indexName, params, globalStats, partitionIds, patternWork, bm25) {
3699
3718
  const pool = state.workerPool;
3700
3719
  if (!pool) return null;
3701
3720
  if (!state.scaledOutIndexes.has(indexName) || state.copyLoadBuffers.has(indexName)) return null;
@@ -3710,7 +3729,7 @@ async function searchViaWorker(state, indexName, params, globalStats, partitionI
3710
3729
  if (idle.length >= 2 && scoresPerPartition(state, indexName, params, globalStats)) {
3711
3730
  leases.push(...idle);
3712
3731
  fork = patternWork.fork(leases.length);
3713
- const merged = await runSplit(leases, scope, indexName, params, globalStats, fork.shared);
3732
+ const merged = await runSplit(leases, scope, indexName, params, globalStats, fork.shared, bm25);
3714
3733
  fork.settle(merged.patternWorkSpent ?? 0);
3715
3734
  return merged;
3716
3735
  }
@@ -3720,7 +3739,7 @@ async function searchViaWorker(state, indexName, params, globalStats, partitionI
3720
3739
  leases.push(lease);
3721
3740
  fork = patternWork.fork(1);
3722
3741
  const result = await lease.executor.execute(
3723
- queryAction(indexName, params, globalStats, partitionIds, fork.shared)
3742
+ queryAction(indexName, params, globalStats, partitionIds, fork.shared, bm25)
3724
3743
  );
3725
3744
  fork.settle(result.patternWorkSpent ?? 0);
3726
3745
  return result;
@@ -3981,7 +4000,7 @@ function createWorkerOrchestrator(config, executor, indexRegistry, callbacks, ve
3981
4000
  segmentBuildConcurrency: (indexName) => segmentBuildConcurrency(state, indexName),
3982
4001
  holdUnbroadcastSegments: (indexName, segmentIds) => holdUnbroadcastSegments(state, indexName, segmentIds),
3983
4002
  releaseUnbroadcastSegments: (indexName, segmentIds) => releaseUnbroadcastSegments(state, indexName, segmentIds),
3984
- searchViaWorker: (indexName, params, globalStats, partitionIds, patternWork) => searchViaWorker(state, indexName, params, globalStats, partitionIds, patternWork),
4003
+ searchViaWorker: (indexName, params, globalStats, partitionIds, patternWork, bm25) => searchViaWorker(state, indexName, params, globalStats, partitionIds, patternWork, bm25),
3985
4004
  hasWorkerPool: () => state.workerPool !== null,
3986
4005
  mainCopyQueries: () => state.mainCopyQueries ?? "lone",
3987
4006
  shareMainThread: () => {
@@ -4045,7 +4064,7 @@ async function emitWriteEventAfter(source, indexName, write) {
4045
4064
  // src/engine/core.ts
4046
4065
  async function createEngineCore(config, hooks, capacityScope = "index") {
4047
4066
  validateWorkerConfig(config?.workers, config?.lifecycle);
4048
- const rerankSettings = config?.rerankTimeout === void 0 && config?.maxRerankWindow === void 0 ? { timeoutMs: DEFAULT_RERANK_TIMEOUT_MS, maxWindow: DEFAULT_MAX_RERANK_WINDOW } : (await import('./runtime-XNYW6AWX.mjs')).resolveRerankSettings(config);
4067
+ const rerankSettings = config?.rerankTimeout === void 0 && config?.maxRerankWindow === void 0 ? { timeoutMs: DEFAULT_RERANK_TIMEOUT_MS, maxWindow: DEFAULT_MAX_RERANK_WINDOW } : (await import('./runtime-7MLQ7J64.mjs')).resolveRerankSettings(config);
4049
4068
  const eventHandlers = eventHandlersOf(config?.events);
4050
4069
  const vectorWorkerCount = splitWorkerBudget(resolveWorkerCount(config?.workers?.count)).vector;
4051
4070
  const vectorCopyPolicy = {
@@ -4056,7 +4075,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
4056
4075
  if (config?.lifecycle !== void 0 && durabilityTier === null) {
4057
4076
  throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Index lifecycle settings require durability");
4058
4077
  }
4059
- const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-UGGUNATA.mjs');
4078
+ const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-S7OX2MAI.mjs');
4060
4079
  const filesystemDurability = durabilityTier?.kind === "wal";
4061
4080
  const executor = createDirectExecutor({
4062
4081
  vectorWorkerCopies: vectorCopyPolicy,
@@ -4222,7 +4241,9 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
4222
4241
  resyncIndex: (indexName, wasPromoted) => orchestrator.resyncIndex(indexName, wasPromoted),
4223
4242
  recordCurrentAnalysis: (indexName) => {
4224
4243
  const entry = indexRegistry.get(indexName);
4225
- if (entry !== void 0 && !analysisRebuild.isStale(indexName)) entry.analysisRevision = entry.language.revision;
4244
+ if (entry === void 0 || analysisRebuild.isStale(indexName)) return;
4245
+ entry.analysisRevision = entry.language.revision;
4246
+ entry.arrayPositionGap = ARRAY_POSITION_GAP;
4226
4247
  },
4227
4248
  durabilityManager: durability?.manager ?? null
4228
4249
  });
@@ -4353,7 +4374,7 @@ async function shutdownEngine(core) {
4353
4374
  }
4354
4375
  }
4355
4376
  if (core.rerankAdapters.size > 0) {
4356
- await (await import('./runtime-XNYW6AWX.mjs')).shutdownRerankAdapters(core.rerankAdapters);
4377
+ await (await import('./runtime-7MLQ7J64.mjs')).shutdownRerankAdapters(core.rerankAdapters);
4357
4378
  }
4358
4379
  await orchestrator.shutdown();
4359
4380
  await executor.shutdown();
@@ -4689,6 +4710,7 @@ function indexConfigurationOf(entry) {
4689
4710
  entry.language,
4690
4711
  entry.embeddingAdapterName,
4691
4712
  entry.analysisRevision,
4713
+ entry.arrayPositionGap,
4692
4714
  synonyms
4693
4715
  );
4694
4716
  }
@@ -4698,7 +4720,8 @@ function requireConfigurationWithinSizeLimit(config, language) {
4698
4720
  config,
4699
4721
  language,
4700
4722
  typeof adapter === "string" ? adapter : null,
4701
- language.revision
4723
+ language.revision,
4724
+ ARRAY_POSITION_GAP
4702
4725
  );
4703
4726
  if (messagePackUpperBoundBytes(payload) <= MAX_INDEX_CONFIGURATION_BYTES) return;
4704
4727
  const bytes = encode(payload).byteLength;
@@ -4709,19 +4732,21 @@ function requireConfigurationWithinSizeLimit(config, language) {
4709
4732
  { bytes, maximum: MAX_INDEX_CONFIGURATION_BYTES }
4710
4733
  );
4711
4734
  }
4712
- function configurationPayloadOf(config, language, adapterName, analysisRevision, synonyms) {
4735
+ function configurationPayloadOf(config, language, adapterName, analysisRevision, arrayPositionGap, synonyms) {
4713
4736
  const bm25 = config.bm25;
4714
4737
  return {
4715
4738
  schema: config.schema,
4716
4739
  language: language.name,
4717
4740
  ...analysisRevision !== null ? { analysisRevision } : {},
4741
+ ...arrayPositionGap !== null ? { arrayPositionGap } : {},
4718
4742
  ...typeof config.tokenizer === "string" ? { tokenizer: config.tokenizer } : {},
4719
4743
  ...typeof config.stopWords === "string" ? { stopWords: config.stopWords } : {},
4720
4744
  ...config.stopWords instanceof Set ? { stopWordList: [...config.stopWords].sort(compareCodePoints) } : {},
4721
4745
  ...bm25 !== void 0 ? {
4722
4746
  bm25: {
4723
4747
  ...bm25.k1 !== void 0 ? { k1: bm25.k1 } : {},
4724
- ...bm25.b !== void 0 ? { b: bm25.b } : {}
4748
+ ...bm25.b !== void 0 ? { b: bm25.b } : {},
4749
+ ...bm25.fields !== void 0 ? { fields: bm25.fields } : {}
4725
4750
  }
4726
4751
  } : {},
4727
4752
  surfaceForms: config.surfaceForms !== false,
@@ -4809,14 +4834,21 @@ async function createEngineIndex(core, config, name, requestedConfig, creation =
4809
4834
  const schema = validateSchema(requestedConfig.schema);
4810
4835
  if (appliesCreationLimits) requireCreatableSchema(schema);
4811
4836
  const configured = schema === requestedConfig.schema ? requestedConfig : { ...requestedConfig, schema };
4812
- const indexConfig = withoutSynonyms(configured);
4837
+ const indexConfig = { ...withoutSynonyms(configured) };
4813
4838
  requirePatternSearchFor(schema);
4814
4839
  requirePartialWordSearchFor(schema);
4815
4840
  validatePatternValueLimit(indexConfig.patternValueLimit);
4816
4841
  requireSurfaceFormsForPartialFields(schema, indexConfig.surfaceForms);
4817
4842
  validateVectorPromotion(indexConfig.vectorPromotion);
4818
4843
  validateVectorStorage(indexConfig.vectorPromotion, core.filesystemDurability);
4819
- validateBM25Params(indexConfig.bm25);
4844
+ if (indexConfig.bm25 !== void 0) {
4845
+ validateBM25Params(
4846
+ indexConfig.bm25,
4847
+ schema,
4848
+ ErrorCodes.CONFIG_INVALID,
4849
+ appliesCreationLimits ? "settable" : "stored"
4850
+ );
4851
+ }
4820
4852
  if (indexConfig.partitions) {
4821
4853
  validatePartitionConfig(indexConfig.partitions);
4822
4854
  }
@@ -4883,6 +4915,7 @@ async function createEngineIndex(core, config, name, requestedConfig, creation =
4883
4915
  documentCount: 0,
4884
4916
  partitionCount: indexConfig.partitions?.maxPartitions ?? 1,
4885
4917
  analysisRevision: language.revision,
4918
+ arrayPositionGap: ARRAY_POSITION_GAP,
4886
4919
  synonyms: synonyms?.encoded ?? null
4887
4920
  });
4888
4921
  await core.indexState.registerOpen(name);
@@ -6485,6 +6518,58 @@ function readProcessMemory() {
6485
6518
  }
6486
6519
  }
6487
6520
 
6521
+ // src/engine/bm25-update.ts
6522
+ async function replaceNow(core, indexName, bm25) {
6523
+ const { config } = core.requireIndex(indexName);
6524
+ const previous = config.bm25;
6525
+ config.bm25 = bm25;
6526
+ try {
6527
+ if (core.durability) await core.durability.manager.persistMetadata(indexName);
6528
+ } catch (err) {
6529
+ config.bm25 = previous;
6530
+ throw err;
6531
+ }
6532
+ await core.orchestrator.replicateToWorkers({
6533
+ type: "replaceBm25",
6534
+ indexName,
6535
+ requestId: `replace-bm25-${indexName}`,
6536
+ ...bm25 !== void 0 ? { bm25 } : {}
6537
+ });
6538
+ await core.orchestrator.awaitWrites(indexName);
6539
+ }
6540
+ function updateIndexBm25(core, indexName, value) {
6541
+ return withOpenIndex(
6542
+ core,
6543
+ indexName,
6544
+ () => oneAtATime(core, indexName, () => {
6545
+ const entry = core.requireIndex(indexName);
6546
+ validateBM25Params(value, entry.config.schema, ErrorCodes.CONFIG_INVALID);
6547
+ return replaceNow(core, indexName, storedBM25Params(value));
6548
+ })
6549
+ );
6550
+ }
6551
+ function applyStoredIndexBm25(core, indexName, load) {
6552
+ return withOpenIndex(
6553
+ core,
6554
+ indexName,
6555
+ () => oneAtATime(core, indexName, async () => {
6556
+ const loaded = load();
6557
+ if (loaded === null) return false;
6558
+ await replaceNow(core, indexName, loaded.bm25);
6559
+ return true;
6560
+ })
6561
+ );
6562
+ }
6563
+
6564
+ // src/narsil/bm25.ts
6565
+ function bm25Operations(core) {
6566
+ return {
6567
+ async updateBM25(indexName, bm25) {
6568
+ await updateIndexBm25(core, indexName, bm25);
6569
+ }
6570
+ };
6571
+ }
6572
+
6488
6573
  // src/persistence/archive/byte-reader.ts
6489
6574
  async function* chunksOf(source) {
6490
6575
  if (source instanceof Uint8Array) {
@@ -6942,7 +7027,7 @@ async function readDocumentExport(engine, indexName, source) {
6942
7027
 
6943
7028
  // src/narsil/portability.ts
6944
7029
  function portabilityOperations(core, config, engine) {
6945
- async function withOpenIndex(indexName, action) {
7030
+ async function withOpenIndex2(indexName, action) {
6946
7031
  core.guardShutdown();
6947
7032
  core.requireIndex(indexName);
6948
7033
  const release = await core.indexState.acquire(indexName);
@@ -6970,25 +7055,25 @@ function portabilityOperations(core, config, engine) {
6970
7055
  }
6971
7056
  return {
6972
7057
  snapshot(indexName) {
6973
- return withOpenIndex(indexName, async () => {
6974
- const { createSnapshot } = await import('./snapshot-P7IQGNNQ.mjs');
7058
+ return withOpenIndex2(indexName, async () => {
7059
+ const { createSnapshot } = await import('./snapshot-DOQLGGEX.mjs');
6975
7060
  return createSnapshot(snapshotDepsOf(indexName));
6976
7061
  });
6977
7062
  },
6978
7063
  async restore(indexName, data) {
6979
7064
  core.guardShutdown();
6980
7065
  validateIndexName(indexName);
6981
- const restored = import('./restore-queue-NVMWJMHI.mjs').then(
7066
+ const restored = import('./restore-queue-JAMNRC6T.mjs').then(
6982
7067
  ({ queueRestore }) => queueRestore(core, restoreHost, restoresInFlight, indexName, data)
6983
7068
  );
6984
7069
  await emitWriteEventAfter(core, indexName, restored);
6985
7070
  core.heapPressureNotifier.check(indexName);
6986
7071
  },
6987
7072
  exportDocuments(indexName) {
6988
- return withOpenIndex(indexName, async () => {
7073
+ return withOpenIndex2(indexName, async () => {
6989
7074
  const [{ checkpointForArchive }, { documentExportStream }] = await Promise.all([
6990
- import('./snapshot-P7IQGNNQ.mjs'),
6991
- import('./write-WZVM7ZL6.mjs')
7075
+ import('./snapshot-DOQLGGEX.mjs'),
7076
+ import('./write-ZKR7SNRT.mjs')
6992
7077
  ]);
6993
7078
  const header = indexConfigurationOf(core.requireIndex(indexName));
6994
7079
  return documentExportStream(header, await checkpointForArchive(snapshotDepsOf(indexName)));
@@ -7015,6 +7100,12 @@ async function readUnderOneAnalysis(core, indexName, read) {
7015
7100
  }
7016
7101
  return { result, analysisStale };
7017
7102
  }
7103
+ function phraseReadinessOf(core, indexName, config) {
7104
+ return () => {
7105
+ if (!core.analysisRebuild.isStale(indexName) || !holdsStringArrayField(config.schema)) return;
7106
+ requireLoadedPhraseCode().refusePhraseUntilRebuilt(indexName, core.analysisRebuild.rebuildMode);
7107
+ };
7108
+ }
7018
7109
  function scopedParams(params, options) {
7019
7110
  if (options?.globalStats === void 0) {
7020
7111
  return params;
@@ -7040,7 +7131,7 @@ async function runEngineQuery(core, indexName, params, options) {
7040
7131
  const manager = core.requireManager(indexName);
7041
7132
  const scoped = scopedParams(params, options);
7042
7133
  await core.pluginRegistry.runHook("beforeSearch", { indexName, params: scoped });
7043
- const rerank = scoped.rerank === void 0 ? void 0 : await import('./runtime-XNYW6AWX.mjs');
7134
+ const rerank = scoped.rerank === void 0 ? void 0 : await import('./runtime-7MLQ7J64.mjs');
7044
7135
  const resolvedParams = await resolveVectorText(
7045
7136
  rerank === void 0 ? scoped : rerank.withRerankQueryText(scoped),
7046
7137
  entry.embeddingAdapter,
@@ -7057,9 +7148,11 @@ async function runEngineQuery(core, indexName, params, options) {
7057
7148
  broadcastStats: broadcastStatsFor(core, options),
7058
7149
  partitionIds: options?.partitionIds,
7059
7150
  rescoreWindow: options?.rescoreWindow,
7151
+ indexBm25: options?.indexBm25,
7060
7152
  cursorBinding: lazyQueryBinding(params),
7061
7153
  patternWorkCap: core.patternWorkCap,
7062
- rerank: rerank?.rerankRunnerFor(core)
7154
+ rerank: rerank?.rerankRunnerFor(core),
7155
+ requirePhraseReady: phraseReadinessOf(core, indexName, entry.config)
7063
7156
  };
7064
7157
  const { result, analysisStale } = await readUnderOneAnalysis(
7065
7158
  core,
@@ -7106,8 +7199,10 @@ async function runEnginePreflight(core, indexName, params, options) {
7106
7199
  indexName,
7107
7200
  broadcastStats: broadcastStatsFor(core, options),
7108
7201
  partitionIds: options?.partitionIds,
7202
+ indexBm25: options?.indexBm25,
7109
7203
  cursorBinding: lazyQueryBinding(params),
7110
- patternWorkCap: core.patternWorkCap
7204
+ patternWorkCap: core.patternWorkCap,
7205
+ requirePhraseReady: phraseReadinessOf(core, indexName, entry.config)
7111
7206
  };
7112
7207
  const { result, analysisStale } = await readUnderOneAnalysis(
7113
7208
  core,
@@ -7147,6 +7242,8 @@ async function runEngineQueryStats(core, indexName, terms, partitionIds, scope)
7147
7242
  const entry = core.requireIndex(indexName);
7148
7243
  const manager = core.requireManager(indexName);
7149
7244
  const term = terms.join(" ");
7245
+ const loadingPhraseCode = loadPhraseCodeFor(term);
7246
+ if (loadingPhraseCode !== null) await loadingPhraseCode;
7150
7247
  const analysis = {
7151
7248
  stopWords: manager.analysis.stopWords,
7152
7249
  customTokenizer: manager.analysis.customTokenizer,
@@ -7216,7 +7313,7 @@ function createNarsilFromCore(core, config) {
7216
7313
  mutationCtx,
7217
7314
  rebalanceCtx
7218
7315
  } = core;
7219
- async function withOpenIndex(indexName, action) {
7316
+ async function withOpenIndex2(indexName, action) {
7220
7317
  guardShutdown();
7221
7318
  requireIndex(indexName);
7222
7319
  const release = await core.indexState.acquire(indexName);
@@ -7227,7 +7324,7 @@ function createNarsilFromCore(core, config) {
7227
7324
  }
7228
7325
  }
7229
7326
  function withOpenIndexWrite(indexName, action) {
7230
- return emitWriteEventAfter(core, indexName, withOpenIndex(indexName, action));
7327
+ return emitWriteEventAfter(core, indexName, withOpenIndex2(indexName, action));
7231
7328
  }
7232
7329
  const narsil = {
7233
7330
  createIndex(name, indexConfig) {
@@ -7313,12 +7410,12 @@ function createNarsilFromCore(core, config) {
7313
7410
  return orchestrator.awaitWrites(indexName);
7314
7411
  },
7315
7412
  async get(indexName, docId) {
7316
- return withOpenIndex(indexName, () => executor.execute({ type: "get", indexName, docId, requestId: docId }));
7413
+ return withOpenIndex2(indexName, () => executor.execute({ type: "get", indexName, docId, requestId: docId }));
7317
7414
  },
7318
7415
  async getMultiple(indexName, docIds) {
7319
7416
  guardShutdown();
7320
7417
  requireIndex(indexName);
7321
- return withOpenIndex(indexName, async () => {
7418
+ return withOpenIndex2(indexName, async () => {
7322
7419
  const result = /* @__PURE__ */ new Map();
7323
7420
  for (const docId of docIds) {
7324
7421
  const doc = await executor.execute({
@@ -7333,10 +7430,10 @@ function createNarsilFromCore(core, config) {
7333
7430
  });
7334
7431
  },
7335
7432
  async has(indexName, docId) {
7336
- return withOpenIndex(indexName, () => executor.execute({ type: "has", indexName, docId, requestId: docId }));
7433
+ return withOpenIndex2(indexName, () => executor.execute({ type: "has", indexName, docId, requestId: docId }));
7337
7434
  },
7338
7435
  async countDocuments(indexName) {
7339
- return withOpenIndex(indexName, () => executor.execute({ type: "count", indexName, requestId: indexName }));
7436
+ return withOpenIndex2(indexName, () => executor.execute({ type: "count", indexName, requestId: indexName }));
7340
7437
  },
7341
7438
  async listDocuments(indexName, params) {
7342
7439
  return runEngineListDocuments(core, indexName, params ?? {});
@@ -7357,10 +7454,11 @@ function createNarsilFromCore(core, config) {
7357
7454
  },
7358
7455
  ...portabilityOperations(core, config, () => narsil),
7359
7456
  ...synonymOperations(core),
7457
+ ...bm25Operations(core),
7360
7458
  async checkpoint(indexName) {
7361
7459
  guardShutdown();
7362
7460
  requireIndex(indexName);
7363
- await withOpenIndex(indexName, async () => {
7461
+ await withOpenIndex2(indexName, async () => {
7364
7462
  if (durability) await durability.manager.checkpoint(indexName);
7365
7463
  });
7366
7464
  },
@@ -7383,7 +7481,7 @@ function createNarsilFromCore(core, config) {
7383
7481
  },
7384
7482
  async updatePartitionConfig(indexName, partitionConfig) {
7385
7483
  guardShutdown();
7386
- return withOpenIndex(indexName, async () => {
7484
+ return withOpenIndex2(indexName, async () => {
7387
7485
  const entry = requireIndex(indexName);
7388
7486
  const manager = requireManager(indexName);
7389
7487
  if (rebalancingIndexes.has(indexName)) {
@@ -7498,4 +7596,4 @@ async function createNarsil(config) {
7498
7596
  // src/index.ts
7499
7597
  var VERSION = "0.1.0";
7500
7598
 
7501
- export { BYTES_TAG, DATE_TAG, DOCUMENT_EXPORT_FORMAT, DOCUMENT_EXPORT_VERSION, HEADER_SIZE, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND, NUMBER_TAG, OBJECT_TAG, VERSION, crc322 as crc32, crc32Final, crc32Init, crc32Update, createByteReader, createEngineCore, createEngineIndex, createNarsil, createNarsilFromCore, decodeIndexConfiguration, emptySerializablePartition, encodeBase64, encodeIndexConfiguration, engineVersionParts, hasNrslMagic, insertDocumentVectors, openChecksummedEnvelope, packChecksummedEnvelope, prepareConfiguredSynonyms, prepareDocumentVectors, prepareStoredSynonyms, readHeader, reconstructSchemaFromMetadata, removeDocumentVectors, requireConfigurationWithinSizeLimit, requireKnownConfig, resolveRunnableConfig, rulesOfStoredSynonyms, runEngineListDocuments, runEnginePreflight, runEngineQuery, runEngineQueryStats, runEngineSuggest, startEngineCore, startsWithTagPrefix, validateEmbeddingConfig, validateRequiredFieldsInSchema, writeHeader, yieldToEventLoop };
7599
+ export { BYTES_TAG, DATE_TAG, DOCUMENT_EXPORT_FORMAT, DOCUMENT_EXPORT_VERSION, HEADER_SIZE, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND, NUMBER_TAG, OBJECT_TAG, VERSION, applyStoredIndexBm25, arrayPositionsAreStale, crc322 as crc32, crc32Final, crc32Init, crc32Update, createByteReader, createEngineCore, createEngineIndex, createNarsil, createNarsilFromCore, decodeIndexConfiguration, emptySerializablePartition, encodeBase64, encodeIndexConfiguration, engineVersionParts, hasNrslMagic, insertDocumentVectors, openChecksummedEnvelope, packChecksummedEnvelope, prepareConfiguredSynonyms, prepareDocumentVectors, prepareStoredSynonyms, readHeader, reconstructSchemaFromMetadata, removeDocumentVectors, requireConfigurationWithinSizeLimit, requireKnownConfig, resolveRunnableConfig, rulesOfStoredSynonyms, runEngineListDocuments, runEnginePreflight, runEngineQuery, runEngineQueryStats, runEngineSuggest, startEngineCore, startsWithTagPrefix, storedArrayPositionGap, validateEmbeddingConfig, validateRequiredFieldsInSchema, writeHeader, yieldToEventLoop };
@@ -10,6 +10,7 @@ var KNOWN_ACTION_TYPES = [
10
10
  "count",
11
11
  "createIndex",
12
12
  "replaceSynonyms",
13
+ "replaceBm25",
13
14
  "copyLoaded",
14
15
  "loadVectorCopy",
15
16
  "dropVectorCopy",
@@ -1,10 +1,10 @@
1
- import { vectorsPerFile } from './chunk-SEG4CL6W.mjs';
2
- import { writeLiveVectors, decodeSegmentManifest, openManifestPayload, listedKeysOf, decodeManifestPayload, SINGLE_NODE_PRIMARY_TERM } from './chunk-JIXO442E.mjs';
3
- import { vectorsToBytes, VECTOR_FILE_PAYLOAD_VERSION } from './chunk-OCB7TMUQ.mjs';
4
- import { writeCheckpointSegments, DEFAULT_COMPACTION_THRESHOLD, commitCheckpointManifest, manifestKey, manifestFileRefs, partitionContentsOf } from './chunk-QSCVJJW5.mjs';
5
- import { HEADER_SIZE } from './chunk-ENBN5VQ6.mjs';
1
+ import { vectorsPerFile } from './chunk-SOHMMNCH.mjs';
2
+ import { writeLiveVectors, decodeSegmentManifest, openManifestPayload, listedKeysOf, decodeManifestPayload, SINGLE_NODE_PRIMARY_TERM } from './chunk-K77FJXKS.mjs';
3
+ import { vectorsToBytes, VECTOR_FILE_PAYLOAD_VERSION } from './chunk-Y2U5VVWX.mjs';
4
+ import { writeCheckpointSegments, DEFAULT_COMPACTION_THRESHOLD, commitCheckpointManifest, manifestKey, manifestFileRefs, partitionContentsOf } from './chunk-2JWNJSNE.mjs';
5
+ import { HEADER_SIZE } from './chunk-TGHNXN7W.mjs';
6
6
  import { MAX_FILE_BYTES } from './chunk-U476IXKQ.mjs';
7
- import { NarsilError, ErrorCodes } from './chunk-OBWUWZRA.mjs';
7
+ import { NarsilError, ErrorCodes } from './chunk-CZ7ISLXA.mjs';
8
8
 
9
9
  // src/persistence/archive/memory-store.ts
10
10
  function joined(chunks) {
@@ -2,11 +2,11 @@ import { stopUsingTheNativeSearchCore, noteFallback, nativeSearchCoreIsEnabled }
2
2
  import { unpackLevels, readTrailer, stageQueryLevels, osqCodeBytes, osqStagedQueryBytes, osqRecordBytes, writeRecord } from './chunk-37CD3OKS.mjs';
3
3
  import { markSimdUnavailable } from './chunk-KOKM4PQN.mjs';
4
4
  import { MAX_WASM_PAGES, WASM_PAGE_BYTES, VECTOR_SCRATCH_SLOTS, UNPLACED_FLAG_CHUNK_ORDINALS, OSQ_STEPS, OSQ_GRID, VECTOR_BLOCK_INITIAL_SLOTS, MAX_VECTOR_ORDINALS, VECTOR_STORE_INITIAL_CAPACITY, LOCK_SPIN_ITERATIONS, LOCK_WAIT_SLICE_MS, OSQ_REFINE_ROUNDS, OSQ_REFINE_TOLERANCE, OSQ_PLACEMENT_QUERY_BITS, GRAPH_LOCK_WAIT_SLICE_MS, OSQ_QUERY_BITS, NATIVE_ATTACH_RETRY_MS, GRAPH_LOCK_WAIT_DEADLINE_MS, OSQ_LAMBDA, MAX_DOC_ID_TABLE_BYTES } from './chunk-QSK35UC2.mjs';
5
- import { loadNativeCore } from './chunk-VK45J47R.mjs';
5
+ import { loadNativeCore } from './chunk-2C3WXBQS.mjs';
6
6
  import { COMPACTION_TOMBSTONE_RATIO, COMPACTION_ABSOLUTE_THRESHOLD, PLACEMENT_ROOM_REQUESTS, MAX_LAYER_CAP, INITIAL_LIST_CAPACITY, INITIAL_UPPER_SLOTS, DEFAULT_EF_SEARCH, NEAREST_LINK_FALLBACK_HOSTS, FARTHEST_REJECTED_LINKS_KEPT } from './chunk-VJS4JFBQ.mjs';
7
7
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
8
8
  import { threadSlotGone } from './chunk-RFBLQLLZ.mjs';
9
- import { NarsilError, ErrorCodes } from './chunk-OBWUWZRA.mjs';
9
+ import { NarsilError, ErrorCodes } from './chunk-CZ7ISLXA.mjs';
10
10
 
11
11
  // src/vector/shared-buffers/growable.ts
12
12
  function sharedMemoryAvailable() {
@@ -1,12 +1,12 @@
1
- import { readRecentMemoryFigures, readMemoryFigures, answerRefusalOf } from './chunk-HFJXEFFV.mjs';
1
+ import { readRecentMemoryFigures, readMemoryFigures, answerRefusalOf } from './chunk-4GDLFDPZ.mjs';
2
2
  import { collectGarbageBeforeRefusal, collectYoungGenerationBeforeRefusal, reportRefusalAfterCollection, reservedHeapBytes, admitHeapBytes } from './chunk-IWVEG5CX.mjs';
3
3
  import { nativeSearchCoreIsEnabled } from './chunk-DJHHF2L5.mjs';
4
4
  import { DEFAULT_RERANK_WINDOW } from './chunk-HJSN7UYG.mjs';
5
- import { loadNativeCore } from './chunk-VK45J47R.mjs';
5
+ import { loadNativeCore } from './chunk-2C3WXBQS.mjs';
6
6
  import { MAX_FILTER_DEPTH } from './chunk-WQBCBKY3.mjs';
7
- import { MAX_SORT_FIELDS } from './chunk-E74YLAIG.mjs';
7
+ import { MAX_SORT_FIELDS } from './chunk-FQBFZAWG.mjs';
8
8
  import { HEAP_BLOCK_FRACTION_BELOW_V8_INEFFECTIVE_MARK_COMPACT_LINE } from './chunk-22YPZVMG.mjs';
9
- import { NarsilError, ServerErrorCodes, ErrorCodes } from './chunk-OBWUWZRA.mjs';
9
+ import { NarsilError, ServerErrorCodes, ErrorCodes } from './chunk-CZ7ISLXA.mjs';
10
10
  import { randomUUID } from 'crypto';
11
11
  import { mkdtemp, open, rm } from 'fs/promises';
12
12
  import { tmpdir } from 'os';
@@ -71,6 +71,7 @@ var REBUILD_ANALYSIS_CAPABILITY = "indexes.rebuildAnalysis";
71
71
  var INDEX_LIFECYCLE_CAPABILITY = "indexes.lifecycle";
72
72
  var DOCUMENT_EXPORT_CAPABILITY = "indexes.documentExport";
73
73
  var SYNONYMS_CAPABILITY = "indexes.synonyms";
74
+ var BM25_TUNING_CAPABILITY = "indexes.bm25";
74
75
  var SERVER_CAPABILITIES = [
75
76
  ASYNC_IMPORT_CAPABILITY,
76
77
  TASK_CANCEL_CAPABILITY,
@@ -78,7 +79,8 @@ var SERVER_CAPABILITIES = [
78
79
  REBUILD_ANALYSIS_CAPABILITY,
79
80
  INDEX_LIFECYCLE_CAPABILITY,
80
81
  DOCUMENT_EXPORT_CAPABILITY,
81
- SYNONYMS_CAPABILITY
82
+ SYNONYMS_CAPABILITY,
83
+ BM25_TUNING_CAPABILITY
82
84
  ];
83
85
 
84
86
  // src/server/concurrency-gate.ts
@@ -179,6 +181,8 @@ var STATUS_BY_CODE = {
179
181
  SEARCH_INVALID_CURSOR: 400,
180
182
  SEARCH_RESULT_WINDOW_EXCEEDED: 400,
181
183
  SEARCH_WORK_CAP_EXCEEDED: 400,
184
+ SEARCH_INVALID_PHRASE: 400,
185
+ SEARCH_PHRASE_NOT_READY: 503,
182
186
  LANGUAGE_NOT_SUPPORTED: 400,
183
187
  CONFIG_INVALID: 400,
184
188
  EMBEDDING_DIMENSION_MISMATCH: 400,
@@ -209,6 +213,7 @@ var STATUS_BY_CODE = {
209
213
  EMBEDDING_FAILED: 503,
210
214
  RERANK_FAILED: 503,
211
215
  QUERY_ROUTING_FAILED: 503,
216
+ BM25_NOT_READY: 503,
212
217
  QUERY_PARTIAL_FAILURE: 503,
213
218
  QUERY_NODE_TIMEOUT: 503,
214
219
  QUERY_NO_ACTIVE_REPLICA: 503,
@@ -1704,6 +1709,7 @@ function serverRoutes(limits) {
1704
1709
  { method: "post", path: "/indexes/:name/partition-config", handler: "partitionConfig", options: namedBody },
1705
1710
  { method: "get", path: "/indexes/:name/synonyms", handler: "readSynonyms", options: named },
1706
1711
  { method: "post", path: "/indexes/:name/synonyms", handler: "replaceSynonyms", options: namedBody },
1712
+ { method: "post", path: "/indexes/:name/bm25", handler: "updateBm25", options: namedBody },
1707
1713
  {
1708
1714
  method: "post",
1709
1715
  path: "/indexes/:name/restore",
@@ -1830,4 +1836,4 @@ async function departureConfirmation(word) {
1830
1836
  if (waiting.async) await waiting.value;
1831
1837
  }
1832
1838
 
1833
- export { ASYNC_IMPORT_CAPABILITY, DEFAULT_IMPORT_BATCH_SIZE, DEFAULT_MAX_BODY_BYTES, DEFAULT_MAX_BODY_BYTES_IN_FLIGHT_FRACTION, DEFAULT_MAX_CONCURRENT_REQUESTS, DEFAULT_MAX_CONCURRENT_TASKS, DEFAULT_MAX_FETCH_DOCUMENTS, DEFAULT_MAX_IMPORT_BYTES, DEFAULT_MAX_IMPORT_ERRORS, DEFAULT_MAX_LINE_BYTES, DEFAULT_MAX_RERANK_WINDOW, DEFAULT_MAX_RESTORE_BYTES, DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_RETAINED_TASKS, DEFAULT_MAX_TASK_PAGE_SIZE, DEFAULT_TASK_PAGE_SIZE, DOCUMENT_EXPORT_CAPABILITY, DOCUMENT_EXPORT_CONTENT_TYPE, IMPORT_FLUSHES_IN_FLIGHT, INDEX_LIFECYCLE_CAPABILITY, INDEX_TOUCH_INTERVALS_PER_IDLE_TIMEOUT, MAIN_THREAD_GATE_SLOT, MAX_BODY_BYTES_IN_FLIGHT_FRACTION, MAX_INDEX_TOUCH_INTERVAL_MS, MAX_LONG_QUERIES_IN_FLIGHT, MIN_COUNTED_SERVER_LIMIT, MIN_UNBOUNDED_SERVER_LIMIT, REBUILD_ANALYSIS_CAPABILITY, RELAY_STREAM_CHUNKS_IN_FLIGHT, REQUEST_THREAD_CLOSE_AT_EXIT_MS, REQUEST_THREAD_DEPARTURE_DRAIN_MS, REQUEST_THREAD_MOVE_AFTER_MS, RUNNING_TASK_TTL_MS, SEARCH_CLOCK_SAMPLE_UNITS, SERVER_CAPABILITIES, SNAPSHOT_ARCHIVE_CONTENT_TYPE, SYNONYMS_CAPABILITY, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, TASK_PROGRESS_WRITE_INTERVAL_MS, TERMINAL_TASK_TTL_MS, acceptorOf, authorizerFor, awaitDepartureConfirmation, badRequest, childAppOf, clearBodyBudgetSlot, clearGateSlot, closeEveryThreadAtExit, closeWhenTheProcessExits, confirmDeparture, corsHeaderReader, createBodyBudgetBuffer, createCloseAtExitWords, createDepartureWord, createDocumentReadHandlers, createRouteRunner, createSharedBodyBudget, createSharedGateBuffer, createSharedRequestGate, createVersionHandler, departureConfirmation, departureConfirmed, encodeJson, gateSlotOfWorker, httpStatusForNarsilError, isRemoveOnlyBatch, loadUWebSockets, parseJson, parseJsonOptional, parseRefusalOf, parseTaskListQuery, parseWriteJson, refuseRegex, registerServerRoutes, rejectInvalid, resolveCors, respondAnswer, respondError, respondJson, sendError, sendRelayed, sendStream, sendText, serializeBatchResult, serializeNarsilError, serverRoutes, statusLine, toHttpError, validateBatch, validateCreateIndex, validateDocumentBody, validateQuery, validateRebalance, validateSuggest, versionReport, withServerRerankWindow };
1839
+ export { ASYNC_IMPORT_CAPABILITY, BM25_TUNING_CAPABILITY, DEFAULT_IMPORT_BATCH_SIZE, DEFAULT_MAX_BODY_BYTES, DEFAULT_MAX_BODY_BYTES_IN_FLIGHT_FRACTION, DEFAULT_MAX_CONCURRENT_REQUESTS, DEFAULT_MAX_CONCURRENT_TASKS, DEFAULT_MAX_FETCH_DOCUMENTS, DEFAULT_MAX_IMPORT_BYTES, DEFAULT_MAX_IMPORT_ERRORS, DEFAULT_MAX_LINE_BYTES, DEFAULT_MAX_RERANK_WINDOW, DEFAULT_MAX_RESTORE_BYTES, DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_RETAINED_TASKS, DEFAULT_MAX_TASK_PAGE_SIZE, DEFAULT_TASK_PAGE_SIZE, DOCUMENT_EXPORT_CAPABILITY, DOCUMENT_EXPORT_CONTENT_TYPE, IMPORT_FLUSHES_IN_FLIGHT, INDEX_LIFECYCLE_CAPABILITY, INDEX_TOUCH_INTERVALS_PER_IDLE_TIMEOUT, MAIN_THREAD_GATE_SLOT, MAX_BODY_BYTES_IN_FLIGHT_FRACTION, MAX_INDEX_TOUCH_INTERVAL_MS, MAX_LONG_QUERIES_IN_FLIGHT, MIN_COUNTED_SERVER_LIMIT, MIN_UNBOUNDED_SERVER_LIMIT, REBUILD_ANALYSIS_CAPABILITY, RELAY_STREAM_CHUNKS_IN_FLIGHT, REQUEST_THREAD_CLOSE_AT_EXIT_MS, REQUEST_THREAD_DEPARTURE_DRAIN_MS, REQUEST_THREAD_MOVE_AFTER_MS, RUNNING_TASK_TTL_MS, SEARCH_CLOCK_SAMPLE_UNITS, SERVER_CAPABILITIES, SNAPSHOT_ARCHIVE_CONTENT_TYPE, SYNONYMS_CAPABILITY, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, TASK_PROGRESS_WRITE_INTERVAL_MS, TERMINAL_TASK_TTL_MS, acceptorOf, authorizerFor, awaitDepartureConfirmation, badRequest, childAppOf, clearBodyBudgetSlot, clearGateSlot, closeEveryThreadAtExit, closeWhenTheProcessExits, confirmDeparture, corsHeaderReader, createBodyBudgetBuffer, createCloseAtExitWords, createDepartureWord, createDocumentReadHandlers, createRouteRunner, createSharedBodyBudget, createSharedGateBuffer, createSharedRequestGate, createVersionHandler, departureConfirmation, departureConfirmed, encodeJson, gateSlotOfWorker, httpStatusForNarsilError, isRemoveOnlyBatch, loadUWebSockets, parseJson, parseJsonOptional, parseRefusalOf, parseTaskListQuery, parseWriteJson, refuseRegex, registerServerRoutes, rejectInvalid, resolveCors, respondAnswer, respondError, respondJson, sendError, sendRelayed, sendStream, sendText, serializeBatchResult, serializeNarsilError, serverRoutes, statusLine, toHttpError, validateBatch, validateCreateIndex, validateDocumentBody, validateQuery, validateRebalance, validateSuggest, versionReport, withServerRerankWindow };
@@ -1,6 +1,6 @@
1
1
  import { osqRecordBytes } from './chunk-37CD3OKS.mjs';
2
2
  import { MAX_M, EARLIER_RELEASE_MIN_M, MIN_M } from './chunk-VJS4JFBQ.mjs';
3
- import { NarsilError, ErrorCodes } from './chunk-OBWUWZRA.mjs';
3
+ import { NarsilError, ErrorCodes } from './chunk-CZ7ISLXA.mjs';
4
4
 
5
5
  // src/vector/vector-index/dead-bits.ts
6
6
  var NO_LIVE_VECTOR_AT_POSITION = -1;
@@ -1,6 +1,6 @@
1
- import { openSharedQuantizer, STORE_ORDINAL_LAYOUT_GENERATION, searchOrdinals, insertNode, GRAPH_RETIRED, nodeCountOf, tombstoneCountOf, BLOCK_MAX_BYTES, sharedVectorStoreBytes, STORE_SLOTS, STORE_LIVE_COUNT, IN_MEMORY, resetStoreHeader, STORE_RELEASED_VECTORS_TO_DISK, magnitude, openGraphState, fixedView, createSharedVectorStoreHandles, STORE_DOC_ID_BYTES, unplacedChunkCount, blocksGrowthBytes, growBufferTo, createOrdinalFilter, addToOrdinalFilter, slotByteOffset, openVectorBlock, NOTHING_STAGED, arenaFloat32Distance, detachNativeStore, STORE_BLOCK_COUNT, STORE_CODE_BLOCK_COUNT, grownByteLength, createVectorBlock, ensureBlockSlots, QUERY_STAGED, euclideanDistance, dotProduct, cosineSimilarityWithMagnitudes } from './chunk-62IPM62F.mjs';
1
+ import { openSharedQuantizer, STORE_ORDINAL_LAYOUT_GENERATION, searchOrdinals, insertNode, GRAPH_RETIRED, nodeCountOf, tombstoneCountOf, BLOCK_MAX_BYTES, sharedVectorStoreBytes, STORE_SLOTS, STORE_LIVE_COUNT, IN_MEMORY, resetStoreHeader, STORE_RELEASED_VECTORS_TO_DISK, magnitude, openGraphState, fixedView, createSharedVectorStoreHandles, STORE_DOC_ID_BYTES, unplacedChunkCount, blocksGrowthBytes, growBufferTo, createOrdinalFilter, addToOrdinalFilter, slotByteOffset, openVectorBlock, NOTHING_STAGED, arenaFloat32Distance, detachNativeStore, STORE_BLOCK_COUNT, STORE_CODE_BLOCK_COUNT, grownByteLength, createVectorBlock, ensureBlockSlots, QUERY_STAGED, euclideanDistance, dotProduct, cosineSimilarityWithMagnitudes } from './chunk-X5CNUKD5.mjs';
2
2
  import { MAX_VECTOR_ORDINALS } from './chunk-QSK35UC2.mjs';
3
- import { NarsilError, ErrorCodes } from './chunk-OBWUWZRA.mjs';
3
+ import { NarsilError, ErrorCodes } from './chunk-CZ7ISLXA.mjs';
4
4
  import { readSync, closeSync, openSync } from 'fs';
5
5
 
6
6
  function createVectorFileReader() {
@@ -1,5 +1,5 @@
1
- import { sendError, RELAY_STREAM_CHUNKS_IN_FLIGHT } from './chunk-IE43SRL3.mjs';
2
- import { ServerErrorCodes } from './chunk-OBWUWZRA.mjs';
1
+ import { sendError, RELAY_STREAM_CHUNKS_IN_FLIGHT } from './chunk-XABMCBHA.mjs';
2
+ import { ServerErrorCodes } from './chunk-CZ7ISLXA.mjs';
3
3
  import { rm } from 'fs/promises';
4
4
  import path from 'path';
5
5