sensemaking 0.25.1 → 0.26.0

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 (316) hide show
  1. package/README.md +13 -9
  2. package/dist/cjs/cli/index.d.cts +1 -1
  3. package/dist/cjs/cli/index.d.ts +1 -1
  4. package/dist/cjs/cli/index.js +1 -1
  5. package/dist/cjs/cli/index.js.map +1 -1
  6. package/dist/cjs/cli/path.js +5 -29
  7. package/dist/cjs/cli/path.js.map +1 -1
  8. package/dist/cjs/cli/related.js +4 -3
  9. package/dist/cjs/cli/related.js.map +1 -1
  10. package/dist/cjs/commands/index.d.cts +6 -3
  11. package/dist/cjs/commands/index.d.ts +6 -3
  12. package/dist/cjs/commands/index.js +4 -0
  13. package/dist/cjs/commands/index.js.map +1 -1
  14. package/dist/cjs/commands/map.d.cts +14 -5
  15. package/dist/cjs/commands/map.d.ts +14 -5
  16. package/dist/cjs/commands/map.js +42 -35
  17. package/dist/cjs/commands/map.js.map +1 -1
  18. package/dist/cjs/commands/path.d.cts +14 -0
  19. package/dist/cjs/commands/path.d.ts +14 -0
  20. package/dist/cjs/commands/path.js +209 -0
  21. package/dist/cjs/commands/path.js.map +1 -0
  22. package/dist/cjs/commands/peek.d.cts +16 -1
  23. package/dist/cjs/commands/peek.d.ts +16 -1
  24. package/dist/cjs/commands/peek.js +71 -33
  25. package/dist/cjs/commands/peek.js.map +1 -1
  26. package/dist/cjs/commands/related.d.cts +16 -3
  27. package/dist/cjs/commands/related.d.ts +16 -3
  28. package/dist/cjs/commands/related.js +131 -98
  29. package/dist/cjs/commands/related.js.map +1 -1
  30. package/dist/cjs/commands/scope.d.cts +1 -0
  31. package/dist/cjs/commands/scope.d.ts +1 -0
  32. package/dist/cjs/commands/scope.js +149 -0
  33. package/dist/cjs/commands/scope.js.map +1 -1
  34. package/dist/cjs/commands/search.d.cts +26 -3
  35. package/dist/cjs/commands/search.d.ts +26 -3
  36. package/dist/cjs/commands/search.js +211 -71
  37. package/dist/cjs/commands/search.js.map +1 -1
  38. package/dist/cjs/commands/signals.d.cts +4 -3
  39. package/dist/cjs/commands/signals.d.ts +4 -3
  40. package/dist/cjs/commands/signals.js +13 -4
  41. package/dist/cjs/commands/signals.js.map +1 -1
  42. package/dist/cjs/commands/snapshot.d.cts +3 -0
  43. package/dist/cjs/commands/snapshot.d.ts +3 -0
  44. package/dist/cjs/commands/snapshot.js +180 -0
  45. package/dist/cjs/commands/snapshot.js.map +1 -0
  46. package/dist/cjs/embed/cohere.js +41 -16
  47. package/dist/cjs/embed/cohere.js.map +1 -1
  48. package/dist/cjs/embed/endpoint.d.cts +2 -0
  49. package/dist/cjs/embed/endpoint.d.ts +2 -0
  50. package/dist/cjs/embed/endpoint.js +30 -0
  51. package/dist/cjs/embed/endpoint.js.map +1 -0
  52. package/dist/cjs/embed/handoff.d.cts +7 -2
  53. package/dist/cjs/embed/handoff.d.ts +7 -2
  54. package/dist/cjs/embed/handoff.js +10 -0
  55. package/dist/cjs/embed/handoff.js.map +1 -1
  56. package/dist/cjs/embed/http.d.cts +18 -1
  57. package/dist/cjs/embed/http.d.ts +18 -1
  58. package/dist/cjs/embed/http.js +239 -40
  59. package/dist/cjs/embed/http.js.map +1 -1
  60. package/dist/cjs/embed/openai.js +39 -17
  61. package/dist/cjs/embed/openai.js.map +1 -1
  62. package/dist/cjs/embed/query.d.cts +9 -3
  63. package/dist/cjs/embed/query.d.ts +9 -3
  64. package/dist/cjs/embed/query.js +257 -90
  65. package/dist/cjs/embed/query.js.map +1 -1
  66. package/dist/cjs/embed/registry.d.cts +2 -2
  67. package/dist/cjs/embed/registry.d.ts +2 -2
  68. package/dist/cjs/embed/registry.js +36 -4
  69. package/dist/cjs/embed/registry.js.map +1 -1
  70. package/dist/cjs/embed/static.js +6 -2
  71. package/dist/cjs/embed/static.js.map +1 -1
  72. package/dist/cjs/embed/store.js +42 -77
  73. package/dist/cjs/embed/store.js.map +1 -1
  74. package/dist/cjs/embed/types.d.cts +5 -2
  75. package/dist/cjs/embed/types.d.ts +5 -2
  76. package/dist/cjs/embed/types.js.map +1 -1
  77. package/dist/cjs/features/embed.js +290 -43
  78. package/dist/cjs/features/embed.js.map +1 -1
  79. package/dist/cjs/graph/traverse.d.cts +2 -2
  80. package/dist/cjs/graph/traverse.d.ts +2 -2
  81. package/dist/cjs/graph/traverse.js +15 -5
  82. package/dist/cjs/graph/traverse.js.map +1 -1
  83. package/dist/cjs/index.d.cts +2 -2
  84. package/dist/cjs/index.d.ts +2 -2
  85. package/dist/cjs/index.js +6 -0
  86. package/dist/cjs/index.js.map +1 -1
  87. package/dist/cjs/output/output.d.cts +4 -36
  88. package/dist/cjs/output/output.d.ts +4 -36
  89. package/dist/cjs/output/output.js +1 -2
  90. package/dist/cjs/output/output.js.map +1 -1
  91. package/dist/cjs/scan/pool.d.cts +2 -1
  92. package/dist/cjs/scan/pool.d.ts +2 -1
  93. package/dist/cjs/scan/pool.js +116 -27
  94. package/dist/cjs/scan/pool.js.map +1 -1
  95. package/dist/cjs/scan/reparse.d.cts +1 -0
  96. package/dist/cjs/scan/reparse.d.ts +1 -0
  97. package/dist/cjs/scan/reparse.js +75 -21
  98. package/dist/cjs/scan/reparse.js.map +1 -1
  99. package/dist/cjs/store/builder.d.cts +11 -21
  100. package/dist/cjs/store/builder.d.ts +11 -21
  101. package/dist/cjs/store/builder.js +1077 -438
  102. package/dist/cjs/store/builder.js.map +1 -1
  103. package/dist/cjs/store/duckdb/connection.js +16 -2
  104. package/dist/cjs/store/duckdb/connection.js.map +1 -1
  105. package/dist/cjs/store/duckdb/open.d.cts +1 -1
  106. package/dist/cjs/store/duckdb/open.d.ts +1 -1
  107. package/dist/cjs/store/duckdb/open.js +73 -65
  108. package/dist/cjs/store/duckdb/open.js.map +1 -1
  109. package/dist/cjs/store/duckdb/reconcile.js +533 -15
  110. package/dist/cjs/store/duckdb/reconcile.js.map +1 -1
  111. package/dist/cjs/store/embed-scope.js +19 -9
  112. package/dist/cjs/store/embed-scope.js.map +1 -1
  113. package/dist/cjs/store/index.d.cts +6 -0
  114. package/dist/cjs/store/index.d.ts +6 -0
  115. package/dist/cjs/store/index.js +8 -4
  116. package/dist/cjs/store/index.js.map +1 -1
  117. package/dist/cjs/store/open.d.cts +6 -1
  118. package/dist/cjs/store/open.d.ts +6 -1
  119. package/dist/cjs/store/open.js +230 -307
  120. package/dist/cjs/store/open.js.map +1 -1
  121. package/dist/cjs/store/readiness.d.cts +5 -0
  122. package/dist/cjs/store/readiness.d.ts +5 -0
  123. package/dist/cjs/store/readiness.js +39 -0
  124. package/dist/cjs/store/readiness.js.map +1 -0
  125. package/dist/cjs/store/reconcile.d.cts +26 -1
  126. package/dist/cjs/store/reconcile.d.ts +26 -1
  127. package/dist/cjs/store/reconcile.js +670 -576
  128. package/dist/cjs/store/reconcile.js.map +1 -1
  129. package/dist/cjs/store/signature.d.cts +1 -0
  130. package/dist/cjs/store/signature.d.ts +1 -0
  131. package/dist/cjs/store/signature.js +9 -0
  132. package/dist/cjs/store/signature.js.map +1 -1
  133. package/dist/cjs/store/sqlite/open.d.cts +1 -1
  134. package/dist/cjs/store/sqlite/open.d.ts +1 -1
  135. package/dist/cjs/store/sqlite/open.js +84 -90
  136. package/dist/cjs/store/sqlite/open.js.map +1 -1
  137. package/dist/cjs/store/sqlite/reconcile.js.map +1 -1
  138. package/dist/cjs/store/sqlite/store.js +63 -60
  139. package/dist/cjs/store/sqlite/store.js.map +1 -1
  140. package/dist/cjs/store/sqlite/vectors.d.cts +2 -2
  141. package/dist/cjs/store/sqlite/vectors.d.ts +2 -2
  142. package/dist/cjs/store/sqlite/vectors.js +8 -4
  143. package/dist/cjs/store/sqlite/vectors.js.map +1 -1
  144. package/dist/cjs/store/stages.js.map +1 -1
  145. package/dist/cjs/store/turso/connection.d.cts +1 -0
  146. package/dist/cjs/store/turso/connection.d.ts +1 -0
  147. package/dist/cjs/store/turso/connection.js +319 -94
  148. package/dist/cjs/store/turso/connection.js.map +1 -1
  149. package/dist/cjs/store/turso/open.d.cts +1 -1
  150. package/dist/cjs/store/turso/open.d.ts +1 -1
  151. package/dist/cjs/store/turso/open.js +70 -74
  152. package/dist/cjs/store/turso/open.js.map +1 -1
  153. package/dist/cjs/store/turso/store.js +25 -23
  154. package/dist/cjs/store/turso/store.js.map +1 -1
  155. package/dist/cjs/store/turso/vectors.d.cts +2 -2
  156. package/dist/cjs/store/turso/vectors.d.ts +2 -2
  157. package/dist/cjs/store/turso/vectors.js +26 -16
  158. package/dist/cjs/store/turso/vectors.js.map +1 -1
  159. package/dist/cjs/store/types.d.cts +4 -1
  160. package/dist/cjs/store/types.d.ts +4 -1
  161. package/dist/cjs/store/types.js.map +1 -1
  162. package/dist/cjs/store/vectors.d.cts +14 -1
  163. package/dist/cjs/store/vectors.d.ts +14 -1
  164. package/dist/cjs/store/vectors.js +61 -0
  165. package/dist/cjs/store/vectors.js.map +1 -1
  166. package/dist/cjs/watch.d.cts +6 -0
  167. package/dist/cjs/watch.d.ts +6 -0
  168. package/dist/cjs/watch.js +42 -10
  169. package/dist/cjs/watch.js.map +1 -1
  170. package/dist/cjs/workers/parse.d.cts +4 -3
  171. package/dist/cjs/workers/parse.d.ts +4 -3
  172. package/dist/cjs/workers/parse.js +19 -17
  173. package/dist/cjs/workers/parse.js.map +1 -1
  174. package/dist/esm/cli/index.d.ts +1 -1
  175. package/dist/esm/cli/index.js +1 -1
  176. package/dist/esm/cli/index.js.map +1 -1
  177. package/dist/esm/cli/path.js +4 -10
  178. package/dist/esm/cli/path.js.map +1 -1
  179. package/dist/esm/cli/related.js +5 -3
  180. package/dist/esm/cli/related.js.map +1 -1
  181. package/dist/esm/commands/index.d.ts +6 -3
  182. package/dist/esm/commands/index.js +1 -0
  183. package/dist/esm/commands/index.js.map +1 -1
  184. package/dist/esm/commands/map.d.ts +14 -5
  185. package/dist/esm/commands/map.js +2 -0
  186. package/dist/esm/commands/map.js.map +1 -1
  187. package/dist/esm/commands/path.d.ts +14 -0
  188. package/dist/esm/commands/path.js +33 -0
  189. package/dist/esm/commands/path.js.map +1 -0
  190. package/dist/esm/commands/peek.d.ts +16 -1
  191. package/dist/esm/commands/peek.js +35 -9
  192. package/dist/esm/commands/peek.js.map +1 -1
  193. package/dist/esm/commands/related.d.ts +16 -3
  194. package/dist/esm/commands/related.js +45 -28
  195. package/dist/esm/commands/related.js.map +1 -1
  196. package/dist/esm/commands/scope.d.ts +1 -0
  197. package/dist/esm/commands/scope.js +58 -0
  198. package/dist/esm/commands/scope.js.map +1 -1
  199. package/dist/esm/commands/search.d.ts +26 -3
  200. package/dist/esm/commands/search.js +85 -18
  201. package/dist/esm/commands/search.js.map +1 -1
  202. package/dist/esm/commands/signals.d.ts +4 -3
  203. package/dist/esm/commands/signals.js +11 -4
  204. package/dist/esm/commands/signals.js.map +1 -1
  205. package/dist/esm/commands/snapshot.d.ts +3 -0
  206. package/dist/esm/commands/snapshot.js +25 -0
  207. package/dist/esm/commands/snapshot.js.map +1 -0
  208. package/dist/esm/embed/cohere.js +35 -10
  209. package/dist/esm/embed/cohere.js.map +1 -1
  210. package/dist/esm/embed/endpoint.d.ts +2 -0
  211. package/dist/esm/embed/endpoint.js +11 -0
  212. package/dist/esm/embed/endpoint.js.map +1 -0
  213. package/dist/esm/embed/handoff.d.ts +7 -2
  214. package/dist/esm/embed/handoff.js +7 -0
  215. package/dist/esm/embed/handoff.js.map +1 -1
  216. package/dist/esm/embed/http.d.ts +18 -1
  217. package/dist/esm/embed/http.js +137 -17
  218. package/dist/esm/embed/http.js.map +1 -1
  219. package/dist/esm/embed/openai.js +34 -12
  220. package/dist/esm/embed/openai.js.map +1 -1
  221. package/dist/esm/embed/query.d.ts +9 -3
  222. package/dist/esm/embed/query.js +98 -26
  223. package/dist/esm/embed/query.js.map +1 -1
  224. package/dist/esm/embed/registry.d.ts +2 -2
  225. package/dist/esm/embed/registry.js +34 -5
  226. package/dist/esm/embed/registry.js.map +1 -1
  227. package/dist/esm/embed/static.js +10 -2
  228. package/dist/esm/embed/static.js.map +1 -1
  229. package/dist/esm/embed/store.js +30 -21
  230. package/dist/esm/embed/store.js.map +1 -1
  231. package/dist/esm/embed/types.d.ts +5 -2
  232. package/dist/esm/embed/types.js.map +1 -1
  233. package/dist/esm/features/embed.js +82 -21
  234. package/dist/esm/features/embed.js.map +1 -1
  235. package/dist/esm/graph/traverse.d.ts +2 -2
  236. package/dist/esm/graph/traverse.js +4 -2
  237. package/dist/esm/graph/traverse.js.map +1 -1
  238. package/dist/esm/index.d.ts +2 -2
  239. package/dist/esm/index.js +1 -1
  240. package/dist/esm/index.js.map +1 -1
  241. package/dist/esm/output/output.d.ts +4 -36
  242. package/dist/esm/output/output.js +1 -2
  243. package/dist/esm/output/output.js.map +1 -1
  244. package/dist/esm/scan/pool.d.ts +2 -1
  245. package/dist/esm/scan/pool.js +80 -23
  246. package/dist/esm/scan/pool.js.map +1 -1
  247. package/dist/esm/scan/reparse.d.ts +1 -0
  248. package/dist/esm/scan/reparse.js +40 -12
  249. package/dist/esm/scan/reparse.js.map +1 -1
  250. package/dist/esm/store/builder.d.ts +11 -21
  251. package/dist/esm/store/builder.js +337 -133
  252. package/dist/esm/store/builder.js.map +1 -1
  253. package/dist/esm/store/duckdb/connection.js +9 -1
  254. package/dist/esm/store/duckdb/connection.js.map +1 -1
  255. package/dist/esm/store/duckdb/open.d.ts +1 -1
  256. package/dist/esm/store/duckdb/open.js +13 -9
  257. package/dist/esm/store/duckdb/open.js.map +1 -1
  258. package/dist/esm/store/duckdb/reconcile.js +145 -10
  259. package/dist/esm/store/duckdb/reconcile.js.map +1 -1
  260. package/dist/esm/store/embed-scope.js +16 -6
  261. package/dist/esm/store/embed-scope.js.map +1 -1
  262. package/dist/esm/store/index.d.ts +6 -0
  263. package/dist/esm/store/index.js +10 -4
  264. package/dist/esm/store/index.js.map +1 -1
  265. package/dist/esm/store/open.d.ts +6 -1
  266. package/dist/esm/store/open.js +77 -87
  267. package/dist/esm/store/open.js.map +1 -1
  268. package/dist/esm/store/readiness.d.ts +5 -0
  269. package/dist/esm/store/readiness.js +11 -0
  270. package/dist/esm/store/readiness.js.map +1 -0
  271. package/dist/esm/store/reconcile.d.ts +26 -1
  272. package/dist/esm/store/reconcile.js +142 -120
  273. package/dist/esm/store/reconcile.js.map +1 -1
  274. package/dist/esm/store/signature.d.ts +1 -0
  275. package/dist/esm/store/signature.js +8 -0
  276. package/dist/esm/store/signature.js.map +1 -1
  277. package/dist/esm/store/sqlite/open.d.ts +1 -1
  278. package/dist/esm/store/sqlite/open.js +12 -12
  279. package/dist/esm/store/sqlite/open.js.map +1 -1
  280. package/dist/esm/store/sqlite/reconcile.js +2 -2
  281. package/dist/esm/store/sqlite/reconcile.js.map +1 -1
  282. package/dist/esm/store/sqlite/store.js +21 -18
  283. package/dist/esm/store/sqlite/store.js.map +1 -1
  284. package/dist/esm/store/sqlite/vectors.d.ts +2 -2
  285. package/dist/esm/store/sqlite/vectors.js +7 -5
  286. package/dist/esm/store/sqlite/vectors.js.map +1 -1
  287. package/dist/esm/store/stages.js.map +1 -1
  288. package/dist/esm/store/turso/connection.d.ts +1 -0
  289. package/dist/esm/store/turso/connection.js +97 -28
  290. package/dist/esm/store/turso/connection.js.map +1 -1
  291. package/dist/esm/store/turso/open.d.ts +1 -1
  292. package/dist/esm/store/turso/open.js +9 -8
  293. package/dist/esm/store/turso/open.js.map +1 -1
  294. package/dist/esm/store/turso/store.js +16 -14
  295. package/dist/esm/store/turso/store.js.map +1 -1
  296. package/dist/esm/store/turso/vectors.d.ts +2 -2
  297. package/dist/esm/store/turso/vectors.js +27 -17
  298. package/dist/esm/store/turso/vectors.js.map +1 -1
  299. package/dist/esm/store/types.d.ts +4 -1
  300. package/dist/esm/store/types.js.map +1 -1
  301. package/dist/esm/store/vectors.d.ts +14 -1
  302. package/dist/esm/store/vectors.js +55 -0
  303. package/dist/esm/store/vectors.js.map +1 -1
  304. package/dist/esm/watch.d.ts +6 -0
  305. package/dist/esm/watch.js +40 -14
  306. package/dist/esm/watch.js.map +1 -1
  307. package/dist/esm/workers/parse.d.ts +4 -3
  308. package/dist/esm/workers/parse.js +19 -17
  309. package/dist/esm/workers/parse.js.map +1 -1
  310. package/package.json +1 -1
  311. package/skills/sense/SKILL.md +4 -2
  312. package/skills/sense/references/stores/duckdb.md +1 -1
  313. package/skills/sense-setup/SKILL.md +2 -2
  314. package/skills/sense-setup/references/embeddings.md +1 -1
  315. package/skills/sense-setup/references/store-benchmarks.md +5 -5
  316. package/skills/sense-setup/references/stores/duckdb.md +1 -1
