pi-mega-compact 0.11.4 → 0.11.5

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 (307) hide show
  1. package/dist/extensions/dashboard-server/api-contracts/endpoints.js +19 -0
  2. package/dist/extensions/dashboard-server/api-contracts/memory.js +8 -0
  3. package/dist/extensions/dashboard-server/api-contracts/provider-cache.js +1 -0
  4. package/dist/extensions/dashboard-server/api-contracts/setup.js +10 -0
  5. package/dist/extensions/dashboard-server/index-reader.js +6 -2
  6. package/dist/extensions/dashboard-server/routes-cache.js +115 -55
  7. package/dist/extensions/dashboard-server/routes-memory.js +51 -0
  8. package/dist/extensions/dashboard-server/routes-repo.js +2 -2
  9. package/dist/extensions/dashboard-server/routes-setup.js +162 -0
  10. package/dist/extensions/dashboard-server/routes.js +2 -0
  11. package/dist/extensions/dashboard-server/server.js +7 -1
  12. package/dist/extensions/mega-commands.js +189 -1
  13. package/dist/extensions/mega-config.js +2 -0
  14. package/dist/extensions/mega-events/agent-handlers.js +19 -4
  15. package/dist/extensions/mega-events/compact-handlers.js +1 -0
  16. package/dist/extensions/mega-events/context-handler.js +37 -92
  17. package/dist/extensions/mega-events/context-hwm.js +51 -0
  18. package/dist/extensions/mega-events/error-classifier.js +16 -5
  19. package/dist/extensions/mega-events/mirror-append.js +107 -0
  20. package/dist/extensions/mega-events/outage-advisor.js +7 -1
  21. package/dist/extensions/mega-events/perf-handler.js +51 -1
  22. package/dist/extensions/mega-events/recall-tail.js +59 -0
  23. package/dist/extensions/mega-events/session-handlers.js +15 -8
  24. package/dist/extensions/mega-runtime/reset-runtime.js +5 -0
  25. package/dist/extensions/mega-runtime/runtime.js +6 -0
  26. package/dist/src/embedder.js +41 -2
  27. package/dist/src/memoryStats.js +75 -0
  28. package/dist/src/prefix-break.js +43 -0
  29. package/dist/src/pricing.js +1 -1
  30. package/dist/src/store/sqlite/perf-samples.js +144 -16
  31. package/dist/src/store/turns/memory-store.js +8 -0
  32. package/dist/src/store/turns/sqlite-store.js +14 -3
  33. package/dist/src/store/turns/types.js +18 -1
  34. package/dist/src/store/vectorIndex.js +26 -5
  35. package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js → AchievementTiles-BoL7qBOJ.js} +2 -2
  36. package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js.map → AchievementTiles-BoL7qBOJ.js.map} +1 -1
  37. package/extensions/dashboard-client/dist/assets/AchievementsTab-BFDE3HYc.js +2 -0
  38. package/extensions/dashboard-client/dist/assets/{AchievementsTab-DjxfYrDc.js.map → AchievementsTab-BFDE3HYc.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/CacheTab-eKVc-NV1.js +2 -0
  40. package/extensions/dashboard-client/dist/assets/CacheTab-eKVc-NV1.js.map +1 -0
  41. package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js → ConfigTab-DDFE-ckA.js} +2 -2
  42. package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js.map → ConfigTab-DDFE-ckA.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js → EventsTab-B6UxZ7PM.js} +2 -2
  44. package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js.map → EventsTab-B6UxZ7PM.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js → GameTab-DehUX-KE.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js.map → GameTab-DehUX-KE.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js → MaintenanceTab-0GWRt4wn.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js.map → MaintenanceTab-0GWRt4wn.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js → MetricsTab-C3rwMVsN.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js.map → MetricsTab-C3rwMVsN.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/OverviewTab-39O9_x5j.js +2 -0
  52. package/extensions/dashboard-client/dist/assets/{OverviewTab-D4kGvsiQ.js.map → OverviewTab-39O9_x5j.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/ReposTab-Cfj6Q5sH.js +2 -0
  54. package/extensions/dashboard-client/dist/assets/ReposTab-Cfj6Q5sH.js.map +1 -0
  55. package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js → SessionsTab-DXDTCi3r.js} +2 -2
  56. package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js.map → SessionsTab-DXDTCi3r.js.map} +1 -1
  57. package/extensions/dashboard-client/dist/assets/SetupTab-mMlfunJa.js +2 -0
  58. package/extensions/dashboard-client/dist/assets/SetupTab-mMlfunJa.js.map +1 -0
  59. package/extensions/dashboard-client/dist/assets/TimeSavedCard-Cw1dJ4e9.js +2 -0
  60. package/extensions/dashboard-client/dist/assets/TimeSavedCard-Cw1dJ4e9.js.map +1 -0
  61. package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js → TopicsTab-BAw972BV.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js.map → TopicsTab-BAw972BV.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js → TurnsTab-Cf5mGIdl.js} +2 -2
  64. package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js.map → TurnsTab-Cf5mGIdl.js.map} +1 -1
  65. package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js +2 -0
  66. package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js.map +1 -0
  67. package/extensions/dashboard-client/dist/assets/{index-BX0bcgLu.js → index-4gQ7auad.js} +10 -10
  68. package/extensions/dashboard-client/dist/assets/index-4gQ7auad.js.map +1 -0
  69. package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js +2 -0
  70. package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js.map +1 -0
  71. package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js → useSSE-DNgMuyP6.js} +2 -2
  72. package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js.map → useSSE-DNgMuyP6.js.map} +1 -1
  73. package/extensions/dashboard-client/dist/index.html +1 -1
  74. package/extensions/dashboard-client/src/App.tsx +4 -0
  75. package/extensions/dashboard-client/src/api/client.ts +14 -0
  76. package/extensions/dashboard-client/src/components/ActiveReposTable.tsx +21 -12
  77. package/extensions/dashboard-client/src/components/ProviderCacheCard.tsx +56 -0
  78. package/extensions/dashboard-client/src/components/SavingsByModelTable.tsx +38 -57
  79. package/extensions/dashboard-client/src/tabs/CacheTab.tsx +1 -0
  80. package/extensions/dashboard-client/src/tabs/SetupTab.tsx +355 -0
  81. package/extensions/dashboard-client/tsconfig.json +3 -2
  82. package/extensions/dashboard-client/vite.config.ts +2 -0
  83. package/extensions/dashboard-server/api-contracts/endpoints.ts +36 -3
  84. package/extensions/dashboard-server/api-contracts/index.ts +7 -0
  85. package/extensions/dashboard-server/api-contracts/memory.ts +27 -0
  86. package/extensions/dashboard-server/api-contracts/multi-repo.ts +231 -231
  87. package/extensions/dashboard-server/api-contracts/provider-cache.ts +37 -0
  88. package/extensions/dashboard-server/api-contracts/setup.ts +58 -0
  89. package/extensions/dashboard-server/index-reader.ts +138 -121
  90. package/extensions/dashboard-server/routes-cache.ts +161 -85
  91. package/extensions/dashboard-server/routes-memory.ts +63 -0
  92. package/extensions/dashboard-server/routes-repo.ts +36 -36
  93. package/extensions/dashboard-server/routes-setup.ts +181 -0
  94. package/extensions/dashboard-server/routes.ts +2 -0
  95. package/extensions/dashboard-server/server.ts +6 -0
  96. package/extensions/mega-commands.ts +211 -1
  97. package/extensions/mega-config.ts +10 -0
  98. package/extensions/mega-events/agent-handlers.ts +20 -4
  99. package/extensions/mega-events/compact-handlers.ts +1 -0
  100. package/extensions/mega-events/context-handler.ts +45 -110
  101. package/extensions/mega-events/context-hwm.ts +85 -0
  102. package/extensions/mega-events/error-classifier.ts +15 -4
  103. package/extensions/mega-events/mirror-append.ts +155 -0
  104. package/extensions/mega-events/outage-advisor.ts +11 -5
  105. package/extensions/mega-events/perf-handler.ts +79 -5
  106. package/extensions/mega-events/recall-tail.ts +88 -0
  107. package/extensions/mega-events/session-handlers.ts +14 -7
  108. package/extensions/mega-runtime/helpers.ts +12 -0
  109. package/extensions/mega-runtime/reset-runtime.ts +5 -0
  110. package/extensions/mega-runtime/runtime.ts +6 -0
  111. package/package.json +5 -2
  112. package/src/embedder.ts +42 -2
  113. package/src/memoryStats.ts +107 -0
  114. package/src/prefix-break.ts +83 -0
  115. package/src/pricing.ts +2 -2
  116. package/src/store/sqlite/perf-samples.ts +215 -22
  117. package/src/store/turns/memory-store.ts +10 -1
  118. package/src/store/turns/sqlite-store.ts +27 -15
  119. package/src/store/turns/types.ts +21 -0
  120. package/src/store/vectorIndex.ts +33 -4
  121. package/dist/extensions/conflict-scan.test.js +0 -115
  122. package/dist/extensions/dashboard-server/api-contracts.test.js +0 -884
  123. package/dist/extensions/dashboard-server/html.test.js +0 -52
  124. package/dist/extensions/dashboard-server/perf-server.test.js +0 -80
  125. package/dist/extensions/dashboard-server/routes-cache.test.js +0 -248
  126. package/dist/extensions/dashboard-server/server.test.js +0 -120
  127. package/dist/extensions/dashboard-server-s32.test.js +0 -181
  128. package/dist/extensions/dashboard-server.test.js +0 -339
  129. package/dist/extensions/mega-cache-replay.test.js +0 -400
  130. package/dist/extensions/mega-compact-s38.test.js +0 -1383
  131. package/dist/extensions/mega-compact.test.js +0 -1112
  132. package/dist/extensions/mega-events.test.js +0 -47
  133. package/dist/extensions/mega-game-cmds.test.js +0 -163
  134. package/dist/extensions/mega-runtime/snapshot.test.js +0 -127
  135. package/dist/extensions/mega-runtime/state.test.js +0 -266
  136. package/dist/extensions/mega-runtime/widget.test.js +0 -343
  137. package/dist/extensions/mega-shutdown-widget.test.js +0 -121
  138. package/dist/extensions/mega-teamrun.test.js +0 -156
  139. package/dist/extensions/mega-trim.test.js +0 -58
  140. package/dist/extensions/mega-turn-store.test.js +0 -68
  141. package/dist/src/boundary.test.js +0 -170
  142. package/dist/src/compact.test.js +0 -78
  143. package/dist/src/config/themes.test.js +0 -94
  144. package/dist/src/dedup/dedup.test.js +0 -41
  145. package/dist/src/dedup/l1.test.js +0 -50
  146. package/dist/src/dedup/raptor/buildHistory.test.js +0 -292
  147. package/dist/src/dedup/raptor/multilevel-serve.test.js +0 -229
  148. package/dist/src/dedup/raptor/multilevel.test.js +0 -238
  149. package/dist/src/dedup/raptor/promote.test.js +0 -69
  150. package/dist/src/dedup/raptor/raptor.test.js +0 -248
  151. package/dist/src/dedup/raptor/retrieval.test.js +0 -95
  152. package/dist/src/dedup/raptor/serve-gate.test.js +0 -298
  153. package/dist/src/dedup/sprint12.test.js +0 -219
  154. package/dist/src/dedup-engine.test.js +0 -472
  155. package/dist/src/driftDetection.test.js +0 -87
  156. package/dist/src/e2e.test.js +0 -698
  157. package/dist/src/engine.test.js +0 -111
  158. package/dist/src/extractive.test.js +0 -147
  159. package/dist/src/fork.test.js +0 -81
  160. package/dist/src/game/scoring.test.js +0 -98
  161. package/dist/src/httpEmbedder.test.js +0 -277
  162. package/dist/src/importance.test.js +0 -372
  163. package/dist/src/intent.test.js +0 -78
  164. package/dist/src/log.test.js +0 -42
  165. package/dist/src/mechanical-fix.test.js +0 -65
  166. package/dist/src/memory.test.js +0 -70
  167. package/dist/src/memoryConsolidate.test.js +0 -38
  168. package/dist/src/memoryOps.test.js +0 -129
  169. package/dist/src/memoryRecall.test.js +0 -171
  170. package/dist/src/memoryRoundtrip.test.js +0 -137
  171. package/dist/src/metrics/turns.test.js +0 -152
  172. package/dist/src/mirror/mirror.test.js +0 -185
  173. package/dist/src/raptor-inject-summaries.test.js +0 -162
  174. package/dist/src/ratio.bench.test.js +0 -897
  175. package/dist/src/recall.integration.test.js +0 -77
  176. package/dist/src/recall.test.js +0 -379
  177. package/dist/src/sprint14.test.js +0 -219
  178. package/dist/src/sprint4x-rag-verification.test.js +0 -93
  179. package/dist/src/store/compression.test.js +0 -139
  180. package/dist/src/store/memoryIndex.test.js +0 -51
  181. package/dist/src/store/migrate.test.js +0 -139
  182. package/dist/src/store/pgOpenGuard.test.js +0 -74
  183. package/dist/src/store/phase01.test.js +0 -81
  184. package/dist/src/store/phase04.test.js +0 -54
  185. package/dist/src/store/sprint10.test.js +0 -186
  186. package/dist/src/store/sqlite/game-achievements.test.js +0 -67
  187. package/dist/src/store/sqlite/game-scores.test.js +0 -106
  188. package/dist/src/store/sqlite/game-state.test.js +0 -76
  189. package/dist/src/store/sqlite/global-index.test.js +0 -136
  190. package/dist/src/store/sqlite/mechanical-fix.test.js +0 -146
  191. package/dist/src/store/sqlite/perf-samples.test.js +0 -146
  192. package/dist/src/store/sqlite/raptor.test.js +0 -106
  193. package/dist/src/store/sqlite/turns.test.js +0 -183
  194. package/dist/src/store/sqlite.cachehit.test.js +0 -55
  195. package/dist/src/store/sqlite.dbmaint.test.js +0 -158
  196. package/dist/src/store/sqlite.dbmirror.test.js +0 -184
  197. package/dist/src/store/turns/contract-compliance.test.js +0 -428
  198. package/dist/src/store/turns/memory-store.test.js +0 -9
  199. package/dist/src/store/turns/migrations.test.js +0 -138
  200. package/dist/src/store/turns/sqlite-store.test.js +0 -144
  201. package/dist/src/store/vectorIndex.test.js +0 -123
  202. package/dist/src/store.test.js +0 -161
  203. package/dist/src/supersede.test.js +0 -36
  204. package/dist/src/topics/cluster.test.js +0 -150
  205. package/dist/src/topics/store.test.js +0 -117
  206. package/dist/src/types.test.js +0 -9
  207. package/dist/src/vector-search-cache.test.js +0 -157
  208. package/dist/src/vectorStore.test.js +0 -479
  209. package/dist/src/wiki.test.js +0 -171
  210. package/extensions/conflict-scan.test.ts +0 -129
  211. package/extensions/dashboard-client/dist/assets/AchievementsTab-DjxfYrDc.js +0 -2
  212. package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js +0 -2
  213. package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js.map +0 -1
  214. package/extensions/dashboard-client/dist/assets/OverviewTab-D4kGvsiQ.js +0 -2
  215. package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js +0 -2
  216. package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js.map +0 -1
  217. package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js +0 -2
  218. package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js.map +0 -1
  219. package/extensions/dashboard-client/dist/assets/index-BX0bcgLu.js.map +0 -1
  220. package/extensions/dashboard-server/api-contracts.test.ts +0 -1065
  221. package/extensions/dashboard-server/html.test.ts +0 -62
  222. package/extensions/dashboard-server/perf-server.test.ts +0 -101
  223. package/extensions/dashboard-server/routes-cache.test.ts +0 -302
  224. package/extensions/dashboard-server/server.test.ts +0 -131
  225. package/extensions/dashboard-server-s32.test.ts +0 -195
  226. package/extensions/dashboard-server.test.ts +0 -382
  227. package/extensions/mega-cache-replay.test.ts +0 -526
  228. package/extensions/mega-compact-s38.test.ts +0 -1433
  229. package/extensions/mega-compact.test.ts +0 -1509
  230. package/extensions/mega-events.test.ts +0 -55
  231. package/extensions/mega-game-cmds.test.ts +0 -197
  232. package/extensions/mega-runtime/snapshot.test.ts +0 -139
  233. package/extensions/mega-runtime/state.test.ts +0 -262
  234. package/extensions/mega-runtime/widget.test.ts +0 -468
  235. package/extensions/mega-shutdown-widget.test.ts +0 -141
  236. package/extensions/mega-teamrun.test.ts +0 -176
  237. package/extensions/mega-trim.test.ts +0 -64
  238. package/extensions/mega-turn-store.test.ts +0 -108
  239. package/src/boundary.test.ts +0 -187
  240. package/src/compact.test.ts +0 -99
  241. package/src/config/themes.test.ts +0 -116
  242. package/src/dedup/dedup.test.ts +0 -46
  243. package/src/dedup/l1.test.ts +0 -57
  244. package/src/dedup/raptor/buildHistory.test.ts +0 -353
  245. package/src/dedup/raptor/multilevel-serve.test.ts +0 -273
  246. package/src/dedup/raptor/multilevel.test.ts +0 -325
  247. package/src/dedup/raptor/promote.test.ts +0 -82
  248. package/src/dedup/raptor/raptor.test.ts +0 -297
  249. package/src/dedup/raptor/retrieval.test.ts +0 -118
  250. package/src/dedup/raptor/serve-gate.test.ts +0 -348
  251. package/src/dedup/sprint12.test.ts +0 -242
  252. package/src/dedup-engine.test.ts +0 -670
  253. package/src/driftDetection.test.ts +0 -100
  254. package/src/e2e.test.ts +0 -843
  255. package/src/engine.test.ts +0 -123
  256. package/src/extractive.test.ts +0 -174
  257. package/src/fork.test.ts +0 -94
  258. package/src/game/scoring.test.ts +0 -103
  259. package/src/httpEmbedder.test.ts +0 -286
  260. package/src/importance.test.ts +0 -538
  261. package/src/intent.test.ts +0 -87
  262. package/src/log.test.ts +0 -47
  263. package/src/mechanical-fix.test.ts +0 -70
  264. package/src/memory.test.ts +0 -92
  265. package/src/memoryConsolidate.test.ts +0 -47
  266. package/src/memoryOps.test.ts +0 -148
  267. package/src/memoryRecall.test.ts +0 -194
  268. package/src/memoryRoundtrip.test.ts +0 -155
  269. package/src/metrics/turns.test.ts +0 -165
  270. package/src/mirror/mirror.test.ts +0 -240
  271. package/src/raptor-inject-summaries.test.ts +0 -228
  272. package/src/ratio.bench.test.ts +0 -1316
  273. package/src/recall.integration.test.ts +0 -96
  274. package/src/recall.test.ts +0 -467
  275. package/src/sprint14.test.ts +0 -245
  276. package/src/sprint4x-rag-verification.test.ts +0 -119
  277. package/src/store/compression.test.ts +0 -168
  278. package/src/store/memoryIndex.test.ts +0 -61
  279. package/src/store/migrate.test.ts +0 -158
  280. package/src/store/pgOpenGuard.test.ts +0 -89
  281. package/src/store/phase01.test.ts +0 -88
  282. package/src/store/phase04.test.ts +0 -58
  283. package/src/store/sprint10.test.ts +0 -214
  284. package/src/store/sqlite/game-achievements.test.ts +0 -80
  285. package/src/store/sqlite/game-scores.test.ts +0 -132
  286. package/src/store/sqlite/game-state.test.ts +0 -89
  287. package/src/store/sqlite/global-index.test.ts +0 -222
  288. package/src/store/sqlite/mechanical-fix.test.ts +0 -162
  289. package/src/store/sqlite/perf-samples.test.ts +0 -169
  290. package/src/store/sqlite/raptor.test.ts +0 -139
  291. package/src/store/sqlite/turns.test.ts +0 -218
  292. package/src/store/sqlite.cachehit.test.ts +0 -68
  293. package/src/store/sqlite.dbmaint.test.ts +0 -193
  294. package/src/store/sqlite.dbmirror.test.ts +0 -229
  295. package/src/store/turns/contract-compliance.test.ts +0 -562
  296. package/src/store/turns/memory-store.test.ts +0 -15
  297. package/src/store/turns/migrations.test.ts +0 -161
  298. package/src/store/turns/sqlite-store.test.ts +0 -161
  299. package/src/store/vectorIndex.test.ts +0 -140
  300. package/src/store.test.ts +0 -191
  301. package/src/supersede.test.ts +0 -42
  302. package/src/topics/cluster.test.ts +0 -176
  303. package/src/topics/store.test.ts +0 -132
  304. package/src/types.test.ts +0 -10
  305. package/src/vector-search-cache.test.ts +0 -190
  306. package/src/vectorStore.test.ts +0 -533
  307. package/src/wiki.test.ts +0 -217
