dsh-context-compression-improved 0.10.1 → 0.10.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 (262) 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 +73 -12
  6. package/package.json +125 -112
  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 -39
  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 -544
  22. package/CHANGELOG.ru.md +0 -554
  23. package/CHANGELOG.zh.md +0 -238
  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/eslint.config.js +0 -30
  49. package/packages/selector/LICENSE +0 -21
  50. package/packages/selector/README.md +0 -26
  51. package/packages/selector/README.zh.md +0 -24
  52. package/packages/selector/THIRD_PARTY_NOTICES.md +0 -32
  53. package/packages/selector/docs/history-tool-call-working-set-spec.md +0 -112
  54. package/packages/selector/docs/native-tool-result-selector-spec.md +0 -34
  55. package/packages/selector/docs/subagent-cache-reuse-spec.md +0 -46
  56. package/packages/selector/lib/style.css +0 -350
  57. package/packages/selector/package.json +0 -178
  58. package/packages/selector/screenshots.json +0 -3
  59. package/packages/selector/src/client/CompressionProfileControls.tsx +0 -293
  60. package/packages/selector/src/client/CompressionProfileSelector.module.css +0 -199
  61. package/packages/selector/src/client/CompressionProfileSelector.tsx +0 -85
  62. package/packages/selector/src/client/CustomPolicyEditor.tsx +0 -216
  63. package/packages/selector/src/client/EstimatorControls.tsx +0 -277
  64. package/packages/selector/src/client/bridge-scope.ts +0 -125
  65. package/packages/selector/src/client/decode.ts +0 -57
  66. package/packages/selector/src/client/index.ts +0 -424
  67. package/packages/selector/src/client/locales/de.ts +0 -158
  68. package/packages/selector/src/client/locales/es.ts +0 -158
  69. package/packages/selector/src/client/locales/fr.ts +0 -158
  70. package/packages/selector/src/client/locales/it.ts +0 -158
  71. package/packages/selector/src/client/locales/ja.ts +0 -158
  72. package/packages/selector/src/client/locales/ko.ts +0 -158
  73. package/packages/selector/src/client/locales/ru.ts +0 -158
  74. package/packages/selector/src/client/locales.ts +0 -316
  75. package/packages/selector/src/client/monitor-fab.ts +0 -419
  76. package/packages/selector/src/client/preset-options.ts +0 -88
  77. package/packages/selector/src/client/savings-card.tsx +0 -269
  78. package/packages/selector/src/client/scope-face.ts +0 -24
  79. package/packages/selector/src/client/settings-section.tsx +0 -140
  80. package/packages/selector/src/compat/host-generation.ts +0 -96
  81. package/packages/selector/src/compat/llm-messages.ts +0 -50
  82. package/packages/selector/src/compat/settings-lease.ts +0 -108
  83. package/packages/selector/src/compat/tool-result.ts +0 -91
  84. package/packages/selector/src/css-modules.d.ts +0 -6
  85. package/packages/selector/src/deepseek-v4-tokenizer.ts +0 -205
  86. package/packages/selector/src/estimator-catalog.ts +0 -104
  87. package/packages/selector/src/index.ts +0 -890
  88. package/packages/selector/src/invariant.ts +0 -113
  89. package/packages/selector/src/preset-overlay.ts +0 -749
  90. package/packages/selector/src/profiles.ts +0 -431
  91. package/packages/selector/src/pruner/content.ts +0 -198
  92. package/packages/selector/src/pruner/session.ts +0 -97
  93. package/packages/selector/src/pruner/state.ts +0 -61
  94. package/packages/selector/src/pruner/tuning.ts +0 -23
  95. package/packages/selector/src/pruner/types.ts +0 -78
  96. package/packages/selector/src/pruner.ts +0 -2914
  97. package/packages/selector/src/runtime/adaptive-cost.ts +0 -205
  98. package/packages/selector/src/runtime/audit.ts +0 -320
  99. package/packages/selector/src/runtime/config.ts +0 -756
  100. package/packages/selector/src/runtime/custom-policy.ts +0 -278
  101. package/packages/selector/src/runtime/deepseek-official-pricing.ts +0 -298
  102. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +0 -254
  103. package/packages/selector/src/runtime/display-prefs.ts +0 -98
  104. package/packages/selector/src/runtime/measurement.ts +0 -444
  105. package/packages/selector/src/runtime/monitor.ts +0 -310
  106. package/packages/selector/src/runtime/panel-command.ts +0 -213
  107. package/packages/selector/src/runtime/reducers.ts +0 -1754
  108. package/packages/selector/src/runtime/retrieve.ts +0 -503
  109. package/packages/selector/src/runtime/savings-integral.ts +0 -117
  110. package/packages/selector/src/runtime/savings-projection.ts +0 -229
  111. package/packages/selector/src/runtime/savings-verify.ts +0 -446
  112. package/packages/selector/src/runtime/savings.ts +0 -526
  113. package/packages/selector/src/runtime/session-events.ts +0 -30
  114. package/packages/selector/src/runtime/session-file-decode.ts +0 -523
  115. package/packages/selector/src/runtime/stats-backfill.ts +0 -541
  116. package/packages/selector/src/runtime/stats-db.ts +0 -492
  117. package/packages/selector/src/runtime/stats-schema.ts +0 -123
  118. package/packages/selector/src/runtime/stats-sync.ts +0 -307
  119. package/packages/selector/src/runtime/summary-command.ts +0 -127
  120. package/packages/selector/src/runtime/tail-trim.ts +0 -176
  121. package/packages/selector/src/runtime/token-count.ts +0 -72
  122. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +0 -233
  123. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -204
  124. package/packages/selector/src/runtime/tokenpilot/advisor.ts +0 -419
  125. package/packages/selector/src/runtime/tokenpilot/benefit.ts +0 -200
  126. package/packages/selector/src/runtime/tokenpilot/dedup.ts +0 -81
  127. package/packages/selector/src/runtime/tokenpilot/estimator.ts +0 -151
  128. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  129. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  130. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  131. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  132. package/packages/selector/src/runtime/tokenpilot/locator.ts +0 -128
  133. package/packages/selector/src/runtime/tokenpilot/read-state.ts +0 -98
  134. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +0 -303
  135. package/packages/selector/src/runtime/toolclass.ts +0 -103
  136. package/packages/selector/src/runtime/types.ts +0 -365
  137. package/packages/selector/src/runtime/value.ts +0 -48
  138. package/packages/selector/src/settings-bridge.ts +0 -175
  139. package/packages/selector/tests/advisor-report.host.spec.ts +0 -223
  140. package/packages/selector/tests/auto-compact.client.spec.tsx +0 -214
  141. package/packages/selector/tests/built/client-artifact.spec.ts +0 -56
  142. package/packages/selector/tests/cache-prefix-audit.spec.ts +0 -123
  143. package/packages/selector/tests/code-skeleton.client.spec.ts +0 -98
  144. package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +0 -150
  145. package/packages/selector/tests/custom-contract.client.spec.ts +0 -226
  146. package/packages/selector/tests/estimator-catalog.spec.ts +0 -70
  147. package/packages/selector/tests/estimator-channel.client.spec.tsx +0 -253
  148. package/packages/selector/tests/estimator-route-registration.host.spec.ts +0 -202
  149. package/packages/selector/tests/helpers/legacy-namespace.ts +0 -35
  150. package/packages/selector/tests/helpers/legacy-settings/index.ts +0 -15
  151. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +0 -41
  152. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +0 -647
  153. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +0 -78
  154. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +0 -234
  155. package/packages/selector/tests/host-preset-overlay.host.spec.ts +0 -204
  156. package/packages/selector/tests/monitor-fab.client.spec.ts +0 -220
  157. package/packages/selector/tests/preset-options-write.client.spec.ts +0 -192
  158. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +0 -200
  159. package/packages/selector/tests/preset-overlay.host.spec.ts +0 -246
  160. package/packages/selector/tests/profiles.client.spec.tsx +0 -436
  161. package/packages/selector/tests/public/package-contract.client.spec.ts +0 -86
  162. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +0 -167
  163. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +0 -230
  164. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +0 -272
  165. package/packages/selector/tests/runtime/advisor.spec.ts +0 -226
  166. package/packages/selector/tests/runtime/audit.spec.ts +0 -275
  167. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +0 -523
  168. package/packages/selector/tests/runtime/char-basis.spec.ts +0 -30
  169. package/packages/selector/tests/runtime/code-skeleton.spec.ts +0 -152
  170. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +0 -186
  171. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +0 -122
  172. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +0 -122
  173. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +0 -96
  174. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +0 -273
  175. package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +0 -46
  176. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +0 -106
  177. package/packages/selector/tests/runtime/fixtures/vision-golden.json +0 -459
  178. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +0 -74
  179. package/packages/selector/tests/runtime/fresh-gate.spec.ts +0 -43
  180. package/packages/selector/tests/runtime/html-reducer.spec.ts +0 -212
  181. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  182. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  183. package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +0 -79
  184. package/packages/selector/tests/runtime/line-mapping.spec.ts +0 -153
  185. package/packages/selector/tests/runtime/monitor.spec.ts +0 -354
  186. package/packages/selector/tests/runtime/panel-command.spec.ts +0 -101
  187. package/packages/selector/tests/runtime/prose-reducers.spec.ts +0 -133
  188. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +0 -2781
  189. package/packages/selector/tests/runtime/read-input-cap.spec.ts +0 -33
  190. package/packages/selector/tests/runtime/savings-accounting.spec.ts +0 -291
  191. package/packages/selector/tests/runtime/savings-integral.spec.ts +0 -169
  192. package/packages/selector/tests/runtime/savings-projection.spec.ts +0 -89
  193. package/packages/selector/tests/runtime/savings-verify.spec.ts +0 -226
  194. package/packages/selector/tests/runtime/savings.spec.ts +0 -139
  195. package/packages/selector/tests/runtime/search-reducer.spec.ts +0 -110
  196. package/packages/selector/tests/runtime/session-events.spec.ts +0 -27
  197. package/packages/selector/tests/runtime/session-file-decode.spec.ts +0 -281
  198. package/packages/selector/tests/runtime/settings-unwrap.spec.ts +0 -58
  199. package/packages/selector/tests/runtime/sidechannel.spec.ts +0 -241
  200. package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +0 -167
  201. package/packages/selector/tests/runtime/stats-backfill.spec.ts +0 -348
  202. package/packages/selector/tests/runtime/stats-db.spec.ts +0 -361
  203. package/packages/selector/tests/runtime/stats-privacy.spec.ts +0 -55
  204. package/packages/selector/tests/runtime/stats-sync.spec.ts +0 -278
  205. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
  206. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +0 -159
  207. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +0 -53
  208. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +0 -217
  209. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +0 -52
  210. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +0 -79
  211. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +0 -76
  212. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +0 -119
  213. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +0 -82
  214. package/packages/selector/tests/runtime/toolclass.spec.ts +0 -156
  215. package/packages/selector/tests/runtime/value.spec.ts +0 -23
  216. package/packages/selector/tests/savings-sessions.client.spec.tsx +0 -140
  217. package/packages/selector/tests/settings-seat.client.spec.ts +0 -215
  218. package/packages/selector/tests/standing-generation.host.spec.ts +0 -724
  219. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +0 -269
  220. package/packages/selector/tests/support/cache-prefix-audit.ts +0 -105
  221. package/packages/selector/tests/support/mock-adapter.ts +0 -37
  222. package/packages/selector/tests/support/ui-primitives.tsx +0 -34
  223. package/packages/selector/tsconfig.json +0 -11
  224. package/packages/selector/tsdown.client.config.ts +0 -102
  225. package/packages/selector/tsdown.config.ts +0 -20
  226. package/pnpm-workspace.yaml +0 -76
  227. package/scripts/capture-profile-baseline.mjs +0 -42
  228. package/scripts/cell-browser-e2e.mjs +0 -354
  229. package/scripts/generate-tokenizer-fixtures.py +0 -81
  230. package/scripts/generate-vision-fixtures.py +0 -208
  231. package/scripts/hosts.mjs +0 -78
  232. package/scripts/packed-components-smoke.mjs +0 -763
  233. package/scripts/packed-install-e2e.mjs +0 -1346
  234. package/scripts/sync-hosts.mjs +0 -174
  235. package/scripts/toolclass-corpus-replay.mjs +0 -281
  236. package/scripts/verify-release.mjs +0 -338
  237. package/tests/TEST_INVENTORY.md +0 -41
  238. package/tsconfig.base.json +0 -18
  239. package/tsconfig.json +0 -7
  240. package/tsconfig.tests.json +0 -15
  241. package/vitest.built.config.ts +0 -9
  242. package/vitest.config.ts +0 -54
  243. /package/{packages/selector/assets → assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  244. /package/{packages/selector/assets → assets}/deepseek-v4/manifest.json +0 -0
  245. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer.json +0 -0
  246. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer_config.json +0 -0
  247. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  248. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  249. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  250. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  251. /package/{packages/selector/cordis.patch.yml → cordis.patch.yml} +0 -0
  252. /package/{packages/selector/lib → lib}/client.d.ts +0 -0
  253. /package/{packages/selector/lib → lib}/index.d.ts +0 -0
  254. /package/{packages/selector/lib → lib}/index.js +0 -0
  255. /package/{packages/selector/lib → lib}/invariant.d.ts +0 -0
  256. /package/{packages/selector/lib → lib}/invariant.js +0 -0
  257. /package/{packages/selector/lib → lib}/profiles.d.ts +0 -0
  258. /package/{packages/selector/lib → lib}/pruner.d.ts +0 -0
  259. /package/{packages/selector/lib → lib}/pruner.js +0 -0
  260. /package/{packages/selector/lib → lib}/savings-integral.js +0 -0
  261. /package/{packages/selector/lib → lib}/tail-trim.js +0 -0
  262. /package/{packages/selector/lib → lib}/tool-result.js +0 -0
@@ -1,657 +0,0 @@
1
- # Repair log
2
-
3
- Cross-version ledger of defects that break the **install / boot** path. Every branch and
4
- version must leave its verdict here (affected / unaffected / fixed) before it ships.
5
-
6
- Read this file before starting a new line (see `CONTRIBUTING.md`). A defect class already
7
- recorded here is expected to be *re-checked*, not re-discovered.
8
-
9
- - One defect, one `D#` id.
10
- - One entry must contain: symptom / root cause / evidence / affected surface / fix / verification.
11
- - Evidence means a command and its observed output, not a description of the code.
12
-
13
- Defects that ship to the **settings surface** rather than the boot path use the `U#` series and
14
- keep the same six-part shape. They are recorded here because they are reported the same way —
15
- from a real machine, by someone who cannot tell a gate from a bug.
16
-
17
- ---
18
-
19
- ## D1 — Host plugin entry statically imports a sibling package
20
-
21
- **Symptom.** `dsh web` aborts while loading the plugin tree:
22
-
23
- ```text
24
- failed to import loader entry context-compression-improved-bundle
25
- (dsh-context-compression-improved): Cannot find package
26
- 'dsh-context-compression-improved-runtime' imported from
27
- <profile>/node_modules/dsh-context-compression-improved/packages/selector/lib/index.js
28
- code: 'ERR_MODULE_NOT_FOUND'
29
- ```
30
-
31
- **Root cause.** The repository was installed whole via a git dependency, so pnpm only
32
- installs what the **root** manifest declares. The root manifest declared no
33
- `dependencies`, so the sibling package was never materialized — and
34
- `packages/selector/lib/index.js:3` uses a top-level static `import` of it, which throws
35
- during module evaluation.
36
-
37
- **Cascade.** The Host entry never loads → `settings.register('context-compression', …)`
38
- never runs → the browser `SettingsScopeSnapshot.writable` stays at its initial `false` →
39
- every control in the settings panel renders `disabled`. The panel itself is still visible
40
- because the client bundle is resolved from `dsh.client` metadata and is unaffected by this
41
- failure.
42
-
43
- **Evidence (committed artifacts, not a working tree).**
44
-
45
- | Branch | `packages/selector/lib/index.js` |
46
- | --- | --- |
47
- | `feat/ctx-preset-v2` @ `455f74f` | `L3: import { … } from "dsh-context-compression-improved-runtime";` — the crash site |
48
- | `compat/0.1.5` @ `d7c592d` | no top-level import; only `modulePath("…-runtime", import.meta.resolve("…-runtime"))` |
49
-
50
- **Affected.** `feat/ctx-preset-v2` (the crash itself).
51
-
52
- **Fix.** Merge into a single package: the entry imports `./runtime/config.ts` from inside
53
- its own package.
54
-
55
- **Verification.** `grep` over `lib/**/*.js` must find no
56
- `from "dsh-context-compression-improved-runtime"`. The frozen provenance literal (D5 note
57
- below) is the only remaining occurrence and is required.
58
-
59
- **Status.** Fixed on the merge branch.
60
-
61
- ---
62
-
63
- ## D2 — Root manifest missing the install contract
64
-
65
- **Symptom.** `dsh plugin add github:<owner>/<repo>` completes, yet the profile gains no
66
- usable plugin: no bundle row, no resolvable entry.
67
-
68
- **Root cause.** A git install reads the **root** manifest. Without `main` / `exports` /
69
- `dsh.client.inject` / `dsh.bundle.patch` there is nothing for the harness to mount; and if
70
- the root name is still a private workspace name with `"private": true`, pnpm installs a
71
- private package nothing can load.
72
-
73
- **Evidence.**
74
-
75
- | Branch | Root manifest |
76
- | --- | --- |
77
- | `feat/ctx-preset-v2` @ `455f74f` | correct name, has `main`/`exports`/`dsh`; but `dependencies` **empty**, `exports` missing `./pruner` and `./invariant` |
78
- | `compat/0.1.5` @ `d7c592d` | `dsh-context-compression-improved-workspace`, `private: true`, **no** `main`/`exports`/`dsh`/`dependencies` |
79
- | `main` / `baseline/pre-god-module-split` @ `e337bf5` | same as compat, plus **zero** `lib/` artifacts committed |
80
-
81
- **Affected.** `compat/0.1.5`, `baseline/pre-god-module-split`, `main` (fully);
82
- `feat/ctx-preset-v2` (partially: empty dependencies, incomplete exports).
83
-
84
- `baseline/pre-god-module-split` is a pre-split baseline, not a distribution: it has no
85
- install contract and no built artifacts. Do not use it as a rollback target.
86
-
87
- **Fix.** The root manifest carries the install contract: `name`, `main`, `types`,
88
- `exports`, `dependencies`, `dsh`. `dependencies` lists the real third-party runtime
89
- dependencies (`@huggingface/tokenizers`, `js-yaml`).
90
-
91
- **Verification.** `git show <branch>:package.json` field-by-field; after a real
92
- `dsh plugin add`, confirm `node_modules/<pkg>` exists and contains `lib/index.js`.
93
-
94
- **Status.** Fixed on the merge branch for `dependencies` / `./pruner`. `./invariant` was
95
- added to the root `exports` by the closure commit — the root and the package manifest now
96
- export the same four subpaths (`.`, `./invariant`, `./pruner`, `./client`). See the
97
- verification ledger below for the command-level evidence.
98
-
99
- ---
100
-
101
- ## D3 — Build chunks not committed: the same crash under a different filename
102
-
103
- **Symptom.** After the merge, the built entry starts with:
104
-
105
- ```js
106
- // packages/selector/lib/index.js:1
107
- import { … } from "./config.js";
108
- // packages/selector/lib/invariant.js:1
109
- import { … } from "./tail-trim.js";
110
- ```
111
-
112
- tsdown splits a shared chunk out of every entry that reuses a module.
113
-
114
- **Root cause.** This repository commits `lib/` because pnpm refuses a `prepare` script on a
115
- git dependency, so consumers can only install prebuilt artifacts. After the merge the new
116
- artifacts — `lib/config.js`, `lib/tail-trim.js`, `lib/pruner.js`, `lib/pruner.d.ts`,
117
- `src/deepseek-v4-tokenizer.ts` — were **untracked** while `lib/index.js` already imported
118
- them. Pushing in that state makes a git install fetch an entry whose chunk does not exist:
119
- the identical `ERR_MODULE_NOT_FOUND`, only the specifier changes from the sibling package
120
- to `./config.js`.
121
-
122
- A git install fetches exactly the **tracked** tree, so `pnpm test:e2e:packed` cannot catch
123
- this: `npm pack` builds from the working tree and happily includes untracked files.
124
-
125
- **Evidence.**
126
-
127
- - `git ls-files packages/selector/lib` listed only the seven pre-merge files.
128
- - `git status --porcelain` showed the five untracked artifacts above.
129
- - Before the gate was added, `pnpm verify:release` printed
130
- `release verification: OK` — the release gate did not cover the artifact graph.
131
- - Contrast with history, showing this is merge-introduced: on `feat/ctx-preset-v2` and
132
- `compat/0.1.5`, `packages/runtime/lib/tail-trim.js` is committed, and the selector entry
133
- is self-contained with no relative imports.
134
-
135
- **Affected.** Any release built from the merged single-package layout, i.e. every future
136
- version of this repository. Treat it as a permanent gate, not a one-off fix.
137
-
138
- **Fix.**
139
- 1. Commit `lib/**` together with the sources, including every chunk and entry.
140
- 2. Gate it: every relative import in a shipped artifact must (a) resolve to an existing
141
- file, (b) be covered by the package `files` allowlist (packed install), and (c) be
142
- git-tracked (git install).
143
-
144
- The gate is scoped to the **import graph**. Unreferenced build by-products such as
145
- `lib/style.css` are excluded: its rules are already carried inline by `lib/client.js`
146
- (the `\0dsh-context-compression-css:` region), nothing in the repository reads the file,
147
- and the `files` allowlist deliberately drops it from the tarball. Requiring it would mean
148
- widening the allowlist to ship dead weight.
149
-
150
- **Verification.** `scripts-dist/verify-release.js` (compiled from `scripts/verify-release.ts`). Observed:
151
-
152
- ```text
153
- # untracked chunk present
154
- Error: release verification: packages/selector/lib/config.js is not committed;
155
- a git install would fetch an incomplete artifact graph
156
-
157
- # after git add (the gate reads the index, so staging is enough)
158
- release verification: OK
159
- ```
160
-
161
- **Status.** Gate implemented and verified red → green. The root-cause fix is the
162
- `git add`, applied in the merge commit.
163
-
164
- ---
165
-
166
- ## D4 — Consumer profile leftovers
167
-
168
- **Symptom.** Even with the package fixed, a profile can still install the wrong thing or
169
- fail to install.
170
-
171
- **Evidence (`web` profile).**
172
-
173
- - `package.json` depended on `…-selector-workspace` at
174
- `github:<owner>/<repo>#baseline/pre-god-module-split` — a spec **without**
175
- `&path:/packages/selector`, which resolves to the private workspace root and installs
176
- nothing usable.
177
- - `pnpm-workspace.yaml` kept an `overrides` entry pointing at the now-deleted
178
- `packages/runtime` path.
179
- - `node_modules` held nothing but the useless workspace package.
180
-
181
- **Affected.** Any profile that installs this plugin.
182
-
183
- **Fix.** Remove the stale dependency and the dead override; install by the single-package
184
- spec (no `&path:` needed once the root manifest is the install face).
185
-
186
- **Correction.** An earlier analysis claimed `allowBuilds` for `@huggingface/tokenizers` was
187
- a blocker. `@huggingface/tokenizers@0.1.3` has no `install`/`postinstall` script — `dist/`
188
- ships prebuilt — and the repository's own packed E2E writes a consumer workspace manifest
189
- of just `packages: []`. Adding the `allowBuilds` entry is precautionary, not required.
190
-
191
- **Status.** Delivered as a manual script; not executed by the maintainer agent.
192
-
193
- ---
194
-
195
- ## D5 — `compat/0.1.5` predates the install contract
196
-
197
- **Verdict: it must inherit.** `compat/0.1.5` @ `d7c592d` is four commits behind
198
- `feat/ctx-preset-v2` (`0b20bf2`, `cd03575`, `4635d19`, `455f74f`), so what it needs is not
199
- merely the merge but the whole install contract:
200
-
201
- 1. the root manifest contract (D2) — it currently cannot be mounted at all;
202
- 2. the single-package merge (structural fix for D1) — it is still two packages, with
203
- neither manifest declaring the other as an installable dependency, so a git install
204
- cannot materialize the runtime package: the same root cause, a different presentation;
205
- 3. the artifact-graph gate (D3) and the profile hygiene (D4).
206
-
207
- Its entry lacks a top-level cross-package import only because it resolves the runtime
208
- package lazily through `import.meta.resolve`. That is why it fails as "no bundle to load"
209
- instead of a load-time throw. Same disease, different symptom — do not read it as
210
- "unaffected".
211
-
212
- **Replay, not merge.** `compat/0.1.5` carries 0.1.5-rc.2-only adaptations (client slot
213
- names, `engines.dsh`, pinned overrides, lazy service resolution, estimator host route,
214
- `/api` route prefix). A `git merge` would drag the old-line adaptations back, so the merge
215
- is replayed file by file on that branch instead.
216
-
217
- **Status.** Not started.
218
-
219
- ---
220
-
221
- ## D6 — Consumer profile blocks dependency reconciliation (host precondition)
222
-
223
- **Scope note.** This is *not* a defect of this repository. It is recorded here because it
224
- blocks the real-machine verification step that every branch needs, and because CI is
225
- structurally blind to it.
226
-
227
- **Symptom.** `pnpm install` in the `web` profile fails, at a **different path on every run**:
228
-
229
- ```text
230
- cannot create directory at "...\node_modules\katex\node_modules\commander_pacquet-stage_…":
231
- 拒绝访问。 (os error 5)
232
-
233
- failed to remove existing directory "...\node_modules\better-sqlite3" prior to swap:
234
- 拒绝访问。 (os error 5)
235
- ```
236
-
237
- Progress advances each run (`added 151 → 159 → 205`). The install is not wedged — it is
238
- walking a list of blockers, one per run.
239
-
240
- **Root cause — two independent sources of `os error 5`. Do not conflate them.**
241
-
242
- 1. **ACL denies write**, at exactly one directory: `node_modules\katex\node_modules` lists
243
- only `BUILTIN\Users: ReadAndExecute` and does not name the interactive user at all.
244
- 2. **A mapped native module is held by a live process.** `better-sqlite3` grants the
245
- interactive user `FullControl` on both itself and its nested `node_modules`, yet deletion
246
- still fails. `session-query-sqlite` is enabled and `dsh web` is running, so
247
- `better-sqlite3\build\Release\better_sqlite3.node` is mapped into that process; Windows
248
- returns `ERROR_ACCESS_DENIED` when asked to delete a mapped image. No ACL change fixes
249
- this one — only stopping the process does.
250
-
251
- **Criterion warning — never test this by ownership.** Measured here:
252
-
253
- | criterion | flagged |
254
- | --- | --- |
255
- | owner is not the interactive user | **211** |
256
- | the interactive user actually lacks write | **0** of 269 package dirs, plus **1** nested |
257
-
258
- Ownership is `BUILTIN\Administrators` almost everywhere (the profile was evidently produced
259
- by one elevated install), while the interactive user holds explicit `FullControl` in nearly
260
- all of them. An ownership-based fix would take ownership of 211 directories to solve one.
261
- Test the **effective write right** instead.
262
-
263
- **Affected.** Every real-machine verification on this host, on every branch — including the
264
- `compat/0.1.5` replay, which cannot be validated anywhere else.
265
-
266
- **Fix.** Stop `dsh web`; grant write on the one genuinely denied directory; re-run
267
- `pnpm install --no-frozen-lockfile`; restart. Delivered as
268
- `DSH-ccp-单包修复-04-node_modules依赖收敛阻塞.ps1` — diagnose / repair / re-verify, dry-run
269
- capable, and it never stops the service for you.
270
-
271
- **Verification.** The script's `-DryRun` reports one true target and names the one path.
272
-
273
- **Status. Resolved** in the maintenance window. The consumer ran a plain `pnpm install` in
274
- the profile and it completed: `Packages: +256 -16`, `Progress: resolved 256, reused 256`,
275
- `Done in 11.1s using pnpm v12.4.1`, exit 0.
276
-
277
- **Resolution evidence (read-only re-check after the install):**
278
-
279
- | Check | Result |
280
- | --- | --- |
281
- | `pnpm-lock.yaml` references `dsh-context-compression-selector-workspace` | **none** — lockfile and `package.json` agree again |
282
- | `node_modules\dsh-context-compression*` | exactly one directory, `dsh-context-compression-improved` |
283
- | `*_pacquet-stage_*` residue | none |
284
- | plugin `packages/selector/lib/**` | all ten artifacts present, `invariant.js` 3927 B — byte-size identical to the source build |
285
- | `dsh.profile.bundles` row | `dsh-context-compression-improved` still listed |
286
-
287
- Two things follow for the record. First, the lockfile inconsistency tracked here was a
288
- **symptom** of the failed installs, not a separate defect: once one install succeeded, it
289
- cleared itself — no manual lockfile surgery was needed. Second, the blockage cleared **by
290
- retrying**, without the elevated ACL repair. That does not retire the finding — the `katex`
291
- ACL hole is still real and will bite the next replacement of that subtree — but it does mean
292
- the earlier per-run progress (`added 151 → 159 → 205`) was the decisive mechanism: each
293
- attempt converged further and the last one finished. Record it as *cleared by convergence*,
294
- not as *fixed by the script*; `-04` remains the tool of record if a future install stalls on
295
- the same signature.
296
-
297
- ---
298
-
299
- ## D7 — The estimator catalog route never registered: a detached method lost `this`
300
-
301
- **Symptom.** The settings card's host-route dropdowns stayed empty. An authenticated
302
- `GET /api/dsh-context-compression-improved/estimator-catalog` answered 404 while a sibling
303
- plugin's `/api/dsh-perm-gate/receiver` answered 200 in the same breath.
304
-
305
- **Root cause.** `asWebServer` duck-typed the `webServer` service by pulling `register` off it
306
- and returning a fresh wrapper:
307
-
308
- ```ts
309
- const register = value?.register
310
- return { register } // `this` is now the wrapper
311
- ```
312
-
313
- `dsh-host-webserver`'s `register` reads its own route tables:
314
-
315
- ```js
316
- const table = route.kind === "exact" ? this.exact : this.prefixes;
317
- if (table.has(route.path)) … // L178 — `table` is undefined, TypeError
318
- ```
319
-
320
- `this` was the wrapper, so `this.exact` / `this.prefixes` were `undefined`, the host threw
321
- inside `register`, and the plugin's catch-all swallowed it. **The helper had never once
322
- registered a route since it was written.**
323
-
324
- **Why it stayed invisible.** On the 0.1.2 host the `dsh web` terminal prints no plugin
325
- `ctx.logger` output at all — a full boot produced 1350 bytes containing only Node's
326
- experimental warning and two `dsh web:` lines — and a plugin-load failure travels the same
327
- logger. A swallowed throw and a plugin that quietly did nothing were observationally
328
- identical. Once the diagnostic moved to `console` (as `dsh-perm-gate` already does on this
329
- host), the real frame appeared:
330
-
331
- ```
332
- TypeError: Cannot read properties of undefined (reading 'has')
333
- at Object.register (dsh-host-webserver/lib/index.js:178:13)
334
- at Object.apply (cordis/lib/index.js:120:36)
335
- ```
336
-
337
- **Fix.** `return value as WebServerLike` — pass the service itself; `dsh-perm-gate` works
338
- for exactly this reason.
339
-
340
- **Verification.** Cordis does **not** bind service methods: on a bare `Context`, both a
341
- detached call and a wrapped one lose `this`. On the real host, after installing this fix,
342
- `/api/dsh-context-compression-improved/estimator-catalog` answers **200** with a full
343
- catalog (four provider groups), `/endpoint/…` answers 200, perm-gate stays 200, and a
344
- garbage path stays 401.
345
-
346
- **Guard.** `packages/selector/tests/estimator-route-registration.host.spec.ts` now mounts a
347
- stand-in whose `register` reads its tables off `this`, mirroring the host. Against the
348
- previous implementation it fails **3 of 5** cases with `expected [] to deeply equal […]` —
349
- the same empty route table the host exhibited. The earlier version of that stand-in recorded
350
- routes in a closure, so it could never have caught this.
351
-
352
- **Withdrawn hypotheses.** Everything this ledger recorded before the fix about the cause —
353
- narrowing the injection gate, isolation scope, and moving to the `connection` service — was
354
- a false trail produced by the silence. Two of them are worth keeping as *non*-causes:
355
- isolation is opt-in and this row never opted in, and `connection.rpc` is the wrong transport
356
- here for reasons the project's own `upgrade-pitfalls` §2.1 records independently.
357
-
358
- ---
359
-
360
- ## D8 — The search reducer dropped 21.2% of hits and never reported where they went
361
-
362
- **Symptom.** Large `grep`/`rg` results compressed by `search-by-file` lost every hit the
363
- per-file "first 4 + last" rule did not keep, and the file header only said `(592 matches)`
364
- with no line numbers. The model could not tell which hits were dropped or where to re-read.
365
-
366
- **Root cause.** `reduceSearch` filled each file's keep-set from index 0 (`keep.size < 5`)
367
- and reported only counts. Nothing in the output identified the omitted hit positions, so the
368
- loss was invisible and unrecoverable except by re-running the search.
369
-
370
- **Evidence.** 14 real sessions (18.6M characters, DSH 0.1.5-rc.2): 186 search events /
371
- 5,301 hits; per-file median 18, p90 55, max 592; 1,122 hits (21.2%) discarded silently.
372
-
373
- **Affected surface.** `packages/selector/src/runtime/reducers.ts` (`reduceSearch`).
374
-
375
- **Fix.** Two-tier folding (R10): L1 is a lossless per-file locator
376
- (`## <path> (N matches) L12,L15,…`, one line number per hit, budget reserved first); L2 is
377
- the content quota, water-filled round-robin so no file vanishes. When L1 itself cannot fit
378
- the shortfall is announced (withheld file/match counts), never silently truncated.
379
-
380
- **Verification.** `packages/selector/tests/runtime/search-reducer.spec.ts`: a 592-hit file
381
- reports 592 locator numbers; water-filling serves every file before any file takes a second
382
- row; withheld locators are announced in the output.
383
-
384
- ---
385
-
386
- ## D9 — HTML fell into `pi-head`, which kept the `<head>` and dropped the body
387
-
388
- **Symptom.** Fetched/compressed HTML pages kept `<!DOCTYPE>`, `<meta>`, `<link>`,
389
- `<script>` and `<style>` — the metadata — while the entire body content disappeared.
390
-
391
- **Root cause.** `looksLikeSourceCode` matches no HTML tags (its patterns cover
392
- declarations/imports/decorators only), so pages fell through to the head/tail fallbacks, and
393
- `reduceHead` takes from the top — exactly the worst segment for HTML.
394
-
395
- **Evidence.** `CODE_STRUCTURE_PATTERN` / `CODE_IMPORT_PATTERN` / `CODE_DECORATOR_PATTERN`
396
- match none of `<html|<div|<script|…`; the repository carried zero HTML-input tests (31
397
- `<html|<div|<script` hits, all in TSX sources and tokenizer vocabularies).
398
-
399
- **Affected surface.** `packages/selector/src/runtime/reducers.ts` (candidate chain).
400
-
401
- **Fix.** Two-stage reduction (R13): `html-slim` strips comments, script/style/noscript/svg/
402
- head elements, data URIs, non-whitelisted attributes (`href/src/alt/title/id` survive) and
403
- inline-tag markup, line-aligned so original-event line numbers survive; `html-skeleton`
404
- keeps the heading hierarchy, section first lines and table header rows under tighter budgets.
405
- Classification is pure form (≥3 markup-tag lines in the first 400).
406
-
407
- **Verification.** `packages/selector/tests/runtime/html-reducer.spec.ts`: body paragraphs
408
- and headings survive; script/style/comment/data-URI content is gone; the skeleton fallback
409
- cites original line ranges; TS generics/comparisons are not misclassified as HTML.
410
-
411
- ---
412
-
413
- ## U1 — The estimator card vanished off TokenPilot-inspired instead of explaining its gate
414
-
415
- **Symptom.** With any profile other than TokenPilot-inspired selected, the Settings page showed
416
- no estimator section at all. A reader who had configured nothing could not tell whether the
417
- feature was missing, broken, or gated — the first real-machine report of Defect A was exactly
418
- this, and it was filed alongside D7 even though the two have nothing in common.
419
-
420
- **Root cause.** The render was `current !== 'tokenpilot-inspired' ? null : <EstimatorControls …/>`.
421
- The condition is right: `runtime/config.ts` merges `presetOptions` over the tokenpilot-inspired
422
- defaults alone (`mergePresetOptions`), and `resolvePolicy(config, 'balanced').presetOptions` is
423
- `undefined`, so no other profile can carry an estimator channel. What was wrong is that the gate
424
- was *rendered as nothing*. The profile card that unlocks the section sits elsewhere on the page,
425
- and the one element that would have named it was the section being hidden — a gate the reader
426
- cannot see is indistinguishable from an absent feature.
427
-
428
- **Fix.** Render `EstimatorInactiveNotice` in place of the controls: same `<section>`, same
429
- `#context-compression-estimator-title` heading anchor, one paragraph naming the current profile
430
- and the profile that unlocks the card. Losing the heading was half the defect, so the heading
431
- stays. **The gate is unchanged** — no estimator control exists off TokenPilot-inspired, and no
432
- other profile gains `presetOptions`.
433
-
434
- **Evidence.** `packages/selector/tests/estimator-channel.client.spec.tsx` mounts the section with
435
- `profile: 'balanced'` and asserts the anchor still reads `Estimator (optional)`, that the notice
436
- contains the current profile label and `Select TokenPilot-inspired`, and that no channel select,
437
- no provider input and no `input[list]` exist. Counter-proof: substituting `null` for the notice
438
- turns that case red (`expected undefined to be 'Estimator (optional)'`) while the other six stay
439
- green — the guard fails against the pre-fix behaviour, so it is not vacuous.
440
-
441
- **Affected surface.** Client bundle only: `src/client/CompressionProfileSelector.tsx`,
442
- `src/client/locales.ts` (both dictionaries; `en` satisfies the full key set), `lib/client.js`,
443
- `lib/client.d.ts`. No runtime, config, or persistence change, and no change to
444
- `presetOptions` semantics.
445
-
446
- **Still open.** The save affordance remains unexplained in the UI — fields commit on change or
447
- blur with only a transient busy state, so "did that save?" has no answer on screen. That is a
448
- separate, larger change (explicit save button plus three-state feedback) and is not fixed here.
449
-
450
- ---
451
-
452
- ## Verification ledger — `feat/ctx-preset-v2` closure
453
-
454
- Closure = `935d501` + the root-`exports` completion (`./invariant`). The working tree held
455
- exactly that one manifest change; `lib/**` rebuilt byte-identically, so the build is
456
- deterministic.
457
-
458
- ### Ten gates
459
-
460
- | # | Command | Result |
461
- | --- | --- | --- |
462
- | 1 | `pnpm install` | exit 0 |
463
- | 2 | `pnpm build` | exit 0 |
464
- | 3 | `pnpm typecheck` | exit 0 |
465
- | 4 | `pnpm lint` | exit 0 |
466
- | 5 | `pnpm test` | exit 1 — nondeterministic Windows set, see below |
467
- | 6 | `pnpm test:built` | exit 0 |
468
- | 7 | `pnpm verify:release` | exit 0 |
469
- | 8 | `pnpm pack:dry-run` | exit 0 |
470
- | 9 | `pnpm test:e2e:packed` (`DSH_E2E_MODE=dev`) | exit 0 |
471
- | 10 | `pnpm test:e2e:packed` (release mode) | **blocked** — external precondition, see below |
472
-
473
- ### Gate 5 — the failure set is nondeterministic; do not cite it as "4 known failures"
474
-
475
- A single `pnpm test` run is not a baseline. Eight interleaved runs (four at `455f74f`,
476
- four at the closure commit), same machine, nothing else running:
477
-
478
- | Run | `455f74f` failed | closure failed |
479
- | --- | --- | --- |
480
- | 1 | 3 | 5 |
481
- | 2 | 3 | 2 |
482
- | 3 | 4 | 3 |
483
- | 4 | 3 | 4 |
484
-
485
- A ninth run, taken while a packed-install E2E ran concurrently, reported **9** failures at
486
- `455f74f` — the same commit that reported 3 in three other runs. The count tracks machine
487
- load, not code.
488
-
489
- Per test name, over the four quiet runs on each side:
490
-
491
- | Test | `455f74f` | closure |
492
- | --- | --- | --- |
493
- | `preset-overlay.host.spec.ts` > uses owner-only files and starts a new generation after source content changes | 4/4 | 4/4 |
494
- | `standing-generation.host.spec.ts` > keeps one fully-identical generation under concurrent composition of the same identity | 3/4 | 3/4 |
495
- | `standing-generation.host.spec.ts` > keeps one generation under concurrent and repeated composition of the same identity | 3/4 | 3/4 |
496
- | `standing-generation.host.spec.ts` > separates colliding equal-size generations on a whole-second metadata surface before publish | 3/4 | 3/4 |
497
- | `standing-generation.host.spec.ts` > switches the standing generation for an equal-length source change at a fixed threshold | 0/4 | 1/4 |
498
-
499
- Four of the five fail on both sides at identical frequency: pre-existing. The fifth failed
500
- once in four runs on the closure side and never on the baseline side, inside the same
501
- timing-sensitive `describe` block as three tests that are 3/4 flaky on *both* sides. It is
502
- recorded as **not excluded**, not as clean.
503
-
504
- The visible causes are Windows-only: an owner-only permission assertion (`0o700` against
505
- `0o666`), `fs.rename` `EPERM` during publish under concurrency, and mtime-window
506
- assertions that assume a coarser clock.
507
-
508
- **Consequence for review.** Any criterion phrased as "the failure set matches the baseline
509
- item by item" is unsatisfiable — the baseline has no single failure set. Compare
510
- *ever-failed* sets over at least three interleaved runs per side instead.
511
-
512
- ### Gate 10 — external precondition, not a defect
513
-
514
- Release mode needs the *published* previous release to build the upgrade leg of its
515
- fixture. `0.1.0-beta.2` was never published, so the fixture aborts with `release gate
516
- requires the published previous release for the upgrade leg: packument responded 404`.
517
- `DSH_E2E_MODE=dev` (gate 9) is the runnable leg and passes. Blocked on publishing, not on
518
- this repository.
519
-
520
- ### Criterion withdrawn
521
-
522
- The earlier merge plan carried "the overlay identity hash is unchanged across the merge".
523
- That is unsatisfiable by construction: identity is `sha256(preset.id ‖ source ‖
524
- JSON.stringify({modules, autoCompactThresholdPercent}))` computed over **absolute** module
525
- paths, so collapsing two packages into one necessarily changes it. The replacement is
526
- structural — `canonicalCompressionRows` stays byte-identical and the only permitted
527
- difference in the generated YAML is the `tool-result-pruner` row's `name` resolving to the
528
- merged package.
529
-
530
- ### `invariant.ts` literal decision
531
-
532
- The merged package keeps **one** invariant companion, and it is the runtime's: `name =
533
- 'context-compression-selector-runtime-invariant'`, `PACKAGE_NAME =
534
- 'dsh-context-compression-improved-runtime'`. Both stay verbatim.
535
-
536
- - The string is the frozen provenance literal (inheritance rule 4) and is written into
537
- durable session logs, so renaming it would discard historical tail-trim entries.
538
- - The companion's real checks (`validatePublishedTailTrim`, `sessionEvents`) belong to the
539
- runtime, so the runtime identity is the semantically correct one.
540
- - The pre-merge `packages/selector/src/invariant.ts` companion
541
- (`client-ui-context-compression-selector-invariant`, `PACKAGE_NAME =
542
- 'dsh-context-compression-improved'`) installed **no** checks (`install = () => {}`) and
543
- was dropped by the merge. Nothing is lost: its only effect was reserving a name in the
544
- invariant registry, which is keyed by the installing package either way.
545
-
546
- ---
547
-
548
- ## Affected-surface matrix
549
-
550
- | Branch / version | D1 entry import | D2 install contract | D3 artifact chunks | D4 profile | Verdict |
551
- | --- | --- | --- | --- | --- | --- |
552
- | `feat/ctx-preset-v2` @ `455f74f` | **present (crash)** | partial | n/a before merge | needed | affected; D1/D2 fixed on merge branch |
553
- | merged single package | eliminated | fixed (all four subpaths) | **gated** | delivered | this change |
554
- | `compat/0.1.5` @ `d7c592d` | no (lazy) | **absent** | n/a | needed | **inherits the whole contract** |
555
- | `ts/0.1.5` @ `refactor/ts-0.1.5-merge` | no | **fixed by the R3 replay** (root manifest is the install surface, `./pruner` + `./invariant` declared) | **gated** (shared `lib/config.js` chunk added by the replay) | needed (script delivered) | contract inherited; D7 re-checked and the route defect it masked fixed —see below |
556
- | `baseline/pre-god-module-split`, `main` @ `e337bf5` | no | **absent, no `lib/`** | n/a | needed | not distributable by design |
557
- | any future single-package release | structurally impossible | — | **permanent gate** | — | inherits D3 |
558
- | every branch on this host | — | — | — | — | was **blocked by D6**; the profile install now completes, so real-machine verification is unblocked |
559
-
560
- ### D7 per branch — the fix must travel one way only
561
-
562
- `asWebServer` has two different bodies across the branches, and they are not equivalent:
563
-
564
- | Branch | `asWebServer` returns | Verdict |
565
- | --- | --- | --- |
566
- | `compat/0.1.5` @ `d7c592d` | `value as WebServerLike` — the service itself | **correct; never had D7** |
567
- | `feat/ctx-preset-v2` @ `e588f1c`, `ts/0.1.2+` @ `0eb5183` | `{ register }` — a detached method | **carries D7** |
568
- | `baseline/pre-god-module-split`, `main` @ `e337bf5` | no such helper | n/a |
569
- | `ts/0.1.5` @ `refactor/ts-0.1.5-merge` | `value as WebServerLike` —the service itself | **correct; never had D7**. The helper was taken from this line, not from the V2 line |
570
-
571
- The defect was introduced on the V2 line, not inherited from the 0.1.x line. That inverts the
572
- usual direction of these hand-offs: **the 0.1.5 replay must not copy this helper out of
573
- `feat/ctx-preset-v2`.** Take `compat`'s body, or the fixed one from `00afcfc`; they agree.
574
-
575
- ## `ts/0.1.5` (compat) verdicts —2026-09-15
576
-
577
- Branch `refactor/ts-0.1.5-merge`, the R3 replay of the single-package install contract
578
- (`6941d2f` merge, `e511fe8` contract specs, `165f495` route registration, `e7e927c` lint
579
- paths, `66c8c63` toolchain sweep, `6f2cb51` rebuilt artifacts, `75e3327` settings schema).
580
-
581
- | Defect | Verdict on this line |
582
- | --- | --- |
583
- | D1 —host entry statically imports a sibling package | **unaffected.** This line had already inlined the namespace and downgraded the settings schema to `z.any()` (`ab2175a`) to keep the entry free of cross-package imports; the replay removed the reason for both. |
584
- | D2 —root manifest missing the install contract | **fixed by the replay.** The root manifest is the install surface again: `name`, `main`, `types`, `exports` (`.`, `./invariant`, `./pruner`, `./client`), `dependencies`, `dsh`. |
585
- | D3 —build chunks not committed | **gated here too.** The replay reintroduced a shared chunk (`lib/config.js`, imported by both entries through the settings schema), so the artifact-graph gate was run red 鈫?green: 11 artifacts, every relative import resolves, every non-CSS artifact is inside the `files` whitelist and tracked, no `.css` entry declared. |
586
- | D4 —consumer profile leftovers | **same status as the other lines**: the hygiene script is delivered, the profile side is a host precondition the operator runs. |
587
- | D5 —`compat/0.1.5` predates the install contract | **this replay is the D5 action.** |
588
- | D6 —profile blocks dependency reconciliation | **unchanged.** No `os error 5` in this round; the `katex` write gap is still on the books for the next subtree replacement. |
589
- | D7 —estimator catalog route never registered | **the detached-method body was never here**, but the route still had a registration defect of its own: the injection gate asked for `webServer`, `llm` and `agentDefaultModel`, and an unsatisfied `ctx.inject` callback is silent, so a usable `webServer` with a late `llm` left the plugin with no HTTP API at all. Fixed by `165f495` (dual prefix, guarded two-channel registration, per-request service resolution, `console` lifecycle lines); guard `estimator-route-registration.host.spec.ts`, six cases, falsified against the old gate (4 of 6 red). |
590
- | U1 —the estimator card hides itself | **present, not fixed on this line.** The 0.1.5 client still renders nothing when the profile or channel does not enable the estimator, so the block disappears without saying why. The 0.1.2 line fixed this in `bb1f496`; this replay did not carry the client change. Recorded here so it is not silently inherited —porting it is a client-side item, not part of the install contract. |
591
-
592
- **Estimator defects as first reported (`D-1` route, `D-2` save awareness).** `D-1` is D7 above;
593
- on this line it was the over-broad gate, now fixed. `D-2` (explicit save button with three-state
594
- feedback) is **not implemented on either line**: this branch still commits on blur, exactly like
595
- `ts/0.1.2+`, where the item was explicitly descoped once the real defect turned out to be the
596
- route.
597
-
598
- **One more defect found and fixed by the replay.** `ab2175a` downgraded the settings schema to
599
- `z.any()`, and that schema was the only thing publishing the daily Custom defaults, so
600
- `settings.get('context-compression')` no longer carried `custom`. It was already failing before
601
- the merge: the loader E2E case `publishes the daily Custom defaults from the plugin-owned
602
- settings row` and the packed install E2E both stop on `settings.custom` being undefined, and the
603
- five `public-runtime` Auto Compact cases assert audits derived from the same document. `75e3327`
604
- restores `ContextCompressionSettingsSchema` in both `settings.register` calls, matching the
605
- 0.1.2 line.
606
-
607
- **Suite effect of this branch, same machine and command:** 22 failed / 358 passed before
608
- (`d7c592d`), 1 failed / 365 passed after. The remaining failure is the Windows mtime flake in
609
- `standing-generation.host.spec.ts` that the compat report already documents as environment
610
- caused.
611
-
612
- ## Inheritance rules
613
-
614
- 1. **The root manifest is the install contract**: `name`, `main`, `types`, `exports`,
615
- `dependencies`, `dsh` — all six. A new subpath export is declared in both the root and
616
- the package manifest.
617
- 2. **No top-level cross-package import inside one package.** `lib/**/*.js` may only
618
- reference the frozen provenance literal.
619
- 3. **`lib/**` ships in the same commit as its sources**, and every chunk an entry imports
620
- must be committed. Enforced by `pnpm verify:release`.
621
- 4. **The provenance literal `dsh-context-compression-improved-runtime` is frozen.** It is
622
- already written into durable session logs (`source.plugin` on tail-trim manifests) and
623
- validated on read, so renaming it silently discards historical tail-trim entries. This
624
- covers every occurrence, including `src/invariant.ts`'s `PACKAGE_NAME` and companion
625
- `name` — the merge does **not** rename them to match the merged package name.
626
- 5. **Profile-side hygiene**: install spec that actually resolves, no dead `overrides`. And
627
- before trusting any profile-side install result: reconcile dependencies **with the host
628
- stopped**, and test a directory's write right — never its owner (D6).
629
- 6. **Never detach a method off a host service.** Duck typing that returns `{ register }`
630
- instead of the service loses `this`, and `dsh-host-webserver.register` reads its route
631
- tables off `this`. Pass the service object itself; `dsh-perm-gate` does, which is why it
632
- serves its routes. The same trap applies to any service whose methods touch instance
633
- state, so check the contract before narrowing a service to a single method (D7).
634
- 7. **A conditional the user cannot see is a defect, not a design.** If a section renders only
635
- under some profile, mode, or capability, the hidden branch must say what is missing and what
636
- would restore it — and keep its heading and anchor id so the panel is still findable where
637
- the reader last saw it. Gating *semantics* are not what is on trial here; hiding the *reason*
638
- is (U1).
639
-
640
- ## Change log
641
-
642
- | Date | Entry | Action |
643
- | --- | --- | --- |
644
- | 2026-09-14 | D1–D5 | Ledger created; D1 fixed; D2 fixed for `dependencies`/`./pruner`; D3 gate added and verified; D4 delivered as a script; D5 recorded for `compat/0.1.5` |
645
- | 2026-09-14 | D2 | `./invariant` added to the root `exports`; root and package manifests now agree. Ten-gate closure ledger added, with the gate-5 flakiness evidence and the withdrawn identity-hash criterion || 2026-09-15 | D2/D3 | `ts/0.1.2+` fast-forwarded onto the god-module-split branch (`04f86e4`) and pushed; the rebuild reproduces the committed `lib/` blob for blob |
646
- | 2026-09-15 | D5 | `ts/0.1.5` replay: runtime merged into the selector package, root manifest made the install surface, toolchain/scripts/CI swept to one package, artifacts committed, D3 gate green |
647
- | 2026-09-15 | D7 | `ts/0.1.5` route registration rewritten to the verified pattern; guard added and falsified against the old gate |
648
- | 2026-09-15 | settings defaults | `z.any()` reverted to `ContextCompressionSettingsSchema` on `ts/0.1.5`; the loader E2E, the packed E2E and the five Auto Compact cases pass again || 2026-09-15 | docs | `ts/0.1.5` docs swept to the single package (four-language installation guides, selector READMEs, `THIRD_PARTY_NOTICES`, `TEST_INVENTORY`, four CHANGELOGs) |
649
- | 2026-09-15 | known doc defect | `README.md`, `README.zh.md` and the three localized installation guides carry a handful of corrupted non-ASCII bytes (`0xE2` sequences) **on both lines, pre-dating this work**. The stale two-package sentences were replaced with correct text; the surrounding corruption still needs a regeneration pass from the English source. Recorded so it is not mistaken for a merge artifact |
650
- | 2026-09-14 | D6 | Profile dependency-reconciliation blocker diagnosed: two independent `os error 5` sources (one ACL-denied directory; mapped native modules held by the live host), plus the ownership-vs-write-right criterion warning. Delivered as a dry-runnable script |
651
- | 2026-09-15 | D6 | **Resolved.** One plain `pnpm install` in the profile converged (`+256 -16`, exit 0); the lockfile repointed itself and the `_pacquet-stage_` residue is gone. Cleared by convergence over successive attempts, not by the ACL repair — the `katex` denial stays on record |
652
- | 2026-09-15 | D7 | **The estimator catalog route had never registered at all.** `asWebServer` detached `register` from the service, `this` became the wrapper, the host threw inside `register`, and a catch-all swallowed it. Fixed by passing the service itself; 200 verified on the real host; the injection, isolation and transport hypotheses recorded earlier are withdrawn |
653
- | 2026-09-15 | U1 | **The estimator card was hidden by its own gate.** Off TokenPilot-inspired the section rendered `null`, so the reader saw a missing feature rather than a gated one. The heading and anchor are now kept and the hidden branch names the profile that unlocks the card; the gate itself is unchanged. Guard added with a counter-proof; the save-affordance question stays open |
654
- | 2026-09-15 | doc corruption — mechanism | **Diagnosed.** A damaged spot is the 2-byte prefix of a three-byte UTF-8 character followed by `0x3F`: the character lost its third byte and, in most spots, the byte that followed it was consumed too (a double-byte-code-page decode/write pair collapse; 0 or 1 bytes lost per spot). The damage is **inherited, not produced here**: the newest valid blob of every affected file is `e337bf5`, while the same files are already defective at the `compat/0.1.5` baseline `d7c592d` and at `04f86e4`. Ten files carry it, not five — `README.{zh,ja,ko}.md` and `scripts/packed-install-e2e.mjs` were missed by the earlier note |
655
- | 2026-09-15 | doc corruption — repaired | **Batch I / T-I2.** All ten files repaired by restoring each damaged spot from `e337bf5`, with three independent checks: the restored character must carry the surviving 2-byte prefix; re-corrupting the repair reproduces the previous bytes exactly (so the edit touches nothing but the damage, and no line, no EOL and no other character moves); and the repair must agree with the valid ancestor everywhere outside the restored spots. Every affected file is now valid UTF-8. The English `README.md` is the clean case: ten spots, all `—`/quote characters plus their following space, zero other differences from the ancestor |
656
- | 2026-09-15 | ledger encoding | The twelve `—` characters in this file had been mangled to `鈥?` by the PowerShell port of the ledger (the 0.1.2 source has none); restored. Same class as the doc corruption above, introduced by that one-time port rather than inherited |
657
- | 2026-09-19 | D8/D9 | Compression-quality defects ledgered on `feat/ctx-compression-v2-compat015`: search hits were dropped unlocatably (21.2%), HTML kept its `<head>` and lost its body; both fixed with two-tier search folding and two-stage HTML reduction, each with counter-proof tests |