dsh-context-compression-improved 0.11.0 → 0.11.2

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 (310) 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} +2 -2
  5. package/{packages/selector/lib → lib}/index.js +101 -0
  6. package/package.json +129 -116
  7. package/screenshots.json +3 -6
  8. package/.agents/plans/improve/checklist.md +0 -32
  9. package/.agents/plans/improve/findings.md +0 -102
  10. package/.agents/plans/improve/spec.md +0 -53
  11. package/.agents/plans/improve/tasks.md +0 -70
  12. package/.gitattributes +0 -2
  13. package/.githooks/pre-push +0 -37
  14. package/.github/workflows/ci.yml +0 -47
  15. package/CHANGELOG.de.md +0 -580
  16. package/CHANGELOG.es.md +0 -588
  17. package/CHANGELOG.fr.md +0 -576
  18. package/CHANGELOG.it.md +0 -577
  19. package/CHANGELOG.ja.md +0 -261
  20. package/CHANGELOG.ko.md +0 -254
  21. package/CHANGELOG.md +0 -557
  22. package/CHANGELOG.ru.md +0 -554
  23. package/CHANGELOG.zh.md +0 -247
  24. package/CONTRIBUTING.md +0 -22
  25. package/README.de.md +0 -96
  26. package/README.es.md +0 -96
  27. package/README.fr.md +0 -96
  28. package/README.it.md +0 -96
  29. package/README.ja.md +0 -102
  30. package/README.ko.md +0 -102
  31. package/README.ru.md +0 -96
  32. package/SECURITY.md +0 -18
  33. package/assets/board.png +0 -0
  34. package/assets/context.png +0 -0
  35. package/docs/assets/context-compression-selector-profiles.jpg +0 -0
  36. package/docs/assets/context-compression-selector-settings.png +0 -0
  37. package/docs/compat-0.1.5-report.md +0 -77
  38. package/docs/installation.de.md +0 -104
  39. package/docs/installation.es.md +0 -104
  40. package/docs/installation.fr.md +0 -104
  41. package/docs/installation.it.md +0 -104
  42. package/docs/installation.ja.md +0 -78
  43. package/docs/installation.ko.md +0 -78
  44. package/docs/installation.md +0 -103
  45. package/docs/installation.ru.md +0 -104
  46. package/docs/installation.zh.md +0 -100
  47. package/docs/repair-log.md +0 -657
  48. package/docs/shallow-teaching-preset-template.md +0 -46
  49. package/eslint.config.js +0 -30
  50. package/packages/selector/LICENSE +0 -21
  51. package/packages/selector/README.md +0 -26
  52. package/packages/selector/README.zh.md +0 -24
  53. package/packages/selector/THIRD_PARTY_NOTICES.md +0 -32
  54. package/packages/selector/docs/history-tool-call-working-set-spec.md +0 -112
  55. package/packages/selector/docs/native-tool-result-selector-spec.md +0 -34
  56. package/packages/selector/docs/subagent-cache-reuse-spec.md +0 -46
  57. package/packages/selector/lib/style.css +0 -350
  58. package/packages/selector/package.json +0 -178
  59. package/packages/selector/screenshots.json +0 -3
  60. package/packages/selector/src/client/CompressionProfileControls.tsx +0 -352
  61. package/packages/selector/src/client/CompressionProfileSelector.module.css +0 -199
  62. package/packages/selector/src/client/CompressionProfileSelector.tsx +0 -89
  63. package/packages/selector/src/client/CustomPolicyEditor.tsx +0 -216
  64. package/packages/selector/src/client/EstimatorControls.tsx +0 -277
  65. package/packages/selector/src/client/bridge-scope.ts +0 -125
  66. package/packages/selector/src/client/decode.ts +0 -68
  67. package/packages/selector/src/client/fab-pos.ts +0 -71
  68. package/packages/selector/src/client/index.ts +0 -438
  69. package/packages/selector/src/client/locales/de.ts +0 -167
  70. package/packages/selector/src/client/locales/es.ts +0 -167
  71. package/packages/selector/src/client/locales/fr.ts +0 -167
  72. package/packages/selector/src/client/locales/it.ts +0 -167
  73. package/packages/selector/src/client/locales/ja.ts +0 -167
  74. package/packages/selector/src/client/locales/ko.ts +0 -167
  75. package/packages/selector/src/client/locales/ru.ts +0 -167
  76. package/packages/selector/src/client/locales.ts +0 -334
  77. package/packages/selector/src/client/monitor-fab.ts +0 -445
  78. package/packages/selector/src/client/preset-options.ts +0 -88
  79. package/packages/selector/src/client/savings-card.tsx +0 -269
  80. package/packages/selector/src/client/scope-face.ts +0 -24
  81. package/packages/selector/src/client/settings-section.tsx +0 -156
  82. package/packages/selector/src/compat/host-generation.ts +0 -96
  83. package/packages/selector/src/compat/llm-messages.ts +0 -50
  84. package/packages/selector/src/compat/settings-lease.ts +0 -108
  85. package/packages/selector/src/compat/tool-result.ts +0 -91
  86. package/packages/selector/src/css-modules.d.ts +0 -6
  87. package/packages/selector/src/deepseek-v4-tokenizer.ts +0 -205
  88. package/packages/selector/src/estimator-catalog.ts +0 -104
  89. package/packages/selector/src/index.ts +0 -890
  90. package/packages/selector/src/invariant.ts +0 -113
  91. package/packages/selector/src/preset-overlay.ts +0 -749
  92. package/packages/selector/src/profiles.ts +0 -554
  93. package/packages/selector/src/pruner/content.ts +0 -199
  94. package/packages/selector/src/pruner/session.ts +0 -97
  95. package/packages/selector/src/pruner/state.ts +0 -61
  96. package/packages/selector/src/pruner/tuning.ts +0 -23
  97. package/packages/selector/src/pruner/types.ts +0 -78
  98. package/packages/selector/src/pruner.ts +0 -3222
  99. package/packages/selector/src/runtime/adaptive-cost.ts +0 -205
  100. package/packages/selector/src/runtime/audit.ts +0 -321
  101. package/packages/selector/src/runtime/config.ts +0 -887
  102. package/packages/selector/src/runtime/custom-policy.ts +0 -300
  103. package/packages/selector/src/runtime/deepseek-official-pricing.ts +0 -298
  104. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +0 -254
  105. package/packages/selector/src/runtime/display-prefs.ts +0 -98
  106. package/packages/selector/src/runtime/fold-router.ts +0 -143
  107. package/packages/selector/src/runtime/measurement.ts +0 -444
  108. package/packages/selector/src/runtime/monitor.ts +0 -341
  109. package/packages/selector/src/runtime/panel-command.ts +0 -213
  110. package/packages/selector/src/runtime/reducers.ts +0 -1755
  111. package/packages/selector/src/runtime/retrieve.ts +0 -505
  112. package/packages/selector/src/runtime/savings-integral.ts +0 -117
  113. package/packages/selector/src/runtime/savings-projection.ts +0 -229
  114. package/packages/selector/src/runtime/savings-verify.ts +0 -446
  115. package/packages/selector/src/runtime/savings.ts +0 -526
  116. package/packages/selector/src/runtime/sediment-card.ts +0 -126
  117. package/packages/selector/src/runtime/sediment-clock.ts +0 -87
  118. package/packages/selector/src/runtime/sediment-guard.ts +0 -136
  119. package/packages/selector/src/runtime/sediment-publish.ts +0 -144
  120. package/packages/selector/src/runtime/sediment-span.ts +0 -170
  121. package/packages/selector/src/runtime/sediment.ts +0 -209
  122. package/packages/selector/src/runtime/session-events.ts +0 -30
  123. package/packages/selector/src/runtime/session-file-decode.ts +0 -523
  124. package/packages/selector/src/runtime/shallow-tools.ts +0 -342
  125. package/packages/selector/src/runtime/stats-backfill.ts +0 -541
  126. package/packages/selector/src/runtime/stats-db.ts +0 -492
  127. package/packages/selector/src/runtime/stats-schema.ts +0 -123
  128. package/packages/selector/src/runtime/stats-sync.ts +0 -307
  129. package/packages/selector/src/runtime/summary-command.ts +0 -127
  130. package/packages/selector/src/runtime/tail-trim.ts +0 -177
  131. package/packages/selector/src/runtime/token-count.ts +0 -72
  132. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +0 -233
  133. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -204
  134. package/packages/selector/src/runtime/tokenpilot/advisor.ts +0 -419
  135. package/packages/selector/src/runtime/tokenpilot/benefit.ts +0 -200
  136. package/packages/selector/src/runtime/tokenpilot/dedup.ts +0 -82
  137. package/packages/selector/src/runtime/tokenpilot/estimator.ts +0 -151
  138. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  139. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  140. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  141. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  142. package/packages/selector/src/runtime/tokenpilot/locator.ts +0 -129
  143. package/packages/selector/src/runtime/tokenpilot/read-state.ts +0 -98
  144. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +0 -303
  145. package/packages/selector/src/runtime/tool-names.ts +0 -42
  146. package/packages/selector/src/runtime/toolclass.ts +0 -103
  147. package/packages/selector/src/runtime/triage/masks.ts +0 -128
  148. package/packages/selector/src/runtime/triage/shallow.ts +0 -132
  149. package/packages/selector/src/runtime/triage/signals.ts +0 -167
  150. package/packages/selector/src/runtime/triage/types.ts +0 -125
  151. package/packages/selector/src/runtime/types.ts +0 -396
  152. package/packages/selector/src/runtime/value.ts +0 -48
  153. package/packages/selector/src/settings-bridge.ts +0 -175
  154. package/packages/selector/tests/advisor-report.host.spec.ts +0 -223
  155. package/packages/selector/tests/auto-compact.client.spec.tsx +0 -214
  156. package/packages/selector/tests/built/client-artifact.spec.ts +0 -56
  157. package/packages/selector/tests/cache-prefix-audit.spec.ts +0 -123
  158. package/packages/selector/tests/code-skeleton.client.spec.ts +0 -98
  159. package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +0 -150
  160. package/packages/selector/tests/custom-contract.client.spec.ts +0 -226
  161. package/packages/selector/tests/estimator-catalog.spec.ts +0 -70
  162. package/packages/selector/tests/estimator-channel.client.spec.tsx +0 -253
  163. package/packages/selector/tests/estimator-route-registration.host.spec.ts +0 -202
  164. package/packages/selector/tests/fab-pos.client.spec.ts +0 -47
  165. package/packages/selector/tests/fixtures/sediment-pool/52adc205-cloud-5.orig.txt +0 -231
  166. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-25.orig.txt +0 -236
  167. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-38.orig.txt +0 -220
  168. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-42.orig.txt +0 -140
  169. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-53.orig.txt +0 -117
  170. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-local-10.orig.txt +0 -67
  171. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-45.orig.txt +0 -119
  172. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-49.orig.txt +0 -119
  173. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-63.orig.txt +0 -131
  174. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-75.orig.txt +0 -196
  175. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-76.orig.txt +0 -71
  176. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-85.orig.txt +0 -126
  177. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-86.orig.txt +0 -86
  178. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-87.orig.txt +0 -50
  179. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-96.orig.txt +0 -102
  180. package/packages/selector/tests/helpers/legacy-namespace.ts +0 -35
  181. package/packages/selector/tests/helpers/legacy-settings/index.ts +0 -15
  182. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +0 -41
  183. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +0 -647
  184. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +0 -78
  185. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +0 -234
  186. package/packages/selector/tests/host-preset-overlay.host.spec.ts +0 -204
  187. package/packages/selector/tests/monitor-fab.client.spec.ts +0 -240
  188. package/packages/selector/tests/preset-options-write.client.spec.ts +0 -192
  189. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +0 -200
  190. package/packages/selector/tests/preset-overlay.host.spec.ts +0 -246
  191. package/packages/selector/tests/profiles.client.spec.tsx +0 -436
  192. package/packages/selector/tests/ptc-custom-write.client.spec.ts +0 -86
  193. package/packages/selector/tests/public/package-contract.client.spec.ts +0 -89
  194. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +0 -167
  195. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +0 -230
  196. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +0 -272
  197. package/packages/selector/tests/runtime/advisor.spec.ts +0 -226
  198. package/packages/selector/tests/runtime/audit.spec.ts +0 -275
  199. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +0 -523
  200. package/packages/selector/tests/runtime/char-basis.spec.ts +0 -30
  201. package/packages/selector/tests/runtime/code-skeleton.spec.ts +0 -152
  202. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +0 -186
  203. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +0 -122
  204. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +0 -122
  205. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +0 -96
  206. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +0 -273
  207. package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +0 -46
  208. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +0 -106
  209. package/packages/selector/tests/runtime/fixtures/vision-golden.json +0 -459
  210. package/packages/selector/tests/runtime/fold-router.spec.ts +0 -140
  211. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +0 -74
  212. package/packages/selector/tests/runtime/fresh-gate.spec.ts +0 -43
  213. package/packages/selector/tests/runtime/html-reducer.spec.ts +0 -212
  214. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  215. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  216. package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +0 -79
  217. package/packages/selector/tests/runtime/line-mapping.spec.ts +0 -153
  218. package/packages/selector/tests/runtime/monitor.spec.ts +0 -354
  219. package/packages/selector/tests/runtime/panel-command.spec.ts +0 -101
  220. package/packages/selector/tests/runtime/prose-reducers.spec.ts +0 -133
  221. package/packages/selector/tests/runtime/ptc-profile.spec.ts +0 -133
  222. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +0 -2795
  223. package/packages/selector/tests/runtime/read-input-cap.spec.ts +0 -33
  224. package/packages/selector/tests/runtime/savings-accounting.spec.ts +0 -291
  225. package/packages/selector/tests/runtime/savings-integral.spec.ts +0 -169
  226. package/packages/selector/tests/runtime/savings-projection.spec.ts +0 -89
  227. package/packages/selector/tests/runtime/savings-verify.spec.ts +0 -226
  228. package/packages/selector/tests/runtime/savings.spec.ts +0 -139
  229. package/packages/selector/tests/runtime/search-reducer.spec.ts +0 -110
  230. package/packages/selector/tests/runtime/sediment-card.spec.ts +0 -111
  231. package/packages/selector/tests/runtime/sediment-config.spec.ts +0 -56
  232. package/packages/selector/tests/runtime/sediment-guard.spec.ts +0 -71
  233. package/packages/selector/tests/runtime/sediment-masks.spec.ts +0 -95
  234. package/packages/selector/tests/runtime/sediment-orchestrator.spec.ts +0 -166
  235. package/packages/selector/tests/runtime/sediment-pool-share.spec.ts +0 -65
  236. package/packages/selector/tests/runtime/sediment-publish.spec.ts +0 -142
  237. package/packages/selector/tests/runtime/sediment-real-shapes.spec.ts +0 -158
  238. package/packages/selector/tests/runtime/sediment-settings.spec.ts +0 -73
  239. package/packages/selector/tests/runtime/sediment-signals.spec.ts +0 -124
  240. package/packages/selector/tests/runtime/sediment-span.spec.ts +0 -92
  241. package/packages/selector/tests/runtime/session-events.spec.ts +0 -27
  242. package/packages/selector/tests/runtime/session-file-decode.spec.ts +0 -281
  243. package/packages/selector/tests/runtime/settings-unwrap.spec.ts +0 -58
  244. package/packages/selector/tests/runtime/shallow-primitives.spec.ts +0 -135
  245. package/packages/selector/tests/runtime/sidechannel.spec.ts +0 -241
  246. package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +0 -167
  247. package/packages/selector/tests/runtime/stats-backfill.spec.ts +0 -350
  248. package/packages/selector/tests/runtime/stats-db.spec.ts +0 -361
  249. package/packages/selector/tests/runtime/stats-privacy.spec.ts +0 -55
  250. package/packages/selector/tests/runtime/stats-sync.spec.ts +0 -278
  251. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
  252. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +0 -159
  253. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +0 -53
  254. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +0 -217
  255. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +0 -52
  256. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +0 -79
  257. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +0 -76
  258. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +0 -121
  259. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +0 -82
  260. package/packages/selector/tests/runtime/toolclass.spec.ts +0 -156
  261. package/packages/selector/tests/runtime/value.spec.ts +0 -23
  262. package/packages/selector/tests/savings-sessions.client.spec.tsx +0 -140
  263. package/packages/selector/tests/settings-seat.client.spec.ts +0 -215
  264. package/packages/selector/tests/standing-generation.host.spec.ts +0 -724
  265. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +0 -269
  266. package/packages/selector/tests/support/cache-prefix-audit.ts +0 -105
  267. package/packages/selector/tests/support/mock-adapter.ts +0 -37
  268. package/packages/selector/tests/support/ui-primitives.tsx +0 -34
  269. package/packages/selector/tsconfig.json +0 -11
  270. package/packages/selector/tsdown.client.config.ts +0 -102
  271. package/packages/selector/tsdown.config.ts +0 -20
  272. package/pnpm-workspace.yaml +0 -76
  273. package/scripts/capture-profile-baseline.mjs +0 -42
  274. package/scripts/cell-browser-e2e.mjs +0 -354
  275. package/scripts/generate-tokenizer-fixtures.py +0 -81
  276. package/scripts/generate-vision-fixtures.py +0 -208
  277. package/scripts/hosts.d.mts +0 -3
  278. package/scripts/hosts.mjs +0 -79
  279. package/scripts/packed-components-smoke.mjs +0 -763
  280. package/scripts/packed-install-e2e.mjs +0 -1346
  281. package/scripts/sediment-latency-report.mjs +0 -63
  282. package/scripts/sync-hosts.mjs +0 -174
  283. package/scripts/toolclass-corpus-replay.mjs +0 -281
  284. package/scripts/verify-release.mjs +0 -343
  285. package/tests/TEST_INVENTORY.md +0 -41
  286. package/tsconfig.base.json +0 -18
  287. package/tsconfig.json +0 -7
  288. package/tsconfig.tests.json +0 -15
  289. package/vitest.built.config.ts +0 -9
  290. package/vitest.config.ts +0 -54
  291. /package/{packages/selector/assets → assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  292. /package/{packages/selector/assets → assets}/deepseek-v4/manifest.json +0 -0
  293. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer.json +0 -0
  294. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer_config.json +0 -0
  295. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  296. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  297. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  298. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  299. /package/{packages/selector/cordis.patch.yml → cordis.patch.yml} +0 -0
  300. /package/{packages/selector/lib → lib}/client.d.ts +0 -0
  301. /package/{packages/selector/lib → lib}/client.js +0 -0
  302. /package/{packages/selector/lib → lib}/index.d.ts +0 -0
  303. /package/{packages/selector/lib → lib}/invariant.d.ts +0 -0
  304. /package/{packages/selector/lib → lib}/invariant.js +0 -0
  305. /package/{packages/selector/lib → lib}/profiles.d.ts +0 -0
  306. /package/{packages/selector/lib → lib}/pruner.d.ts +0 -0
  307. /package/{packages/selector/lib → lib}/pruner.js +0 -0
  308. /package/{packages/selector/lib → lib}/savings-integral.js +0 -0
  309. /package/{packages/selector/lib → lib}/tail-trim.js +0 -0
  310. /package/{packages/selector/lib → lib}/tool-result.js +0 -0
@@ -1,523 +0,0 @@
1
- /** Auto Compact threshold settings schema and History linkage formula. */
2
-
3
- import { describe, expect, it } from 'vitest'
4
- import {
5
- AUTO_COMPACT_THRESHOLD_LIMITS,
6
- ContextCompressionSettingsSchema,
7
- DEFAULT_CUSTOM_COMPRESSION_POLICY,
8
- isValidAutoCompactThresholdPercent,
9
- parseContextCompressionSettings,
10
- resolveConfig,
11
- resolvePolicy,
12
- } from '../../src/pruner.ts'
13
- import {
14
- AUTO_COMPACT_THRESHOLD_LIMITS as BROWSER_LIMITS,
15
- decodeAutoCompactSettings as browserDecodeAutoCompact,
16
- isValidAutoCompactThresholdPercent as browserIsValid,
17
- } from '../../src/profiles.ts'
18
- import { decodeSettings as browserDecodeSettings } from '../../src/client/decode.ts'
19
-
20
- const BASE_SETTINGS = {
21
- profile: 'balanced' as const,
22
- custom: structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
23
- }
24
-
25
- describe('autoCompact settings validation', () => {
26
- it('defaults legacy settings without an autoCompact section to 80%', () => {
27
- const settings = parseContextCompressionSettings(structuredClone(BASE_SETTINGS))
28
- expect(settings.autoCompact).toEqual({ thresholdPercent: 80 })
29
- })
30
-
31
- it('accepts any integer threshold from 50 through 90, including non-quick values', () => {
32
- for (const thresholdPercent of [50, 69, 70, 73, 80, 82, 85, 90]) {
33
- const settings = parseContextCompressionSettings({
34
- ...structuredClone(BASE_SETTINGS),
35
- autoCompact: { thresholdPercent },
36
- } as never)
37
- expect(settings.autoCompact.thresholdPercent).toBe(thresholdPercent)
38
- }
39
- })
40
-
41
- it.each([
42
- 49, 91, 0, -1, 100, 72.5, 80.5, Number.NaN, Number.POSITIVE_INFINITY,
43
- ])('rejects the out-of-range or fractional value %s', (thresholdPercent) => {
44
- expect(() => parseContextCompressionSettings({
45
- ...structuredClone(BASE_SETTINGS),
46
- autoCompact: { thresholdPercent },
47
- })).toThrow()
48
- expect(isValidAutoCompactThresholdPercent(thresholdPercent)).toBe(false)
49
- })
50
-
51
- it('rejects malformed autoCompact sections and unknown keys', () => {
52
- for (const autoCompact of [
53
- { thresholdPercent: '80' },
54
- { thresholdPercent: null },
55
- {},
56
- { thresholdPercent: 80, extra: true },
57
- null,
58
- ]) {
59
- expect(() => parseContextCompressionSettings({
60
- ...structuredClone(BASE_SETTINGS),
61
- autoCompact,
62
- })).toThrow()
63
- }
64
- expect(() => parseContextCompressionSettings({
65
- ...structuredClone(BASE_SETTINGS),
66
- autoCompact: { thresholdPercent: 80 },
67
- unrelated: true,
68
- } as never)).toThrow(/unknown key/u)
69
- })
70
-
71
- it('publishes one shared validation contract for UI, persistence, and runtime', () => {
72
- expect(AUTO_COMPACT_THRESHOLD_LIMITS).toEqual({
73
- min: 50,
74
- max: 90,
75
- step: 1,
76
- default: 80,
77
- })
78
- expect(isValidAutoCompactThresholdPercent(73)).toBe(true)
79
- expect(isValidAutoCompactThresholdPercent(80)).toBe(true)
80
- expect(isValidAutoCompactThresholdPercent('73')).toBe(false)
81
- expect(isValidAutoCompactThresholdPercent(undefined)).toBe(false)
82
- })
83
-
84
- it('keeps the browser-safe mirror of the contract identical to the runtime contract', () => {
85
- expect(BROWSER_LIMITS).toEqual(AUTO_COMPACT_THRESHOLD_LIMITS)
86
- for (const value of [50, 73, 80, 90, 49, 91, 72.5, '73', null]) {
87
- expect(browserIsValid(value)).toBe(isValidAutoCompactThresholdPercent(value))
88
- }
89
- })
90
-
91
- it('keeps the full settings document browser/runtime parity', () => {
92
- const documents = [
93
- ['legacy without autoCompact', { profile: 'off', custom: structuredClone(BASE_SETTINGS.custom) }],
94
- ['complete document', {
95
- profile: 'off',
96
- custom: structuredClone(BASE_SETTINGS.custom),
97
- autoCompact: { thresholdPercent: 73 },
98
- }],
99
- ['top-level unknown key', {
100
- profile: 'off',
101
- custom: structuredClone(BASE_SETTINGS.custom),
102
- autoCompact: { thresholdPercent: 80 },
103
- unrelated: true,
104
- }],
105
- ['null document', null],
106
- ['array document', [{ profile: 'off' }]],
107
- ['primitive document', 42],
108
- ['empty object', {}],
109
- ['missing profile', { custom: structuredClone(BASE_SETTINGS.custom) }],
110
- ['invalid profile', { profile: 'turbo', custom: structuredClone(BASE_SETTINGS.custom) }],
111
- ['missing custom', { profile: 'off' }],
112
- ['malformed autoCompact', {
113
- profile: 'off',
114
- custom: structuredClone(BASE_SETTINGS.custom),
115
- autoCompact: { thresholdPercent: '80' },
116
- }],
117
- ['null profile', { profile: null, custom: structuredClone(BASE_SETTINGS.custom) }],
118
- ['null custom', { profile: 'off', custom: null }],
119
- ['both sections null', { profile: null, custom: null }],
120
- ['own-property undefined profile', { profile: undefined, custom: structuredClone(BASE_SETTINGS.custom) }],
121
- ['own-property undefined custom', { profile: 'off', custom: undefined }],
122
- ['profile off plus malformed autoCompact', {
123
- profile: 'off',
124
- custom: structuredClone(BASE_SETTINGS.custom),
125
- autoCompact: { thresholdPercent: 400 },
126
- }],
127
- ['codeSkeleton enabled', {
128
- profile: 'off',
129
- custom: structuredClone(BASE_SETTINGS.custom),
130
- codeSkeleton: { enabled: true },
131
- }],
132
- ['codeSkeleton disabled', {
133
- profile: 'off',
134
- custom: structuredClone(BASE_SETTINGS.custom),
135
- codeSkeleton: { enabled: false },
136
- }],
137
- ['malformed codeSkeleton section', {
138
- profile: 'off',
139
- custom: structuredClone(BASE_SETTINGS.custom),
140
- codeSkeleton: { enabled: 'on' },
141
- }],
142
- ['empty codeSkeleton section', {
143
- profile: 'off',
144
- custom: structuredClone(BASE_SETTINGS.custom),
145
- codeSkeleton: {},
146
- }],
147
- ['codeSkeleton with extra key', {
148
- profile: 'off',
149
- custom: structuredClone(BASE_SETTINGS.custom),
150
- codeSkeleton: { enabled: true, extra: true },
151
- }],
152
- ['null codeSkeleton section', {
153
- profile: 'off',
154
- custom: structuredClone(BASE_SETTINGS.custom),
155
- codeSkeleton: null,
156
- }],
157
- ['custom with wrong version', { profile: 'off', custom: { ...structuredClone(BASE_SETTINGS.custom), version: 99 } }],
158
- ] as const
159
- for (const [label, document] of documents) {
160
- const runtimeAccepts = (() => {
161
- try {
162
- parseContextCompressionSettings(structuredClone(document))
163
- return true
164
- } catch {
165
- return false
166
- }
167
- })()
168
- const browserDecoded = browserDecodeSettings(structuredClone(document))
169
- expect(browserDecoded !== undefined, label).toBe(runtimeAccepts)
170
- // When both accept, the decoded values must agree on the COMPLETE
171
- // canonical document — profile, custom, and autoCompact alike.
172
- if (runtimeAccepts && browserDecoded !== undefined) {
173
- const runtimeDecoded = parseContextCompressionSettings(structuredClone(document))
174
- expect(browserDecoded, label).toEqual(runtimeDecoded)
175
- }
176
- }
177
- })
178
-
179
- it('enforces the same plain-record boundary without erasing prototypes', () => {
180
- class SettingsDocument {
181
- profile = 'off' as const
182
- custom = structuredClone(BASE_SETTINGS.custom)
183
- autoCompact = { thresholdPercent: 73 }
184
- }
185
-
186
- class AutoCompactDocument {
187
- thresholdPercent = 73
188
- }
189
-
190
- const customPrototypeDocument = (): Record<string, unknown> => {
191
- const custom = structuredClone(BASE_SETTINGS.custom) as unknown as Record<string, unknown>
192
- Object.setPrototypeOf(custom, { inheritedMarker: true })
193
- return {
194
- profile: 'off',
195
- custom,
196
- autoCompact: { thresholdPercent: 73 },
197
- }
198
- }
199
-
200
- const invalidFactories: ReadonlyArray<readonly [string, () => unknown]> = [
201
- ['Date top-level document', () => new Date(0)],
202
- ['class top-level document', () => new SettingsDocument()],
203
- ['class autoCompact section', () => ({
204
- ...structuredClone(BASE_SETTINGS),
205
- autoCompact: new AutoCompactDocument(),
206
- })],
207
- ['custom-prototype Custom section', customPrototypeDocument],
208
- ]
209
-
210
- for (const [label, createDocument] of invalidFactories) {
211
- expect(() => ContextCompressionSettingsSchema(createDocument() as never), `host: ${label}`).toThrow()
212
- expect(() => parseContextCompressionSettings(createDocument()), `runtime: ${label}`).toThrow()
213
- expect(browserDecodeSettings(createDocument()), `browser: ${label}`).toBeUndefined()
214
- }
215
-
216
- const nullPrototypeDocument = Object.assign(Object.create(null) as Record<string, unknown>, {
217
- profile: 'off',
218
- custom: structuredClone(BASE_SETTINGS.custom),
219
- autoCompact: { thresholdPercent: 73 },
220
- })
221
- const hostDecoded = ContextCompressionSettingsSchema(nullPrototypeDocument as never)
222
- const runtimeDecoded = parseContextCompressionSettings(nullPrototypeDocument)
223
- const browserDecoded = browserDecodeSettings(nullPrototypeDocument)
224
- expect(hostDecoded).toEqual(runtimeDecoded)
225
- expect(browserDecoded).toEqual(runtimeDecoded)
226
- })
227
-
228
- it('canonicalizes legacy Custom v1 documents identically on both ends', () => {
229
- const legacyV1 = {
230
- version: 1,
231
- unit: 'tokens',
232
- fresh: { enabled: true, trigger: 8_192, target: 3_072 },
233
- aggregate: { enabled: true, trigger: 32_768, target: 12_288 },
234
- history: {
235
- enabled: true,
236
- trigger: 500_000,
237
- keepRecentTurns: 4,
238
- keepRecent: 64_000,
239
- minReclaim: 96_000,
240
- },
241
- prefixPolicy: 'pressure-break',
242
- }
243
- const runtimeDecoded = parseContextCompressionSettings({
244
- profile: 'custom',
245
- custom: structuredClone(legacyV1),
246
- })
247
- const browserDecoded = browserDecodeSettings({
248
- profile: 'custom',
249
- custom: structuredClone(legacyV1),
250
- })
251
- expect(browserDecoded).toEqual(runtimeDecoded)
252
- // Canonicalization is part of the shared contract: both ends upgrade the
253
- // legacy document to the same complete v3 policy.
254
- const custom = runtimeDecoded.custom
255
- if (custom.version !== 3) throw new Error('runtime did not canonicalize the legacy document to v3')
256
- expect(custom.version).toBe(3)
257
- expect(custom.history.keepRecentToolCalls).toBe(10)
258
- expect(custom.history.keepRecentTokens).toBe(64_000)
259
- expect(custom.tailTrim).toEqual({ enabled: false, trigger: 700_000 })
260
- })
261
-
262
- it('decodes the browser autoCompact section with exactly the runtime strictness', () => {
263
- for (const [section, expected] of [
264
- [undefined, { thresholdPercent: 80 }],
265
- [{ thresholdPercent: 73 }, { thresholdPercent: 73 }],
266
- [{ thresholdPercent: 50 }, { thresholdPercent: 50 }],
267
- [{ thresholdPercent: 90 }, { thresholdPercent: 90 }],
268
- [null, undefined],
269
- [[80], undefined],
270
- [80, undefined],
271
- ['80', undefined],
272
- [{}, undefined],
273
- [{ thresholdPercent: 80, extra: true }, undefined],
274
- [{ thresholdPercent: null }, undefined],
275
- [{ thresholdPercent: '73' }, undefined],
276
- [{ thresholdPercent: 91 }, undefined],
277
- [{ thresholdPercent: 72.5 }, undefined],
278
- [{ percent: 80 }, undefined],
279
- ] as const) {
280
- expect(browserDecodeAutoCompact(section), JSON.stringify(section)).toEqual(expected)
281
- // The runtime schema agrees on accept/reject for the whole section.
282
- const accepted = (() => {
283
- try {
284
- parseContextCompressionSettings({ ...structuredClone(BASE_SETTINGS), ...(section === undefined ? {} : { autoCompact: section }) })
285
- return true
286
- } catch {
287
- return false
288
- }
289
- })()
290
- expect(accepted, JSON.stringify(section)).toBe(expected !== undefined)
291
- }
292
- })
293
- })
294
-
295
- describe('Auto Compact History linkage formula', () => {
296
- it('restores the exact current preset numbers at the 80% default on a 1M window', () => {
297
- for (const [profile, expected] of [
298
- ['balanced', { h: 500_000, m: 96_000 }],
299
- ['adaptive', { h: 500_000, m: 96_000 }],
300
- ['savings', { h: 400_000, m: 128_000 }],
301
- ['cache-strict', { h: 600_000, m: 128_000 }],
302
- ] as const) {
303
- const policy = resolvePolicy(resolveConfig(), profile, undefined, {
304
- contextWindowTokens: 1_000_000,
305
- autoCompactThresholdPercent: 80,
306
- })
307
- expect(policy.historyTriggerTokens, `${profile} trigger`).toBe(expected.h)
308
- expect(policy.historyMinReclaimTokens, `${profile} min reclaim`).toBe(expected.m)
309
- expect(policy.historyKeepRecentTokens, `${profile} tail`).toBe(64_000)
310
- expect(policy.autoCompactTokens).toBe(800_000)
311
- expect(policy.microDeadlineTokens).toBe(700_000)
312
- }
313
- })
314
-
315
- it('scales H/M/K and the micro deadline for arbitrary thresholds', () => {
316
- const balanced73 = resolvePolicy(resolveConfig(), 'balanced', undefined, {
317
- contextWindowTokens: 1_000_000,
318
- autoCompactThresholdPercent: 73,
319
- })
320
- expect(balanced73.autoCompactTokens).toBe(730_000)
321
- expect(balanced73.microDeadlineTokens).toBe(638_750)
322
- expect(balanced73.historyTriggerTokens).toBe(456_250)
323
- expect(balanced73.historyMinReclaimTokens).toBe(87_600)
324
- expect(balanced73.historyKeepRecentTokens).toBe(58_400)
325
-
326
- const savings70 = resolvePolicy(resolveConfig(), 'savings', undefined, {
327
- contextWindowTokens: 1_000_000,
328
- autoCompactThresholdPercent: 70,
329
- })
330
- expect(savings70.autoCompactTokens).toBe(700_000)
331
- expect(savings70.microDeadlineTokens).toBe(612_500)
332
- expect(savings70.historyTriggerTokens).toBe(350_000)
333
- expect(savings70.historyMinReclaimTokens).toBe(112_000)
334
- expect(savings70.historyKeepRecentTokens).toBe(56_000)
335
-
336
- const cacheStrict85 = resolvePolicy(resolveConfig(), 'cache-strict', undefined, {
337
- contextWindowTokens: 1_000_000,
338
- autoCompactThresholdPercent: 85,
339
- })
340
- expect(cacheStrict85.autoCompactTokens).toBe(850_000)
341
- expect(cacheStrict85.microDeadlineTokens).toBe(743_750)
342
- expect(cacheStrict85.historyTriggerTokens).toBe(637_500)
343
- expect(cacheStrict85.historyMinReclaimTokens).toBe(136_000)
344
- expect(cacheStrict85.historyKeepRecentTokens).toBe(68_000)
345
- })
346
-
347
- it('matches the native engine float evaluation order on rounding-edge pairs', () => {
348
- // compaction-basic computes floor(window * (p / 100)); integer-first
349
- // division differs by one token on exactly these pairs.
350
- for (const [thresholdPercent, contextWindowTokens, expected] of [
351
- [57, 200_000, 113_999],
352
- [58, 200_000, 115_999],
353
- [57, 1_000_000, 570_000],
354
- ] as const) {
355
- const policy = resolvePolicy(resolveConfig(), 'balanced', undefined, {
356
- contextWindowTokens,
357
- autoCompactThresholdPercent: thresholdPercent,
358
- })
359
- expect(policy.autoCompactTokens, `${String(thresholdPercent)}@${String(contextWindowTokens)}`)
360
- .toBe(expected)
361
- expect(policy.autoCompactTokens)
362
- .toBe(Math.floor(contextWindowTokens * (thresholdPercent / 100)))
363
- }
364
- })
365
-
366
- it('keeps every watermark floor-based and exact on odd context windows', () => {
367
- const contextWindow = 999_983
368
- const policy = resolvePolicy(resolveConfig(), 'balanced', undefined, {
369
- contextWindowTokens: contextWindow,
370
- autoCompactThresholdPercent: 73,
371
- })
372
- const autoTokens = Math.floor(contextWindow * (73 / 100))
373
- expect(policy.autoCompactTokens).toBe(autoTokens)
374
- expect(policy.microDeadlineTokens).toBe(Math.floor(autoTokens * 0.875))
375
- expect(policy.historyTriggerTokens).toBe(Math.floor(0.625 * autoTokens))
376
- expect(policy.historyMinReclaimTokens).toBe(Math.floor(0.12 * autoTokens))
377
- expect(policy.historyKeepRecentTokens).toBe(Math.floor(0.08 * autoTokens))
378
- })
379
-
380
- it('covers the 50% and 90% hard boundaries', () => {
381
- const low = resolvePolicy(resolveConfig(), 'balanced', undefined, {
382
- contextWindowTokens: 1_000_000,
383
- autoCompactThresholdPercent: 50,
384
- })
385
- expect(low.autoCompactTokens).toBe(500_000)
386
- expect(low.microDeadlineTokens).toBe(437_500)
387
- const high = resolvePolicy(resolveConfig(), 'balanced', undefined, {
388
- contextWindowTokens: 1_000_000,
389
- autoCompactThresholdPercent: 90,
390
- })
391
- expect(high.autoCompactTokens).toBe(900_000)
392
- expect(high.microDeadlineTokens).toBe(787_500)
393
- })
394
-
395
- it('never links Custom, Off, or Native profiles', () => {
396
- const custom = resolvePolicy(resolveConfig(), 'custom', structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY), {
397
- contextWindowTokens: 1_000_000,
398
- autoCompactThresholdPercent: 73,
399
- })
400
- expect(custom.historyTriggerTokens).toBe(500_000)
401
- expect(custom.autoCompactTokens).toBeUndefined()
402
- expect(custom.microDeadlineTokens).toBeUndefined()
403
- for (const profile of ['off', 'native'] as const) {
404
- const policy = resolvePolicy(resolveConfig(), profile, undefined, {
405
- contextWindowTokens: 1_000_000,
406
- autoCompactThresholdPercent: 73,
407
- })
408
- expect(policy.autoCompactTokens).toBeUndefined()
409
- expect(policy.microDeadlineTokens).toBeUndefined()
410
- expect(policy.historyMode).toBe('disabled')
411
- }
412
- })
413
-
414
- it('falls back to the fixed preset numbers without a resolved context window', () => {
415
- const policy = resolvePolicy(resolveConfig(), 'balanced', undefined, { autoCompactThresholdPercent: 73 })
416
- expect(policy.historyTriggerTokens).toBe(500_000)
417
- expect(policy.historyMinReclaimTokens).toBe(96_000)
418
- expect(policy.historyKeepRecentTokens).toBe(64_000)
419
- expect(policy.autoCompactTokens).toBeUndefined()
420
- expect(policy.microDeadlineTokens).toBeUndefined()
421
- })
422
-
423
- it('rejects an out-of-range deployment-config threshold percent', () => {
424
- for (const autoCompactThresholdPercent of [49, 91, 72.5]) {
425
- expect(() => resolveConfig({ autoCompactThresholdPercent }), String(autoCompactThresholdPercent))
426
- .toThrow(/autoCompactThresholdPercent/u)
427
- }
428
- expect(resolveConfig({ autoCompactThresholdPercent: 73 }).autoCompactThresholdPercent).toBe(73)
429
- })
430
-
431
- it('ignores linkage when the context window is zero, fractional, or negative', () => {
432
- for (const contextWindowTokens of [0, -1_000_000, 999_999.5]) {
433
- const policy = resolvePolicy(resolveConfig(), 'balanced', undefined, {
434
- contextWindowTokens,
435
- autoCompactThresholdPercent: 73,
436
- })
437
- expect(policy.historyTriggerTokens).toBe(500_000)
438
- expect(policy.autoCompactTokens).toBeUndefined()
439
- expect(policy.microDeadlineTokens).toBeUndefined()
440
- }
441
- })
442
-
443
- it('ignores linkage when the threshold is missing or invalid', () => {
444
- for (const autoCompactThresholdPercent of [undefined, 49, 91, 72.5]) {
445
- const policy = resolvePolicy(resolveConfig(), 'balanced', undefined, {
446
- contextWindowTokens: 1_000_000,
447
- ...(autoCompactThresholdPercent === undefined ? {} : { autoCompactThresholdPercent }),
448
- })
449
- expect(policy.historyTriggerTokens).toBe(500_000)
450
- expect(policy.microDeadlineTokens).toBeUndefined()
451
- }
452
- })
453
-
454
- it('keeps explicit deployment overrides ahead of linkage values', () => {
455
- const config = resolveConfig({ historyTriggerTokens: 123_456, historyMinReclaimTokens: 12_345 })
456
- const policy = resolvePolicy(config, 'balanced', undefined, {
457
- contextWindowTokens: 1_000_000,
458
- autoCompactThresholdPercent: 73,
459
- })
460
- expect(policy.historyTriggerTokens).toBe(123_456)
461
- expect(policy.historyMinReclaimTokens).toBe(12_345)
462
- expect(policy.historyKeepRecentTokens).toBe(58_400)
463
- })
464
-
465
- it('keeps the 10-call working set and Fresh/Aggregate budgets independent of the threshold', () => {
466
- for (const autoCompactThresholdPercent of [50, 73, 90]) {
467
- const policy = resolvePolicy(resolveConfig(), 'balanced', undefined, {
468
- contextWindowTokens: 1_000_000,
469
- autoCompactThresholdPercent,
470
- })
471
- expect(policy.historyKeepRecentToolCalls).toBe(10)
472
- expect(policy.freshTriggerTokens).toBe(8_192)
473
- expect(policy.freshTargetTokens).toBe(3_072)
474
- expect(policy.aggregateTriggerTokens).toBe(32_768)
475
- expect(policy.aggregateTargetTokens).toBe(12_288)
476
- }
477
- })
478
- })
479
-
480
- describe('codeSkeleton settings validation', () => {
481
- it('defaults legacy settings without a codeSkeleton section to off', () => {
482
- const settings = parseContextCompressionSettings(structuredClone(BASE_SETTINGS))
483
- expect(settings.codeSkeleton).toEqual({ enabled: false })
484
- })
485
-
486
- it('accepts an explicit boolean enabled flag on either side', () => {
487
- for (const enabled of [true, false]) {
488
- const settings = parseContextCompressionSettings({
489
- ...structuredClone(BASE_SETTINGS),
490
- codeSkeleton: { enabled },
491
- } as never)
492
- expect(settings.codeSkeleton).toEqual({ enabled })
493
- }
494
- })
495
-
496
- it('rejects malformed codeSkeleton sections', () => {
497
- for (const codeSkeleton of [
498
- { enabled: 'true' },
499
- { enabled: 1 },
500
- {},
501
- { enabled: true, extra: true },
502
- null,
503
- 'on',
504
- ]) {
505
- expect(() => parseContextCompressionSettings({
506
- ...structuredClone(BASE_SETTINGS),
507
- codeSkeleton,
508
- })).toThrow()
509
- }
510
- })
511
-
512
- it('mirrors the browser decode for legacy, valid, and malformed documents', () => {
513
- const legacy = structuredClone(BASE_SETTINGS)
514
- const enabled = { ...structuredClone(BASE_SETTINGS), codeSkeleton: { enabled: true } }
515
- const malformed = { ...structuredClone(BASE_SETTINGS), codeSkeleton: { enabled: 'on' } }
516
- expect(browserDecodeSettings(structuredClone(legacy)))
517
- .toEqual(parseContextCompressionSettings(structuredClone(legacy)))
518
- expect(browserDecodeSettings(structuredClone(enabled)))
519
- .toEqual(parseContextCompressionSettings(structuredClone(enabled) as never))
520
- expect(browserDecodeSettings(structuredClone(malformed))).toBeUndefined()
521
- expect(() => parseContextCompressionSettings(structuredClone(malformed))).toThrow()
522
- })
523
- })
@@ -1,30 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
-
3
- import { CHARS_PER_TOKEN, charsForTokens, charsToTokens } from '../../src/runtime/config.ts'
4
-
5
- describe('character basis conversion', () => {
6
- it('derives zero tokens for non-positive or non-finite character counts', () => {
7
- expect(charsToTokens(0)).toBe(0)
8
- expect(charsToTokens(-1)).toBe(0)
9
- expect(charsToTokens(NaN)).toBe(0)
10
- expect(charsToTokens(Infinity)).toBe(0)
11
- })
12
-
13
- it('derives the telemetry token figure from characters', () => {
14
- expect(charsToTokens(1)).toBe(1)
15
- expect(charsToTokens(4)).toBe(1)
16
- expect(charsToTokens(5)).toBe(1)
17
- expect(charsToTokens(8)).toBe(2)
18
- })
19
-
20
- it('expresses token-named gates on the character basis', () => {
21
- expect(charsForTokens(0)).toBe(0)
22
- expect(charsForTokens(1000)).toBe(4000)
23
- expect(CHARS_PER_TOKEN).toBe(4.0)
24
- })
25
-
26
- it('stays finite at the integer upper bound (off/native gates must not misfire)', () => {
27
- expect(Number.isFinite(charsForTokens(Number.MAX_SAFE_INTEGER))).toBe(true)
28
- expect(charsForTokens(Number.MAX_SAFE_INTEGER)).toBeLessThan(Infinity)
29
- })
30
- })