dsh-context-compression-improved 0.7.0-beta.1 → 0.8.0-beta.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.
- package/CHANGELOG.de.md +539 -0
- package/CHANGELOG.es.md +547 -0
- package/CHANGELOG.fr.md +534 -0
- package/CHANGELOG.it.md +536 -0
- package/CHANGELOG.ja.md +226 -220
- package/CHANGELOG.ko.md +220 -214
- package/CHANGELOG.md +372 -376
- package/CHANGELOG.ru.md +517 -0
- package/CHANGELOG.zh.md +204 -199
- package/README.de.md +98 -0
- package/README.es.md +98 -0
- package/README.fr.md +98 -0
- package/README.it.md +98 -0
- package/README.ja.md +85 -85
- package/README.ko.md +85 -85
- package/README.md +98 -97
- package/README.ru.md +98 -0
- package/README.zh.md +85 -86
- package/docs/installation.de.md +104 -0
- package/docs/installation.es.md +104 -0
- package/docs/installation.fr.md +104 -0
- package/docs/installation.it.md +104 -0
- package/docs/installation.ja.md +78 -78
- package/docs/installation.ko.md +78 -78
- package/docs/installation.md +103 -103
- package/docs/installation.ru.md +104 -0
- package/docs/installation.zh.md +100 -100
- package/eslint.config.js +30 -76
- package/package.json +69 -70
- package/packages/selector/dsh.plugin.json +2 -2
- package/packages/selector/lib/{intent-gate.js → advisor-state.js} +3 -91
- package/packages/selector/lib/client.js +736 -14
- package/packages/selector/lib/index.js +1 -92
- package/packages/selector/lib/profiles.d.ts +0 -9
- package/packages/selector/lib/pruner.d.ts +0 -59
- package/packages/selector/lib/pruner.js +7 -410
- package/packages/selector/lib/style.css +46 -46
- package/packages/selector/package.json +114 -114
- package/packages/selector/src/client/decode.ts +2 -6
- package/packages/selector/src/client/index.ts +244 -213
- package/packages/selector/src/client/locales/de.ts +98 -0
- package/packages/selector/src/client/locales/es.ts +98 -0
- package/packages/selector/src/client/locales/fr.ts +98 -0
- package/packages/selector/src/client/locales/it.ts +98 -0
- package/packages/selector/src/client/locales/ja.ts +98 -0
- package/packages/selector/src/client/locales/ko.ts +98 -0
- package/packages/selector/src/client/locales/ru.ts +98 -0
- package/packages/selector/src/deepseek-v4-tokenizer.ts +1 -1
- package/packages/selector/src/index.ts +411 -418
- package/packages/selector/src/preset-overlay.ts +0 -3
- package/packages/selector/src/profiles.ts +10 -30
- package/packages/selector/src/pruner/content.ts +1 -1
- package/packages/selector/src/pruner/state.ts +0 -7
- package/packages/selector/src/pruner.ts +9 -253
- package/packages/selector/src/runtime/audit.ts +0 -17
- package/packages/selector/src/runtime/config.ts +11 -36
- package/packages/selector/src/runtime/reducers.ts +1 -1
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +1 -46
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -55
- package/packages/selector/src/runtime/tokenpilot/locator.ts +2 -2
- package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +1 -4
- package/packages/selector/src/runtime/types.ts +0 -12
- package/packages/selector/tests/auto-compact.client.spec.tsx +213 -214
- package/packages/selector/tests/built/client-artifact.spec.ts +59 -61
- package/packages/selector/tests/code-skeleton.client.spec.ts +93 -94
- package/packages/selector/tests/custom-contract.client.spec.ts +222 -223
- package/packages/selector/tests/estimator-channel.client.spec.tsx +252 -252
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -204
- package/packages/selector/tests/preset-options-write.client.spec.ts +187 -188
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -200
- package/packages/selector/tests/profiles.client.spec.tsx +434 -436
- package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -230
- package/packages/selector/tests/runtime/audit.spec.ts +274 -275
- package/packages/selector/tests/runtime/auto-compact-config.spec.ts +3 -3
- package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +4 -4
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2731 -2736
- package/packages/selector/tests/standing-generation.host.spec.ts +724 -704
- package/pnpm-workspace.yaml +66 -66
- package/scripts/packed-components-smoke.mjs +0 -2
- package/scripts/packed-install-e2e.mjs +5 -7
- package/scripts/verify-release.mjs +2 -3
- package/tests/TEST_INVENTORY.md +41 -41
- package/tsconfig.tests.json +1 -3
- package/vitest.config.ts +0 -14
- package/packages/selector/src/runtime/summary-command.ts +0 -133
- package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
- package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
- package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
- package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
- package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
- package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
- package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
|
@@ -1,223 +1,222 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
-
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
3
|
-
import type { ScopeSnapshot } from '../src/client/scope-face.ts'
|
|
4
|
-
import {
|
|
5
|
-
DEFAULT_CUSTOM_COMPRESSION_POLICY,
|
|
6
|
-
isCustomCompressionPolicy,
|
|
7
|
-
} from '../src/profiles.ts'
|
|
8
|
-
import { apply } from '../src/client/index.ts'
|
|
9
|
-
import { decodeSettings } from '../src/client/decode.ts'
|
|
10
|
-
import type {
|
|
11
|
-
CompressionSelectorInjected,
|
|
12
|
-
ContextCompressionSettings,
|
|
13
|
-
} from '../src/client/CompressionProfileSelector.tsx'
|
|
14
|
-
|
|
15
|
-
vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({
|
|
16
|
-
IconChevronDownOutlineMedium: () => null,
|
|
17
|
-
Menu: () => null,
|
|
18
|
-
}))
|
|
19
|
-
|
|
20
|
-
const CUSTOM = {
|
|
21
|
-
version: 1,
|
|
22
|
-
unit: 'tokens',
|
|
23
|
-
fresh: { enabled: true, trigger: 4_096, target: 2_048 },
|
|
24
|
-
aggregate: { enabled: true, trigger: 16_384, target: 8_192 },
|
|
25
|
-
history: {
|
|
26
|
-
enabled: true,
|
|
27
|
-
trigger: 32_768,
|
|
28
|
-
keepRecentTurns: 2,
|
|
29
|
-
keepRecent: 16_384,
|
|
30
|
-
minReclaim: 8_192,
|
|
31
|
-
},
|
|
32
|
-
prefixPolicy: 'pressure-break',
|
|
33
|
-
} as const satisfies ContextCompressionSettings['custom']
|
|
34
|
-
|
|
35
|
-
describe('context compression browser contract', () => {
|
|
36
|
-
it('accepts legacy v1 and defaults new edits to v3 with TailTrim disabled', () => {
|
|
37
|
-
expect(isCustomCompressionPolicy(CUSTOM)).toBe(true)
|
|
38
|
-
expect(DEFAULT_CUSTOM_COMPRESSION_POLICY).toMatchObject({
|
|
39
|
-
version: 3,
|
|
40
|
-
tailTrim: { enabled: false, trigger: 700_000 },
|
|
41
|
-
})
|
|
42
|
-
expect(isCustomCompressionPolicy(DEFAULT_CUSTOM_COMPRESSION_POLICY)).toBe(true)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('fails the browser narrowing for unknown or invalid Custom fields', () => {
|
|
46
|
-
expect(isCustomCompressionPolicy({
|
|
47
|
-
...structuredClone(CUSTOM),
|
|
48
|
-
tailTrim: { enabled: true },
|
|
49
|
-
})).toBe(false)
|
|
50
|
-
expect(isCustomCompressionPolicy({
|
|
51
|
-
...structuredClone(CUSTOM),
|
|
52
|
-
fresh: { enabled: true, trigger: 100, target: 100 },
|
|
53
|
-
})).toBe(false)
|
|
54
|
-
for (const trigger of [0, -1]) {
|
|
55
|
-
expect(isCustomCompressionPolicy({
|
|
56
|
-
...structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
|
|
57
|
-
tailTrim: { enabled: true, trigger },
|
|
58
|
-
})).toBe(false)
|
|
59
|
-
}
|
|
60
|
-
expect(isCustomCompressionPolicy({
|
|
61
|
-
...structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
|
|
62
|
-
unit: 'context-percent',
|
|
63
|
-
tailTrim: { enabled: true, trigger: 101 },
|
|
64
|
-
})).toBe(false)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
it('decodes legacy settings to the default threshold and rejects malformed sections', async () => {
|
|
68
|
-
// Legacy documents stored before autoCompact existed inherit 80%.
|
|
69
|
-
const legacy = decodeSettings({ profile: 'balanced', custom: structuredClone(CUSTOM) })
|
|
70
|
-
expect(legacy).toMatchObject({ autoCompact: { thresholdPercent: 80 } })
|
|
71
|
-
// A present-but-invalid threshold fails the whole decode.
|
|
72
|
-
expect(decodeSettings({
|
|
73
|
-
profile: 'balanced',
|
|
74
|
-
custom: structuredClone(CUSTOM),
|
|
75
|
-
autoCompact: { thresholdPercent: 91 },
|
|
76
|
-
})).toBeUndefined()
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('reports a recovered no-op write only on the selector boundary', async () => {
|
|
80
|
-
let revision = 7
|
|
81
|
-
let commit = false
|
|
82
|
-
let rewriteCustom = false
|
|
83
|
-
let rewriteReset = false
|
|
84
|
-
let dropTailTrim = false
|
|
85
|
-
let downgradeVersion = false
|
|
86
|
-
let value: ContextCompressionSettings = {
|
|
87
|
-
profile: 'balanced',
|
|
88
|
-
custom: structuredClone(CUSTOM),
|
|
89
|
-
autoCompact: { thresholdPercent: 80 },
|
|
90
|
-
codeSkeleton: { enabled: false },
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
accepted
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
accepted
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
custom.fresh.
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
requested.fresh.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
expect(scope.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
expect(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
})
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
3
|
+
import type { ScopeSnapshot } from '../src/client/scope-face.ts'
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_CUSTOM_COMPRESSION_POLICY,
|
|
6
|
+
isCustomCompressionPolicy,
|
|
7
|
+
} from '../src/profiles.ts'
|
|
8
|
+
import { apply } from '../src/client/index.ts'
|
|
9
|
+
import { decodeSettings } from '../src/client/decode.ts'
|
|
10
|
+
import type {
|
|
11
|
+
CompressionSelectorInjected,
|
|
12
|
+
ContextCompressionSettings,
|
|
13
|
+
} from '../src/client/CompressionProfileSelector.tsx'
|
|
14
|
+
|
|
15
|
+
vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({
|
|
16
|
+
IconChevronDownOutlineMedium: () => null,
|
|
17
|
+
Menu: () => null,
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
const CUSTOM = {
|
|
21
|
+
version: 1,
|
|
22
|
+
unit: 'tokens',
|
|
23
|
+
fresh: { enabled: true, trigger: 4_096, target: 2_048 },
|
|
24
|
+
aggregate: { enabled: true, trigger: 16_384, target: 8_192 },
|
|
25
|
+
history: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
trigger: 32_768,
|
|
28
|
+
keepRecentTurns: 2,
|
|
29
|
+
keepRecent: 16_384,
|
|
30
|
+
minReclaim: 8_192,
|
|
31
|
+
},
|
|
32
|
+
prefixPolicy: 'pressure-break',
|
|
33
|
+
} as const satisfies ContextCompressionSettings['custom']
|
|
34
|
+
|
|
35
|
+
describe('context compression browser contract', () => {
|
|
36
|
+
it('accepts legacy v1 and defaults new edits to v3 with TailTrim disabled', () => {
|
|
37
|
+
expect(isCustomCompressionPolicy(CUSTOM)).toBe(true)
|
|
38
|
+
expect(DEFAULT_CUSTOM_COMPRESSION_POLICY).toMatchObject({
|
|
39
|
+
version: 3,
|
|
40
|
+
tailTrim: { enabled: false, trigger: 700_000 },
|
|
41
|
+
})
|
|
42
|
+
expect(isCustomCompressionPolicy(DEFAULT_CUSTOM_COMPRESSION_POLICY)).toBe(true)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('fails the browser narrowing for unknown or invalid Custom fields', () => {
|
|
46
|
+
expect(isCustomCompressionPolicy({
|
|
47
|
+
...structuredClone(CUSTOM),
|
|
48
|
+
tailTrim: { enabled: true },
|
|
49
|
+
})).toBe(false)
|
|
50
|
+
expect(isCustomCompressionPolicy({
|
|
51
|
+
...structuredClone(CUSTOM),
|
|
52
|
+
fresh: { enabled: true, trigger: 100, target: 100 },
|
|
53
|
+
})).toBe(false)
|
|
54
|
+
for (const trigger of [0, -1]) {
|
|
55
|
+
expect(isCustomCompressionPolicy({
|
|
56
|
+
...structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
|
|
57
|
+
tailTrim: { enabled: true, trigger },
|
|
58
|
+
})).toBe(false)
|
|
59
|
+
}
|
|
60
|
+
expect(isCustomCompressionPolicy({
|
|
61
|
+
...structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
|
|
62
|
+
unit: 'context-percent',
|
|
63
|
+
tailTrim: { enabled: true, trigger: 101 },
|
|
64
|
+
})).toBe(false)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('decodes legacy settings to the default threshold and rejects malformed sections', async () => {
|
|
68
|
+
// Legacy documents stored before autoCompact existed inherit 80%.
|
|
69
|
+
const legacy = decodeSettings({ profile: 'balanced', custom: structuredClone(CUSTOM) })
|
|
70
|
+
expect(legacy).toMatchObject({ autoCompact: { thresholdPercent: 80 } })
|
|
71
|
+
// A present-but-invalid threshold fails the whole decode.
|
|
72
|
+
expect(decodeSettings({
|
|
73
|
+
profile: 'balanced',
|
|
74
|
+
custom: structuredClone(CUSTOM),
|
|
75
|
+
autoCompact: { thresholdPercent: 91 },
|
|
76
|
+
})).toBeUndefined()
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('reports a recovered no-op write only on the selector boundary', async () => {
|
|
80
|
+
let revision = 7
|
|
81
|
+
let commit = false
|
|
82
|
+
let rewriteCustom = false
|
|
83
|
+
let rewriteReset = false
|
|
84
|
+
let dropTailTrim = false
|
|
85
|
+
let downgradeVersion = false
|
|
86
|
+
let value: ContextCompressionSettings = {
|
|
87
|
+
profile: 'balanced',
|
|
88
|
+
custom: structuredClone(CUSTOM),
|
|
89
|
+
autoCompact: { thresholdPercent: 80 },
|
|
90
|
+
codeSkeleton: { enabled: false },
|
|
91
|
+
}
|
|
92
|
+
const snapshot = (): ScopeSnapshot<ContextCompressionSettings> => ({
|
|
93
|
+
status: 'ready',
|
|
94
|
+
value,
|
|
95
|
+
base: undefined,
|
|
96
|
+
user: undefined,
|
|
97
|
+
revision,
|
|
98
|
+
writable: true,
|
|
99
|
+
mode: 'host',
|
|
100
|
+
})
|
|
101
|
+
const scope = {
|
|
102
|
+
getSnapshot: snapshot,
|
|
103
|
+
subscribe: vi.fn(() => () => {}),
|
|
104
|
+
set: vi.fn(async (field: string, next: unknown) => {
|
|
105
|
+
if (!commit) return
|
|
106
|
+
revision += 1
|
|
107
|
+
if (field === 'custom' && rewriteCustom) {
|
|
108
|
+
const accepted = structuredClone(next as ContextCompressionSettings['custom'])
|
|
109
|
+
accepted.fresh.trigger += 1
|
|
110
|
+
value = { ...value, custom: accepted }
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
if (field === 'custom' && rewriteReset) {
|
|
114
|
+
const accepted = structuredClone(next as ContextCompressionSettings['custom'])
|
|
115
|
+
accepted.fresh.trigger += 1
|
|
116
|
+
value = { ...value, custom: accepted }
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
if (field === 'custom' && dropTailTrim) {
|
|
120
|
+
const accepted = structuredClone(next as ContextCompressionSettings['custom'])
|
|
121
|
+
if (accepted.version === 3) {
|
|
122
|
+
accepted.tailTrim = { enabled: false, trigger: 700_000 }
|
|
123
|
+
}
|
|
124
|
+
value = { ...value, custom: accepted }
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
if (field === 'custom' && downgradeVersion) {
|
|
128
|
+
value = { ...value, custom: structuredClone(CUSTOM) }
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
value = { ...value, [field]: next }
|
|
132
|
+
}),
|
|
133
|
+
unset: vi.fn(async () => {
|
|
134
|
+
if (!commit) return
|
|
135
|
+
revision += 1
|
|
136
|
+
const custom: ContextCompressionSettings['custom'] = structuredClone(CUSTOM)
|
|
137
|
+
if (rewriteReset) {
|
|
138
|
+
custom.fresh.trigger = 8_192
|
|
139
|
+
custom.fresh.target = 4_096
|
|
140
|
+
}
|
|
141
|
+
value = { ...value, custom }
|
|
142
|
+
}),
|
|
143
|
+
}
|
|
144
|
+
let injected: (() => CompressionSelectorInjected) | undefined
|
|
145
|
+
const ctx = {
|
|
146
|
+
effect: (install: () => unknown) => { install() },
|
|
147
|
+
locale: { register: vi.fn(() => () => {}) },
|
|
148
|
+
// 0.1.7: the plugin commits the whole doc through configForms; the fake
|
|
149
|
+
// routes each changed top-level field back onto the old scope stub so
|
|
150
|
+
// the rewrite/drop semantics below stay observable per field.
|
|
151
|
+
configForms: {
|
|
152
|
+
get: vi.fn(() => ({
|
|
153
|
+
getSnapshot: () => ({ ...snapshot(), value: { settings: value } }),
|
|
154
|
+
subscribe: scope.subscribe,
|
|
155
|
+
set: async (_field: string, doc: unknown) => {
|
|
156
|
+
const next = doc as unknown as Record<string, unknown>
|
|
157
|
+
for (const key of Object.keys(next)) {
|
|
158
|
+
if (JSON.stringify((value as unknown as Record<string, unknown>)[key]) !== JSON.stringify(next[key])) {
|
|
159
|
+
await scope.set(key, (next as Record<string, unknown>)[key])
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return true
|
|
163
|
+
},
|
|
164
|
+
unset: scope.unset,
|
|
165
|
+
})),
|
|
166
|
+
},
|
|
167
|
+
slots: {
|
|
168
|
+
inject: (_slot: string, install: () => unknown) => { install() },
|
|
169
|
+
register: (registration: { inject?: () => CompressionSelectorInjected }) => {
|
|
170
|
+
// The R4 overlay registration carries no inject face; keep the card's.
|
|
171
|
+
if (typeof registration.inject === 'function') injected = registration.inject
|
|
172
|
+
return () => {}
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
} as unknown as ClientContext
|
|
176
|
+
|
|
177
|
+
apply(ctx)
|
|
178
|
+
const actions = injected?.()
|
|
179
|
+
expect(actions).toBeDefined()
|
|
180
|
+
if (actions === undefined) throw new Error('selector injection was not registered')
|
|
181
|
+
await expect(actions.select('native')).rejects.toThrow('were not saved')
|
|
182
|
+
|
|
183
|
+
commit = true
|
|
184
|
+
await expect(actions.select('native')).resolves.toBeUndefined()
|
|
185
|
+
expect(value.profile).toBe('native')
|
|
186
|
+
|
|
187
|
+
const requested: ContextCompressionSettings['custom'] = structuredClone(CUSTOM)
|
|
188
|
+
requested.fresh.trigger = 8_192
|
|
189
|
+
requested.fresh.target = 4_096
|
|
190
|
+
rewriteCustom = true
|
|
191
|
+
await expect(actions.saveCustom(requested)).rejects.toThrow('were not saved')
|
|
192
|
+
|
|
193
|
+
rewriteCustom = false
|
|
194
|
+
const requestedV3 = structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY)
|
|
195
|
+
if (requestedV3.version !== 3) throw new Error('Custom TailTrim persistence fixture requires policy v3')
|
|
196
|
+
requestedV3.tailTrim = { enabled: true, trigger: 49_152 }
|
|
197
|
+
dropTailTrim = true
|
|
198
|
+
await expect(actions.saveCustom(requestedV3)).rejects.toThrow('were not saved')
|
|
199
|
+
|
|
200
|
+
dropTailTrim = false
|
|
201
|
+
downgradeVersion = true
|
|
202
|
+
await expect(actions.saveCustom(requestedV3)).rejects.toThrow('were not saved')
|
|
203
|
+
|
|
204
|
+
downgradeVersion = false
|
|
205
|
+
rewriteReset = true
|
|
206
|
+
await expect(actions.resetCustom()).rejects.toThrow('were not saved')
|
|
207
|
+
|
|
208
|
+
rewriteReset = false
|
|
209
|
+
await expect(actions.resetCustom()).resolves.toBeUndefined()
|
|
210
|
+
expect(scope.set).toHaveBeenLastCalledWith('custom', DEFAULT_CUSTOM_COMPRESSION_POLICY)
|
|
211
|
+
expect(scope.unset).not.toHaveBeenCalled()
|
|
212
|
+
|
|
213
|
+
// The Auto Compact threshold shares the same confirm-on-write boundary:
|
|
214
|
+
// committed writes resolve, and a silent host drop rejects.
|
|
215
|
+
commit = false
|
|
216
|
+
await expect(actions.saveAutoCompact(73)).rejects.toThrow('were not saved')
|
|
217
|
+
commit = true
|
|
218
|
+
await expect(actions.saveAutoCompact(73)).resolves.toBeUndefined()
|
|
219
|
+
expect(scope.set).toHaveBeenLastCalledWith('autoCompact', { thresholdPercent: 73 })
|
|
220
|
+
expect(value.autoCompact).toEqual({ thresholdPercent: 73 })
|
|
221
|
+
})
|
|
222
|
+
})
|