pi-mega-compact 0.11.4 → 0.11.6

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 (381) hide show
  1. package/dist/extensions/dashboard-server/api-contracts/cache-stripes.js +8 -0
  2. package/dist/extensions/dashboard-server/api-contracts/endpoints.js +32 -0
  3. package/dist/extensions/dashboard-server/api-contracts/memory-map.js +1 -0
  4. package/dist/extensions/dashboard-server/api-contracts/memory.js +8 -0
  5. package/dist/extensions/dashboard-server/api-contracts/provider-cache.js +1 -0
  6. package/dist/extensions/dashboard-server/api-contracts/setup.js +10 -0
  7. package/dist/extensions/dashboard-server/index-reader.js +6 -2
  8. package/dist/extensions/dashboard-server/routes-cache.js +135 -47
  9. package/dist/extensions/dashboard-server/routes-game.js +3 -0
  10. package/dist/extensions/dashboard-server/routes-memory-map.js +50 -0
  11. package/dist/extensions/dashboard-server/routes-memory.js +51 -0
  12. package/dist/extensions/dashboard-server/routes-repo.js +2 -2
  13. package/dist/extensions/dashboard-server/routes-setup.js +267 -0
  14. package/dist/extensions/dashboard-server/routes.js +4 -0
  15. package/dist/extensions/dashboard-server/server.js +13 -1
  16. package/dist/extensions/mega-commands.js +189 -1
  17. package/dist/extensions/mega-compact.js +5 -0
  18. package/dist/extensions/mega-config.js +7 -0
  19. package/dist/extensions/mega-events/agent-handlers.js +19 -4
  20. package/dist/extensions/mega-events/compact-handlers.js +1 -0
  21. package/dist/extensions/mega-events/context-handler.js +45 -92
  22. package/dist/extensions/mega-events/context-hwm.js +51 -0
  23. package/dist/extensions/mega-events/error-classifier.js +16 -5
  24. package/dist/extensions/mega-events/mirror-append.js +107 -0
  25. package/dist/extensions/mega-events/outage-advisor.js +7 -1
  26. package/dist/extensions/mega-events/perf-handler.js +134 -2
  27. package/dist/extensions/mega-events/recall-tail.js +59 -0
  28. package/dist/extensions/mega-events/separated-prompt.js +248 -0
  29. package/dist/extensions/mega-events/session-handlers.js +15 -8
  30. package/dist/extensions/mega-runtime/env-loader.js +56 -0
  31. package/dist/extensions/mega-runtime/reset-runtime.js +6 -0
  32. package/dist/extensions/mega-runtime/runtime-snapshot.js +1 -0
  33. package/dist/extensions/mega-runtime/runtime.js +7 -0
  34. package/dist/extensions/mega-runtime/snapshot.js +1 -0
  35. package/dist/extensions/mega-runtime/widget.js +5 -0
  36. package/dist/src/cache-stripe-impl.js +288 -0
  37. package/dist/src/cache-stripe.js +11 -0
  38. package/dist/src/config/stopwords.js +24 -0
  39. package/dist/src/config.js +17 -0
  40. package/dist/src/embedder.js +41 -2
  41. package/dist/src/memoryGraph.js +299 -0
  42. package/dist/src/memoryStats.js +75 -0
  43. package/dist/src/monitoring.js +13 -0
  44. package/dist/src/prefix-break.js +43 -0
  45. package/dist/src/pricing.js +1 -1
  46. package/dist/src/queryExpansion.js +163 -0
  47. package/dist/src/queryReformulation/cache.js +123 -0
  48. package/dist/src/queryReformulation/rrf.js +29 -0
  49. package/dist/src/queryReformulation/tfidf.js +61 -0
  50. package/dist/src/queryReformulation/vagueness.js +33 -0
  51. package/dist/src/queryReformulation.js +225 -0
  52. package/dist/src/recallMetrics.js +258 -0
  53. package/dist/src/store/sqlite/cache-stripes.js +133 -0
  54. package/dist/src/store/sqlite/fts5-search.js +68 -0
  55. package/dist/src/store/sqlite/perf-samples.js +145 -16
  56. package/dist/src/store/sqlite/schema.js +60 -1
  57. package/dist/src/store/sqlite.js +1 -0
  58. package/dist/src/store/turns/memory-store.js +8 -0
  59. package/dist/src/store/turns/sqlite-store.js +14 -3
  60. package/dist/src/store/turns/types.js +18 -1
  61. package/dist/src/store/vectorIndex.js +55 -10
  62. package/dist/src/tiered-router/types.js +18 -0
  63. package/dist/src/tieredRouter.js +421 -0
  64. package/dist/src/vectorStore.js +8 -6
  65. package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js → AchievementTiles-DR9cLGDL.js} +2 -2
  66. package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js.map → AchievementTiles-DR9cLGDL.js.map} +1 -1
  67. package/extensions/dashboard-client/dist/assets/AchievementsTab-svNUgJ1e.js +2 -0
  68. package/extensions/dashboard-client/dist/assets/{AchievementsTab-DjxfYrDc.js.map → AchievementsTab-svNUgJ1e.js.map} +1 -1
  69. package/extensions/dashboard-client/dist/assets/CacheTab-ASwhOMjR.js +2 -0
  70. package/extensions/dashboard-client/dist/assets/CacheTab-ASwhOMjR.js.map +1 -0
  71. package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js → ConfigTab-CmmWheuW.js} +2 -2
  72. package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js.map → ConfigTab-CmmWheuW.js.map} +1 -1
  73. package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js → EventsTab-CFE7jLsa.js} +2 -2
  74. package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js.map → EventsTab-CFE7jLsa.js.map} +1 -1
  75. package/extensions/dashboard-client/dist/assets/GameTab-CJAX_th_.js +2 -0
  76. package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js.map → GameTab-CJAX_th_.js.map} +1 -1
  77. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js → MaintenanceTab-P4SUsvMf.js} +2 -2
  78. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js.map → MaintenanceTab-P4SUsvMf.js.map} +1 -1
  79. package/extensions/dashboard-client/dist/assets/MemoryMapTab-BBiH76eF.js +2 -0
  80. package/extensions/dashboard-client/dist/assets/MemoryMapTab-BBiH76eF.js.map +1 -0
  81. package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js → MetricsTab-CHQscixy.js} +2 -2
  82. package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js.map → MetricsTab-CHQscixy.js.map} +1 -1
  83. package/extensions/dashboard-client/dist/assets/OverviewTab-DBs4DJdd.js +2 -0
  84. package/extensions/dashboard-client/dist/assets/{OverviewTab-D4kGvsiQ.js.map → OverviewTab-DBs4DJdd.js.map} +1 -1
  85. package/extensions/dashboard-client/dist/assets/ReposTab-DeFz76L5.js +2 -0
  86. package/extensions/dashboard-client/dist/assets/ReposTab-DeFz76L5.js.map +1 -0
  87. package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js → SessionsTab-BWNsj1OB.js} +2 -2
  88. package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js.map → SessionsTab-BWNsj1OB.js.map} +1 -1
  89. package/extensions/dashboard-client/dist/assets/SetupTab-uS6A0xmw.js +2 -0
  90. package/extensions/dashboard-client/dist/assets/SetupTab-uS6A0xmw.js.map +1 -0
  91. package/extensions/dashboard-client/dist/assets/TimeSavedCard-CiqCOQuL.js +2 -0
  92. package/extensions/dashboard-client/dist/assets/TimeSavedCard-CiqCOQuL.js.map +1 -0
  93. package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js → TopicsTab-BWWQxltv.js} +2 -2
  94. package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js.map → TopicsTab-BWWQxltv.js.map} +1 -1
  95. package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js → TurnsTab-CVz4f4-o.js} +2 -2
  96. package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js.map → TurnsTab-CVz4f4-o.js.map} +1 -1
  97. package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js +2 -0
  98. package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js.map +1 -0
  99. package/extensions/dashboard-client/dist/assets/index-CUNn22iV.css +1 -0
  100. package/extensions/dashboard-client/dist/assets/index-DrktNOoT.js +42 -0
  101. package/extensions/dashboard-client/dist/assets/index-DrktNOoT.js.map +1 -0
  102. package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js +2 -0
  103. package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js.map +1 -0
  104. package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js → useSSE-Bf5LOLSi.js} +2 -2
  105. package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js.map → useSSE-Bf5LOLSi.js.map} +1 -1
  106. package/extensions/dashboard-client/dist/index.html +2 -2
  107. package/extensions/dashboard-client/src/App.tsx +28 -8
  108. package/extensions/dashboard-client/src/api/client.ts +29 -0
  109. package/extensions/dashboard-client/src/components/ActiveReposTable.tsx +21 -12
  110. package/extensions/dashboard-client/src/components/CacheHitRateTrendCard.tsx +100 -0
  111. package/extensions/dashboard-client/src/components/ProviderCacheCard.tsx +56 -0
  112. package/extensions/dashboard-client/src/components/SavingsByModelTable.tsx +38 -57
  113. package/extensions/dashboard-client/src/components/StripeDistributionCard.tsx +110 -0
  114. package/extensions/dashboard-client/src/components/TabBar.tsx +49 -4
  115. package/extensions/dashboard-client/src/main.tsx +1 -0
  116. package/extensions/dashboard-client/src/styles/base.css +30 -0
  117. package/extensions/dashboard-client/src/styles/cache.css +167 -0
  118. package/extensions/dashboard-client/src/tabs/CacheTab.tsx +75 -12
  119. package/extensions/dashboard-client/src/tabs/MemoryMapTab.tsx +440 -0
  120. package/extensions/dashboard-client/src/tabs/SetupTab.tsx +418 -0
  121. package/extensions/dashboard-client/tsconfig.json +3 -2
  122. package/extensions/dashboard-client/vite.config.ts +2 -0
  123. package/extensions/dashboard-server/api-contracts/cache-stripes.ts +49 -0
  124. package/extensions/dashboard-server/api-contracts/endpoints.ts +66 -3
  125. package/extensions/dashboard-server/api-contracts/index.ts +22 -0
  126. package/extensions/dashboard-server/api-contracts/memory-map.ts +50 -0
  127. package/extensions/dashboard-server/api-contracts/memory.ts +27 -0
  128. package/extensions/dashboard-server/api-contracts/multi-repo.ts +231 -231
  129. package/extensions/dashboard-server/api-contracts/provider-cache.ts +37 -0
  130. package/extensions/dashboard-server/api-contracts/setup.ts +80 -0
  131. package/extensions/dashboard-server/index-reader.ts +138 -121
  132. package/extensions/dashboard-server/routes-cache.ts +186 -75
  133. package/extensions/dashboard-server/routes-game.ts +3 -0
  134. package/extensions/dashboard-server/routes-memory-map.ts +105 -0
  135. package/extensions/dashboard-server/routes-memory.ts +63 -0
  136. package/extensions/dashboard-server/routes-repo.ts +36 -36
  137. package/extensions/dashboard-server/routes-setup.ts +293 -0
  138. package/extensions/dashboard-server/routes.ts +4 -0
  139. package/extensions/dashboard-server/server.ts +12 -0
  140. package/extensions/mega-commands.ts +211 -1
  141. package/extensions/mega-compact.ts +5 -0
  142. package/extensions/mega-config.ts +27 -0
  143. package/extensions/mega-events/agent-handlers.ts +20 -4
  144. package/extensions/mega-events/compact-handlers.ts +1 -0
  145. package/extensions/mega-events/context-handler.ts +53 -110
  146. package/extensions/mega-events/context-hwm.ts +85 -0
  147. package/extensions/mega-events/error-classifier.ts +15 -4
  148. package/extensions/mega-events/mirror-append.ts +155 -0
  149. package/extensions/mega-events/outage-advisor.ts +11 -5
  150. package/extensions/mega-events/perf-handler.ts +190 -6
  151. package/extensions/mega-events/recall-tail.ts +88 -0
  152. package/extensions/mega-events/separated-prompt.ts +329 -0
  153. package/extensions/mega-events/session-handlers.ts +14 -7
  154. package/extensions/mega-runtime/env-loader.ts +55 -0
  155. package/extensions/mega-runtime/helpers.ts +14 -0
  156. package/extensions/mega-runtime/reset-runtime.ts +6 -0
  157. package/extensions/mega-runtime/runtime-snapshot.ts +1 -0
  158. package/extensions/mega-runtime/runtime.ts +7 -0
  159. package/extensions/mega-runtime/snapshot.ts +6 -0
  160. package/extensions/mega-runtime/widget-types.ts +3 -0
  161. package/extensions/mega-runtime/widget.ts +5 -0
  162. package/package.json +5 -2
  163. package/src/cache-stripe-impl.ts +385 -0
  164. package/src/cache-stripe.ts +18 -0
  165. package/src/config/stopwords.ts +25 -0
  166. package/src/config.ts +26 -0
  167. package/src/embedder.ts +42 -2
  168. package/src/memoryGraph.ts +438 -0
  169. package/src/memoryStats.ts +107 -0
  170. package/src/monitoring.ts +35 -0
  171. package/src/prefix-break.ts +83 -0
  172. package/src/pricing.ts +2 -2
  173. package/src/queryExpansion.ts +206 -0
  174. package/src/queryReformulation/cache.ts +169 -0
  175. package/src/queryReformulation/rrf.ts +51 -0
  176. package/src/queryReformulation/tfidf.ts +79 -0
  177. package/src/queryReformulation/vagueness.ts +38 -0
  178. package/src/queryReformulation.ts +355 -0
  179. package/src/recallMetrics.ts +388 -0
  180. package/src/store/sqlite/cache-stripes.ts +196 -0
  181. package/src/store/sqlite/fts5-search.ts +90 -0
  182. package/src/store/sqlite/perf-samples.ts +218 -23
  183. package/src/store/sqlite/schema.ts +60 -1
  184. package/src/store/sqlite.ts +1 -0
  185. package/src/store/turns/memory-store.ts +10 -1
  186. package/src/store/turns/sqlite-store.ts +27 -15
  187. package/src/store/turns/types.ts +21 -0
  188. package/src/store/vectorIndex.ts +71 -11
  189. package/src/tiered-router/types.ts +64 -0
  190. package/src/tieredRouter.ts +489 -0
  191. package/src/vectorStore.ts +9 -5
  192. package/dist/extensions/conflict-scan.test.js +0 -115
  193. package/dist/extensions/dashboard-server/api-contracts.test.js +0 -884
  194. package/dist/extensions/dashboard-server/html.test.js +0 -52
  195. package/dist/extensions/dashboard-server/perf-server.test.js +0 -80
  196. package/dist/extensions/dashboard-server/routes-cache.test.js +0 -248
  197. package/dist/extensions/dashboard-server/server.test.js +0 -120
  198. package/dist/extensions/dashboard-server-s32.test.js +0 -181
  199. package/dist/extensions/dashboard-server.test.js +0 -339
  200. package/dist/extensions/mega-cache-replay.test.js +0 -400
  201. package/dist/extensions/mega-compact-s38.test.js +0 -1383
  202. package/dist/extensions/mega-compact.test.js +0 -1112
  203. package/dist/extensions/mega-events.test.js +0 -47
  204. package/dist/extensions/mega-game-cmds.test.js +0 -163
  205. package/dist/extensions/mega-runtime/snapshot.test.js +0 -127
  206. package/dist/extensions/mega-runtime/state.test.js +0 -266
  207. package/dist/extensions/mega-runtime/widget.test.js +0 -343
  208. package/dist/extensions/mega-shutdown-widget.test.js +0 -121
  209. package/dist/extensions/mega-teamrun.test.js +0 -156
  210. package/dist/extensions/mega-trim.test.js +0 -58
  211. package/dist/extensions/mega-turn-store.test.js +0 -68
  212. package/dist/src/boundary.test.js +0 -170
  213. package/dist/src/compact.test.js +0 -78
  214. package/dist/src/config/themes.test.js +0 -94
  215. package/dist/src/dedup/dedup.test.js +0 -41
  216. package/dist/src/dedup/l1.test.js +0 -50
  217. package/dist/src/dedup/raptor/buildHistory.test.js +0 -292
  218. package/dist/src/dedup/raptor/multilevel-serve.test.js +0 -229
  219. package/dist/src/dedup/raptor/multilevel.test.js +0 -238
  220. package/dist/src/dedup/raptor/promote.test.js +0 -69
  221. package/dist/src/dedup/raptor/raptor.test.js +0 -248
  222. package/dist/src/dedup/raptor/retrieval.test.js +0 -95
  223. package/dist/src/dedup/raptor/serve-gate.test.js +0 -298
  224. package/dist/src/dedup/sprint12.test.js +0 -219
  225. package/dist/src/dedup-engine.test.js +0 -472
  226. package/dist/src/driftDetection.test.js +0 -87
  227. package/dist/src/e2e.test.js +0 -698
  228. package/dist/src/engine.test.js +0 -111
  229. package/dist/src/extractive.test.js +0 -147
  230. package/dist/src/fork.test.js +0 -81
  231. package/dist/src/game/scoring.test.js +0 -98
  232. package/dist/src/httpEmbedder.test.js +0 -277
  233. package/dist/src/importance.test.js +0 -372
  234. package/dist/src/intent.test.js +0 -78
  235. package/dist/src/log.test.js +0 -42
  236. package/dist/src/mechanical-fix.test.js +0 -65
  237. package/dist/src/memory.test.js +0 -70
  238. package/dist/src/memoryConsolidate.test.js +0 -38
  239. package/dist/src/memoryOps.test.js +0 -129
  240. package/dist/src/memoryRecall.test.js +0 -171
  241. package/dist/src/memoryRoundtrip.test.js +0 -137
  242. package/dist/src/metrics/turns.test.js +0 -152
  243. package/dist/src/mirror/mirror.test.js +0 -185
  244. package/dist/src/raptor-inject-summaries.test.js +0 -162
  245. package/dist/src/ratio.bench.test.js +0 -897
  246. package/dist/src/recall.integration.test.js +0 -77
  247. package/dist/src/recall.test.js +0 -379
  248. package/dist/src/sprint14.test.js +0 -219
  249. package/dist/src/sprint4x-rag-verification.test.js +0 -93
  250. package/dist/src/store/compression.test.js +0 -139
  251. package/dist/src/store/memoryIndex.test.js +0 -51
  252. package/dist/src/store/migrate.test.js +0 -139
  253. package/dist/src/store/pgOpenGuard.test.js +0 -74
  254. package/dist/src/store/phase01.test.js +0 -81
  255. package/dist/src/store/phase04.test.js +0 -54
  256. package/dist/src/store/sprint10.test.js +0 -186
  257. package/dist/src/store/sqlite/game-achievements.test.js +0 -67
  258. package/dist/src/store/sqlite/game-scores.test.js +0 -106
  259. package/dist/src/store/sqlite/game-state.test.js +0 -76
  260. package/dist/src/store/sqlite/global-index.test.js +0 -136
  261. package/dist/src/store/sqlite/mechanical-fix.test.js +0 -146
  262. package/dist/src/store/sqlite/perf-samples.test.js +0 -146
  263. package/dist/src/store/sqlite/raptor.test.js +0 -106
  264. package/dist/src/store/sqlite/turns.test.js +0 -183
  265. package/dist/src/store/sqlite.cachehit.test.js +0 -55
  266. package/dist/src/store/sqlite.dbmaint.test.js +0 -158
  267. package/dist/src/store/sqlite.dbmirror.test.js +0 -184
  268. package/dist/src/store/turns/contract-compliance.test.js +0 -428
  269. package/dist/src/store/turns/memory-store.test.js +0 -9
  270. package/dist/src/store/turns/migrations.test.js +0 -138
  271. package/dist/src/store/turns/sqlite-store.test.js +0 -144
  272. package/dist/src/store/vectorIndex.test.js +0 -123
  273. package/dist/src/store.test.js +0 -161
  274. package/dist/src/supersede.test.js +0 -36
  275. package/dist/src/topics/cluster.test.js +0 -150
  276. package/dist/src/topics/store.test.js +0 -117
  277. package/dist/src/types.test.js +0 -9
  278. package/dist/src/vector-search-cache.test.js +0 -157
  279. package/dist/src/vectorStore.test.js +0 -479
  280. package/dist/src/wiki.test.js +0 -171
  281. package/extensions/conflict-scan.test.ts +0 -129
  282. package/extensions/dashboard-client/dist/assets/AchievementsTab-DjxfYrDc.js +0 -2
  283. package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js +0 -2
  284. package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js.map +0 -1
  285. package/extensions/dashboard-client/dist/assets/GameTab-BLDudcO5.js +0 -2
  286. package/extensions/dashboard-client/dist/assets/OverviewTab-D4kGvsiQ.js +0 -2
  287. package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js +0 -2
  288. package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js.map +0 -1
  289. package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js +0 -2
  290. package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js.map +0 -1
  291. package/extensions/dashboard-client/dist/assets/index-BEdKlpAB.css +0 -1
  292. package/extensions/dashboard-client/dist/assets/index-BX0bcgLu.js +0 -42
  293. package/extensions/dashboard-client/dist/assets/index-BX0bcgLu.js.map +0 -1
  294. package/extensions/dashboard-server/api-contracts.test.ts +0 -1065
  295. package/extensions/dashboard-server/html.test.ts +0 -62
  296. package/extensions/dashboard-server/perf-server.test.ts +0 -101
  297. package/extensions/dashboard-server/routes-cache.test.ts +0 -302
  298. package/extensions/dashboard-server/server.test.ts +0 -131
  299. package/extensions/dashboard-server-s32.test.ts +0 -195
  300. package/extensions/dashboard-server.test.ts +0 -382
  301. package/extensions/mega-cache-replay.test.ts +0 -526
  302. package/extensions/mega-compact-s38.test.ts +0 -1433
  303. package/extensions/mega-compact.test.ts +0 -1509
  304. package/extensions/mega-events.test.ts +0 -55
  305. package/extensions/mega-game-cmds.test.ts +0 -197
  306. package/extensions/mega-runtime/snapshot.test.ts +0 -139
  307. package/extensions/mega-runtime/state.test.ts +0 -262
  308. package/extensions/mega-runtime/widget.test.ts +0 -468
  309. package/extensions/mega-shutdown-widget.test.ts +0 -141
  310. package/extensions/mega-teamrun.test.ts +0 -176
  311. package/extensions/mega-trim.test.ts +0 -64
  312. package/extensions/mega-turn-store.test.ts +0 -108
  313. package/src/boundary.test.ts +0 -187
  314. package/src/compact.test.ts +0 -99
  315. package/src/config/themes.test.ts +0 -116
  316. package/src/dedup/dedup.test.ts +0 -46
  317. package/src/dedup/l1.test.ts +0 -57
  318. package/src/dedup/raptor/buildHistory.test.ts +0 -353
  319. package/src/dedup/raptor/multilevel-serve.test.ts +0 -273
  320. package/src/dedup/raptor/multilevel.test.ts +0 -325
  321. package/src/dedup/raptor/promote.test.ts +0 -82
  322. package/src/dedup/raptor/raptor.test.ts +0 -297
  323. package/src/dedup/raptor/retrieval.test.ts +0 -118
  324. package/src/dedup/raptor/serve-gate.test.ts +0 -348
  325. package/src/dedup/sprint12.test.ts +0 -242
  326. package/src/dedup-engine.test.ts +0 -670
  327. package/src/driftDetection.test.ts +0 -100
  328. package/src/e2e.test.ts +0 -843
  329. package/src/engine.test.ts +0 -123
  330. package/src/extractive.test.ts +0 -174
  331. package/src/fork.test.ts +0 -94
  332. package/src/game/scoring.test.ts +0 -103
  333. package/src/httpEmbedder.test.ts +0 -286
  334. package/src/importance.test.ts +0 -538
  335. package/src/intent.test.ts +0 -87
  336. package/src/log.test.ts +0 -47
  337. package/src/mechanical-fix.test.ts +0 -70
  338. package/src/memory.test.ts +0 -92
  339. package/src/memoryConsolidate.test.ts +0 -47
  340. package/src/memoryOps.test.ts +0 -148
  341. package/src/memoryRecall.test.ts +0 -194
  342. package/src/memoryRoundtrip.test.ts +0 -155
  343. package/src/metrics/turns.test.ts +0 -165
  344. package/src/mirror/mirror.test.ts +0 -240
  345. package/src/raptor-inject-summaries.test.ts +0 -228
  346. package/src/ratio.bench.test.ts +0 -1316
  347. package/src/recall.integration.test.ts +0 -96
  348. package/src/recall.test.ts +0 -467
  349. package/src/sprint14.test.ts +0 -245
  350. package/src/sprint4x-rag-verification.test.ts +0 -119
  351. package/src/store/compression.test.ts +0 -168
  352. package/src/store/memoryIndex.test.ts +0 -61
  353. package/src/store/migrate.test.ts +0 -158
  354. package/src/store/pgOpenGuard.test.ts +0 -89
  355. package/src/store/phase01.test.ts +0 -88
  356. package/src/store/phase04.test.ts +0 -58
  357. package/src/store/sprint10.test.ts +0 -214
  358. package/src/store/sqlite/game-achievements.test.ts +0 -80
  359. package/src/store/sqlite/game-scores.test.ts +0 -132
  360. package/src/store/sqlite/game-state.test.ts +0 -89
  361. package/src/store/sqlite/global-index.test.ts +0 -222
  362. package/src/store/sqlite/mechanical-fix.test.ts +0 -162
  363. package/src/store/sqlite/perf-samples.test.ts +0 -169
  364. package/src/store/sqlite/raptor.test.ts +0 -139
  365. package/src/store/sqlite/turns.test.ts +0 -218
  366. package/src/store/sqlite.cachehit.test.ts +0 -68
  367. package/src/store/sqlite.dbmaint.test.ts +0 -193
  368. package/src/store/sqlite.dbmirror.test.ts +0 -229
  369. package/src/store/turns/contract-compliance.test.ts +0 -562
  370. package/src/store/turns/memory-store.test.ts +0 -15
  371. package/src/store/turns/migrations.test.ts +0 -161
  372. package/src/store/turns/sqlite-store.test.ts +0 -161
  373. package/src/store/vectorIndex.test.ts +0 -140
  374. package/src/store.test.ts +0 -191
  375. package/src/supersede.test.ts +0 -42
  376. package/src/topics/cluster.test.ts +0 -176
  377. package/src/topics/store.test.ts +0 -132
  378. package/src/types.test.ts +0 -10
  379. package/src/vector-search-cache.test.ts +0 -190
  380. package/src/vectorStore.test.ts +0 -533
  381. package/src/wiki.test.ts +0 -217