@@ -8,17 +8,35 @@ Object.defineProperty(exports, "createBuilder", {
8
8
  return createBuilder;
9
9
  }
10
10
  });
11
+ var _nodediagnostics_channel = require("node:diagnostics_channel");
11
12
  var _indexts = require("../config/index.js");
13
+ var _errorsts = require("../errors.js");
12
14
  var _embedts = require("../features/embed.js");
13
15
  var _indexts1 = require("../features/index.js");
14
16
  var _rankts = require("../features/rank.js");
15
17
  var _indexts2 = require("../scan/index.js");
16
18
  var _poolts = require("../scan/pool.js");
17
19
  var _reparsets = require("../scan/reparse.js");
20
+ var _embedscopets = require("./embed-scope.js");
18
21
  var _featurescopets = require("./feature-scope.js");
22
+ var _presetscopets = require("./preset-scope.js");
23
+ var _readinessts = require("./readiness.js");
19
24
  var _reconcilets = require("./reconcile.js");
20
25
  var _sharedts = require("./shared.js");
26
+ var _signaturets = require("./signature.js");
21
27
  var _transactionts = require("./transaction.js");
28
+ function _array_like_to_array(arr, len) {
29
+ if (len == null || len > arr.length) len = arr.length;
30
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
31
+ return arr2;
32
+ }
33
+ function _array_without_holes(arr) {
34
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
35
+ }
36
+ function _assert_this_initialized(self) {
37
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
38
+ return self;
39
+ }
22
40
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
23
41
  try {
24
42
  var info = gen[key](arg);
@@ -45,6 +63,87 @@ function _async_to_generator(fn) {
45
63
  });
