dsh-context-compression-improved 0.11.1 → 0.11.3

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 (311) hide show
  1. package/README.md +15 -110
  2. package/README.zh.md +14 -104
  3. package/THIRD_PARTY_NOTICES.md +25 -7
  4. package/{packages/selector/dsh.plugin.json → dsh.plugin.json} +1 -1
  5. package/{packages/selector/lib → lib}/client.js +27 -10
  6. package/{packages/selector/lib → lib}/index.js +101 -0
  7. package/package.json +125 -112
  8. package/screenshots.json +3 -6
  9. package/.agents/plans/improve/checklist.md +0 -32
  10. package/.agents/plans/improve/findings.md +0 -102
  11. package/.agents/plans/improve/spec.md +0 -53
  12. package/.agents/plans/improve/tasks.md +0 -70
  13. package/.gitattributes +0 -2
  14. package/.githooks/pre-push +0 -37
  15. package/.github/workflows/ci.yml +0 -47
  16. package/CHANGELOG.de.md +0 -580
  17. package/CHANGELOG.es.md +0 -588
  18. package/CHANGELOG.fr.md +0 -576
  19. package/CHANGELOG.it.md +0 -577
  20. package/CHANGELOG.ja.md +0 -261
  21. package/CHANGELOG.ko.md +0 -254
  22. package/CHANGELOG.md +0 -557
  23. package/CHANGELOG.ru.md +0 -554
  24. package/CHANGELOG.zh.md +0 -247
  25. package/CONTRIBUTING.md +0 -22
  26. package/README.de.md +0 -96
  27. package/README.es.md +0 -96
  28. package/README.fr.md +0 -96
  29. package/README.it.md +0 -96
  30. package/README.ja.md +0 -102
  31. package/README.ko.md +0 -102
  32. package/README.ru.md +0 -96
  33. package/SECURITY.md +0 -18
  34. package/assets/board.png +0 -0
  35. package/assets/context.png +0 -0
  36. package/assets/dshfind-card.svg +0 -33
  37. package/docs/assets/context-compression-selector-profiles.jpg +0 -0
  38. package/docs/assets/context-compression-selector-settings.png +0 -0
  39. package/docs/compat-0.1.5-report.md +0 -77
  40. package/docs/installation.de.md +0 -104
  41. package/docs/installation.es.md +0 -104
  42. package/docs/installation.fr.md +0 -104
  43. package/docs/installation.it.md +0 -104
  44. package/docs/installation.ja.md +0 -78
  45. package/docs/installation.ko.md +0 -78
  46. package/docs/installation.md +0 -103
  47. package/docs/installation.ru.md +0 -104
  48. package/docs/installation.zh.md +0 -100
  49. package/docs/repair-log.md +0 -657
  50. package/docs/shallow-teaching-preset-template.md +0 -46
  51. package/eslint.config.js +0 -30
  52. package/packages/selector/LICENSE +0 -21
  53. package/packages/selector/README.md +0 -26
  54. package/packages/selector/README.zh.md +0 -24
  55. package/packages/selector/THIRD_PARTY_NOTICES.md +0 -32
  56. package/packages/selector/docs/history-tool-call-working-set-spec.md +0 -112
  57. package/packages/selector/docs/native-tool-result-selector-spec.md +0 -34
  58. package/packages/selector/docs/subagent-cache-reuse-spec.md +0 -46
  59. package/packages/selector/lib/style.css +0 -350
  60. package/packages/selector/package.json +0 -178
  61. package/packages/selector/screenshots.json +0 -3
  62. package/packages/selector/src/client/CompressionProfileControls.tsx +0 -352
  63. package/packages/selector/src/client/CompressionProfileSelector.module.css +0 -199
  64. package/packages/selector/src/client/CompressionProfileSelector.tsx +0 -89
  65. package/packages/selector/src/client/CustomPolicyEditor.tsx +0 -216
  66. package/packages/selector/src/client/EstimatorControls.tsx +0 -277
  67. package/packages/selector/src/client/bridge-scope.ts +0 -125
  68. package/packages/selector/src/client/decode.ts +0 -68
  69. package/packages/selector/src/client/fab-pos.ts +0 -71
  70. package/packages/selector/src/client/index.ts +0 -438
  71. package/packages/selector/src/client/locales/de.ts +0 -167
  72. package/packages/selector/src/client/locales/es.ts +0 -167
  73. package/packages/selector/src/client/locales/fr.ts +0 -167
  74. package/packages/selector/src/client/locales/it.ts +0 -167
  75. package/packages/selector/src/client/locales/ja.ts +0 -167
  76. package/packages/selector/src/client/locales/ko.ts +0 -167
  77. package/packages/selector/src/client/locales/ru.ts +0 -167
  78. package/packages/selector/src/client/locales.ts +0 -334
  79. package/packages/selector/src/client/monitor-fab.ts +0 -445
  80. package/packages/selector/src/client/preset-options.ts +0 -88
  81. package/packages/selector/src/client/savings-card.tsx +0 -269
  82. package/packages/selector/src/client/scope-face.ts +0 -24
  83. package/packages/selector/src/client/settings-section.tsx +0 -156
  84. package/packages/selector/src/compat/host-generation.ts +0 -96
  85. package/packages/selector/src/compat/llm-messages.ts +0 -50
  86. package/packages/selector/src/compat/settings-lease.ts +0 -108
  87. package/packages/selector/src/compat/tool-result.ts +0 -91
  88. package/packages/selector/src/css-modules.d.ts +0 -6
  89. package/packages/selector/src/deepseek-v4-tokenizer.ts +0 -205
  90. package/packages/selector/src/estimator-catalog.ts +0 -104
  91. package/packages/selector/src/index.ts +0 -890
  92. package/packages/selector/src/invariant.ts +0 -113
  93. package/packages/selector/src/preset-overlay.ts +0 -749
  94. package/packages/selector/src/profiles.ts +0 -554
  95. package/packages/selector/src/pruner/content.ts +0 -199
  96. package/packages/selector/src/pruner/session.ts +0 -97
  97. package/packages/selector/src/pruner/state.ts +0 -61
  98. package/packages/selector/src/pruner/tuning.ts +0 -23
  99. package/packages/selector/src/pruner/types.ts +0 -78
  100. package/packages/selector/src/pruner.ts +0 -3222
  101. package/packages/selector/src/runtime/adaptive-cost.ts +0 -205
  102. package/packages/selector/src/runtime/audit.ts +0 -321
  103. package/packages/selector/src/runtime/config.ts +0 -887
  104. package/packages/selector/src/runtime/custom-policy.ts +0 -300
  105. package/packages/selector/src/runtime/deepseek-official-pricing.ts +0 -298
  106. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +0 -254
  107. package/packages/selector/src/runtime/display-prefs.ts +0 -98
  108. package/packages/selector/src/runtime/fold-router.ts +0 -143
  109. package/packages/selector/src/runtime/measurement.ts +0 -444
  110. package/packages/selector/src/runtime/monitor.ts +0 -341
  111. package/packages/selector/src/runtime/panel-command.ts +0 -213
  112. package/packages/selector/src/runtime/reducers.ts +0 -1755
  113. package/packages/selector/src/runtime/retrieve.ts +0 -505
  114. package/packages/selector/src/runtime/savings-integral.ts +0 -117
  115. package/packages/selector/src/runtime/savings-projection.ts +0 -229
  116. package/packages/selector/src/runtime/savings-verify.ts +0 -446
  117. package/packages/selector/src/runtime/savings.ts +0 -526
  118. package/packages/selector/src/runtime/sediment-card.ts +0 -126
  119. package/packages/selector/src/runtime/sediment-clock.ts +0 -87
  120. package/packages/selector/src/runtime/sediment-guard.ts +0 -136
  121. package/packages/selector/src/runtime/sediment-publish.ts +0 -144
  122. package/packages/selector/src/runtime/sediment-span.ts +0 -170
  123. package/packages/selector/src/runtime/sediment.ts +0 -209
  124. package/packages/selector/src/runtime/session-events.ts +0 -30
  125. package/packages/selector/src/runtime/session-file-decode.ts +0 -523
  126. package/packages/selector/src/runtime/shallow-tools.ts +0 -342
  127. package/packages/selector/src/runtime/stats-backfill.ts +0 -541
  128. package/packages/selector/src/runtime/stats-db.ts +0 -492
  129. package/packages/selector/src/runtime/stats-schema.ts +0 -123
  130. package/packages/selector/src/runtime/stats-sync.ts +0 -307
  131. package/packages/selector/src/runtime/summary-command.ts +0 -127
  132. package/packages/selector/src/runtime/tail-trim.ts +0 -177
  133. package/packages/selector/src/runtime/token-count.ts +0 -72
  134. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +0 -233
  135. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -204
  136. package/packages/selector/src/runtime/tokenpilot/advisor.ts +0 -419
  137. package/packages/selector/src/runtime/tokenpilot/benefit.ts +0 -200
  138. package/packages/selector/src/runtime/tokenpilot/dedup.ts +0 -82
  139. package/packages/selector/src/runtime/tokenpilot/estimator.ts +0 -151
  140. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  141. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  142. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  143. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  144. package/packages/selector/src/runtime/tokenpilot/locator.ts +0 -129
  145. package/packages/selector/src/runtime/tokenpilot/read-state.ts +0 -98
  146. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +0 -303
  147. package/packages/selector/src/runtime/tool-names.ts +0 -42
  148. package/packages/selector/src/runtime/toolclass.ts +0 -103
  149. package/packages/selector/src/runtime/triage/masks.ts +0 -128
  150. package/packages/selector/src/runtime/triage/shallow.ts +0 -132
  151. package/packages/selector/src/runtime/triage/signals.ts +0 -167
  152. package/packages/selector/src/runtime/triage/types.ts +0 -125
  153. package/packages/selector/src/runtime/types.ts +0 -396
  154. package/packages/selector/src/runtime/value.ts +0 -48
  155. package/packages/selector/src/settings-bridge.ts +0 -175
  156. package/packages/selector/tests/advisor-report.host.spec.ts +0 -223
  157. package/packages/selector/tests/auto-compact.client.spec.tsx +0 -214
  158. package/packages/selector/tests/built/client-artifact.spec.ts +0 -56
  159. package/packages/selector/tests/cache-prefix-audit.spec.ts +0 -123
  160. package/packages/selector/tests/code-skeleton.client.spec.ts +0 -98
  161. package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +0 -150
  162. package/packages/selector/tests/custom-contract.client.spec.ts +0 -226
  163. package/packages/selector/tests/estimator-catalog.spec.ts +0 -70
  164. package/packages/selector/tests/estimator-channel.client.spec.tsx +0 -253
  165. package/packages/selector/tests/estimator-route-registration.host.spec.ts +0 -202
  166. package/packages/selector/tests/fab-pos.client.spec.ts +0 -47
  167. package/packages/selector/tests/fixtures/sediment-pool/52adc205-cloud-5.orig.txt +0 -231
  168. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-25.orig.txt +0 -236
  169. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-38.orig.txt +0 -220
  170. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-42.orig.txt +0 -140
  171. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-53.orig.txt +0 -117
  172. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-local-10.orig.txt +0 -67
  173. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-45.orig.txt +0 -119
  174. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-49.orig.txt +0 -119
  175. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-63.orig.txt +0 -131
  176. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-75.orig.txt +0 -196
  177. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-76.orig.txt +0 -71
  178. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-85.orig.txt +0 -126
  179. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-86.orig.txt +0 -86
  180. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-87.orig.txt +0 -50
  181. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-96.orig.txt +0 -102
  182. package/packages/selector/tests/helpers/legacy-namespace.ts +0 -35
  183. package/packages/selector/tests/helpers/legacy-settings/index.ts +0 -15
  184. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +0 -41
  185. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +0 -647
  186. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +0 -78
  187. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +0 -234
  188. package/packages/selector/tests/host-preset-overlay.host.spec.ts +0 -204
  189. package/packages/selector/tests/monitor-fab.client.spec.ts +0 -240
  190. package/packages/selector/tests/preset-options-write.client.spec.ts +0 -192
  191. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +0 -200
  192. package/packages/selector/tests/preset-overlay.host.spec.ts +0 -246
  193. package/packages/selector/tests/profiles.client.spec.tsx +0 -436
  194. package/packages/selector/tests/ptc-custom-write.client.spec.ts +0 -86
  195. package/packages/selector/tests/public/package-contract.client.spec.ts +0 -89
  196. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +0 -167
  197. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +0 -230
  198. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +0 -272
  199. package/packages/selector/tests/runtime/advisor.spec.ts +0 -226
  200. package/packages/selector/tests/runtime/audit.spec.ts +0 -275
  201. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +0 -523
  202. package/packages/selector/tests/runtime/char-basis.spec.ts +0 -30
  203. package/packages/selector/tests/runtime/code-skeleton.spec.ts +0 -152
  204. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +0 -186
  205. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +0 -122
  206. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +0 -122
  207. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +0 -96
  208. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +0 -273
  209. package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +0 -46
  210. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +0 -106
  211. package/packages/selector/tests/runtime/fixtures/vision-golden.json +0 -459
  212. package/packages/selector/tests/runtime/fold-router.spec.ts +0 -140
  213. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +0 -74
  214. package/packages/selector/tests/runtime/fresh-gate.spec.ts +0 -43
  215. package/packages/selector/tests/runtime/html-reducer.spec.ts +0 -212
  216. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  217. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  218. package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +0 -79
  219. package/packages/selector/tests/runtime/line-mapping.spec.ts +0 -153
  220. package/packages/selector/tests/runtime/monitor.spec.ts +0 -354
  221. package/packages/selector/tests/runtime/panel-command.spec.ts +0 -101
  222. package/packages/selector/tests/runtime/prose-reducers.spec.ts +0 -133
  223. package/packages/selector/tests/runtime/ptc-profile.spec.ts +0 -133
  224. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +0 -2795
  225. package/packages/selector/tests/runtime/read-input-cap.spec.ts +0 -33
  226. package/packages/selector/tests/runtime/savings-accounting.spec.ts +0 -291
  227. package/packages/selector/tests/runtime/savings-integral.spec.ts +0 -169
  228. package/packages/selector/tests/runtime/savings-projection.spec.ts +0 -89
  229. package/packages/selector/tests/runtime/savings-verify.spec.ts +0 -226
  230. package/packages/selector/tests/runtime/savings.spec.ts +0 -139
  231. package/packages/selector/tests/runtime/search-reducer.spec.ts +0 -110
  232. package/packages/selector/tests/runtime/sediment-card.spec.ts +0 -111
  233. package/packages/selector/tests/runtime/sediment-config.spec.ts +0 -56
  234. package/packages/selector/tests/runtime/sediment-guard.spec.ts +0 -71
  235. package/packages/selector/tests/runtime/sediment-masks.spec.ts +0 -95
  236. package/packages/selector/tests/runtime/sediment-orchestrator.spec.ts +0 -166
  237. package/packages/selector/tests/runtime/sediment-pool-share.spec.ts +0 -65
  238. package/packages/selector/tests/runtime/sediment-publish.spec.ts +0 -142
  239. package/packages/selector/tests/runtime/sediment-real-shapes.spec.ts +0 -158
  240. package/packages/selector/tests/runtime/sediment-settings.spec.ts +0 -73
  241. package/packages/selector/tests/runtime/sediment-signals.spec.ts +0 -124
  242. package/packages/selector/tests/runtime/sediment-span.spec.ts +0 -92
  243. package/packages/selector/tests/runtime/session-events.spec.ts +0 -27
  244. package/packages/selector/tests/runtime/session-file-decode.spec.ts +0 -281
  245. package/packages/selector/tests/runtime/settings-unwrap.spec.ts +0 -58
  246. package/packages/selector/tests/runtime/shallow-primitives.spec.ts +0 -135
  247. package/packages/selector/tests/runtime/sidechannel.spec.ts +0 -241
  248. package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +0 -167
  249. package/packages/selector/tests/runtime/stats-backfill.spec.ts +0 -350
  250. package/packages/selector/tests/runtime/stats-db.spec.ts +0 -361
  251. package/packages/selector/tests/runtime/stats-privacy.spec.ts +0 -55
  252. package/packages/selector/tests/runtime/stats-sync.spec.ts +0 -278
  253. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
  254. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +0 -159
  255. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +0 -53
  256. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +0 -217
  257. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +0 -52
  258. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +0 -79
  259. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +0 -76
  260. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +0 -121
  261. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +0 -82
  262. package/packages/selector/tests/runtime/toolclass.spec.ts +0 -156
  263. package/packages/selector/tests/runtime/value.spec.ts +0 -23
  264. package/packages/selector/tests/savings-sessions.client.spec.tsx +0 -140
  265. package/packages/selector/tests/settings-seat.client.spec.ts +0 -215
  266. package/packages/selector/tests/standing-generation.host.spec.ts +0 -724
  267. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +0 -269
  268. package/packages/selector/tests/support/cache-prefix-audit.ts +0 -105
  269. package/packages/selector/tests/support/mock-adapter.ts +0 -37
  270. package/packages/selector/tests/support/ui-primitives.tsx +0 -34
  271. package/packages/selector/tsconfig.json +0 -11
  272. package/packages/selector/tsdown.client.config.ts +0 -102
  273. package/packages/selector/tsdown.config.ts +0 -20
  274. package/pnpm-workspace.yaml +0 -76
  275. package/scripts/capture-profile-baseline.mjs +0 -42
  276. package/scripts/cell-browser-e2e.mjs +0 -354
  277. package/scripts/generate-tokenizer-fixtures.py +0 -81
  278. package/scripts/generate-vision-fixtures.py +0 -208
  279. package/scripts/hosts.d.mts +0 -3
  280. package/scripts/hosts.mjs +0 -81
  281. package/scripts/packed-components-smoke.mjs +0 -763
  282. package/scripts/packed-install-e2e.mjs +0 -1346
  283. package/scripts/sediment-latency-report.mjs +0 -63
  284. package/scripts/sync-hosts.mjs +0 -174
  285. package/scripts/toolclass-corpus-replay.mjs +0 -281
  286. package/scripts/verify-release.mjs +0 -343
  287. package/tests/TEST_INVENTORY.md +0 -41
  288. package/tsconfig.base.json +0 -18
  289. package/tsconfig.json +0 -7
  290. package/tsconfig.tests.json +0 -15
  291. package/vitest.built.config.ts +0 -9
  292. package/vitest.config.ts +0 -54
  293. /package/{packages/selector/assets → assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  294. /package/{packages/selector/assets → assets}/deepseek-v4/manifest.json +0 -0
  295. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer.json +0 -0
  296. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer_config.json +0 -0
  297. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  298. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  299. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  300. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  301. /package/{packages/selector/cordis.patch.yml → cordis.patch.yml} +0 -0
  302. /package/{packages/selector/lib → lib}/client.d.ts +0 -0
  303. /package/{packages/selector/lib → lib}/index.d.ts +0 -0
  304. /package/{packages/selector/lib → lib}/invariant.d.ts +0 -0
  305. /package/{packages/selector/lib → lib}/invariant.js +0 -0
  306. /package/{packages/selector/lib → lib}/profiles.d.ts +0 -0
  307. /package/{packages/selector/lib → lib}/pruner.d.ts +0 -0
  308. /package/{packages/selector/lib → lib}/pruner.js +0 -0
  309. /package/{packages/selector/lib → lib}/savings-integral.js +0 -0
  310. /package/{packages/selector/lib → lib}/tail-trim.js +0 -0
  311. /package/{packages/selector/lib → lib}/tool-result.js +0 -0
@@ -1,361 +0,0 @@
1
- /**
2
- * 持久层主干(T1–T5)单测:开关纪律 / schema 幂等 / claims 落库与聚合 /
3
- * BC #2671 两断言 / 双连接写 / 生命周期与可见降级。
4
- *
5
- * 全部用临时目录注入路径,绝不触碰真实 `~/.dsh`。
6
- */
7
- import { mkdtempSync, rmSync } from 'node:fs'
8
- import { homedir, tmpdir } from 'node:os'
9
- import { join } from 'node:path'
10
- import { DatabaseSync } from 'node:sqlite'
11
- import { afterEach, describe, expect, it, vi } from 'vitest'
12
- import {
13
- StatsStore,
14
- closeStatsStore,
15
- getStatsStore,
16
- openStatsDatabase,
17
- statsPersistenceState,
18
- } from '../../src/runtime/stats-db.ts'
19
- import {
20
- CCI_STATS_APPLICATION_ID,
21
- OFFICIAL_SESSION_QUERY_APPLICATION_ID,
22
- STATS_SCHEMA_VERSION,
23
- resolveStatsDbPath,
24
- } from '../../src/runtime/stats-schema.ts'
25
-
26
- const dirs: string[] = []
27
-
28
- /** 每个用例一个独立临时目录,收尾删干净。 */
29
- function tempDir(name: string): string {
30
- const dir = mkdtempSync(join(tmpdir(), `cci-stats-${name}-`))
31
- dirs.push(dir)
32
- return dir
33
- }
34
-
35
- const tempDbPath = (name: string): string => join(tempDir(name), 'stats.sqlite')
36
-
37
- async function openStore(path: string): Promise<StatsStore> {
38
- const opened = await openStatsDatabase(path)
39
- if (opened === null) throw new Error('no sqlite driver in this environment')
40
- return new StatsStore(opened.db, opened.driver)
41
- }
42
-
43
- function pragma(db: DatabaseSync, sql: string): Record<string, unknown> {
44
- return db.prepare(sql).get() as Record<string, unknown>
45
- }
46
-
47
- function countRows(path: string, table: string): number {
48
- const db = new DatabaseSync(path)
49
- try {
50
- return Number((db.prepare(`SELECT COUNT(*) AS c FROM ${table}`).get() as { c: number | bigint }).c)
51
- } finally {
52
- db.close()
53
- }
54
- }
55
-
56
- afterEach(() => {
57
- closeStatsStore()
58
- vi.restoreAllMocks()
59
- while (dirs.length > 0) {
60
- const dir = dirs.pop()!
61
- try { rmSync(dir, { recursive: true, force: true }) } catch { /* Windows 句柄释放滞后时尽力而为 */ }
62
- }
63
- })
64
-
65
- describe('stats-db 开关纪律(T1:打开/拒他人库/版本不符重建)', () => {
66
- it('空库打开:建表齐三张 + pragma 到位 + application_id/user_version 盖章', async () => {
67
- const opened = await openStatsDatabase(tempDbPath('open'))
68
- expect(opened).not.toBeNull()
69
- const { db, driver } = opened!
70
- expect(['better-sqlite3', 'node:sqlite']).toContain(driver)
71
- try {
72
- expect(Number(pragma(db, 'PRAGMA application_id').application_id)).toBe(CCI_STATS_APPLICATION_ID)
73
- expect(Number(pragma(db, 'PRAGMA user_version').user_version)).toBe(STATS_SCHEMA_VERSION)
74
- expect(Number(pragma(db, 'PRAGMA busy_timeout').timeout)).toBe(5000)
75
- expect(String(pragma(db, 'PRAGMA journal_mode').journal_mode).toLowerCase()).toBe('wal')
76
- const tables = db.prepare(
77
- `SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%' ORDER BY name`,
78
- ).all() as { name: string }[]
79
- expect(tables.map(row => row.name)).toEqual(['claims', 'meta', 'sessions'])
80
- } finally {
81
- db.close()
82
- }
83
- })
84
-
85
- it('拒开他人库:官方派生库与任意第三方 application_id 都抛错', async () => {
86
- // 官方 session-query 派生库(0x44534851)
87
- const officialPath = tempDbPath('foreign-official')
88
- const rawOfficial = new DatabaseSync(officialPath)
89
- rawOfficial.exec(`CREATE TABLE IF NOT EXISTS sentinel (x INTEGER)`)
90
- rawOfficial.exec(`PRAGMA application_id = ${OFFICIAL_SESSION_QUERY_APPLICATION_ID}`)
91
- rawOfficial.close()
92
- await expect(openStatsDatabase(officialPath)).rejects.toThrow(/refusing to open/)
93
-
94
- // 不认识的第三方库
95
- const otherPath = tempDbPath('foreign-other')
96
- const rawOther = new DatabaseSync(otherPath)
97
- rawOther.exec(`CREATE TABLE IF NOT EXISTS sentinel (x INTEGER)`)
98
- rawOther.exec(`PRAGMA application_id = ${0x0DEADBEE}`)
99
- rawOther.close()
100
- await expect(openStatsDatabase(otherPath)).rejects.toThrow(/another application/)
101
- })
102
-
103
- it('版本不符 drop 重建:user_version 被篡成高值后重开 = 空表 + 版本复位', async () => {
104
- const path = tempDbPath('rebuild')
105
- const first = await openStore(path)
106
- first.recordClaims('s1', [{ seq: 3, kind: 'saving', component: 'fresh', basis: 'exact-tokenizer', tokens: 42, at: 1 }])
107
- first.close()
108
-
109
- // 外部篡改 user_version(模拟不兼容代际)
110
- const raw = new DatabaseSync(path)
111
- raw.exec(`PRAGMA user_version = ${STATS_SCHEMA_VERSION + 99}`)
112
- raw.close()
113
-
114
- const reopened = await openStatsDatabase(path)
115
- expect(reopened).not.toBeNull()
116
- const { db } = reopened!
117
- try {
118
- expect(Number(pragma(db, 'PRAGMA user_version').user_version)).toBe(STATS_SCHEMA_VERSION)
119
- expect(Number(pragma(db, 'PRAGMA application_id').application_id)).toBe(CCI_STATS_APPLICATION_ID)
120
- expect(countRows(path, 'claims')).toBe(0)
121
- } finally {
122
- db.close()
123
- }
124
- })
125
-
126
- it('二次打开幂等:数据原样保留,建表语句空转不报错', async () => {
127
- const path = tempDbPath('idempotent-open')
128
- const first = await openStore(path)
129
- expect(first.recordClaims('s1', [{ seq: 1, kind: 'usage', component: 'input', basis: '', tokens: 10, at: 1 }])).toBe(1)
130
- first.close()
131
- const second = await openStore(path) // ensureSchema 空转不抛
132
- expect(countRows(path, 'claims')).toBe(1)
133
- second.close()
134
- })
135
- })
136
-
137
- describe('resolveStatsDbPath(T2 路径解析优先级)', () => {
138
- const expected = (home: string) => join(home, 'storages', 'dsh-context-compression', 'stats.sqlite')
139
-
140
- it('dbPath 显式覆盖最高优先;空白串按未设置', () => {
141
- expect(resolveStatsDbPath({ dbPath: 'X:/custom/stats.sqlite', dshHome: 'X:/home' })).toBe('X:/custom/stats.sqlite')
142
- expect(resolveStatsDbPath({ dbPath: ' ', dshHome: 'X:/home' })).toBe(expected('X:/home'))
143
- })
144
-
145
- it('dshHome > $DSH_HOME > homedir/.dsh;空 env 按未设置(镜像宿主 resolveDshHome 语义)', () => {
146
- expect(resolveStatsDbPath({ dshHome: 'X:/explicit', env: { DSH_HOME: 'X:/env' } })).toBe(expected('X:/explicit'))
147
- expect(resolveStatsDbPath({ env: { DSH_HOME: 'X:/env' } })).toBe(expected('X:/env'))
148
- // 空白 env 按未设置 → 兜底 homedir/.dsh(宿主 resolveDshHome 同语义)
149
- expect(resolveStatsDbPath({ env: { DSH_HOME: ' ' } })).toBe(join(homedir(), '.dsh', 'storages', 'dsh-context-compression', 'stats.sqlite'))
150
- expect(resolveStatsDbPath({ env: {} })).toBe(join(homedir(), '.dsh', 'storages', 'dsh-context-compression', 'stats.sqlite'))
151
- })
152
- })
153
-
154
- describe('recordClaims 与聚合(T3 + BC #2671 两断言 + 写后读回对账)', () => {
155
- it('幂等重放零新增:同一批行二次落库 added=0 且总行数不变', async () => {
156
- const path = tempDbPath('replay')
157
- const store = await openStore(path)
158
- const rows = [
159
- { seq: 5, kind: 'saving' as const, component: 'fresh', basis: 'exact-tokenizer', tokens: 900, at: 10 },
160
- { seq: 5, kind: 'offset' as const, component: 'retrieve', basis: 'characters', tokens: 200, at: 11 },
161
- { seq: 6, kind: 'usage' as const, component: 'input', basis: '', tokens: 1234, at: 12 },
162
- ]
163
- expect(store.recordClaims('s1', rows)).toBe(3)
164
- expect(store.recordClaims('s1', rows)).toBe(0)
165
- expect(countRows(path, 'claims')).toBe(3)
166
- store.close()
167
- })
168
-
169
- it('跨会话不覆盖(BC #2671-2):同 (seq,kind,component,basis) 两会话各自完整', async () => {
170
- const store = await openStore(tempDbPath('cross-session'))
171
- store.recordClaims('s1', [{ seq: 7, kind: 'saving', component: 'fresh', basis: 'exact-tokenizer', tokens: 100, at: 1 }])
172
- store.recordClaims('s2', [{ seq: 7, kind: 'saving', component: 'fresh', basis: 'exact-tokenizer', tokens: 250, at: 2 }])
173
- const per = store.perSessionAggregates()
174
- expect(per).toHaveLength(2)
175
- expect(per.find(row => row.sessionId === 's1')?.gross.exact).toBe(100)
176
- expect(per.find(row => row.sessionId === 's2')?.gross.exact).toBe(250)
177
- // 净额精确降序
178
- expect(per[0]?.sessionId).toBe('s2')
179
- store.close()
180
- })
181
-
182
- it('latestActiveSessionId:claims.at 最大者为最近压缩会话(空库 undefined)', async () => {
183
- const store = await openStore(tempDbPath('latest-active'))
184
- expect(store.latestActiveSessionId()).toBeUndefined()
185
- store.recordClaims('s-old', [{ seq: 1, kind: 'saving', component: 'fresh', basis: 'characters', tokens: 10, at: 100 }])
186
- store.recordClaims('s-new', [{ seq: 1, kind: 'usage', component: 'input', basis: '', tokens: 20, at: 200 }])
187
- expect(store.latestActiveSessionId()).toBe('s-new')
188
- store.close()
189
- })
190
- it('sessionComponents:按路径×口径聚合 saving,可聚焦单会话,不含 usage/offset', async () => {
191
- const store = await openStore(tempDbPath('components'))
192
- store.recordClaims('s1', [
193
- { seq: 1, kind: 'saving', component: 'fresh', basis: 'exact-tokenizer', tokens: 900, at: 1 },
194
- { seq: 2, kind: 'saving', component: 'fresh', basis: 'exact-tokenizer', tokens: 100, at: 2 },
195
- { seq: 3, kind: 'saving', component: 'history', basis: 'characters', tokens: 400, at: 3 },
196
- { seq: 4, kind: 'offset', component: 'retrieve', basis: 'characters', tokens: 150, at: 4 },
197
- { seq: 5, kind: 'usage', component: 'input', basis: '', tokens: 5000, at: 5 },
198
- ])
199
- store.recordClaims('s2', [{ seq: 1, kind: 'saving', component: 'tail-trim', basis: 'characters', tokens: 77, at: 6 }])
200
- expect(store.sessionComponents('s1')).toEqual([
201
- { component: 'fresh', basis: 'exact-tokenizer', tokens: 1000, events: 2 },
202
- { component: 'history', basis: 'characters', tokens: 400, events: 1 },
203
- ])
204
- // 无 sessionId = 全库组成,按 tokens 降序
205
- const all = store.sessionComponents()
206
- expect(all[0]).toEqual({ component: 'fresh', basis: 'exact-tokenizer', tokens: 1000, events: 2 })
207
- expect(all).toHaveLength(3)
208
- store.close()
209
- })
210
-
211
- it('绝对 seq 写后读回对账(BC #2671-1):perSession/total 与逐条目手算一致', async () => {
212
- const store = await openStore(tempDbPath('reconcile'))
213
- store.recordClaims('s1', [
214
- { seq: 3, kind: 'saving', component: 'fresh', basis: 'exact-tokenizer', tokens: 1000, at: 1 },
215
- { seq: 9, kind: 'saving', component: 'history', basis: 'characters', tokens: 400, at: 2 },
216
- { seq: 12, kind: 'offset', component: 'retrieve', basis: 'characters', tokens: 150, at: 3 },
217
- ])
218
- store.recordClaims('s2', [
219
- { seq: 4, kind: 'saving', component: 'tail-trim', basis: 'exact-tokenizer', tokens: 700, at: 4 },
220
- { seq: 8, kind: 'offset', component: 'full-read', basis: 'exact-tokenizer', tokens: 300, at: 5 },
221
- ])
222
- const per = store.perSessionAggregates()
223
- const s1 = per.find(row => row.sessionId === 's1')!
224
- const s2 = per.find(row => row.sessionId === 's2')!
225
- expect(s1.gross).toEqual({ exact: 1000, estimated: 400 })
226
- expect(s1.offsets).toEqual({ exact: 0, estimated: 150 })
227
- expect(s1.net).toEqual({ exact: 1000, estimated: 250 })
228
- expect(s2.net).toEqual({ exact: 400, estimated: 0 })
229
- expect(store.total()).toEqual({
230
- gross: { exact: 1700, estimated: 400 },
231
- offsets: { exact: 300, estimated: 150 },
232
- net: { exact: 1400, estimated: 250 },
233
- })
234
- store.close()
235
- })
236
-
237
- it('sumSamples:边界采样按组件累计、calls=distinct 边界数;重放零增量', async () => {
238
- const store = await openStore(tempDbPath('samples'))
239
- const sampleRows = (seq: number, netExact: number, netEstimated: number, cached: number, uncached: number) => ([
240
- { seq, kind: 'sample' as const, component: 'netExact', basis: '', tokens: netExact, at: seq * 10 },
241
- { seq, kind: 'sample' as const, component: 'netEstimated', basis: '', tokens: netEstimated, at: seq * 10 },
242
- { seq, kind: 'sample' as const, component: 'cachedInput', basis: '', tokens: cached, at: seq * 10 },
243
- { seq, kind: 'sample' as const, component: 'uncachedInput', basis: '', tokens: uncached, at: seq * 10 },
244
- ])
245
- const batch = [...sampleRows(10, 100, 50, 900, 100), ...sampleRows(11, 80, 40, 950, 50)]
246
- expect(store.recordClaims('s1', batch)).toBe(8)
247
- expect(store.recordClaims('s1', batch)).toBe(0)
248
- expect(store.sumSamples('s1')).toEqual({ netExact: 180, netEstimated: 90, cachedInput: 1850, uncachedInput: 150, calls: 2 })
249
- // 别的会话没有采样
250
- expect(store.sumSamples('s2').calls).toBe(0)
251
- store.close()
252
- })
253
-
254
- it('水位单调不减 + source 一旦 live 不被 backfill 降级', async () => {
255
- const path = tempDbPath('watermark')
256
- const store = await openStore(path)
257
- expect(store.getSessionWatermark('unknown')).toBe(0)
258
- store.setSessionWatermark('s1', 7, { project: 'p', source: 'live' })
259
- expect(store.getSessionWatermark('s1')).toBe(7)
260
- store.setSessionWatermark('s1', 3, { source: 'backfill' })
261
- expect(store.getSessionWatermark('s1')).toBe(7)
262
- store.setSessionWatermark('s1', 9, { source: 'backfill' })
263
- expect(store.getSessionWatermark('s1')).toBe(9)
264
- const db = new DatabaseSync(path)
265
- try {
266
- const row = db.prepare(`SELECT project, source FROM sessions WHERE session_id = 's1'`).get() as { project: string; source: string }
267
- expect(row).toEqual({ project: 'p', source: 'live' })
268
- } finally {
269
- db.close()
270
- }
271
- store.close()
272
- })
273
-
274
- it('拒收坏行:未知 kind / 非有限数抛错;关闭后调用即抛', async () => {
275
- const store = await openStore(tempDbPath('bad-rows'))
276
- expect(() => store.recordClaims('s1', [{ seq: 1, kind: 'wat' as never, component: 'x', basis: '', tokens: 1, at: 1 }])).toThrow(/unsupported claim kind/)
277
- expect(() => store.recordClaims('s1', [{ seq: Number.NaN, kind: 'usage', component: 'x', basis: '', tokens: 1, at: 1 }])).toThrow(/non-finite/)
278
- expect(() => store.setSessionWatermark('s1', -2)).toThrow(/non-negative/)
279
- store.close()
280
- expect(store.isOpen).toBe(false)
281
- expect(() => store.recordClaims('s1', [{ seq: 1, kind: 'usage', component: 'x', basis: '', tokens: 1, at: 1 }])).toThrow(/closed/)
282
- })
283
- })
284
-
285
- describe('双连接并发写(busy_timeout/多实例拓扑)', () => {
286
- it('同一文件两个句柄交替写小事务互不失败,合并对账一致', async () => {
287
- const path = tempDbPath('two-conns')
288
- const a = await openStore(path)
289
- const b = await openStore(path)
290
- try {
291
- a.recordClaims('s1', [{ seq: 1, kind: 'saving', component: 'fresh', basis: 'exact-tokenizer', tokens: 10, at: 1 }])
292
- b.recordClaims('s2', [{ seq: 1, kind: 'saving', component: 'fresh', basis: 'exact-tokenizer', tokens: 20, at: 2 }])
293
- a.recordClaims('s1', [{ seq: 2, kind: 'offset', component: 'retrieve', basis: 'characters', tokens: 4, at: 3 }])
294
- b.recordClaims('s2', [{ seq: 2, kind: 'offset', component: 'retrieve', basis: 'characters', tokens: 8, at: 4 }])
295
- expect(b.total().net).toEqual({ exact: 30, estimated: -12 })
296
- expect(a.perSessionAggregates()).toHaveLength(2)
297
- // 另一连接写过的行重放:幂等零新增(跨连接的主键去重)
298
- expect(b.recordClaims('s1', [{ seq: 1, kind: 'saving', component: 'fresh', basis: 'exact-tokenizer', tokens: 10, at: 1 }])).toBe(0)
299
- expect(countRows(path, 'claims')).toBe(4)
300
- } finally {
301
- a.close()
302
- b.close()
303
- }
304
- })
305
- })
306
-
307
- describe('生命周期与可见降级(T5:warn 恰一次 + persisted 状态导出)', () => {
308
- /** resetModules 拿全新模块实例,单例与 warn 门闩互不串扰。 */
309
- async function freshStatsDbModule() {
310
- vi.resetModules()
311
- return await import('../../src/runtime/stats-db.ts')
312
- }
313
-
314
- it('ensureStatsStore 幂等打开;closeStatsStore 后状态回落 not-opened', async () => {
315
- const mod = await freshStatsDbModule()
316
- const path = tempDbPath('lifecycle')
317
- const store = await mod.ensureStatsStore(path)
318
- expect(store).not.toBeNull()
319
- expect(mod.getStatsStore()).toBe(store)
320
- expect(mod.statsPersistenceState()).toMatchObject({ persisted: true })
321
- const again = await mod.ensureStatsStore(path)
322
- expect(again).toBe(store)
323
- mod.closeStatsStore()
324
- expect(mod.getStatsStore()).toBeNull()
325
- expect(mod.statsPersistenceState()).toMatchObject({ persisted: false, reason: 'not-opened', driver: null })
326
- expect(store?.isOpen).toBe(false)
327
- })
328
-
329
- it('open 失败(他人库)→ 不抛、persisted:false reason=open-failed、warn 恰一次', async () => {
330
- const mod = await freshStatsDbModule()
331
- const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
332
- const path = join(tempDir('foreign-lc'), 'stats.sqlite')
333
- const raw = new DatabaseSync(path)
334
- raw.exec(`CREATE TABLE IF NOT EXISTS sentinel (x INTEGER)`)
335
- raw.exec(`PRAGMA application_id = ${OFFICIAL_SESSION_QUERY_APPLICATION_ID}`)
336
- raw.close()
337
-
338
- const first = await mod.ensureStatsStore(path)
339
- const second = await mod.ensureStatsStore(path)
340
- expect(first).toBeNull()
341
- expect(second).toBeNull()
342
- expect(mod.statsPersistenceState()).toMatchObject({ persisted: false, reason: 'open-failed', driver: null })
343
- expect(warn).toHaveBeenCalledTimes(1)
344
- })
345
-
346
- it('ctx.effect 卸载缝:close 后句柄不泄漏(isOpen=false + 目录可整体删除)', async () => {
347
- const mod = await freshStatsDbModule()
348
- const dir = tempDir('effect-close')
349
- const path = join(dir, 'stats.sqlite')
350
- const store = await mod.ensureStatsStore(path)
351
- expect(store?.isOpen).toBe(true)
352
- // 模拟 ctx.effect 清理器:再次卸载幂等,不抛
353
- mod.closeStatsStore()
354
- mod.closeStatsStore()
355
- expect(store?.isOpen).toBe(false)
356
- // 句柄已释放:WAL 残留文件不阻碍整目录删除
357
- rmSync(dir, { recursive: true, force: true })
358
- expect(getStatsStore()).toBeNull()
359
- expect(statsPersistenceState()).toMatchObject({ persisted: false, reason: 'not-opened' })
360
- })
361
- })
@@ -1,55 +0,0 @@
1
- /**
2
- * T33:审计消息净化 + 统计库隐私守卫——errorMessage 首行/截断/控制字符折叠,
3
- * 以及 claims 表字段封闭性(component/kind 全部白名单枚举,自由文本无处落表)。
4
- */
5
- import { mkdtempSync, rmSync } from 'node:fs'
6
- import { tmpdir } from 'node:os'
7
- import { join } from 'node:path'
8
- import { DatabaseSync } from 'node:sqlite'
9
- import { afterEach, describe, expect, it } from 'vitest'
10
- import { AUDIT_MESSAGE_MAX_CHARS, sanitizeAuditMessage } from '../../src/runtime/audit.ts'
11
- import { STATS_CLAIM_KINDS } from '../../src/runtime/stats-schema.ts'
12
- import { closeStatsStore, ensureStatsStore, getStatsStore } from '../../src/runtime/stats-db.ts'
13
- import { claimFromLand } from '../../src/runtime/stats-sync.ts'
14
-
15
- const dirs: string[] = []
16
-
17
- afterEach(() => {
18
- closeStatsStore()
19
- for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true })
20
- })
21
-
22
- describe('sanitizeAuditMessage(T33)', () => {
23
- it('多行取首行、控制字符折叠、超长截断', () => {
24
- expect(sanitizeAuditMessage(new Error('boom at line1\n at stack (file.ts:1)\n at deeper'))).toBe('boom at line1')
25
- expect(sanitizeAuditMessage('a\tb\u0000c')).toBe('a b c')
26
- const long = 'x'.repeat(500)
27
- expect(sanitizeAuditMessage(long)).toHaveLength(AUDIT_MESSAGE_MAX_CHARS)
28
- expect(sanitizeAuditMessage(new Error('普通长度消息'))).toBe('普通长度消息')
29
- expect(sanitizeAuditMessage(42)).toBe('42')
30
- })
31
- })
32
-
33
- describe('统计库隐私守卫(自由文本无处落表)', () => {
34
- it('claims 表的 kind/component 恒为封闭枚举;无自由文本列', async () => {
35
- const dir = mkdtempSync(join(tmpdir(), 'cci-privacy-'))
36
- dirs.push(dir)
37
- const store = await ensureStatsStore(join(dir, 'stats.sqlite'))
38
- if (store === null || getStatsStore() === null) throw new Error('no sqlite driver')
39
- claimFromLand({ sessionId: 'sess-privacy', component: 'fresh', tokensBefore: 500, tokensAfter: 100, basis: 'exact-tokenizer', replacementSeq: 7 })
40
- const db = new DatabaseSync(join(dir, 'stats.sqlite'))
41
- try {
42
- const kinds = (db.prepare(`SELECT DISTINCT kind FROM claims`).all() as { kind: string }[]).map(row => row.kind)
43
- expect(kinds.every(kind => (STATS_CLAIM_KINDS as readonly string[]).includes(kind))).toBe(true)
44
- const components = (db.prepare(`SELECT DISTINCT component FROM claims`).all() as { component: string }[]).map(row => row.component)
45
- // component 全部是白名单枚举值(保存组件/科目/sample 字段名),绝非任意文本
46
- const COMPONENT_WHITELIST = new Set(['fresh', 'aggregate', 'history', 'tail-trim', 'dedupe', 'native', 'projection', 'retrieve', 'tailtrim-retrieve', 'full-read', 'input', 'output', 'cacheRead', 'cacheWrite', 'netExact', 'netEstimated', 'cachedInput', 'uncachedInput'])
47
- expect(components.every(component => COMPONENT_WHITELIST.has(component))).toBe(true)
48
- // claims 表无 message/text/note 类列——自由文本没有落表位置
49
- const columns = (db.prepare(`PRAGMA table_info(claims)`).all() as { name: string }[]).map(row => row.name)
50
- expect(columns).toEqual(['session_id', 'seq', 'kind', 'component', 'basis', 'tokens', 'at'])
51
- } finally {
52
- db.close()
53
- }
54
- })
55
- })