@@ -1,52 +0,0 @@
1
- /**
2
- * html.test.ts — S34 Game Mode tab presence in the dashboard HTML template.
3
- */
4
- import { test, describe } from "node:test";
5
- import assert from "node:assert/strict";
6
- import { dashboardHtml } from "./html.js";
7
- describe("S34 dashboard HTML Game Mode", () => {
8
- const html = dashboardHtml("custom");
9
- test("Game Mode tab button + panel-game exist", () => {
10
- assert.ok(html.includes('<button class="tab" data-tab="game">Game Mode</button>'), "game tab button present");
11
- assert.ok(html.includes('<div class="tab-panel" id="panel-game">'), "panel-game present");
12
- });
13
- test("level-up-pulse + mega-flash keyframes present", () => {
14
- assert.ok(html.includes("@keyframes level-up-pulse"), "level-up-pulse keyframe present");
15
- assert.ok(html.includes("@keyframes mega-flash"), "mega-flash keyframe present");
16
- });
17
- test("empty-state string present", () => {
18
- assert.ok(html.includes("No scores yet — run a session with game mode on."), "empty-state string present");
19
- });
20
- });
21
- describe("S35 dashboard HTML achievements", () => {
22
- const html = dashboardHtml("custom");
23
- test("Achievements heading + ach-tiles/ach-toast containers present", () => {
24
- assert.ok(html.includes(">Achievements</h3>"), "Achievements heading present");
25
- assert.ok(html.includes('id="ach-tiles"'), "ach-tiles container present");
26
- assert.ok(html.includes('id="ach-toast"'), "ach-toast element present");
27
- });
28
- test("ach-unlock-pulse keyframe + ach-tile classes present", () => {
29
- assert.ok(html.includes("@keyframes ach-unlock-pulse"), "ach-unlock-pulse keyframe present");
30
- assert.ok(html.includes(".ach-tile"), "ach-tile class present");
31
- assert.ok(html.includes(".ach-tile.unlocked"), "unlocked class present");
32
- assert.ok(html.includes(".ach-tile.locked"), "locked class present");
33
- });
34
- test("renderAchievements fn + GET /api/achievements fetch present", () => {
35
- assert.ok(html.includes("function renderAchievements"), "renderAchievements fn present");
36
- assert.ok(html.includes("fetch('/api/achievements')"), "achievements fetch present");
37
- });
38
- test("visible-but-locked teaser string present", () => {
39
- assert.ok(html.includes("??? "), "??? teaser present");
40
- });
41
- });
42
- describe("S35 dashboard HTML achievements escaping (v0.8.4 fix)", () => {
43
- const html = dashboardHtml("custom");
44
- test("Opie's Wild Ride JS string is backslash-escaped (no bare apostrophe)", () => {
45
- // The served <script> uses single-quoted JS strings: '🏆 Opie\'s Wild Ride...'.
46
- // A bare apostrophe (Opie's) would terminate the string and halt the script,
47
- // breaking .tab click bindings. The served HTML MUST contain the escaped
48
- // form Opie\'s and MUST NOT contain the bare form '🏆 Opie's'.
49
- assert.ok(html.includes("🏆 Opie\\'s Wild Ride"), "served JS contains Opie\\'s (escaped)");
50
- assert.ok(!html.includes("🏆 Opie's Wild Ride"), "no bare Opie's in served JS");
51
- });
52
- });
@@ -1,80 +0,0 @@
1
- /**
2
- * perf-server.test.ts — v0.8.8 /api/perf endpoint (GET aggregates + 405).
3
- * Mirrors the server.test.ts spawn-and-fetch harness (self-contained so the
4
- * dashboard HTTP-port lane stays isolated).
5
- */
6
- import { test, describe } from "node:test";
7
- import assert from "node:assert/strict";
8
- import { mkdtempSync, rmSync, readFileSync } from "node:fs";
9
- import { tmpdir } from "node:os";
10
- import { join } from "node:path";
11
- import { spawn } from "node:child_process";
12
- import { recordPerfSample } from "../../src/store/sqlite.js";
13
- const SERVER_ENTRY = new URL("./server.js", import.meta.url).pathname;
14
- function waitFor(cond, timeoutMs = 6000) {
15
- const start = Date.now();
16
- return new Promise((resolve, reject) => {
17
- const tick = async () => {
18
- if (await cond())
19
- return resolve();
20
- if (Date.now() - start > timeoutMs)
21
- return reject(new Error("timeout"));
22
- setTimeout(tick, 50);
23
- };
24
- tick();
25
- });
26
- }
27
- function freshDir(prefix) {
28
- return mkdtempSync(join(tmpdir(), prefix));
29
- }
30
- async function withServer(port, dir, fn) {
31
- process.env.MEGACOMPACT_DASHBOARD_PORT = port;
32
- const child = spawn(process.execPath, [SERVER_ENTRY, dir], { stdio: "ignore" });
33
- try {
34
- await waitFor(async () => {
35
- try {
36
- const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
37
- const res = await fetch(`http://localhost:${raw.port}/api/version`);
38
- return res.ok;
39
- }
40
- catch {
41
- return false;
42
- }
43
- });
44
- const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
45
- return await fn(raw.port);
46
- }
47
- finally {
48
- child.kill("SIGTERM");
49
- delete process.env.MEGACOMPACT_DASHBOARD_PORT;
50
- rmSync(dir, { recursive: true, force: true });
51
- }
52
- }
53
- describe("v0.8.8 /api/perf", () => {
54
- test("GET returns aggregates over recorded perf_samples", async () => {
55
- const dir = freshDir("dash-perf-agg-");
56
- recordPerfSample(dir, "turn_latency_ms", 100, { turnIndex: 1 });
57
- recordPerfSample(dir, "turn_latency_ms", 200);
58
- recordPerfSample(dir, "tps", 50);
59
- recordPerfSample(dir, "rss_mb", 256);
60
- await withServer("19440", dir, async (port) => {
61
- const res = await fetch(`http://localhost:${port}/api/perf?minutes=30`);
62
- assert.equal(res.status, 200);
63
- const d = (await res.json());
64
- assert.equal(d.sampleCount, 4);
65
- assert.equal(d.turn_latency_ms.n, 2);
66
- assert.equal(d.turn_latency_ms.p50, 100); // nearest-rank p50 of [100,200]
67
- assert.equal(d.turn_latency_ms.p95, 200); // nearest-rank p95 of [100,200]
68
- assert.equal(d.tps.avg, 50);
69
- assert.equal(d.rss_mb.latest, 256);
70
- assert.equal(d.diag, null); // no runtime wrote dashboard.json in this dir
71
- });
72
- });
73
- test("non-GET (POST) -> 405", async () => {
74
- const dir = freshDir("dash-perf-meth-");
75
- await withServer("19441", dir, async (port) => {
76
- const res = await fetch(`http://localhost:${port}/api/perf`, { method: "POST" });
77
- assert.equal(res.status, 405);
78
- });
79
- });
80
- });
@@ -1,248 +0,0 @@
1
- /**
2
- * routes-cache.test.ts — Sprint A /api/provider-cache endpoint tests.
3
- *
4
- * Covers the A.4 spec:
5
- * - GET 200 → shape matches ProviderCacheResponse
6
- * - POST → 405
7
- * - empty perf_samples → zeros/nulls
8
- * - no model snapshot → savings: null
9
- * - with model snapshot → priced savings fields
10
- *
11
- * Uses the same spawn-and-fetch harness as perf-server.test.ts.
12
- */
13
- import { test, describe } from "node:test";
14
- import assert from "node:assert/strict";
15
- import { mkdtempSync, rmSync, readFileSync } from "node:fs";
16
- import { tmpdir } from "node:os";
17
- import { join } from "node:path";
18
- import { spawn } from "node:child_process";
19
- import { recordPerfSample, recordModelSnapshot, } from "../../src/store/sqlite.js";
20
- const SERVER_ENTRY = new URL("./server.js", import.meta.url).pathname;
21
- function waitFor(cond, timeoutMs = 6000) {
22
- const start = Date.now();
23
- return new Promise((resolve, reject) => {
24
- const tick = async () => {
25
- if (await cond())
26
- return resolve();
27
- if (Date.now() - start > timeoutMs)
28
- return reject(new Error("timeout"));
29
- setTimeout(tick, 50);
30
- };
31
- tick();
32
- });
33
- }
34
- function freshDir(prefix) {
35
- return mkdtempSync(join(tmpdir(), prefix));
36
- }
37
- async function withServer(port, dir, fn) {
38
- process.env.MEGACOMPACT_DASHBOARD_PORT = port;
39
- const child = spawn(process.execPath, [SERVER_ENTRY, dir], {
40
- stdio: "ignore",
41
- });
42
- try {
43
- await waitFor(async () => {
44
- try {
45
- const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
46
- const res = await fetch(`http://localhost:${raw.port}/api/version`);
47
- return res.ok;
48
- }
49
- catch {
50
- return false;
51
- }
52
- });
53
- const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
54
- return await fn(raw.port);
55
- }
56
- finally {
57
- child.kill("SIGTERM");
58
- delete process.env.MEGACOMPACT_DASHBOARD_PORT;
59
- rmSync(dir, { recursive: true, force: true });
60
- }
61
- }
62
- describe("/api/provider-cache", () => {
63
- test("GET 200 — shape matches ProviderCacheResponse", async () => {
64
- const dir = freshDir("dash-pcache-agg-");
65
- // Seed one cache_hit_pct sample with full meta.
66
- recordPerfSample(dir, "cache_hit_pct", 42, {
67
- cacheRead: 100,
68
- cacheWrite: 20,
69
- input: 500,
70
- });
71
- await withServer("19450", dir, async (port) => {
72
- const res = await fetch(`http://localhost:${port}/api/provider-cache`);
73
- assert.equal(res.status, 200);
74
- const body = (await res.json());
75
- // Shape assertions
76
- assert.ok("cache" in body, "should have cache");
77
- assert.ok("savings" in body, "should have savings");
78
- assert.ok("updatedAt" in body, "should have updatedAt");
79
- assert.equal(body.cache.turnCount, 1);
80
- assert.equal(body.cache.totalCacheRead, 100);
81
- assert.equal(body.cache.totalCacheWrite, 20);
82
- assert.equal(body.cache.totalInput, 500);
83
- assert.ok(typeof body.cache.firstTurnAt === "string");
84
- assert.ok(typeof body.cache.latestTurnAt === "string");
85
- assert.ok(typeof body.updatedAt === "string");
86
- });
87
- });
88
- test("GET 200 — empty perf_samples returns zeros/nulls", async () => {
89
- const dir = freshDir("dash-pcache-empty-");
90
- await withServer("19451", dir, async (port) => {
91
- const res = await fetch(`http://localhost:${port}/api/provider-cache`);
92
- assert.equal(res.status, 200);
93
- const body = (await res.json());
94
- assert.equal(body.cache.turnCount, 0);
95
- assert.equal(body.cache.avgHitPct, 0);
96
- assert.equal(body.cache.totalCacheRead, 0);
97
- assert.equal(body.cache.totalCacheWrite, 0);
98
- assert.equal(body.cache.totalInput, 0);
99
- assert.equal(body.cache.firstTurnAt, null);
100
- assert.equal(body.cache.latestTurnAt, null);
101
- assert.equal(body.savings, null);
102
- });
103
- });
104
- test("POST → 405", async () => {
105
- const dir = freshDir("dash-pcache-meth-");
106
- await withServer("19452", dir, async (port) => {
107
- const res = await fetch(`http://localhost:${port}/api/provider-cache`, {
108
- method: "POST",
109
- });
110
- assert.equal(res.status, 405);
111
- const body = (await res.json());
112
- assert.equal(body.error, "method_not_allowed");
113
- });
114
- });
115
- test("no model snapshot → savings: null", async () => {
116
- const dir = freshDir("dash-pcache-nosnap-");
117
- recordPerfSample(dir, "cache_hit_pct", 50, {
118
- cacheRead: 200,
119
- cacheWrite: 30,
120
- input: 1000,
121
- });
122
- await withServer("19453", dir, async (port) => {
123
- const res = await fetch(`http://localhost:${port}/api/provider-cache`);
124
- assert.equal(res.status, 200);
125
- const body = (await res.json());
126
- assert.equal(body.savings, null);
127
- });
128
- });
129
- test("with model snapshot → priced savings fields", async () => {
130
- const dir = freshDir("dash-pcache-savings-");
131
- recordPerfSample(dir, "cache_hit_pct", 50, {
132
- cacheRead: 2000,
133
- cacheWrite: 400,
134
- input: 10000,
135
- });
136
- // Record a model snapshot with a known input rate.
137
- recordModelSnapshot("/tmp/test-repo", {
138
- provider: "anthropic",
139
- providerName: "Anthropic",
140
- modelId: "claude-sonnet-4-20250514",
141
- modelName: "Claude Sonnet 4",
142
- inputRate: 3e-6, // $3 / 1M tokens
143
- outputRate: 15e-6,
144
- contextWindow: 200000,
145
- maxTokens: 32000,
146
- reasoning: false,
147
- }, dir);
148
- await withServer("19454", dir, async (port) => {
149
- const res = await fetch(`http://localhost:${port}/api/provider-cache`);
150
- assert.equal(res.status, 200);
151
- const body = (await res.json());
152
- assert.ok(body.savings, "savings should not be null");
153
- // cacheReadSaved = 2000 * 3e-6 * 0.9 = 0.0054
154
- assert.ok(body.savings.cacheReadSaved > 0, "cacheReadSaved > 0");
155
- // cacheWriteCost = 400 * 3e-6 * 0.25 = 0.0003
156
- assert.ok(body.savings.cacheWriteCost > 0, "cacheWriteCost > 0");
157
- assert.ok(body.savings.netSaved ===
158
- body.savings.cacheReadSaved - body.savings.cacheWriteCost, "netSaved = cacheReadSaved - cacheWriteCost");
159
- assert.equal(body.savings.model, "Claude Sonnet 4");
160
- assert.equal(body.savings.inputRate, 3e-6);
161
- });
162
- });
163
- test("partial meta (missing fields) → treated as 0", async () => {
164
- const dir = freshDir("dash-pcache-partial-");
165
- // Only input in meta; cacheRead/cacheWrite missing → treated as 0.
166
- recordPerfSample(dir, "cache_hit_pct", 30, { input: 800 });
167
- // Only cacheRead in meta; input/cacheWrite missing → treated as 0.
168
- recordPerfSample(dir, "cache_hit_pct", 60, { cacheRead: 150 });
169
- await withServer("19455", dir, async (port) => {
170
- const res = await fetch(`http://localhost:${port}/api/provider-cache`);
171
- assert.equal(res.status, 200);
172
- const body = (await res.json());
173
- // First sample: input=800, cacheRead=0, cacheWrite=0
174
- // Second sample: cacheRead=150, input=0, cacheWrite=0
175
- assert.equal(body.cache.turnCount, 2);
176
- assert.equal(body.cache.totalCacheRead, 150);
177
- assert.equal(body.cache.totalCacheWrite, 0);
178
- assert.equal(body.cache.totalInput, 800);
179
- });
180
- });
181
- test("NULL meta → counted in turnCount, contributes 0 tokens + 0 avg", async () => {
182
- const dir = freshDir("dash-pcache-nullmeta-");
183
- // avgHitPct is derived from (cacheRead / (cacheRead + input + cacheWrite)) * 100,
184
- // NOT from the `value` column. NULL meta → no tokens → avg 0, not 25.
185
- recordPerfSample(dir, "cache_hit_pct", 25, undefined);
186
- await withServer("19456", dir, async (port) => {
187
- const res = await fetch(`http://localhost:${port}/api/provider-cache`);
188
- assert.equal(res.status, 200);
189
- const body = (await res.json());
190
- assert.equal(body.cache.turnCount, 1);
191
- assert.equal(body.cache.avgHitPct, 0);
192
- assert.equal(body.cache.totalCacheRead, 0);
193
- assert.equal(body.cache.totalCacheWrite, 0);
194
- assert.equal(body.cache.totalInput, 0);
195
- });
196
- });
197
- test("model snapshot with modelName=null → falls back to modelId", async () => {
198
- const dir = freshDir("dash-pcache-modelid-");
199
- recordPerfSample(dir, "cache_hit_pct", 10, {
200
- cacheRead: 100,
201
- cacheWrite: 10,
202
- input: 1000,
203
- });
204
- recordModelSnapshot("/tmp/test-repo", {
205
- provider: "openai",
206
- providerName: null,
207
- modelId: "gpt-4o",
208
- modelName: null,
209
- inputRate: 2.5e-6,
210
- outputRate: 10e-6,
211
- contextWindow: 128000,
212
- maxTokens: 16384,
213
- reasoning: false,
214
- }, dir);
215
- await withServer("19457", dir, async (port) => {
216
- const res = await fetch(`http://localhost:${port}/api/provider-cache`);
217
- assert.equal(res.status, 200);
218
- const body = (await res.json());
219
- assert.ok(body.savings);
220
- assert.equal(body.savings.model, "gpt-4o");
221
- });
222
- });
223
- test("model snapshot with zero inputRate → savings: null", async () => {
224
- const dir = freshDir("dash-pcache-zerorate-");
225
- recordPerfSample(dir, "cache_hit_pct", 10, {
226
- cacheRead: 100,
227
- cacheWrite: 10,
228
- input: 1000,
229
- });
230
- recordModelSnapshot("/tmp/test-repo", {
231
- provider: "local",
232
- providerName: null,
233
- modelId: "local-llm",
234
- modelName: null,
235
- inputRate: 0,
236
- outputRate: 0,
237
- contextWindow: 4096,
238
- maxTokens: 2048,
239
- reasoning: false,
240
- }, dir);
241
- await withServer("19458", dir, async (port) => {
242
- const res = await fetch(`http://localhost:${port}/api/provider-cache`);
243
- assert.equal(res.status, 200);
244
- const body = (await res.json());
245
- assert.equal(body.savings, null);
246
- });
247
- });
248
- });
@@ -1,120 +0,0 @@
1
- /**
2
- * server.test.ts — S34 /api/game-scores endpoint (GET leaderboard, metric
3
- * validation, method + limit handling). Mirrors the S32 /api/game-state
4
- * spawn-and-fetch harness.
5
- */
6
- import { test, describe } from "node:test";
7
- import assert from "node:assert/strict";
8
- import { mkdtempSync, rmSync, readFileSync } from "node:fs";
9
- import { tmpdir } from "node:os";
10
- import { join } from "node:path";
11
- import { spawn } from "node:child_process";
12
- import { recordScore } from "../../src/store/sqlite.js";
13
- const SERVER_ENTRY = new URL("./server.js", import.meta.url).pathname;
14
- function waitFor(cond, timeoutMs = 6000) {
15
- const start = Date.now();
16
- return new Promise((resolve, reject) => {
17
- const tick = async () => {
18
- if (await cond())
19
- return resolve();
20
- if (Date.now() - start > timeoutMs)
21
- return reject(new Error("timeout"));
22
- setTimeout(tick, 50);
23
- };
24
- tick();
25
- });
26
- }
27
- function freshDir(prefix) {
28
- return mkdtempSync(join(tmpdir(), prefix));
29
- }
30
- async function withServer(port, dir, fn) {
31
- process.env.MEGACOMPACT_DASHBOARD_PORT = port;
32
- const child = spawn(process.execPath, [SERVER_ENTRY, dir], { stdio: "ignore" });
33
- try {
34
- await waitFor(async () => {
35
- try {
36
- const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
37
- const res = await fetch(`http://localhost:${raw.port}/api/version`);
38
- return res.ok;
39
- }
40
- catch {
41
- return false;
42
- }
43
- });
44
- const raw = JSON.parse(readFileSync(join(dir, "port.pid"), "utf-8"));
45
- return await fn(raw.port);
46
- }
47
- finally {
48
- child.kill("SIGTERM");
49
- delete process.env.MEGACOMPACT_DASHBOARD_PORT;
50
- rmSync(dir, { recursive: true, force: true });
51
- }
52
- }
53
- describe("S34 /api/game-scores", () => {
54
- test("GET ?metric=cache returns recorded rows as JSON array", async () => {
55
- const dir = freshDir("dash-gs-cache-");
56
- recordScore(dir, { repo_root: "/repo/a", metric: "cache", value: 42 });
57
- await withServer("19430", dir, async (port) => {
58
- const res = await fetch(`http://localhost:${port}/api/game-scores?metric=cache`);
59
- assert.equal(res.status, 200);
60
- const rows = (await res.json());
61
- assert.ok(Array.isArray(rows));
62
- assert.equal(rows.length, 1);
63
- assert.equal(rows[0].repo_root, "/repo/a");
64
- assert.equal(rows[0].value, 42);
65
- assert.ok(typeof rows[0].ts === "number");
66
- });
67
- });
68
- test("unknown metric -> 400", async () => {
69
- const dir = freshDir("dash-gs-bad-");
70
- await withServer("19431", dir, async (port) => {
71
- const res = await fetch(`http://localhost:${port}/api/game-scores?metric=bogus`);
72
- assert.equal(res.status, 400);
73
- });
74
- });
75
- test("non-GET (POST) -> 405", async () => {
76
- const dir = freshDir("dash-gs-meth-");
77
- await withServer("19432", dir, async (port) => {
78
- const res = await fetch(`http://localhost:${port}/api/game-scores`, { method: "POST" });
79
- assert.equal(res.status, 405);
80
- });
81
- });
82
- test("limit clamp: 3 rows -> default 10 returns 3, limit=2 caps to 2, limit<=0 clamps to >=1", async () => {
83
- const dir = freshDir("dash-gs-lim-");
84
- recordScore(dir, { repo_root: "/repo/a", metric: "cache", value: 1 });
85
- recordScore(dir, { repo_root: "/repo/b", metric: "cache", value: 2 });
86
- recordScore(dir, { repo_root: "/repo/c", metric: "cache", value: 3 });
87
- await withServer("19433", dir, async (port) => {
88
- const all = (await fetch(`http://localhost:${port}/api/game-scores?metric=cache`).then((r) => r.json()));
89
- assert.equal(all.length, 3);
90
- const capped = (await fetch(`http://localhost:${port}/api/game-scores?metric=cache&limit=2`).then((r) => r.json()));
91
- assert.equal(capped.length, 2);
92
- const zero = (await fetch(`http://localhost:${port}/api/game-scores?metric=cache&limit=0`).then((r) => r.json()));
93
- assert.ok(zero.length >= 1, "limit<=0 clamps to >=1 row");
94
- });
95
- });
96
- });
97
- describe("S35 /api/achievements", () => {
98
- test("GET returns the 9 seeded achievement rows", async () => {
99
- const dir = freshDir("dash-ach-");
100
- await withServer("19434", dir, async (port) => {
101
- const res = await fetch(`http://localhost:${port}/api/achievements`);
102
- assert.equal(res.status, 200);
103
- const rows = (await res.json());
104
- assert.ok(Array.isArray(rows));
105
- assert.equal(rows.length, 9);
106
- const opie = rows.find((r) => r.id === "opie_wild_ride");
107
- assert.ok(opie, "opie_wild_ride seeded");
108
- assert.equal(opie.hidden, 1);
109
- assert.equal(opie.unlocked_at, null);
110
- assert.equal(rows.find((r) => r.id === "first_compact").title, "First Compact");
111
- });
112
- });
113
- test("non-GET (POST) -> 405", async () => {
114
- const dir = freshDir("dash-ach-meth-");
115
- await withServer("19435", dir, async (port) => {
116
- const res = await fetch(`http://localhost:${port}/api/achievements`, { method: "POST" });
117
- assert.equal(res.status, 405);
118
- });
119
- });
120
- });