@@ -1,169 +0,0 @@
1
- /**
2
- * perf-samples.test.ts — v0.8.8 perf_samples table round-trip + filtering.
3
- * Pi-agnostic. Uses an isolated state dir (never the real user dir — G7).
4
- */
5
- import { describe, it, before, after } from "node:test";
6
- import assert from "node:assert/strict";
7
- import { tmpdir } from "node:os";
8
- import { join } from "node:path";
9
- import { mkdtempSync, rmSync } from "node:fs";
10
- import { closeStore } from "./utils.js";
11
- import {
12
- recordPerfSample,
13
- readPerfSamples,
14
- PERF_KINDS,
15
- readProviderCacheLifetime,
16
- readLatestCacheHitPct,
17
- } from "./perf-samples.js";
18
-
19
- describe("perf-samples (v0.8.8)", () => {
20
- let dir: string;
21
- before(() => {
22
- dir = mkdtempSync(join(tmpdir(), "mc-perfsamples-"));
23
- process.env.MEGACOMPACT_STATE_DIR = dir;
24
- });
25
- after(() => {
26
- closeStore(dir);
27
- delete process.env.MEGACOMPACT_STATE_DIR;
28
- rmSync(dir, { recursive: true, force: true });
29
- });
30
-
31
- it("records + reads back a turn_latency_ms sample with parsed meta", () => {
32
- recordPerfSample(dir, "turn_latency_ms", 123.4, { turnIndex: 2 });
33
- const rows = readPerfSamples(dir, 0);
34
- assert.equal(rows.length, 1);
35
- assert.equal(rows[0].kind, "turn_latency_ms");
36
- assert.equal(rows[0].value, 123.4);
37
- assert.deepEqual(rows[0].meta, { turnIndex: 2 });
38
- });
39
-
40
- it("filters by kind and by sinceTs", () => {
41
- recordPerfSample(dir, "tps", 50);
42
- recordPerfSample(dir, "rss_mb", 256);
43
- const tps = readPerfSamples(dir, 0, "tps");
44
- assert.equal(tps.length, 1);
45
- assert.equal(tps[0].kind, "tps");
46
- assert.equal(tps[0].value, 50);
47
- const future = readPerfSamples(dir, Date.now() + 10000, "tps");
48
- assert.equal(future.length, 0);
49
- });
50
-
51
- it("ignores non-finite values + unknown kinds (never throws, nothing added)", () => {
52
- const before = readPerfSamples(dir, 0).length;
53
- recordPerfSample(dir, "tps", Number.NaN);
54
- recordPerfSample(dir, "tps", Infinity);
55
- assert.doesNotThrow(() => recordPerfSample(dir, "bogus" as never, 1));
56
- const after = readPerfSamples(dir, 0).length;
57
- assert.equal(after, before);
58
- });
59
-
60
- it("PERF_KINDS lists the 10 instrumentation kinds", () => {
61
- assert.equal(PERF_KINDS.length, 10);
62
- assert.ok(PERF_KINDS.includes("db_recompute_ms"));
63
- assert.ok(PERF_KINDS.includes("cache_hit_pct"));
64
- });
65
- });
66
-
67
- // ─── Provider cache lifetime aggregate tests (A.4) — each test uses its
68
- // own clean stateDir so prior inserts never pollute later assertions. ───
69
-
70
- describe("provider cache lifetime (A.4)", () => {
71
- let dir2: string;
72
-
73
- function freshDir(prefix: string) {
74
- if (dir2) {
75
- closeStore(dir2);
76
- rmSync(dir2, { recursive: true, force: true });
77
- }
78
- dir2 = mkdtempSync(join(tmpdir(), prefix));
79
- process.env.MEGACOMPACT_STATE_DIR = dir2;
80
- }
81
-
82
- after(() => {
83
- if (dir2) {
84
- closeStore(dir2);
85
- delete process.env.MEGACOMPACT_STATE_DIR;
86
- rmSync(dir2, { recursive: true, force: true });
87
- }
88
- });
89
-
90
- it("empty table returns zeros/nulls", () => {
91
- freshDir("mc-a4e-");
92
- const r = readProviderCacheLifetime(dir2);
93
- assert.equal(r.sampleCount, 0);
94
- assert.equal(r.avgHitPct, 0);
95
- assert.equal(r.totalCacheRead, 0);
96
- assert.equal(r.totalCacheWrite, 0);
97
- assert.equal(r.totalInput, 0);
98
- assert.equal(r.firstSampleAt, null);
99
- assert.equal(r.latestSampleAt, null);
100
- });
101
-
102
- it("rows with NULL meta are counted but contribute 0 tokens", () => {
103
- freshDir("mc-a4n-");
104
- recordPerfSample(dir2, "cache_hit_pct", 50, null);
105
- recordPerfSample(dir2, "cache_hit_pct", 60, null);
106
- const r = readProviderCacheLifetime(dir2);
107
- assert.equal(r.sampleCount, 2);
108
- assert.equal(r.totalCacheRead, 0);
109
- assert.equal(r.totalCacheWrite, 0);
110
- assert.equal(r.totalInput, 0);
111
- });
112
-
113
- it("partial meta — missing keys treated as 0", () => {
114
- freshDir("mc-a4p-");
115
- recordPerfSample(dir2, "cache_hit_pct", 42, { input: 1000 });
116
- const r = readProviderCacheLifetime(dir2);
117
- assert.equal(r.sampleCount, 1);
118
- assert.equal(r.totalCacheRead, 0);
119
- assert.equal(r.totalCacheWrite, 0);
120
- assert.equal(r.totalInput, 1000);
121
- });
122
-
123
- it("full rows produce correct sums + avg", () => {
124
- freshDir("mc-a4f-");
125
- // cacheRead=1000, cacheWrite=500, input=100 → hit% = 1000/1600=62.5%
126
- // cacheRead=500, cacheWrite=100, input=400 → hit% = 500/1000=50.0%
127
- // cacheRead=100, cacheWrite=200, input=700 → hit% = 100/1000=10.0%
128
- recordPerfSample(dir2, "cache_hit_pct", 55, {
129
- cacheRead: 1000,
130
- cacheWrite: 500,
131
- input: 100,
132
- });
133
- recordPerfSample(dir2, "cache_hit_pct", 56, {
134
- cacheRead: 500,
135
- cacheWrite: 100,
136
- input: 400,
137
- });
138
- recordPerfSample(dir2, "cache_hit_pct", 57, {
139
- cacheRead: 100,
140
- cacheWrite: 200,
141
- input: 700,
142
- });
143
- const r = readProviderCacheLifetime(dir2);
144
- assert.equal(r.sampleCount, 3);
145
- assert.equal(r.totalCacheRead, 1600);
146
- assert.equal(r.totalCacheWrite, 800);
147
- assert.equal(r.totalInput, 1200);
148
- // avg: (62.5 + 50.0 + 10.0) / 3 ≈ 40.833
149
- assert.ok(Math.abs(r.avgHitPct - 40.833) < 0.1);
150
- assert.ok(r.firstSampleAt != null);
151
- assert.ok(r.latestSampleAt != null);
152
- assert.ok(
153
- new Date(r.firstSampleAt!).getTime() <=
154
- new Date(r.latestSampleAt!).getTime(),
155
- );
156
- });
157
-
158
- it("readLatestCacheHitPct: empty → 0", () => {
159
- freshDir("mc-a4le-");
160
- assert.equal(readLatestCacheHitPct(dir2), 0);
161
- });
162
-
163
- it("readLatestCacheHitPct: most recent by ts, tie → highest id", () => {
164
- freshDir("mc-a4lm-");
165
- recordPerfSample(dir2, "cache_hit_pct", 20);
166
- recordPerfSample(dir2, "cache_hit_pct", 80);
167
- assert.equal(readLatestCacheHitPct(dir2), 80);
168
- });
169
- });
@@ -1,139 +0,0 @@
1
- /**
2
- * raptor.test.ts — regression tests for RAPTOR node persistence.
3
- *
4
- * Covers:
5
- * 1. saveRaptorTree atomicity (withTx + openStore nesting safety): rebuilding
6
- * a DIFFERENT tree for the same session leaves no stale nodes from the
7
- * first tree.
8
- * 2. listRaptorNodes robustness: corrupt `children` JSON in a row does not
9
- * throw and that row's children come back as [].
10
- *
11
- * No network. Uses node:sqlite directly via openStore.
12
- */
13
-
14
- import { test, beforeEach, afterEach } from "node:test";
15
- import assert from "node:assert/strict";
16
- import { mkdtempSync, rmSync } from "node:fs";
17
- import { tmpdir } from "node:os";
18
- import { join } from "node:path";
19
- import { openStore, closeStore } from "./utils.js";
20
- import { saveRaptorTree, listRaptorNodes, type StoredRaptorNode } from "./raptor.js";
21
-
22
- let tmpDir: string;
23
-
24
- beforeEach(() => {
25
- tmpDir = mkdtempSync(join(tmpdir(), "mc-raptor-persist-"));
26
- });
27
-
28
- afterEach(() => {
29
- closeStore(tmpDir);
30
- rmSync(tmpDir, { recursive: true, force: true });
31
- });
32
-
33
- /** Build a simple tree map with the minimal shape saveRaptorTree expects. */
34
- function makeTree(nodeSpecs: { id: string; level: number; children: string[] }[]) {
35
- const nodes = new Map();
36
- for (const spec of nodeSpecs) {
37
- nodes.set(spec.id, {
38
- id: spec.id,
39
- level: spec.level,
40
- parentId: spec.level === 0 ? null : "root",
41
- children: spec.children,
42
- summary: `summary for ${spec.id}`,
43
- embedding: [1, 0, 0],
44
- qualityMarker: "low",
45
- tokenEstimate: 10,
46
- });
47
- }
48
- return { nodes };
49
- }
50
-
51
- // ── Test 1: rebuild + save a different tree → no stale nodes ──────────────────
52
-
53
- test("saveRaptorTree: rebuilding a different tree for the same session leaves no stale nodes", () => {
54
- const sid = "sess_replace";
55
- const builtAt1 = 1000;
56
- const builtAt2 = 2000;
57
-
58
- // Tree A: nodes alpha, beta, root.
59
- const treeA = makeTree([
60
- { id: "alpha", level: 1, children: ["leaf_0", "leaf_1"] },
61
- { id: "beta", level: 1, children: ["leaf_2", "leaf_3"] },
62
- { id: "root", level: 2, children: ["leaf_0", "leaf_1", "leaf_2", "leaf_3"] },
63
- ]);
64
-
65
- saveRaptorTree(sid, treeA, builtAt1, tmpDir);
66
-
67
- const afterA = listRaptorNodes(sid, tmpDir);
68
- assert.equal(afterA.length, 3, "tree A has 3 nodes");
69
- assert.deepEqual(
70
- afterA.map((n) => n.id).sort(),
71
- ["alpha", "beta", "root"],
72
- "tree A node ids match",
73
- );
74
-
75
- // Tree B: completely different nodes gamma, delta, root.
76
- const treeB = makeTree([
77
- { id: "gamma", level: 1, children: ["leaf_4", "leaf_5"] },
78
- { id: "delta", level: 1, children: ["leaf_6", "leaf_7"] },
79
- { id: "root", level: 2, children: ["leaf_4", "leaf_5", "leaf_6", "leaf_7"] },
80
- ]);
81
-
82
- saveRaptorTree(sid, treeB, builtAt2, tmpDir);
83
-
84
- const afterB = listRaptorNodes(sid, tmpDir);
85
- assert.equal(afterB.length, 3, "tree B has 3 nodes (stale A nodes gone)");
86
-
87
- // No stale node ids from tree A survive.
88
- const idsAfterB = new Set(afterB.map((n) => n.id));
89
- assert.ok(!idsAfterB.has("alpha"), "stale node alpha is gone");
90
- assert.ok(!idsAfterB.has("beta"), "stale node beta is gone");
91
- assert.ok(idsAfterB.has("gamma"), "new node gamma present");
92
- assert.ok(idsAfterB.has("delta"), "new node delta present");
93
- assert.ok(idsAfterB.has("root"), "root present (upserted, not duplicated)");
94
-
95
- // builtAt was updated to the new timestamp.
96
- for (const n of afterB) {
97
- assert.equal(n.builtAt, builtAt2, `node ${n.id} builtAt updated to tree B timestamp`);
98
- }
99
- });
100
-
101
- // ── Test 2: corrupt children JSON → no throw, children = [] ──────────────────
102
-
103
- test("listRaptorNodes: corrupt children JSON does not throw and returns []", () => {
104
- const sid = "sess_corrupt";
105
- const builtAt = 5000;
106
-
107
- const tree = makeTree([
108
- { id: "good", level: 1, children: ["leaf_0", "leaf_1"] },
109
- { id: "bad", level: 1, children: ["leaf_2", "leaf_3"] },
110
- { id: "root", level: 2, children: ["leaf_0", "leaf_1", "leaf_2", "leaf_3"] },
111
- ]);
112
-
113
- saveRaptorTree(sid, tree, builtAt, tmpDir);
114
-
115
- // Corrupt the `children` JSON for the "bad" row directly in SQLite.
116
- const db = openStore(tmpDir);
117
- db.prepare(
118
- "UPDATE raptor_nodes SET children = ? WHERE session_id = ? AND id = ?",
119
- ).run("{not valid json", sid, "bad");
120
-
121
- // listRaptorNodes must not throw.
122
- let nodes: StoredRaptorNode[];
123
- assert.doesNotThrow(() => {
124
- nodes = listRaptorNodes(sid, tmpDir);
125
- }, "listRaptorNodes must not throw on corrupt children JSON");
126
-
127
- const badNode = nodes!.find((n) => n.id === "bad");
128
- assert.ok(badNode, "bad node still present");
129
- assert.deepEqual(badNode!.children, [], "corrupt children parsed to []");
130
-
131
- // The good node is unaffected.
132
- const goodNode = nodes!.find((n) => n.id === "good");
133
- assert.ok(goodNode, "good node present");
134
- assert.deepEqual(
135
- goodNode!.children,
136
- ["leaf_0", "leaf_1"],
137
- "good node children intact",
138
- );
139
- });
@@ -1,218 +0,0 @@
1
- /**
2
- * turns.test.ts — S43 per-turn + conversation tracking tests.
3
- *
4
- * No network. Real stores with temp state dirs.
5
- */
6
-
7
- import { test, beforeEach, afterEach } from "node:test";
8
- import assert from "node:assert/strict";
9
- import { mkdtempSync, rmSync } from "node:fs";
10
- import { tmpdir } from "node:os";
11
- import { join } from "node:path";
12
- import { openStore } from "./utils.js";
13
- import {
14
- recordTurn,
15
- recordTurnRecall,
16
- getTurn,
17
- getTurnById,
18
- listTurnRecall,
19
- listConversationTurns,
20
- ensureConversationId,
21
- forkConversation,
22
- newConversationId,
23
- clearTurns,
24
- } from "./turns.js";
25
- import { loadSessionState, saveSessionState } from "./session-state.js";
26
-
27
- let tmpDir: string;
28
- let counter = 0;
29
-
30
- beforeEach(() => {
31
- tmpDir = mkdtempSync(join(tmpdir(), "mc-turns-"));
32
- });
33
-
34
- afterEach(() => {
35
- rmSync(tmpDir, { recursive: true, force: true });
36
- });
37
-
38
- function stateDir(): string {
39
- return join(tmpDir, `run-${counter++}`);
40
- }
41
-
42
- // ─── 1. recordTurn upserts + getTurn round-trip ────────────────────────────
43
-
44
- test("S43-1: recordTurn inserts/updates + getTurn finds by conv+index", () => {
45
- const sd = stateDir();
46
- openStore(sd);
47
- const conv = newConversationId();
48
- const id = recordTurn({
49
- conversationId: conv,
50
- sessionId: "sess-1",
51
- turnIndex: 3,
52
- endedAt: 1000,
53
- ctxTokens: 12000,
54
- ctxPercent: 42.5,
55
- pressureBand: "mid",
56
- modelId: "claude-fable-5",
57
- }, sd);
58
- assert.ok(id > 0, "turn id returned");
59
- const t = getTurn(conv, 3, sd);
60
- assert.ok(t, "turn found");
61
- assert.equal(t!.conversationId, conv);
62
- assert.equal(t!.turnIndex, 3);
63
- assert.equal(t!.ctxTokens, 12000);
64
- assert.equal(t!.ctxPercent, 42.5);
65
- assert.equal(t!.pressureBand, "mid");
66
- assert.equal(t!.modelId, "claude-fable-5");
67
- assert.equal(t!.endedAt, 1000);
68
- // Re-record (upsert) with additional metrics — COALESCE preserves started_at.
69
- const id2 = recordTurn({
70
- conversationId: conv,
71
- sessionId: "sess-1",
72
- turnIndex: 3,
73
- startedAt: 900,
74
- ctxTokens: 12500,
75
- }, sd);
76
- assert.equal(id2, id, "same turn id on upsert");
77
- const t2 = getTurn(conv, 3, sd);
78
- assert.equal(t2!.ctxTokens, 12500, "metrics updated");
79
- assert.equal(t2!.startedAt, 900, "started_at set on second write");
80
- });
81
-
82
- // ─── 2. recordTurnRecall + listTurnRecall ───────────────────────────────────
83
-
84
- test("S43-2: recordTurnRecall stores provenance + listTurnRecall returns it", () => {
85
- const sd = stateDir();
86
- openStore(sd);
87
- const conv = newConversationId();
88
- const turnId = recordTurn({
89
- conversationId: conv,
90
- sessionId: "sess-1",
91
- turnIndex: 1,
92
- }, sd);
93
- recordTurnRecall(turnId, [
94
- { checkpointId: "chkpt_003", score: 0.91, source: "flat" },
95
- { checkpointId: "r1_0", score: 0.78, source: "raptor", raptorLevel: 1 },
96
- { checkpointId: "chkpt_007", score: 0.65, source: "cross-repo" },
97
- ], sd);
98
- const recalls = listTurnRecall(turnId, sd);
99
- assert.equal(recalls.length, 3);
100
- assert.equal(recalls[0].checkpointId, "chkpt_003", "sorted by score desc");
101
- assert.equal(recalls[0].score, 0.91);
102
- const raptorHit = recalls.find((r) => r.source === "raptor");
103
- assert.ok(raptorHit, "raptor hit present");
104
- assert.equal(raptorHit!.raptorLevel, 1);
105
- assert.equal(raptorHit!.checkpointId, "r1_0");
106
- // Re-record with a changed score → upsert, no duplicate.
107
- recordTurnRecall(turnId, [{ checkpointId: "chkpt_003", score: 0.95, source: "flat" }], sd);
108
- const recalls2 = listTurnRecall(turnId, sd);
109
- assert.equal(recalls2.length, 3, "no duplicate on re-record");
110
- const updated = recalls2.find((r) => r.checkpointId === "chkpt_003");
111
- assert.equal(updated!.score, 0.95, "score updated");
112
- });
113
-
114
- // ─── 3. listConversationTurns ───────────────────────────────────────────────
115
-
116
- test("S43-3: listConversationTurns returns turns in order", () => {
117
- const sd = stateDir();
118
- openStore(sd);
119
- const conv = newConversationId();
120
- for (let i = 1; i <= 4; i++) {
121
- recordTurn({
122
- conversationId: conv,
123
- sessionId: "sess-1",
124
- turnIndex: i,
125
- endedAt: i * 100,
126
- }, sd);
127
- }
128
- const turns = listConversationTurns(conv, sd);
129
- assert.equal(turns.length, 4);
130
- assert.deepEqual(turns.map((t) => t.turnIndex), [1, 2, 3, 4]);
131
- });
132
-
133
- // ─── 4. ensureConversationId persists + is stable across resumes ───────────
134
-
135
- test("S43-4: ensureConversationId generates once, persists, survives reload", () => {
136
- const sd = stateDir();
137
- openStore(sd);
138
- const sid = "sess-resume";
139
- // First call generates + persists.
140
- const conv1 = ensureConversationId(sid, sd);
141
- assert.ok(conv1.startsWith("conv_"), "generated id has prefix");
142
- // Second call (simulated resume) returns the same id — reads session_state.
143
- const conv2 = ensureConversationId(sid, sd);
144
- assert.equal(conv2, conv1, "stable across resumes");
145
- // A different session gets a different conversation id.
146
- const conv3 = ensureConversationId("sess-other", sd);
147
- assert.notEqual(conv3, conv1);
148
- });
149
-
150
- // ─── 5. forkConversation records lineage + returns recall set ──────────────
151
-
152
- test("S43-5: forkConversation creates child + returns parent's recall set", () => {
153
- const sd = stateDir();
154
- openStore(sd);
155
- const parent = newConversationId();
156
- // Parent conversation: turn 1 with 2 recalled checkpoints.
157
- const turnId = recordTurn({
158
- conversationId: parent,
159
- sessionId: "sess-parent",
160
- turnIndex: 1,
161
- }, sd);
162
- recordTurnRecall(turnId, [
163
- { checkpointId: "chkpt_001", score: 0.9, source: "flat" },
164
- { checkpointId: "chkpt_002", score: 0.7, source: "flat" },
165
- ], sd);
166
- // Fork at turn 1.
167
- const { conversationId: child, recalled } = forkConversation(parent, turnId, sd);
168
- assert.ok(child.startsWith("conv_"), "child is a conversation id");
169
- assert.notEqual(child, parent, "child differs from parent");
170
- assert.equal(recalled.length, 2, "parent's recall set returned for replay");
171
- assert.ok(
172
- recalled.some((r) => r.checkpointId === "chkpt_001"),
173
- "includes parent's recalled checkpoint",
174
- );
175
- // The child conversation is recorded as a branch.
176
- const branches = openStore(sd).prepare(
177
- "SELECT parent_conversation_id, fork_turn_id FROM conversation_branches WHERE conversation_id = ?",
178
- ).get(child) as { parent_conversation_id: string; fork_turn_id: number };
179
- assert.equal(branches.parent_conversation_id, parent);
180
- assert.equal(branches.fork_turn_id, turnId);
181
- });
182
-
183
- // ─── 6. clearTurns removes turns + their recall rows for a session ──────────
184
-
185
- test("S43-6: clearTurns removes turns + cascade turn_recall", () => {
186
- const sd = stateDir();
187
- openStore(sd);
188
- const conv = newConversationId();
189
- const turnId = recordTurn({
190
- conversationId: conv,
191
- sessionId: "sess-clear",
192
- turnIndex: 1,
193
- }, sd);
194
- recordTurnRecall(turnId, [{ checkpointId: "x", score: 0.5, source: "flat" }], sd);
195
- assert.equal(listTurnRecall(turnId, sd).length, 1);
196
- clearTurns("sess-clear", sd);
197
- assert.equal(getTurnById(turnId, sd), null, "turn gone");
198
- assert.equal(listTurnRecall(turnId, sd).length, 0, "recall rows cascaded");
199
- });
200
-
201
- // ─── 7. conversation id survives across SessionState save/load ──────────────
202
-
203
- test("S43-7: conversationId round-trips through SessionState", () => {
204
- const sd = stateDir();
205
- openStore(sd);
206
- const sid = "sess-rt";
207
- // Save a state with a conversationId.
208
- const conv = "conv_roundtrip";
209
- saveSessionState(sid, {
210
- injectedCheckpointIds: [],
211
- storedRegionHashes: [],
212
- conversationId: conv,
213
- }, sd);
214
- const loaded = loadSessionState(sid, sd);
215
- assert.equal(loaded.conversationId, conv, "conversationId persisted");
216
- // ensureConversationId picks up the existing one.
217
- assert.equal(ensureConversationId(sid, sd), conv, "ensure keeps existing");
218
- });
@@ -1,68 +0,0 @@
1
- /**
2
- * sqlite.cachehit.test.ts — tests for the live dashboard counters
3
- * (incCompactCount / getCompactCount, incRecallInjected / getRecallInjected,
4
- * incCacheHitTokens / getCacheHitTokensSaved). These reuse the schemaless
5
- * `meta` integer counter, so no migration is required and the same on-disk
6
- * SQLite store persists the tallies across (re)opens.
7
- */
8
- import { describe, it, beforeEach, afterEach } from "node:test";
9
- import assert from "node:assert/strict";
10
- import { mkdtempSync, rmSync } from "node:fs";
11
- import { tmpdir } from "node:os";
12
- import { join } from "node:path";
13
- import {
14
- openStore,
15
- incCompactCount,
16
- getCompactCount,
17
- incRecallInjected,
18
- getRecallInjected,
19
- incCacheHitTokens,
20
- getCacheHitTokensSaved,
21
- } from "./sqlite.js";
22
-
23
- describe("live dashboard counters (meta integers)", () => {
24
- let dir: string;
25
- beforeEach(() => {
26
- dir = mkdtempSync(join(tmpdir(), "cachehit-test-"));
27
- });
28
- afterEach(() => {
29
- rmSync(dir, { recursive: true, force: true });
30
- });
31
-
32
- it("increments + reads compact_count and persists on reopen", () => {
33
- incCompactCount(dir);
34
- incCompactCount(dir);
35
- assert.equal(getCompactCount(dir), 2);
36
- // Ensure the store handle is (re)opened and the value is read back from disk.
37
- openStore(dir);
38
- assert.equal(getCompactCount(dir), 2);
39
- });
40
-
41
- it("accumulates recall injections + cache-hit tokens", () => {
42
- incRecallInjected(3, dir);
43
- incRecallInjected(2, dir);
44
- assert.equal(getRecallInjected(dir), 5);
45
- incCacheHitTokens(1200, dir);
46
- incCacheHitTokens(800, dir);
47
- assert.equal(getCacheHitTokensSaved(dir), 2000);
48
- });
49
-
50
- it("ignores non-positive increments (no-op)", () => {
51
- incRecallInjected(0, dir);
52
- incRecallInjected(-5, dir);
53
- incCacheHitTokens(0, dir);
54
- assert.equal(getRecallInjected(dir), 0);
55
- assert.equal(getCacheHitTokensSaved(dir), 0);
56
- });
57
-
58
- it("persists all three counters across a fresh openStore handle", () => {
59
- incCompactCount(dir);
60
- incRecallInjected(4, dir);
61
- incCacheHitTokens(500, dir);
62
- // openStore returns the canonical (on-disk) handle; reading back proves durability.
63
- openStore(dir);
64
- assert.equal(getCompactCount(dir), 1);
65
- assert.equal(getRecallInjected(dir), 4);
66
- assert.equal(getCacheHitTokensSaved(dir), 500);
67
- });
68
- });