46
64
  };
47
65
  }
66
+ function _call_super(_this, derived, args) {
67
+ derived = _get_prototype_of(derived);
68
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
69
+ }
70
+ function _class_call_check(instance, Constructor) {
71
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
72
+ }
73
+ function _construct(Parent, args, Class) {
74
+ if (_is_native_reflect_construct()) _construct = Reflect.construct;
75
+ else {
76
+ _construct = function construct(Parent, args, Class) {
77
+ var a = [
78
+ null
79
+ ];
80
+ a.push.apply(a, args);
81
+ var Constructor = Function.bind.apply(Parent, a);
82
+ var instance = new Constructor();
83
+ if (Class) _set_prototype_of(instance, Class.prototype);
84
+ return instance;
85
+ };
86
+ }
87
+ return _construct.apply(null, arguments);
88
+ }
89
+ function _get_prototype_of(o) {
90
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
91
+ return o.__proto__ || Object.getPrototypeOf(o);
92
+ };
93
+ return _get_prototype_of(o);
94
+ }
95
+ function _inherits(subClass, superClass) {
96
+ if (typeof superClass !== "function" && superClass !== null) {
97
+ throw new TypeError("Super expression must either be null or a function");
98
+ }
99
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
100
+ constructor: {
101
+ value: subClass,
102
+ writable: true,
103
+ configurable: true
104
+ }
105
+ });
106
+ if (superClass) _set_prototype_of(subClass, superClass);
107
+ }
108
+ function _instanceof(left, right) {
109
+ "@swc/helpers - instanceof";
110
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
111
+ return !!right[Symbol.hasInstance](left);
112
+ } else return left instanceof right;
113
+ }
114
+ function _is_native_function(fn) {
115
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
116
+ }
117
+ function _is_native_reflect_construct() {
118
+ try {
119
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
120
+ } catch (_) {}
121
+ return (_is_native_reflect_construct = function() {
122
+ return !!result;
123
+ })();
124
+ }
125
+ function _iterable_to_array(iter) {
126
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
127
+ return Array.from(iter);
128
+ }
129
+ }
130
+ function _non_iterable_spread() {
131
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
132
+ }
133
+ function _possible_constructor_return(self, call) {
134
+ if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
135
+ return _assert_this_initialized(self);
136
+ }
137
+ function _set_prototype_of(o, p) {
138
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
139
+ o.__proto__ = p;
140
+ return o;
141
+ };
142
+ return _set_prototype_of(o, p);
143
+ }
144
+ function _to_consumable_array(arr) {
145
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
146
+ }
48
147
  function _ts_generator(thisArg, body) {
49
148
  var f, y, t, _ = {
50
149
  label: 0,
@@ -144,434 +243,482 @@ function _ts_generator(thisArg, body) {
144
243
  };
145
244
  }
146
245
  }
