@magic6/dsh-compaction-policy-engine 0.5.9 → 0.5.10
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.
- package/CHANGELOG.md +67 -0
- package/README.md +36 -17
- package/cordis.patch.yml +47 -33
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,73 @@ All notable changes to this project are documented here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.5.10] - 2026-11-26
|
|
8
|
+
|
|
9
|
+
### Fixed — installing the plugin now actually takes over compaction
|
|
10
|
+
|
|
11
|
+
The bundle shipped its engine row `disabled: true`, on the theory that "superseding the
|
|
12
|
+
stock engine is a deployment decision". That reasoning silently assumed the stock engine
|
|
13
|
+
was *running*. On a preset-based host it is not: `dsh-web-app` — which backs both the
|
|
14
|
+
`web` and `desktop` profiles — disables the host-plane `compaction-basic` itself. So with
|
|
15
|
+
this plugin installed there were **two disabled engines and no owner of `ctx.compaction`**:
|
|
16
|
+
|
|
17
|
+
- the settings card rendered and returned the configured threshold;
|
|
18
|
+
- `engine up` printed nothing, because the engine never mounted;
|
|
19
|
+
- nothing compacted, ever.
|
|
20
|
+
|
|
21
|
+
Observed on a Win11 `desktop` profile: a session grew to 158,118 tokens and then could
|
|
22
|
+
not compact at all. Four forced compactions ran (two in turn 27, one in turn 28, one
|
|
23
|
+
manual `/compact`) and every one came back `context_length_exceeded` from the gateway,
|
|
24
|
+
because the summary request has to carry the same oversized history that triggered it.
|
|
25
|
+
The session was unrecoverable — retrying sent the same request, and compaction could not
|
|
26
|
+
shrink it.
|
|
27
|
+
|
|
28
|
+
The fix is for the bundle to do both halves of the swap in one place:
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
- id: compaction-basic
|
|
32
|
+
disabled: true
|
|
33
|
+
|
|
34
|
+
- insert:
|
|
35
|
+
- id: compaction-control
|
|
36
|
+
name: '@magic6/dsh-compaction-policy-engine/engine'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Uninstalling removes both, so the stock engine comes back automatically. The plugin can no
|
|
40
|
+
longer leave a profile with no compaction at all.
|
|
41
|
+
|
|
42
|
+
`ctx.compaction` is a **single-slot service**, not an agreement between engines: a second
|
|
43
|
+
engine in the same context throws `service "compaction" has been registered at
|
|
44
|
+
<BasicCompactionEngine>` during construction and never mounts (the host only prints
|
|
45
|
+
`dsh: warning: 1 entry did not activate`). That is why "leave the stock engine enabled as
|
|
46
|
+
a late backstop" is not an option — verified by hand on the same Win11 host.
|
|
47
|
+
|
|
48
|
+
### Fixed — a test fixture that hid the bug
|
|
49
|
+
|
|
50
|
+
`e2e/run.sh` wrote `- id: compaction-control / disabled: false` into the fixture profile.
|
|
51
|
+
That was intended to mean "the engine has to be on for the test to run", but it also meant
|
|
52
|
+
the suite could never observe the bundle's own default. Every scenario stayed green while
|
|
53
|
+
the shipped bundle was unusable.
|
|
54
|
+
|
|
55
|
+
The fixture now overrides only `config:`, leaving `disabled` at whatever the bundle ships.
|
|
56
|
+
`fired` additionally asserts that the engine printed its own `[compaction] engine up:` line
|
|
57
|
+
before it judges anything about thresholds — the precondition that the old suite silently
|
|
58
|
+
assumed.
|
|
59
|
+
|
|
60
|
+
Regression check with the corrected fixture (same suite, same fake provider):
|
|
61
|
+
|
|
62
|
+
| version | result |
|
|
63
|
+
|:--|:--|
|
|
64
|
+
| `0.5.9` (buggy) | **0 passed, 1 failed** — "our engine never started", plus "no compaction fired" |
|
|
65
|
+
| this release | 2 passed, 0 failed |
|
|
66
|
+
|
|
67
|
+
### Changed — README
|
|
68
|
+
|
|
69
|
+
The mounting section now states that installing the plugin *is* the takeover, that the
|
|
70
|
+
stock row must be disabled because the seam is single-slot, and that uninstalling restores
|
|
71
|
+
it. The two silent-bad-combination warnings keep their original text but now name which
|
|
72
|
+
one this release fixed.
|
|
73
|
+
|
|
7
74
|
## [0.5.9] - 2026-11-25
|
|
8
75
|
|
|
9
76
|
### Fixed — three bugs that only a real host could expose
|
package/README.md
CHANGED
|
@@ -86,38 +86,55 @@ cd dsh-compaction-policy-engine
|
|
|
86
86
|
dsh plugin --profile web add "$PWD"
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
包本身是 bundle
|
|
89
|
+
包本身是 bundle,**装上即接管压缩**:
|
|
90
90
|
|
|
91
|
-
-
|
|
92
|
-
-
|
|
91
|
+
- 把官方 `compaction-basic` 行设为 `disabled: true`;
|
|
92
|
+
- **启用**引擎行(`compaction-control`);
|
|
93
|
+
- companion 行(`compaction-control-settings`)始终启用,负责设置卡片与上下文提示词;
|
|
93
94
|
它**不**认领 `ctx.compaction`。
|
|
94
95
|
|
|
96
|
+
卸载插件时这三件事一起消失:`compaction-basic` 的覆盖随 bundle 走,官方引擎自动恢复。
|
|
97
|
+
**不会出现「卸掉插件后什么都不压缩」的状态**,这一点有 e2e 守着(见 `e2e/` 的 `fired` 场景)。
|
|
98
|
+
|
|
99
|
+
### 为什么必须自己关官方引擎
|
|
100
|
+
|
|
101
|
+
`ctx.compaction` 是**单槽服务**,不是两个引擎之间的约定:
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
super(ctx, "compaction") // 第二个 -> 'service "compaction" has been registered at …'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
同一 context 里放第二个引擎**不会**退化成「低阈值赢」,而是在构造时抛错、那一行根本不挂载。
|
|
108
|
+
所以「留着官方引擎当兜底」不成立——要么关掉它,要么本插件无法启动。
|
|
109
|
+
|
|
110
|
+
> **上一版(≤0.5.9)出厂把引擎设成 `disabled: true`**,理由是「替换官方引擎属于部署决策」。
|
|
111
|
+
> 那条推理默认官方引擎**正在运行**;而 `dsh-web-app`(`web` / `desktop` profile)本来就把宿主
|
|
112
|
+
> 平面的 `compaction-basic` 停了。两边都没开 → 设置卡片正常渲染、阈值读得回来、压缩一次都不触发。
|
|
113
|
+
> Win11 上一个会话就是这样涨到 158k token,随后四次压缩全被上游拒绝。见 CHANGELOG 0.5.10。
|
|
114
|
+
|
|
95
115
|
### 先确定挂载平面
|
|
96
116
|
|
|
97
|
-
`ctx.compaction` 是**按 realm
|
|
98
|
-
|
|
99
|
-
|
|
117
|
+
`ctx.compaction` 是**按 realm 解析的单槽服务**。`isolate: compaction: true` 让每个 preset realm
|
|
118
|
+
各有一份,所以 preset 宿主里会同时存在「宿主平面一个 + preset 内一个」——两个 context,不冲突。
|
|
119
|
+
宿主平面的引擎服务 `headless` 与解析到宿主平面的 agent;想让策略进到某个 preset 内部,
|
|
120
|
+
替换它自己的 `compaction` 组(见下)。
|
|
100
121
|
|
|
101
|
-
| profile | agent 的压缩引擎属于谁 |
|
|
122
|
+
| profile | agent 的压缩引擎属于谁 | 需要做什么 |
|
|
102
123
|
|:--|:--|:--|
|
|
103
|
-
| `headless` | 宿主平面(没有 preset) |
|
|
104
|
-
| `web` | **agent preset
|
|
124
|
+
| `headless` | 宿主平面(没有 preset) | 无。bundle 已接管 |
|
|
125
|
+
| `web` / `desktop` | **agent preset**(宿主平面的 `compaction-basic` 由 `dsh-web-app` 停用) | 宿主平面已接管;要让 preset 内部也用策略,需覆盖 preset 声明 |
|
|
105
126
|
|
|
106
127
|
#### headless(宿主平面)
|
|
107
128
|
|
|
108
|
-
bundle
|
|
129
|
+
无。装上就生效,bundle 已经写好了那两行。要改门槛就改 `config:`:
|
|
109
130
|
|
|
110
131
|
```yaml
|
|
111
132
|
# $DSH_HOME/profiles/<profile>/cordis.patch.yml
|
|
112
|
-
- id: compaction-basic
|
|
113
|
-
disabled: true
|
|
114
|
-
|
|
115
133
|
- id: compaction-control
|
|
116
|
-
disabled: false
|
|
117
134
|
config:
|
|
118
135
|
default:
|
|
119
|
-
threshold: 0.
|
|
120
|
-
retain: 0.
|
|
136
|
+
threshold: 0.42
|
|
137
|
+
retain: 0.08
|
|
121
138
|
```
|
|
122
139
|
|
|
123
140
|
loader 认的键是 **`disabled`**,不是 `disable`;写错不会报错,会被静态配置静默丢掉
|
|
@@ -145,8 +162,10 @@ dsh plugin --profile web add "$PWD/examples/standard-with-policy"
|
|
|
145
162
|
|
|
146
163
|
两种静默坏组合:
|
|
147
164
|
|
|
148
|
-
-
|
|
165
|
+
- 宿主平面挂了引擎,同一 realm 里原版 `compaction-basic` 还在 → 第二个引擎注册失败,
|
|
166
|
+
只有一行 warning(`dsh: warning: 1 entry did not activate`),策略静默失效;
|
|
149
167
|
- 原版停用了却没有挂任何替代引擎 → 接缝无人认领,会话静默停止压缩,一路涨到被上游拒绝。
|
|
168
|
+
**这正是 0.5.9 及更早版本在 `web` / `desktop` 上的默认行为**,已由 bundle 自身修掉。
|
|
150
169
|
|
|
151
170
|
「停用旧的」和「启用新的」必须写在同一个组合里,一起 review。
|
|
152
171
|
|
package/cordis.patch.yml
CHANGED
|
@@ -1,45 +1,56 @@
|
|
|
1
|
-
# Plugin bundle for dsh-compaction-policy-engine: mounts the policy engine
|
|
2
|
-
#
|
|
1
|
+
# Plugin bundle for dsh-compaction-policy-engine: mounts the policy engine and the
|
|
2
|
+
# host-plane companion.
|
|
3
3
|
#
|
|
4
4
|
# The engine subclasses `BasicCompactionEngine`, so region selection, tool-pairing
|
|
5
5
|
# balance, summary framing, and the durable compaction transaction stay the
|
|
6
6
|
# official implementation — only the policy (three-layer threshold + summarization
|
|
7
7
|
# model) becomes configurable here.
|
|
8
8
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
9
|
+
# ── Mounting this plugin swaps the engine (2026-11-26) ────────────────────────
|
|
10
|
+
#
|
|
11
|
+
# `ctx.compaction` is a SINGLE-SLOT service, not an agreement between engines:
|
|
12
|
+
#
|
|
13
|
+
# super(ctx, "compaction") // -> 'service "compaction" has been registered
|
|
14
|
+
# // at <BasicCompactionEngine>'
|
|
15
|
+
#
|
|
16
|
+
# A second engine in the same context does not lose a threshold race — it throws
|
|
17
|
+
# during construction and never mounts at all. So "leave the stock engine on as a
|
|
18
|
+
# late backstop" is not available: the bundle must disable it, or the policy engine
|
|
19
|
+
# cannot start. This file therefore does both halves in one place:
|
|
20
|
+
#
|
|
21
|
+
# - disables the stock `compaction-basic` row, and
|
|
22
|
+
# - enables the policy engine.
|
|
23
|
+
#
|
|
24
|
+
# Doing only one half is the failure this file used to ship. It shipped the engine
|
|
25
|
+
# `disabled` on the theory that "superseding the stock engine is a deployment
|
|
26
|
+
# decision" — but that theory silently assumed the stock engine was *running*.
|
|
27
|
+
# On a preset-based host (`dsh-web-app`: `web` and `desktop` profiles) the host
|
|
28
|
+
# plane's `compaction-basic` is disabled by the app itself, so a bundle that also
|
|
29
|
+
# left its own engine disabled yielded **no compaction at all**: the settings card
|
|
30
|
+
# rendered, the threshold read back, and nothing ever fired. That is how a Win11
|
|
31
|
+
# session grew past 158k tokens and then could not compact — four forced
|
|
32
|
+
# compactions in a row, every one rejected upstream, and every local test green.
|
|
33
|
+
#
|
|
34
|
+
# Unmounting the plugin reverses both halves automatically: these rows and the
|
|
35
|
+
# `compaction-basic` override disappear together, restoring the stock engine.
|
|
36
|
+
#
|
|
37
|
+
# ── Which realm the engine lands in ──────────────────────────────────────────
|
|
38
|
+
#
|
|
39
|
+
# `isolate: compaction: true` in the agent presets gives each preset realm its own
|
|
40
|
+
# `compaction` slot, so a preset host keeps a stock `compaction-basic` inside the
|
|
41
|
+
# realm alongside this host-plane engine — two engines, two contexts, no conflict.
|
|
42
|
+
# The host-plane one (this row) serves `headless` and any agent that resolves the
|
|
43
|
+
# host plane; a preset that wants the policy inside its realm replaces its own
|
|
44
|
+
# `compaction` group, see `examples/standard-with-policy/`.
|
|
32
45
|
#
|
|
33
46
|
# Thresholds are ratios, never absolute token counts: a model's advertised window
|
|
34
47
|
# is not stable, and a model that declares no window cannot honor a token budget.
|
|
35
48
|
#
|
|
36
|
-
# The companion row
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
# seam resolves per realm, so a host-plane engine would run *beside* the preset
|
|
42
|
-
# one on the same bubbling `agent/pre-step` and the lower threshold would win.
|
|
49
|
+
# The companion row is a **separate, enabled, host-plane** row because the browser
|
|
50
|
+
# bundle is discovered from enabled loader entries (`dsh-client-modules` walks
|
|
51
|
+
# `ctx.loader.entries()` and skips disabled or fiberless ones) — the engine can
|
|
52
|
+
# live inside an agent preset, where that scan cannot see it. It deliberately does
|
|
53
|
+
# NOT claim `ctx.compaction`.
|
|
43
54
|
#
|
|
44
55
|
# `name` is the **bare package name**, which resolves to `lib/companion.js`. That
|
|
45
56
|
# split is load-bearing: the loader mounts a row's `exports.default` and reads no
|
|
@@ -47,10 +58,13 @@
|
|
|
47
58
|
# `export:` key, which was silently dropped — putting a second engine on the host
|
|
48
59
|
# plane at the shipped default and capping every raised threshold. Two
|
|
49
60
|
# `[compact-debug]` lines per step with the same `measured` were the signature.)
|
|
61
|
+
|
|
62
|
+
- id: compaction-basic
|
|
63
|
+
disabled: true
|
|
64
|
+
|
|
50
65
|
- insert:
|
|
51
66
|
- id: compaction-control
|
|
52
67
|
name: '@magic6/dsh-compaction-policy-engine/engine'
|
|
53
|
-
disabled: true
|
|
54
68
|
|
|
55
69
|
- insert:
|
|
56
70
|
- id: compaction-control-settings
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic6/dsh-compaction-policy-engine",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"description": "Layered, live-reloading context compaction policy for DeepSeek Harness: provider-level rules, field-by-field inheritance, ratio/token units and a settings panel on top of the official engine.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/companion.js",
|