147
- // 'model': the provider or model name moved but chunk boundaries did not, so only the vector
148
- // values are stale. No reparse, and no table but embeddings is touched.
149
- function nullEmbedVectors(conn, dialect) {
150
- return _async_to_generator(function() {
151
- return _ts_generator(this, function(_state) {
152
- switch(_state.label){
153
- case 0:
154
- return [
155
- 4,
156
- (0, _transactionts.withTransaction)(conn, function() {
157
- return conn.exec('UPDATE embeddings SET vector = NULL, scale = NULL');
158
- }, dialect.beginMode())
159
- ];
160
- case 1:
161
- _state.sent();
162
- return [
163
- 2,
164
- {
165
- parsed: 0
166
- }
167
- ];
246
+ function _ts_values(o) {
247
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
248
+ if (m) {
249
+ return m.call(o);
250
+ }
251
+ if (o && typeof o.length === "number") {
252
+ return {
253
+ next: function() {
254
+ if (o && i >= o.length) {
255
+ o = void 0;
256
+ }
257
+ return {
258
+ value: o && o[i++],
259
+ done: !o
260
+ };
261
+ }
262
+ };
263
+ }
264
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
265
+ }
266
+ function _type_of(obj) {
267
+ "@swc/helpers - typeof";
268
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
269
+ }
270
+ function _unsupported_iterable_to_array(o, minLen) {
271
+ if (!o) return;
272
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
273
+ var n = Object.prototype.toString.call(o).slice(8, -1);
274
+ if (n === "Object" && o.constructor) n = o.constructor.name;
275
+ if (n === "Map" || n === "Set") return Array.from(n);
276
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
277
+ }
278
+ function _wrap_native_super(Class) {
279
+ var _cache = typeof Map === "function" ? new Map() : undefined;
280
+ _wrap_native_super = function(Class) {
281
+ if (Class === null || !_is_native_function(Class)) return Class;
282
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
283
+ if (typeof _cache !== "undefined") {
284
+ if (_cache.has(Class)) return _cache.get(Class);
285
+ _cache.set(Class, Wrapper);
286
+ }
287
+ function Wrapper() {
288
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
289
+ }
290
+ Wrapper.prototype = Object.create(Class.prototype, {
291
+ constructor: {
292
+ value: Wrapper,
293
+ enumerable: false,
294
+ writable: true,
295
+ configurable: true
168
296
  }
169
297
  });
170
- })();
298
+ return _set_prototype_of(Wrapper, Class);
299
+ };
300
+ return _wrap_native_super(Class);
171
301
  }
172
- // 'chunk': chunkTokens or the chunk version moved, so chunk boundaries genuinely changed. Rebuilds
173
- // every embedding row through the embed feature's own remove/store, touching no other table.
174
- function rebuildEmbeddings(conn, cfg, baseDir, dialect, pool) {
302
+ var StaleBuildPlan = /*#__PURE__*/ function(Error1) {
303
+ "use strict";
304
+ _inherits(StaleBuildPlan, Error1);
305
+ function StaleBuildPlan() {
306
+ _class_call_check(this, StaleBuildPlan);
307
+ return _call_super(this, StaleBuildPlan, arguments);
308
+ }
309
+ return StaleBuildPlan;
310
+ }(_wrap_native_super(Error));
311
+ var buildPlan = (0, _nodediagnostics_channel.channel)('sensemaking.store.build-plan');
312
+ var SCHEMA_VERSION_META_KEY = 'schema_version';
313
+ function readCoreBaseline(conn) {
175
314
  return _async_to_generator(function() {
176
- var existingStmt, existingPaths, _, files, docs, paths, delta;
315
+ var _stmt, _values_get, _values_get1, _values_get2, _values_get3, keys, stmt, values, _;
177
316
  return _ts_generator(this, function(_state) {
178
317
  switch(_state.label){
179
318
  case 0:
319
+ keys = [
320
+ SCHEMA_VERSION_META_KEY,
321
+ _readinessts.FEATURE_SIGNATURE_META_KEY,
322
+ _readinessts.CORE_READY_META_KEY,
323
+ _readinessts.CORE_GENERATION_META_KEY
324
+ ];
180
325
  return [
181
326
  4,
182
- conn.prepare('SELECT "path" FROM frontmatter')
327
+ conn.prepare("SELECT key, value FROM meta WHERE key IN (".concat(keys.map(function() {
328
+ return '?';
329
+ }).join(', '), ")"))
183
330
  ];
184
331
  case 1:
185
- existingStmt = _state.sent();
186
- _ = Set.bind;
332
+ stmt = _state.sent();
333
+ _ = Map.bind;
187
334
  return [
188
335
  4,
189
- existingStmt.all()
336
+ (_stmt = stmt).all.apply(_stmt, _to_consumable_array(keys))
190
337
  ];
191
338
  case 2:
192
- existingPaths = new (_.apply(Set, [
339
+ values = new (_.apply(Map, [
193
340
  void 0,
194
- _state.sent().map(function(r) {
195
- return r.path;
341
+ _state.sent().map(function(row) {
342
+ return [
343
+ row.key,
344
+ row.value
345
+ ];
196
346
  })
197
347
  ]));
198
- // A file added since the last build has no row yet; leaving it for build() to insert avoids a
199
- // primary-key collision between this INSERT and build()'s own insert for the same new file.
200
- files = (0, _indexts2.listFiles)(cfg, baseDir).filter(function(f) {
201
- return f.embed && existingPaths.has(f.relPath);
202
- });
203
- if (files.length === 0) return [
204
- 2,
205
- {
206
- parsed: 0
207
- }
208
- ];
209
- return [
210
- 4,
211
- (0, _reparsets.reparseFiles)(files, [
212
- _embedts.embed
213
- ], cfg, new Set(), undefined, {
214
- pool: pool
215
- })
216
- ];
217
- case 3:
218
- docs = _state.sent().docs;
219
- paths = docs.map(function(d) {
220
- return d.relPath;
221
- });
222
- delta = {
223
- files: files,
224
- reparsed: paths,
225
- added: [],
226
- vanished: []
227
- };
228
- return [
229
- 4,
230
- (0, _transactionts.withTransaction)(conn, function() {
231
- return _async_to_generator(function() {
232
- var _embed_remove, _embed_store;
233
- return _ts_generator(this, function(_state) {
234
- switch(_state.label){
235
- case 0:
236
- return [
237
- 4,
238
- (_embed_remove = _embedts.embed.remove) === null || _embed_remove === void 0 ? void 0 : _embed_remove.call(_embedts.embed, conn, paths, delta)
239
- ];
240
- case 1:
241
- _state.sent();
242
- return [
243
- 4,
244
- (_embed_store = _embedts.embed.store) === null || _embed_store === void 0 ? void 0 : _embed_store.call(_embedts.embed, conn, docs.map(function(d) {
245
- return {
246
- path: d.relPath,
247
- extracted: d.extracted.embed
248
- };
249
- }), delta)
250
- ];
251
- case 2:
252
- _state.sent();
253
- return [
254
- 2
255
- ];
256
- }
257
- });
258
- })();
259
- }, dialect.beginMode())
260
- ];
261
- case 4:
262
- _state.sent();
263
348
  return [
264
349
  2,
265
350
  {
266
- parsed: docs.length
351
+ schemaVersion: (_values_get = values.get(SCHEMA_VERSION_META_KEY)) !== null && _values_get !== void 0 ? _values_get : null,
352
+ features: (_values_get1 = values.get(_readinessts.FEATURE_SIGNATURE_META_KEY)) !== null && _values_get1 !== void 0 ? _values_get1 : null,
353
+ ready: (_values_get2 = values.get(_readinessts.CORE_READY_META_KEY)) !== null && _values_get2 !== void 0 ? _values_get2 : null,
354
+ generation: (_values_get3 = values.get(_readinessts.CORE_GENERATION_META_KEY)) !== null && _values_get3 !== void 0 ? _values_get3 : null
267
355
  }
268
356
  ];
269
357
  }
270
358
  });
271
359
  })();
272
360
  }
273
- // One feature's own table, dropped and (turning on) fully re-derived across every indexed file.
274
- // Rows left over from before this feature was disabled are untrustworthy by construction (files
275
- // added, edited, or deleted got no remove/store for it), so this never diffs against them --
276
- // dropping every row and reparsing the whole tree is the only safe path back to consistent state.
277
- function invalidateFeatureTable(conn, cfg, baseDir, dialect, pool, toggle) {
361
+ function sameBaseline(a, b) {
362
+ return a.schemaVersion === b.schemaVersion && a.features === b.features && a.ready === b.ready && a.generation === b.generation;
363
+ }
364
+ function nextGeneration(value) {
365
+ var current = value === null ? 0 : Number(value);
366
+ if (!Number.isSafeInteger(current) || current < 0 || current === Number.MAX_SAFE_INTEGER) throw new _errorsts.SenseError('INDEX_NOT_READY', "the durable core generation is invalid (".concat(value !== null && value !== void 0 ? value : 'missing', "); run sense build --force to recreate the derived index"));
367
+ return String(current + 1);
368
+ }
369
+ function readPlanningSnapshot(conn, timing) {
370
+ return _async_to_generator(function() {
371
+ return _ts_generator(this, function(_state) {
372
+ return [
373
+ 2,
374
+ (0, _transactionts.withTransaction)(conn, function() {
375
+ return _async_to_generator(function() {
376
+ var baseline, reconcile, tablesStmt, tables, _;
377
+ return _ts_generator(this, function(_state) {
378
+ switch(_state.label){
379
+ case 0:
380
+ return [
381
+ 4,
382
+ readCoreBaseline(conn)
383
+ ];
384
+ case 1:
385
+ baseline = _state.sent();
386
+ return [
387
+ 4,
388
+ (0, _reconcilets.readReconcileSnapshot)(conn, timing)
389
+ ];
390
+ case 2:
391
+ reconcile = _state.sent();
392
+ return [
393
+ 4,
394
+ conn.prepare("SELECT name FROM sqlite_master WHERE type = 'table'")
395
+ ];
396
+ case 3:
397
+ tablesStmt = _state.sent();
398
+ _ = Set.bind;
399
+ return [
400
+ 4,
401
+ tablesStmt.all()
402
+ ];
403
+ case 4:
404
+ tables = new (_.apply(Set, [
405
+ void 0,
406
+ _state.sent().map(function(row) {
407
+ return row.name;
408
+ })
409
+ ]));
410
+ return [
411
+ 2,
412
+ {
413
+ baseline: baseline,
414
+ reconcile: reconcile,
415
+ tables: tables
416
+ }
417
+ ];
418
+ }
419
+ });
420
+ })();
421
+ })
422
+ ];
423
+ });
424
+ })();
425
+ }
426
+ function activeSchemaMissing(snapshot, cfg) {
427
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
428
+ try {
429
+ for(var _iterator = _indexts1.FEATURES[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
430
+ var feature = _step.value;
431
+ if (!(0, _indexts.featureEnabled)(cfg, feature.name)) continue;
432
+ if (feature.name === 'rank') {
433
+ if (!snapshot.reconcile.seenColumns.has('_rank')) return true;
434
+ continue;
435
+ }
436
+ var table = feature.name === 'embed' ? 'embeddings' : _featurescopets.NARROW_FEATURE_TABLE[feature.name];
437
+ if (table && !snapshot.tables.has(table)) return true;
438
+ }
439
+ } catch (err) {
440
+ _didIteratorError = true;
441
+ _iteratorError = err;
442
+ } finally{
443
+ try {
444
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
445
+ _iterator.return();
446
+ }
447
+ } finally{
448
+ if (_didIteratorError) {
449
+ throw _iteratorError;
450
+ }
451
+ }
452
+ }
453
+ return false;
454
+ }
455
+ function classifyBuild(snapshot, cfg, paths, wanted) {
456
+ var before = snapshot.baseline.features;
457
+ var recover = snapshot.baseline.ready === '0';
458
+ var messages = [];
459
+ if (recover) messages.push('sense: recovering an incomplete index generation in place');
460
+ if (!recover && before !== null && before === wanted && activeSchemaMissing(snapshot, cfg)) {
461
+ messages.push('sense: recovering missing feature schema in place');
462
+ return {
463
+ embedKind: null,
464
+ featureToggles: [],
465
+ fullRebuild: true,
466
+ messages: messages
467
+ };
468
+ }
469
+ if (recover || before === null || before === wanted) return {
470
+ embedKind: null,
471
+ featureToggles: [],
472
+ fullRebuild: recover,
473
+ messages: messages
474
+ };
475
+ var changedKeys = (0, _signaturets.changedSignatureKeys)(before, wanted);
476
+ if (changedKeys.size === 1 && changedKeys.has('embed') && (0, _signaturets.embedIdentityAdopted)(before, wanted)) {
477
+ messages.push("sense: recorded the embedding model's resolved identity; vectors are unaffected");
478
+ return {
479
+ embedKind: null,
480
+ featureToggles: [],
481
+ fullRebuild: false,
482
+ messages: messages
483
+ };
484
+ }
485
+ var embedKind = changedKeys.size === 1 && changedKeys.has('embed') ? (0, _embedscopets.classifyEmbedChange)(before, wanted) : null;
486
+ if (embedKind !== null) {
487
+ messages.push(embedKind === 'model' ? 'sense: config change (embed settings) invalidates only the stale vectors' : 'sense: config change (embed settings) rebuilds only the embeddings it affects');
488
+ return {
489
+ embedKind: embedKind,
490
+ featureToggles: [],
491
+ fullRebuild: false,
492
+ messages: messages
493
+ };
494
+ }
495
+ var presetForced = (0, _presetscopets.isPresetOnlyChange)(changedKeys) ? (0, _presetscopets.forcedPresetPaths)(cfg, paths.rootDir, before, changedKeys) : null;
496
+ if (presetForced !== null) {
497
+ messages.push("sense: config change (".concat((0, _signaturets.signatureDiff)(before, wanted), ") reparses only the files it affects"));
498
+ return {
499
+ embedKind: null,
500
+ featureToggles: [],
501
+ forcedPaths: presetForced,
502
+ fullRebuild: false,
503
+ messages: messages
504
+ };
505
+ }
506
+ var toggles = (0, _featurescopets.isFeatureOnlyChange)(changedKeys) ? (0, _featurescopets.classifyFeatureToggles)(before, wanted, changedKeys) : null;
507
+ if (toggles !== null) {
508
+ messages.push("sense: config change (".concat((0, _signaturets.signatureDiff)(before, wanted), ") reparses only the feature it affects"));
509
+ return {
510
+ embedKind: null,
511
+ featureToggles: toggles,
512
+ fullRebuild: false,
513
+ messages: messages
514
+ };
515
+ }
516
+ messages.push("sense: config change (".concat((0, _signaturets.signatureDiff)(before, wanted), ") rebuilds the index"));
517
+ return {
518
+ embedKind: null,
519
+ featureToggles: [],
520
+ fullRebuild: true,
521
+ messages: messages
522
+ };
523
+ }
524
+ function prepareEmbedInvalidation(kind, snapshot, cfg, paths, pool) {
278
525
  return _async_to_generator(function() {
279
- var table, feature, files, docs, docsForFeature, paths, delta;
526
+ var existing, files, docs, pathsChanged, delta;
280
527
  return _ts_generator(this, function(_state) {
281
528
  switch(_state.label){
282
529
  case 0:
283
- table = _featurescopets.NARROW_FEATURE_TABLE[toggle.name];
284
- feature = _indexts1.FEATURES.find(function(f) {
285
- return f.name === toggle.name;
530
+ if (kind === 'model') {
531
+ return [
532
+ 2,
533
+ {
534
+ mutated: true,
535
+ parsed: 0,
536
+ apply: function apply(conn) {
537
+ return conn.exec('UPDATE embeddings SET vector = NULL, scale = NULL');
538
+ }
539
+ }
540
+ ];
541
+ }
542
+ existing = new Set(snapshot.reconcile.existingRows.map(function(row) {
543
+ return row.path;
544
+ }));
545
+ files = (0, _indexts2.listFiles)(cfg, paths.rootDir).filter(function(file) {
546
+ return file.embed && existing.has(file.relPath);
286
547
  });
287
- if (!feature) throw new Error('invalidateFeatureTable: no registered feature named "'.concat(toggle.name, '"'));
288
- if (!!toggle.turnedOn) return [
289
- 3,
290
- 2
291
- ];
292
- return [
293
- 4,
294
- (0, _transactionts.withTransaction)(conn, function() {
295
- return conn.exec("DELETE FROM ".concat(table));
296
- }, dialect.beginMode())
297
- ];
298
- case 1:
299
- _state.sent();
300
- return [
301
- 2,
302
- {
303
- parsed: 0
304
- }
305
- ];
306
- case 2:
307
- files = (0, _indexts2.listFiles)(cfg, baseDir);
308
548
  return [
309
549
  4,
310
550
  (0, _reparsets.reparseFiles)(files, [
311
- feature
551
+ _embedts.embed
312
552
  ], cfg, new Set(), undefined, {
313
553
  pool: pool
314
554
  })
315
555
  ];
316
- case 3:
556
+ case 1:
317
557
  docs = _state.sent().docs;
318
- docsForFeature = docs.map(function(d) {
319
- return {
320
- path: d.relPath,
321
- extracted: d.extracted[feature.name]
322
- };
323
- });
324
- paths = docs.map(function(d) {
325
- return d.relPath;
558
+ pathsChanged = docs.map(function(doc) {
559
+ return doc.relPath;
326
560
  });
327
- // Every path counts as added, not just touched: nothing stale to diff against. Links resolves
328
- // dst inside store() itself when added.length equals files.length (a cold build).
329
561
  delta = {
330
562
  files: files,
331
- reparsed: paths,
332
- added: paths,
563
+ reparsed: pathsChanged,
564
+ added: [],
333
565
  vanished: []
334
566
  };
335
- return [
336
- 4,
337
- (0, _transactionts.withTransaction)(conn, function() {
338
- return _async_to_generator(function() {
339
- var _feature_store, _feature_afterReconcile;
340
- return _ts_generator(this, function(_state) {
341
- switch(_state.label){
342
- case 0:
343
- return [
344
- 4,
345
- conn.exec("DELETE FROM ".concat(table))
346
- ];
347
- case 1:
348
- _state.sent();
349
- return [
350
- 4,
351
- (_feature_store = feature.store) === null || _feature_store === void 0 ? void 0 : _feature_store.call(feature, conn, docsForFeature, delta)
352
- ];
353
- case 2:
354
- _state.sent();
355
- return [
356
- 4,
357
- (_feature_afterReconcile = feature.afterReconcile) === null || _feature_afterReconcile === void 0 ? void 0 : _feature_afterReconcile.call(feature, conn, delta)
358
- ];
359
- case 3:
360
- _state.sent();
361
- return [
362
- 2
363
- ];
364
- }
365
- });
366
- })();
367
- }, dialect.beginMode())
368
- ];
369
- case 4:
370
- _state.sent();
371
567
  return [
372
568
  2,
373
569
  {
374
- parsed: docs.length
570
+ mutated: true,
571
+ parsed: docs.length,
572
+ apply: function apply(conn) {
573
+ return _async_to_generator(function() {
574
+ var _embed_store;
575
+ return _ts_generator(this, function(_state) {
576
+ switch(_state.label){
577
+ case 0:
578
+ if (!(pathsChanged.length > 0)) return [
579
+ 3,
580
+ 2
581
+ ];
582
+ return [
583
+ 4,
584
+ conn.runBatch('DELETE FROM embeddings WHERE "path" = ?', pathsChanged.map(function(path) {
585
+ return [
586
+ path
587
+ ];
588
+ }))
589
+ ];
590
+ case 1:
591
+ _state.sent();
592
+ _state.label = 2;
593
+ case 2:
594
+ return [
595
+ 4,
596
+ (_embed_store = _embedts.embed.store) === null || _embed_store === void 0 ? void 0 : _embed_store.call(_embedts.embed, conn, docs.map(function(doc) {
597
+ return {
598
+ path: doc.relPath,
599
+ extracted: doc.extracted.embed
600
+ };
601
+ }), delta)
602
+ ];
603
+ case 3:
604
+ _state.sent();
605
+ return [
606
+ 2
607
+ ];
608
+ }
609
+ });
610
+ })();
611
+ }
375
612
  }
376
613
  ];
377
614
  }
378
615
  });
379
616
  })();
380
617
  }
381
- // rank has no table of its own: frontmatter._rank is the only state it owns. Guarded on column
382
- // presence, since links can toggle off while rank has never been enabled for this tree.
383
- function nullRank(conn, dialect) {
384
- return _async_to_generator(function() {
385
- var columns;
386
- return _ts_generator(this, function(_state) {
387
- switch(_state.label){
388
- case 0:
389
- return [
390
- 4,
391
- (0, _sharedts.getColumns)(conn)
392
- ];
393
- case 1:
394
- columns = _state.sent();
395
- if (!columns.has('_rank')) return [
396
- 2
397
- ];
398
- return [
399
- 4,
400
- (0, _transactionts.withTransaction)(conn, function() {
401
- return conn.exec('UPDATE frontmatter SET "_rank" = NULL');
402
- }, dialect.beginMode())
403
- ];
404
- case 2:
405
- _state.sent();
406
- return [
407
- 2
408
- ];
409
- }
410
- });
411
- })();
412
- }
413
- // Whole-tree and reparse-free: PageRank is computed from the links table, not from files, so
414
- // turning rank back on needs no reparseFiles pass at all.
415
- function rerunRank(conn, dialect) {
618
+ function prepareFeatureInvalidation(toggles, snapshot, cfg, paths, pool) {
416
619
  return _async_to_generator(function() {
417
- var delta;
620
+ var prepared, parsed, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, err, applyTable, nullRank;
418
621
  return _ts_generator(this, function(_state) {
419
622
  switch(_state.label){
420
623
  case 0:
421
- delta = {
422
- files: [],
423
- reparsed: [],
424
- added: [],
425
- vanished: []
426
- };
427
- return [
428
- 4,
429
- (0, _transactionts.withTransaction)(conn, function() {
430
- return _async_to_generator(function() {
431
- var _rank_afterReconcile;
432
- return _ts_generator(this, function(_state) {
433
- switch(_state.label){
434
- case 0:
435
- return [
436
- 4,
437
- (_rank_afterReconcile = _rankts.rank.afterReconcile) === null || _rank_afterReconcile === void 0 ? void 0 : _rank_afterReconcile.call(_rankts.rank, conn, delta)
438
- ];
439
- case 1:
440
- _state.sent();
441
- return [
442
- 2
443
- ];
444
- }
445
- });
446
- })();
447
- }, dialect.beginMode())
448
- ];
449
- case 1:
450
- _state.sent();
451
- return [
452
- 2
624
+ if (toggles.length === 0) return [
625
+ 2,
626
+ {
627
+ mutated: false,
628
+ parsed: 0,
629
+ apply: function apply() {
630
+ return _async_to_generator(function() {
631
+ return _ts_generator(this, function(_state) {
632
+ return [
633
+ 2
634
+ ];
635
+ });
636
+ })();
637
+ }
638
+ }
453
639
  ];
454
- }
455
- });
456
- })();
457
- }
458
- function invalidateFeatureToggles(conn, cfg, baseDir, dialect, pool, toggles) {
459
- return _async_to_generator(function() {
460
- var byName, parsed, linksToggle, rankToggle, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, toggle, err;
461
- return _ts_generator(this, function(_state) {
462
- switch(_state.label){
463
- case 0:
464
- byName = new Map(toggles.map(function(toggle) {
465
- return [
466
- toggle.name,
467
- toggle
468
- ];
469
- }));
640
+ prepared = new Map();
470
641
  parsed = 0;
471
- // links first, if present: rank's rerun below (whether from its own toggle or the co-change
472
- // rankToggle carries) must read the links table after it is back in its new state.
473
- linksToggle = byName.get('links');
474
- if (!linksToggle) return [
475
- 3,
476
- 3
477
- ];
478
- return [
479
- 4,
480
- invalidateFeatureTable(conn, cfg, baseDir, dialect, pool, linksToggle)
481
- ];
482
- case 1:
483
- parsed = parsed + _state.sent().parsed;
484
- if (!!linksToggle.turnedOn) return [
485
- 3,
486
- 3
487
- ];
488
- return [
489
- 4,
490
- nullRank(conn, dialect)
491
- ];
492
- case 2:
493
- _state.sent();
494
- _state.label = 3;
495
- case 3:
496
- // rank's effective on/off (featureEnabled's links dependency) only appears as a changed
497
- // `feature:rank` segment when it actually flips -- whether that's rank's own config or a
498
- // links toggle taking it along -- so honoring it here is complete on its own.
499
- rankToggle = byName.get('rank');
500
- if (!rankToggle) return [
501
- 3,
502
- 7
503
- ];
504
- if (!rankToggle.turnedOn) return [
505
- 3,
506
- 5
507
- ];
508
- return [
509
- 4,
510
- rerunRank(conn, dialect)
511
- ];
512
- case 4:
513
- _state.sent();
514
- return [
515
- 3,
516
- 7
517
- ];
518
- case 5:
519
- return [
520
- 4,
521
- nullRank(conn, dialect)
522
- ];
523
- case 6:
524
- _state.sent();
525
- _state.label = 7;
526
- case 7:
527
642
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
528
- _state.label = 8;
529
- case 8:
643
+ _state.label = 1;
644
+ case 1:
530
645
  _state.trys.push([
531
- 8,
532
- 13,
533
- 14,
534
- 15
646
+ 1,
647
+ 6,
648
+ 7,
649
+ 8
535
650
  ]);
651
+ _loop = function() {
652
+ var toggle, feature, files, docs;
653
+ return _ts_generator(this, function(_state) {
654
+ switch(_state.label){
655
+ case 0:
656
+ toggle = _step.value;
657
+ if (!toggle.turnedOn || toggle.name === 'rank') return [
658
+ 2,
659
+ "continue"
660
+ ];
661
+ feature = _indexts1.FEATURES.find(function(candidate) {
662
+ return candidate.name === toggle.name;
663
+ });
664
+ if (!feature) throw new Error('prepareFeatureInvalidation: no registered feature named "'.concat(toggle.name, '"'));
665
+ files = (0, _indexts2.listFiles)(cfg, paths.rootDir);
666
+ return [
667
+ 4,
668
+ (0, _reparsets.reparseFiles)(files, [
669
+ feature
670
+ ], cfg, new Set(), undefined, {
671
+ pool: pool
672
+ })
673
+ ];
674
+ case 1:
675
+ docs = _state.sent().docs;
676
+ parsed += docs.length;
677
+ prepared.set(toggle.name, {
678
+ feature: feature,
679
+ docs: docs,
680
+ files: files
681
+ });
682
+ return [
683
+ 2
684
+ ];
685
+ }
686
+ });
687
+ };
536
688
  _iterator = toggles[Symbol.iterator]();
537
- _state.label = 9;
538
- case 9:
689
+ _state.label = 2;
690
+ case 2:
539
691
  if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
540
692
  3,
541
- 12
542
- ];
543
- toggle = _step.value;
544
- if (toggle.name === 'links' || toggle.name === 'rank') return [
545
- 3,
546
- 11
693
+ 5
547
694
  ];
548
695
  return [
549
- 4,
550
- invalidateFeatureTable(conn, cfg, baseDir, dialect, pool, toggle)
696
+ 5,
697
+ _ts_values(_loop())
551
698
  ];
552
- case 10:
553
- parsed = parsed + _state.sent().parsed;
554
- _state.label = 11;
555
- case 11:
699
+ case 3:
700
+ _state.sent();
701
+ _state.label = 4;
702
+ case 4:
556
703
  _iteratorNormalCompletion = true;
557
704
  return [
558
705
  3,
559
- 9
706
+ 2
560
707
  ];
561
- case 12:
708
+ case 5:
562
709
  return [
563
710
  3,
564
- 15
711
+ 8
565
712
  ];
566
- case 13:
713
+ case 6:
567
714
  err = _state.sent();
568
715
  _didIteratorError = true;
569
716
  _iteratorError = err;
570
717
  return [
571
718
  3,
572
- 15
719
+ 8
573
720
  ];
574
- case 14:
721
+ case 7:
575
722
  try {
576
723
  if (!_iteratorNormalCompletion && _iterator.return != null) {
577
724
  _iterator.return();
@@ -584,157 +731,649 @@ function invalidateFeatureToggles(conn, cfg, baseDir, dialect, pool, toggles) {
584
731
  return [
585
732
  7
586
733
  ];
587
- case 15:
734
+ case 8:
735
+ applyTable = function applyTable(conn, toggle) {
736
+ return _async_to_generator(function() {
737
+ var _plan_feature_store, _plan_feature, _plan_feature_afterReconcile, _plan_feature1, table, plan, pathsChanged, delta;
738
+ return _ts_generator(this, function(_state) {
739
+ switch(_state.label){
740
+ case 0:
741
+ table = _featurescopets.NARROW_FEATURE_TABLE[toggle.name];
742
+ if (!table) return [
743
+ 2
744
+ ];
745
+ if (!!toggle.turnedOn) return [
746
+ 3,
747
+ 3
748
+ ];
749
+ if (!snapshot.tables.has(table)) return [
750
+ 3,
751
+ 2
752
+ ];
753
+ return [
754
+ 4,
755
+ conn.exec("DELETE FROM ".concat(table))
756
+ ];
757
+ case 1:
758
+ _state.sent();
759
+ _state.label = 2;
760
+ case 2:
761
+ return [
762
+ 2
763
+ ];
764
+ case 3:
765
+ plan = prepared.get(toggle.name);
766
+ if (!plan) throw new Error('prepareFeatureInvalidation: missing prepared feature "'.concat(toggle.name, '"'));
767
+ pathsChanged = plan.docs.map(function(doc) {
768
+ return doc.relPath;
769
+ });
770
+ delta = {
771
+ files: plan.files,
772
+ reparsed: pathsChanged,
773
+ added: pathsChanged,
774
+ vanished: []
775
+ };
776
+ return [
777
+ 4,
778
+ conn.exec("DELETE FROM ".concat(table))
779
+ ];
780
+ case 4:
781
+ _state.sent();
782
+ return [
783
+ 4,
784
+ (_plan_feature_store = (_plan_feature = plan.feature).store) === null || _plan_feature_store === void 0 ? void 0 : _plan_feature_store.call(_plan_feature, conn, plan.docs.map(function(doc) {
785
+ return {
786
+ path: doc.relPath,
787
+ extracted: doc.extracted[plan.feature.name]
788
+ };
789
+ }), delta)
790
+ ];
791
+ case 5:
792
+ _state.sent();
793
+ return [
794
+ 4,
795
+ (_plan_feature_afterReconcile = (_plan_feature1 = plan.feature).afterReconcile) === null || _plan_feature_afterReconcile === void 0 ? void 0 : _plan_feature_afterReconcile.call(_plan_feature1, conn, delta)
796
+ ];
797
+ case 6:
798
+ _state.sent();
799
+ return [
800
+ 2
801
+ ];
802
+ }
803
+ });
804
+ })();
805
+ };
806
+ nullRank = function nullRank(conn) {
807
+ return _async_to_generator(function() {
808
+ return _ts_generator(this, function(_state) {
809
+ switch(_state.label){
810
+ case 0:
811
+ if (!snapshot.reconcile.seenColumns.has('_rank')) return [
812
+ 3,
813
+ 2
814
+ ];
815
+ return [
816
+ 4,
817
+ conn.exec('UPDATE frontmatter SET "_rank" = NULL')
818
+ ];
819
+ case 1:
820
+ _state.sent();
821
+ _state.label = 2;
822
+ case 2:
823
+ return [
824
+ 2
825
+ ];
826
+ }
827
+ });
828
+ })();
829
+ };
588
830
  return [
589
831
  2,
590
832
  {
591
- parsed: parsed
833
+ mutated: true,
834
+ parsed: parsed,
835
+ apply: function apply(conn) {
836
+ return _async_to_generator(function() {
837
+ var byName, linksToggle, rankToggle, _rank_afterReconcile, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, toggle, err;
838
+ return _ts_generator(this, function(_state) {
839
+ switch(_state.label){
840
+ case 0:
841
+ byName = new Map(toggles.map(function(toggle) {
842
+ return [
843
+ toggle.name,
844
+ toggle
845
+ ];
846
+ }));
847
+ linksToggle = byName.get('links');
848
+ if (!linksToggle) return [
849
+ 3,
850
+ 3
851
+ ];
852
+ return [
853
+ 4,
854
+ applyTable(conn, linksToggle)
855
+ ];
856
+ case 1:
857
+ _state.sent();
858
+ if (!!linksToggle.turnedOn) return [
859
+ 3,
860
+ 3
861
+ ];
862
+ return [
863
+ 4,
864
+ nullRank(conn)
865
+ ];
866
+ case 2:
867
+ _state.sent();
868
+ _state.label = 3;
869
+ case 3:
870
+ rankToggle = byName.get('rank');
871
+ if (!rankToggle) return [
872
+ 3,
873
+ 7
874
+ ];
875
+ if (!rankToggle.turnedOn) return [
876
+ 3,
877
+ 5
878
+ ];
879
+ return [
880
+ 4,
881
+ (_rank_afterReconcile = _rankts.rank.afterReconcile) === null || _rank_afterReconcile === void 0 ? void 0 : _rank_afterReconcile.call(_rankts.rank, conn, {
882
+ files: [],
883
+ reparsed: [],
884
+ added: [],
885
+ vanished: []
886
+ })
887
+ ];
888
+ case 4:
889
+ _state.sent();
890
+ return [
891
+ 3,
892
+ 7
893
+ ];
894
+ case 5:
895
+ return [
896
+ 4,
897
+ nullRank(conn)
898
+ ];
899
+ case 6:
900
+ _state.sent();
901
+ _state.label = 7;
902
+ case 7:
903
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
904
+ _state.label = 8;
905
+ case 8:
906
+ _state.trys.push([
907
+ 8,
908
+ 13,
909
+ 14,
910
+ 15
911
+ ]);
912
+ _iterator = toggles[Symbol.iterator]();
913
+ _state.label = 9;
914
+ case 9:
915
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
916
+ 3,
917
+ 12
918
+ ];
919
+ toggle = _step.value;
920
+ if (!(toggle.name !== 'links' && toggle.name !== 'rank')) return [
921
+ 3,
922
+ 11
923
+ ];
924
+ return [
925
+ 4,
926
+ applyTable(conn, toggle)
927
+ ];
928
+ case 10:
929
+ _state.sent();
930
+ _state.label = 11;
931
+ case 11:
932
+ _iteratorNormalCompletion = true;
933
+ return [
934
+ 3,
935
+ 9
936
+ ];
937
+ case 12:
938
+ return [
939
+ 3,
940
+ 15
941
+ ];
942
+ case 13:
943
+ err = _state.sent();
944
+ _didIteratorError = true;
945
+ _iteratorError = err;
946
+ return [
947
+ 3,
948
+ 15
949
+ ];
950
+ case 14:
951
+ try {
952
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
953
+ _iterator.return();
954
+ }
955
+ } finally{
956
+ if (_didIteratorError) {
957
+ throw _iteratorError;
958
+ }
959
+ }
960
+ return [
961
+ 7
962
+ ];
963
+ case 15:
964
+ return [
965
+ 2
966
+ ];
967
+ }
968
+ });
969
+ })();
970
+ }
592
971
  }
593
972
  ];
594
973
  }
595
974
  });
596
975
  })();
597
976
  }
598
- function recoverIncomplete(conn, cfg, paths, dialect, pool) {
977
+ function recoveryToggles(cfg, snapshot) {
978
+ var toggles = [];
979
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
980
+ try {
981
+ for(var _iterator = _indexts1.FEATURES[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
982
+ var feature = _step.value;
983
+ var table = _featurescopets.NARROW_FEATURE_TABLE[feature.name];
984
+ if (table && !(0, _indexts.featureEnabled)(cfg, feature.name) && snapshot.tables.has(table)) toggles.push({
985
+ name: feature.name,
986
+ turnedOn: false
987
+ });
988
+ }
989
+ } catch (err) {
990
+ _didIteratorError = true;
991
+ _iteratorError = err;
992
+ } finally{
993
+ try {
994
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
995
+ _iterator.return();
996
+ }
997
+ } finally{
998
+ if (_didIteratorError) {
999
+ throw _iteratorError;
1000
+ }
1001
+ }
1002
+ }
1003
+ return toggles;
1004
+ }
1005
+ function prepareInvalidation(classification, snapshot, cfg, paths, pool) {
599
1006
  return _async_to_generator(function() {
600
- var disabled, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, feature, err, toggles, embeddingsTable, forcedPaths;
1007
+ var plans, _, _1, _2;
601
1008
  return _ts_generator(this, function(_state) {
602
1009
  switch(_state.label){
603
1010
  case 0:
604
- disabled = _indexts1.FEATURES.filter(function(feature) {
605
- return !(0, _indexts.featureEnabled)(cfg, feature.name);
606
- });
607
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
608
- _state.label = 1;
1011
+ plans = [];
1012
+ if (!classification.embedKind) return [
1013
+ 3,
1014
+ 2
1015
+ ];
1016
+ _ = plans.push;
1017
+ return [
1018
+ 4,
1019
+ prepareEmbedInvalidation(classification.embedKind, snapshot, cfg, paths, pool)
1020
+ ];
609
1021
  case 1:
610
- _state.trys.push([
611
- 1,
612
- 6,
613
- 7,
614
- 8
1022
+ _.apply(plans, [
1023
+ _state.sent()
615
1024
  ]);
616
- _iterator = disabled[Symbol.iterator]();
617
1025
  _state.label = 2;
618
1026
  case 2:
619
- if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
620
- 3,
621
- 5
622
- ];
623
- feature = _step.value;
624
- if (!(feature.name !== 'embed')) return [
1027
+ if (!(classification.featureToggles.length > 0)) return [
625
1028
  3,
626
1029
  4
627
1030
  ];
1031
+ _1 = plans.push;
628
1032
  return [
629
1033
  4,
630
- feature.schema(conn)
1034
+ prepareFeatureInvalidation(classification.featureToggles, snapshot, cfg, paths, pool)
631
1035
  ];
632
1036
  case 3:
633
- _state.sent();
1037
+ _1.apply(plans, [
1038
+ _state.sent()
1039
+ ]);
634
1040
  _state.label = 4;
635
1041
  case 4:
636
- _iteratorNormalCompletion = true;
637
- return [
1042
+ if (!classification.fullRebuild) return [
638
1043
  3,
639
- 2
1044
+ 6
640
1045
  ];
641
- case 5:
1046
+ _2 = plans.push;
642
1047
  return [
643
- 3,
644
- 8
1048
+ 4,
1049
+ prepareFeatureInvalidation(recoveryToggles(cfg, snapshot), snapshot, cfg, paths, pool)
645
1050
  ];
1051
+ case 5:
1052
+ _2.apply(plans, [
1053
+ _state.sent()
1054
+ ]);
1055
+ // Full rebuild and recovery must not reuse vectors from the prior generation.
1056
+ if (snapshot.tables.has('embeddings')) {
1057
+ plans.push({
1058
+ mutated: true,
1059
+ parsed: 0,
1060
+ apply: function apply(conn) {
1061
+ return conn.exec('DELETE FROM embeddings');
1062
+ }
1063
+ });
1064
+ }
1065
+ if (!(0, _indexts.featureEnabled)(cfg, 'rank') && snapshot.reconcile.seenColumns.has('_rank')) {
1066
+ plans.push({
1067
+ mutated: true,
1068
+ parsed: 0,
1069
+ apply: function apply(conn) {
1070
+ return conn.exec('UPDATE frontmatter SET "_rank" = NULL');
1071
+ }
1072
+ });
1073
+ }
1074
+ _state.label = 6;
646
1075
  case 6:
647
- err = _state.sent();
648
- _didIteratorError = true;
649
- _iteratorError = err;
650
1076
  return [
651
- 3,
652
- 8
653
- ];
654
- case 7:
655
- try {
656
- if (!_iteratorNormalCompletion && _iterator.return != null) {
657
- _iterator.return();
658
- }
659
- } finally{
660
- if (_didIteratorError) {
661
- throw _iteratorError;
1077
+ 2,
1078
+ {
1079
+ mutated: plans.some(function(plan) {
1080
+ return plan.mutated;
1081
+ }),
1082
+ parsed: plans.reduce(function(sum, plan) {
1083
+ return sum + plan.parsed;
1084
+ }, 0),
1085
+ apply: function apply(conn) {
1086
+ return _async_to_generator(function() {
1087
+ var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plan, err;
1088
+ return _ts_generator(this, function(_state) {
1089
+ switch(_state.label){
1090
+ case 0:
1091
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1092
+ _state.label = 1;
1093
+ case 1:
1094
+ _state.trys.push([
1095
+ 1,
1096
+ 6,
1097
+ 7,
1098
+ 8
1099
+ ]);
1100
+ _iterator = plans[Symbol.iterator]();
1101
+ _state.label = 2;
1102
+ case 2:
1103
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
1104
+ 3,
1105
+ 5
1106
+ ];
1107
+ plan = _step.value;
1108
+ return [
1109
+ 4,
1110
+ plan.apply(conn)
1111
+ ];
1112
+ case 3:
1113
+ _state.sent();
1114
+ _state.label = 4;
1115
+ case 4:
1116
+ _iteratorNormalCompletion = true;
1117
+ return [
1118
+ 3,
1119
+ 2
1120
+ ];
1121
+ case 5:
1122
+ return [
1123
+ 3,
1124
+ 8
1125
+ ];
1126
+ case 6:
1127
+ err = _state.sent();
1128
+ _didIteratorError = true;
1129
+ _iteratorError = err;
1130
+ return [
1131
+ 3,
1132
+ 8
1133
+ ];
1134
+ case 7:
1135
+ try {
1136
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1137
+ _iterator.return();
1138
+ }
1139
+ } finally{
1140
+ if (_didIteratorError) {
1141
+ throw _iteratorError;
1142
+ }
1143
+ }
1144
+ return [
1145
+ 7
1146
+ ];
1147
+ case 8:
1148
+ return [
1149
+ 2
1150
+ ];
1151
+ }
1152
+ });
1153
+ })();
1154
+ }
662
1155
  }
663
- }
664
- return [
665
- 7
666
1156
  ];
667
- case 8:
668
- toggles = disabled.filter(function(feature) {
669
- return feature.name !== 'embed';
670
- }).map(function(feature) {
671
- return {
672
- name: feature.name,
673
- turnedOn: false
674
- };
675
- });
1157
+ }
1158
+ });
1159
+ })();
1160
+ }
1161
+ function forcedPaths(classification, snapshot) {
1162
+ if (!classification.fullRebuild) return classification.forcedPaths;
1163
+ // New paths are reparsed by definition. Forcing every previously indexed path makes every
1164
+ // survivor a reparse without a second filesystem scan outside prepareReconcile's one listing.
1165
+ return new Set(snapshot.reconcile.existingRows.map(function(row) {
1166
+ return row.path;
1167
+ }));
1168
+ }
1169
+ function publishAttempt(conn, liveCfg, dialect, pool, ensureFeatureSchema, timing, attempt) {
1170
+ return _async_to_generator(function() {
1171
+ var _cfg_rootDir, _cfg_configDir, cfg, configIdentity, paths, wanted, snapshot, classification, invalidation, reconcile, mutated, txStart, txMs;
1172
+ return _ts_generator(this, function(_state) {
1173
+ switch(_state.label){
1174
+ case 0:
1175
+ cfg = structuredClone(liveCfg);
1176
+ configIdentity = JSON.stringify(cfg);
1177
+ paths = {
1178
+ rootDir: (_cfg_rootDir = cfg.rootDir) !== null && _cfg_rootDir !== void 0 ? _cfg_rootDir : cfg.baseDir,
1179
+ configDir: (_cfg_configDir = cfg.configDir) !== null && _cfg_configDir !== void 0 ? _cfg_configDir : cfg.baseDir
1180
+ };
1181
+ wanted = (0, _indexts.featureSignature)(cfg, _indexts1.FEATURES);
676
1182
  return [
677
1183
  4,
678
- invalidateFeatureToggles(conn, cfg, paths.rootDir, dialect, pool, toggles)
1184
+ readPlanningSnapshot(conn, timing)
679
1185
  ];
680
- case 9:
681
- _state.sent();
682
- if (!disabled.some(function(feature) {
683
- return feature.name === 'embed';
684
- })) return [
685
- 3,
686
- 13
1186
+ case 1:
1187
+ snapshot = _state.sent();
1188
+ classification = classifyBuild(snapshot, cfg, paths, wanted);
1189
+ return [
1190
+ 4,
1191
+ prepareInvalidation(classification, snapshot, cfg, paths, pool)
687
1192
  ];
1193
+ case 2:
1194
+ invalidation = _state.sent();
688
1195
  return [
689
1196
  4,
690
- conn.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'embeddings'")
1197
+ (0, _reconcilets.prepareReconcile)(snapshot.reconcile, cfg, paths, dialect, timing, pool, forcedPaths(classification, snapshot))
691
1198
  ];
692
- case 10:
693
- embeddingsTable = _state.sent();
1199
+ case 3:
1200
+ reconcile = _state.sent();
1201
+ mutated = classification.fullRebuild || invalidation.mutated || reconcile.mutated || snapshot.baseline.features !== wanted || snapshot.baseline.ready !== '1';
1202
+ if (buildPlan.hasSubscribers) buildPlan.publish({
1203
+ attempt: attempt,
1204
+ baseline: snapshot.baseline,
1205
+ wantedSignature: wanted
1206
+ });
1207
+ txStart = Date.now();
1208
+ _state.label = 4;
1209
+ case 4:
1210
+ _state.trys.push([
1211
+ 4,
1212
+ ,
1213
+ 6,
1214
+ 7
1215
+ ]);
694
1216
  return [
695
1217
  4,
696
- embeddingsTable.all()
1218
+ (0, _transactionts.withTransaction)(conn, function() {
1219
+ return _async_to_generator(function() {
1220
+ var current, currentWanted, publishedWanted;
1221
+ return _ts_generator(this, function(_state) {
1222
+ switch(_state.label){
1223
+ case 0:
1224
+ return [
1225
+ 4,
1226
+ readCoreBaseline(conn)
1227
+ ];
1228
+ case 1:
1229
+ current = _state.sent();
1230
+ currentWanted = (0, _indexts.featureSignature)(liveCfg, _indexts1.FEATURES);
1231
+ if (!sameBaseline(current, snapshot.baseline) || JSON.stringify(liveCfg) !== configIdentity || currentWanted !== wanted) {
1232
+ throw new StaleBuildPlan('core generation or configuration changed while this build was planning');
1233
+ }
1234
+ if (!mutated) return [
1235
+ 2
1236
+ ];
1237
+ return [
1238
+ 4,
1239
+ ensureFeatureSchema(cfg)
1240
+ ];
1241
+ case 2:
1242
+ _state.sent();
1243
+ return [
1244
+ 4,
1245
+ invalidation.apply(conn)
1246
+ ];
1247
+ case 3:
1248
+ _state.sent();
1249
+ return [
1250
+ 4,
1251
+ reconcile.apply(conn)
1252
+ ];
1253
+ case 4:
1254
+ _state.sent();
1255
+ publishedWanted = (0, _indexts.featureSignature)(liveCfg, _indexts1.FEATURES);
1256
+ if (JSON.stringify(liveCfg) !== configIdentity || publishedWanted !== wanted) throw new StaleBuildPlan('configuration changed while this build was publishing');
1257
+ return [
1258
+ 4,
1259
+ (0, _sharedts.setMeta)(conn, _readinessts.FEATURE_SIGNATURE_META_KEY, wanted)
1260
+ ];
1261
+ case 5:
1262
+ _state.sent();
1263
+ return [
1264
+ 4,
1265
+ (0, _sharedts.setMeta)(conn, _readinessts.CORE_READY_META_KEY, '1')
1266
+ ];
1267
+ case 6:
1268
+ _state.sent();
1269
+ return [
1270
+ 4,
1271
+ (0, _sharedts.setMeta)(conn, _readinessts.CORE_GENERATION_META_KEY, nextGeneration(snapshot.baseline.generation))
1272
+ ];
1273
+ case 7:
1274
+ _state.sent();
1275
+ return [
1276
+ 2
1277
+ ];
1278
+ }
1279
+ });
1280
+ })();
1281
+ }, dialect.beginMode())
1282
+ ];
1283
+ case 5:
1284
+ _state.sent();
1285
+ return [
1286
+ 3,
1287
+ 7
1288
+ ];
1289
+ case 6:
1290
+ txMs = Date.now() - txStart;
1291
+ timing.txMs += txMs;
1292
+ return [
1293
+ 7
697
1294
  ];
698
- case 11:
699
- if (!(_state.sent().length > 0)) return [
1295
+ case 7:
1296
+ if (!reconcile.mutated) return [
700
1297
  3,
701
- 13
1298
+ 9
702
1299
  ];
703
1300
  return [
704
1301
  4,
705
- (0, _transactionts.withTransaction)(conn, function() {
706
- return conn.exec('DELETE FROM embeddings');
707
- }, dialect.beginMode())
1302
+ reconcile.record(conn, txMs)
708
1303
  ];
709
- case 12:
1304
+ case 8:
710
1305
  _state.sent();
711
- _state.label = 13;
712
- case 13:
713
- forcedPaths = new Set((0, _indexts2.listFiles)(cfg, paths.rootDir).map(function(file) {
714
- return file.relPath;
715
- }));
1306
+ _state.label = 9;
1307
+ case 9:
716
1308
  return [
717
1309
  2,
718
- (0, _reconcilets.reconcile)(conn, cfg, paths, dialect, pool, forcedPaths)
1310
+ {
1311
+ parsed: invalidation.parsed + reconcile.parsed,
1312
+ warnings: reconcile.warnings,
1313
+ stages: reconcile.finish(timing.txMs),
1314
+ messages: classification.messages
1315
+ }
719
1316
  ];
720
1317
  }
721
1318
  });
722
1319
  })();
723
1320
  }
724
- function createBuilder(conn, cfg, paths, dialect) {
1321
+ function createBuilder(conn, cfg, dialect, ensureFeatureSchema) {
725
1322
  var pool = new _poolts.ParsePool();
726
1323
  return {
727
- build: function build(forcedPaths) {
728
- return (0, _reconcilets.reconcile)(conn, cfg, paths, dialect, pool, forcedPaths);
729
- },
730
- recover: function recover() {
731
- return recoverIncomplete(conn, cfg, paths, dialect, pool);
732
- },
733
- invalidate: function invalidate(kind) {
734
- return kind === 'model' ? nullEmbedVectors(conn, dialect) : rebuildEmbeddings(conn, cfg, paths.rootDir, dialect, pool);
735
- },
736
- invalidateFeatures: function invalidateFeatures(toggles) {
737
- return invalidateFeatureToggles(conn, cfg, paths.rootDir, dialect, pool, toggles);
1324
+ build: function build() {
1325
+ return _async_to_generator(function() {
1326
+ var timing, attempt, err;
1327
+ return _ts_generator(this, function(_state) {
1328
+ switch(_state.label){
1329
+ case 0:
1330
+ // One clock and recorder span both bounded attempts. Baseline/catalog reads and feature
1331
+ // invalidation preparation are included in totalMs but remain intentionally unlabelled;
1332
+ // existing/list/parse and publication stages accumulate under their established labels.
1333
+ timing = (0, _reconcilets.createReconcileTiming)(cfg);
1334
+ attempt = 0;
1335
+ _state.label = 1;
1336
+ case 1:
1337
+ if (!(attempt < 2)) return [
1338
+ 3,
1339
+ 6
1340
+ ];
1341
+ _state.label = 2;
1342
+ case 2:
1343
+ _state.trys.push([
1344
+ 2,
1345
+ 4,
1346
+ ,
1347
+ 5
1348
+ ]);
1349
+ return [
1350
+ 4,
1351
+ publishAttempt(conn, cfg, dialect, pool, ensureFeatureSchema, timing, attempt)
1352
+ ];
1353
+ case 3:
1354
+ return [
1355
+ 2,
1356
+ _state.sent()
1357
+ ];
1358
+ case 4:
1359
+ err = _state.sent();
1360
+ if (!_instanceof(err, StaleBuildPlan)) throw err;
1361
+ if (attempt === 1) throw new _errorsts.SenseError('STORE_BUSY', 'the index changed during both bounded publication attempts; wait for the competing build to finish and retry');
1362
+ return [
1363
+ 3,
1364
+ 5
1365
+ ];
1366
+ case 5:
1367
+ attempt++;
1368
+ return [
1369
+ 3,
1370
+ 1
1371
+ ];
1372
+ case 6:
1373
+ throw new Error('unreachable build attempt state');
1374
+ }
1375
+ });
1376
+ })();
738
1377
  },
739
1378
  close: function close() {
740
1379
  return pool.close();