dsh-context-compression-improved 0.6.0 → 0.6.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/package.json +6 -6
- package/packages/selector/lib/client.d.ts +27 -19
- package/packages/selector/lib/client.js +5 -5
- package/packages/selector/lib/pruner.d.ts +7 -0
- package/packages/selector/lib/pruner.js +20 -33
- package/packages/selector/lib/tail-trim.js +3 -6
- package/packages/selector/package.json +1 -1
- package/packages/selector/src/client/CompressionProfileControls.tsx +2 -2
- package/packages/selector/src/client/CompressionProfileSelector.tsx +1 -1
- package/packages/selector/src/client/index.ts +7 -8
- package/packages/selector/src/client/scope-face.ts +21 -0
- package/packages/selector/src/pruner/content.ts +0 -3
- package/packages/selector/src/pruner/session.ts +4 -2
- package/packages/selector/src/pruner.ts +26 -15
- package/packages/selector/src/runtime/measurement.ts +3 -8
- package/packages/selector/src/runtime/retrieve.ts +3 -3
- package/packages/selector/src/runtime/tail-trim.ts +4 -5
- package/packages/selector/tests/code-skeleton.client.spec.ts +93 -93
- package/packages/selector/tests/custom-contract.client.spec.ts +222 -222
- package/packages/selector/tests/helpers/legacy-namespace.ts +31 -31
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +206 -206
- package/packages/selector/tests/preset-options-write.client.spec.ts +1 -1
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +206 -206
- package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +3 -3
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +20 -20
- package/packages/selector/tests/settings-seat.client.spec.ts +118 -118
- package/packages/selector/tests/standing-generation.host.spec.ts +704 -704
- package/packages/selector/tests/support/ui-primitives.tsx +34 -34
- package/pnpm-workspace.yaml +42 -42
|
@@ -1,206 +1,206 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
|
|
2
|
-
import { tmpdir } from 'node:os'
|
|
3
|
-
import { dirname, join } from 'node:path'
|
|
4
|
-
import { Context, Service } from '@deepseek-ai/cordis'
|
|
5
|
-
import type { AgentPreset } from '@deepseek-ai/dsh-agent-presets'
|
|
6
|
-
import {
|
|
7
|
-
SettingsProvider,
|
|
8
|
-
type SettingsNamespace,
|
|
9
|
-
} from '@deepseek-ai/dsh-settings'
|
|
10
|
-
import { afterEach, describe, expect, it } from 'vitest'
|
|
11
|
-
import { apply } from '../src/index.ts'
|
|
12
|
-
import type { OverlayableAgentPresets } from '../src/preset-overlay.ts'
|
|
13
|
-
import { LegacyNamespaceRegistrar } from './helpers/legacy-namespace.ts'
|
|
14
|
-
|
|
15
|
-
// 0.1.5 removed the settingsNamespace() wrapper; namespaces are validated at runtime.
|
|
16
|
-
const nsBrand = (value: string): SettingsNamespace => value as unknown as SettingsNamespace
|
|
17
|
-
|
|
18
|
-
let root: string | undefined
|
|
19
|
-
let ctx: Context | undefined
|
|
20
|
-
|
|
21
|
-
afterEach(async () => {
|
|
22
|
-
await ctx?.fiber.dispose()
|
|
23
|
-
ctx = undefined
|
|
24
|
-
if (root !== undefined) await rm(root, { recursive: true, force: true })
|
|
25
|
-
root = undefined
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
class MemorySettings extends SettingsProvider {
|
|
29
|
-
readonly writable = true
|
|
30
|
-
private readonly stored: Record<string, unknown> = {}
|
|
31
|
-
|
|
32
|
-
protected load(): Promise<Record<string, unknown>> {
|
|
33
|
-
return Promise.resolve(structuredClone(this.stored))
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
protected persist(ns: SettingsNamespace, section: Record<string, unknown>): Promise<void> {
|
|
37
|
-
this.stored[ns] = structuredClone(section)
|
|
38
|
-
return Promise.resolve()
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
class FakeAgentPresets extends Service implements OverlayableAgentPresets {
|
|
43
|
-
constructor(ctx: Context, readonly preset: AgentPreset) {
|
|
44
|
-
super(ctx, 'agentPresets')
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async resolve(): Promise<AgentPreset> {
|
|
48
|
-
return this.preset
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async mount(_agentCtx: unknown): Promise<AgentPreset> {
|
|
52
|
-
return await this.resolve()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async recompose(_agentCtx: unknown, _id: string): Promise<AgentPreset> {
|
|
56
|
-
return await this.resolve()
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async standingKeyFor(): Promise<string> {
|
|
60
|
-
return (await this.resolve()).path
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async function sourcePreset(): Promise<AgentPreset> {
|
|
65
|
-
root = await mkdtemp(join(tmpdir(), 'dsh-selector-host-overlay-'))
|
|
66
|
-
const path = join(root, 'standard', 'agent.cordis.yml')
|
|
67
|
-
await mkdir(dirname(path), { recursive: true })
|
|
68
|
-
await writeFile(path, "- id: persona\n name: '/opt/preset/persona.js'\n")
|
|
69
|
-
return { id: 'standard', trust: 'system', path }
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
describe('context compression selector Host preset integration', () => {
|
|
73
|
-
it('decorates native composition only for the lifetime of the selector fiber', async () => {
|
|
74
|
-
const preset = await sourcePreset()
|
|
75
|
-
ctx = new Context()
|
|
76
|
-
await ctx.plugin(MemorySettings).await()
|
|
77
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
78
|
-
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
79
|
-
|
|
80
|
-
const selector = ctx.plugin({ apply: (child) => {
|
|
81
|
-
apply(child, { presetOverlay: true })
|
|
82
|
-
} })
|
|
83
|
-
await selector.await()
|
|
84
|
-
|
|
85
|
-
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
86
|
-
const mounted = await service.mount({})
|
|
87
|
-
expect(mounted.path).not.toBe(preset.path)
|
|
88
|
-
expect(await readFile(mounted.path, 'utf8')).toContain('id: tool-result-pruner')
|
|
89
|
-
expect((await service.resolve()).path).toBe(preset.path)
|
|
90
|
-
|
|
91
|
-
await selector.dispose()
|
|
92
|
-
expect((await service.mount({})).path).toBe(preset.path)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('0.1.7: duplicate Host rows own independent entry configs — one row\u2019s disposal never disturbs the other', async () => {
|
|
96
|
-
const preset = await sourcePreset()
|
|
97
|
-
ctx = new Context()
|
|
98
|
-
await ctx.plugin(MemorySettings).await()
|
|
99
|
-
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
100
|
-
|
|
101
|
-
const builtIn = ctx.plugin({ apply })
|
|
102
|
-
await builtIn.await()
|
|
103
|
-
|
|
104
|
-
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
105
|
-
expect((await service.mount({})).path).toBe(preset.path)
|
|
106
|
-
|
|
107
|
-
// 0.1.7: there is no shared settings registration to lease — each row
|
|
108
|
-
// carries its own compression doc on its entry config, so duplicate rows
|
|
109
|
-
// cannot disturb each other and disposal is purely per row.
|
|
110
|
-
const bundle = ctx.plugin({ apply: (child) => {
|
|
111
|
-
apply(child, { presetOverlay: true, settings: { profile: 'cache-strict' } } as never)
|
|
112
|
-
} })
|
|
113
|
-
await bundle.await()
|
|
114
|
-
|
|
115
|
-
const mounted = await service.mount({})
|
|
116
|
-
expect(mounted.path).not.toBe(preset.path)
|
|
117
|
-
expect((await service.recompose({}, 'standard')).path).toBe(mounted.path)
|
|
118
|
-
|
|
119
|
-
// Disposing the non-overlay row never touches the overlay row's decoration
|
|
120
|
-
// or its entry config.
|
|
121
|
-
await builtIn.dispose()
|
|
122
|
-
expect((await service.mount({})).path).toBe(mounted.path)
|
|
123
|
-
|
|
124
|
-
await bundle.dispose()
|
|
125
|
-
expect((await service.mount({})).path).toBe(preset.path)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('writes the saved Auto Compact threshold into the generated compaction-basic composition', async () => {
|
|
129
|
-
const preset = await sourcePreset()
|
|
130
|
-
ctx = new Context()
|
|
131
|
-
await ctx.plugin(MemorySettings).await()
|
|
132
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
133
|
-
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
134
|
-
// A settings-owning row must register the namespace before the update.
|
|
135
|
-
await ctx.plugin({ apply }).await()
|
|
136
|
-
const namespace = nsBrand('context-compression')
|
|
137
|
-
await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
|
|
138
|
-
|
|
139
|
-
const bundle = ctx.plugin({ apply: (child) => {
|
|
140
|
-
apply(child, { presetOverlay: true })
|
|
141
|
-
} })
|
|
142
|
-
await bundle.await()
|
|
143
|
-
|
|
144
|
-
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
145
|
-
const mounted = await service.mount({})
|
|
146
|
-
const rendered = await readFile(mounted.path, 'utf8')
|
|
147
|
-
expect(rendered).toContain('id: compaction-basic')
|
|
148
|
-
expect(rendered).toContain('thresholdRatio: 0.73')
|
|
149
|
-
// First-release retention stays pinned at 0.16 next to the threshold.
|
|
150
|
-
expect(rendered).toContain('retainRatio: 0.16')
|
|
151
|
-
// The SAME read feeds the runtime deployment config, so one generation
|
|
152
|
-
// cannot split Auto Compact and micro compact across two thresholds.
|
|
153
|
-
expect(rendered).toContain('id: tool-result-pruner')
|
|
154
|
-
expect(rendered).toContain('autoCompactThresholdPercent: 73')
|
|
155
|
-
await bundle.dispose()
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
it('defaults the generated threshold to 0.8 and keeps it absent from settings until saved', async () => {
|
|
159
|
-
const preset = await sourcePreset()
|
|
160
|
-
ctx = new Context()
|
|
161
|
-
await ctx.plugin(MemorySettings).await()
|
|
162
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
163
|
-
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
164
|
-
|
|
165
|
-
const bundle = ctx.plugin({ apply: (child) => {
|
|
166
|
-
apply(child, { presetOverlay: true })
|
|
167
|
-
} })
|
|
168
|
-
await bundle.await()
|
|
169
|
-
|
|
170
|
-
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
171
|
-
const rendered = await readFile((await service.mount({})).path, 'utf8')
|
|
172
|
-
expect(rendered).toContain('thresholdRatio: 0.8')
|
|
173
|
-
await bundle.dispose()
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
it('moves the standing composition generation when an equal-length threshold changes', async () => {
|
|
177
|
-
const preset = await sourcePreset()
|
|
178
|
-
ctx = new Context()
|
|
179
|
-
await ctx.plugin(MemorySettings).await()
|
|
180
|
-
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
181
|
-
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
182
|
-
// A settings-owning row must register the namespace before the update.
|
|
183
|
-
await ctx.plugin({ apply }).await()
|
|
184
|
-
const namespace = nsBrand('context-compression')
|
|
185
|
-
await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 70 } })
|
|
186
|
-
|
|
187
|
-
const bundle = ctx.plugin({ apply: (child) => {
|
|
188
|
-
apply(child, { presetOverlay: true })
|
|
189
|
-
} })
|
|
190
|
-
await bundle.await()
|
|
191
|
-
|
|
192
|
-
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
193
|
-
const first = await service.mount({})
|
|
194
|
-
expect(await readFile(first.path, 'utf8')).toContain('thresholdRatio: 0.7')
|
|
195
|
-
expect(await service.standingKeyFor()).toBe(first.path)
|
|
196
|
-
|
|
197
|
-
// Same character length, different content: the generated identity and
|
|
198
|
-
// standing composition generation must both move to the new threshold.
|
|
199
|
-
await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 80 } })
|
|
200
|
-
const second = await service.mount({})
|
|
201
|
-
expect(second.path).not.toBe(first.path)
|
|
202
|
-
expect(await readFile(second.path, 'utf8')).toContain('thresholdRatio: 0.8')
|
|
203
|
-
expect(await service.standingKeyFor()).toBe(second.path)
|
|
204
|
-
await bundle.dispose()
|
|
205
|
-
})
|
|
206
|
-
})
|
|
1
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { dirname, join } from 'node:path'
|
|
4
|
+
import { Context, Service } from '@deepseek-ai/cordis'
|
|
5
|
+
import type { AgentPreset } from '@deepseek-ai/dsh-agent-presets'
|
|
6
|
+
import {
|
|
7
|
+
SettingsProvider,
|
|
8
|
+
type SettingsNamespace,
|
|
9
|
+
} from '@deepseek-ai/dsh-settings'
|
|
10
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
11
|
+
import { apply } from '../src/index.ts'
|
|
12
|
+
import type { OverlayableAgentPresets } from '../src/preset-overlay.ts'
|
|
13
|
+
import { LegacyNamespaceRegistrar } from './helpers/legacy-namespace.ts'
|
|
14
|
+
|
|
15
|
+
// 0.1.5 removed the settingsNamespace() wrapper; namespaces are validated at runtime.
|
|
16
|
+
const nsBrand = (value: string): SettingsNamespace => value as unknown as SettingsNamespace
|
|
17
|
+
|
|
18
|
+
let root: string | undefined
|
|
19
|
+
let ctx: Context | undefined
|
|
20
|
+
|
|
21
|
+
afterEach(async () => {
|
|
22
|
+
await ctx?.fiber.dispose()
|
|
23
|
+
ctx = undefined
|
|
24
|
+
if (root !== undefined) await rm(root, { recursive: true, force: true })
|
|
25
|
+
root = undefined
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
class MemorySettings extends SettingsProvider {
|
|
29
|
+
readonly writable = true
|
|
30
|
+
private readonly stored: Record<string, unknown> = {}
|
|
31
|
+
|
|
32
|
+
protected load(): Promise<Record<string, unknown>> {
|
|
33
|
+
return Promise.resolve(structuredClone(this.stored))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected persist(ns: SettingsNamespace, section: Record<string, unknown>): Promise<void> {
|
|
37
|
+
this.stored[ns] = structuredClone(section)
|
|
38
|
+
return Promise.resolve()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class FakeAgentPresets extends Service implements OverlayableAgentPresets {
|
|
43
|
+
constructor(ctx: Context, readonly preset: AgentPreset) {
|
|
44
|
+
super(ctx, 'agentPresets')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async resolve(): Promise<AgentPreset> {
|
|
48
|
+
return this.preset
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async mount(_agentCtx: unknown): Promise<AgentPreset> {
|
|
52
|
+
return await this.resolve()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async recompose(_agentCtx: unknown, _id: string): Promise<AgentPreset> {
|
|
56
|
+
return await this.resolve()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async standingKeyFor(): Promise<string> {
|
|
60
|
+
return (await this.resolve()).path
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function sourcePreset(): Promise<AgentPreset> {
|
|
65
|
+
root = await mkdtemp(join(tmpdir(), 'dsh-selector-host-overlay-'))
|
|
66
|
+
const path = join(root, 'standard', 'agent.cordis.yml')
|
|
67
|
+
await mkdir(dirname(path), { recursive: true })
|
|
68
|
+
await writeFile(path, "- id: persona\n name: '/opt/preset/persona.js'\n")
|
|
69
|
+
return { id: 'standard', trust: 'system', path }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
describe('context compression selector Host preset integration', () => {
|
|
73
|
+
it('decorates native composition only for the lifetime of the selector fiber', async () => {
|
|
74
|
+
const preset = await sourcePreset()
|
|
75
|
+
ctx = new Context()
|
|
76
|
+
await ctx.plugin(MemorySettings).await()
|
|
77
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
78
|
+
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
79
|
+
|
|
80
|
+
const selector = ctx.plugin({ apply: (child) => {
|
|
81
|
+
apply(child, { presetOverlay: true })
|
|
82
|
+
} })
|
|
83
|
+
await selector.await()
|
|
84
|
+
|
|
85
|
+
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
86
|
+
const mounted = await service.mount({})
|
|
87
|
+
expect(mounted.path).not.toBe(preset.path)
|
|
88
|
+
expect(await readFile(mounted.path, 'utf8')).toContain('id: tool-result-pruner')
|
|
89
|
+
expect((await service.resolve()).path).toBe(preset.path)
|
|
90
|
+
|
|
91
|
+
await selector.dispose()
|
|
92
|
+
expect((await service.mount({})).path).toBe(preset.path)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('0.1.7: duplicate Host rows own independent entry configs — one row\u2019s disposal never disturbs the other', async () => {
|
|
96
|
+
const preset = await sourcePreset()
|
|
97
|
+
ctx = new Context()
|
|
98
|
+
await ctx.plugin(MemorySettings).await()
|
|
99
|
+
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
100
|
+
|
|
101
|
+
const builtIn = ctx.plugin({ apply })
|
|
102
|
+
await builtIn.await()
|
|
103
|
+
|
|
104
|
+
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
105
|
+
expect((await service.mount({})).path).toBe(preset.path)
|
|
106
|
+
|
|
107
|
+
// 0.1.7: there is no shared settings registration to lease — each row
|
|
108
|
+
// carries its own compression doc on its entry config, so duplicate rows
|
|
109
|
+
// cannot disturb each other and disposal is purely per row.
|
|
110
|
+
const bundle = ctx.plugin({ apply: (child) => {
|
|
111
|
+
apply(child, { presetOverlay: true, settings: { profile: 'cache-strict' } } as never)
|
|
112
|
+
} })
|
|
113
|
+
await bundle.await()
|
|
114
|
+
|
|
115
|
+
const mounted = await service.mount({})
|
|
116
|
+
expect(mounted.path).not.toBe(preset.path)
|
|
117
|
+
expect((await service.recompose({}, 'standard')).path).toBe(mounted.path)
|
|
118
|
+
|
|
119
|
+
// Disposing the non-overlay row never touches the overlay row's decoration
|
|
120
|
+
// or its entry config.
|
|
121
|
+
await builtIn.dispose()
|
|
122
|
+
expect((await service.mount({})).path).toBe(mounted.path)
|
|
123
|
+
|
|
124
|
+
await bundle.dispose()
|
|
125
|
+
expect((await service.mount({})).path).toBe(preset.path)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('writes the saved Auto Compact threshold into the generated compaction-basic composition', async () => {
|
|
129
|
+
const preset = await sourcePreset()
|
|
130
|
+
ctx = new Context()
|
|
131
|
+
await ctx.plugin(MemorySettings).await()
|
|
132
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
133
|
+
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
134
|
+
// A settings-owning row must register the namespace before the update.
|
|
135
|
+
await ctx.plugin({ apply }).await()
|
|
136
|
+
const namespace = nsBrand('context-compression')
|
|
137
|
+
await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
|
|
138
|
+
|
|
139
|
+
const bundle = ctx.plugin({ apply: (child) => {
|
|
140
|
+
apply(child, { presetOverlay: true })
|
|
141
|
+
} })
|
|
142
|
+
await bundle.await()
|
|
143
|
+
|
|
144
|
+
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
145
|
+
const mounted = await service.mount({})
|
|
146
|
+
const rendered = await readFile(mounted.path, 'utf8')
|
|
147
|
+
expect(rendered).toContain('id: compaction-basic')
|
|
148
|
+
expect(rendered).toContain('thresholdRatio: 0.73')
|
|
149
|
+
// First-release retention stays pinned at 0.16 next to the threshold.
|
|
150
|
+
expect(rendered).toContain('retainRatio: 0.16')
|
|
151
|
+
// The SAME read feeds the runtime deployment config, so one generation
|
|
152
|
+
// cannot split Auto Compact and micro compact across two thresholds.
|
|
153
|
+
expect(rendered).toContain('id: tool-result-pruner')
|
|
154
|
+
expect(rendered).toContain('autoCompactThresholdPercent: 73')
|
|
155
|
+
await bundle.dispose()
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('defaults the generated threshold to 0.8 and keeps it absent from settings until saved', async () => {
|
|
159
|
+
const preset = await sourcePreset()
|
|
160
|
+
ctx = new Context()
|
|
161
|
+
await ctx.plugin(MemorySettings).await()
|
|
162
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
163
|
+
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
164
|
+
|
|
165
|
+
const bundle = ctx.plugin({ apply: (child) => {
|
|
166
|
+
apply(child, { presetOverlay: true })
|
|
167
|
+
} })
|
|
168
|
+
await bundle.await()
|
|
169
|
+
|
|
170
|
+
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
171
|
+
const rendered = await readFile((await service.mount({})).path, 'utf8')
|
|
172
|
+
expect(rendered).toContain('thresholdRatio: 0.8')
|
|
173
|
+
await bundle.dispose()
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('moves the standing composition generation when an equal-length threshold changes', async () => {
|
|
177
|
+
const preset = await sourcePreset()
|
|
178
|
+
ctx = new Context()
|
|
179
|
+
await ctx.plugin(MemorySettings).await()
|
|
180
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
181
|
+
await ctx.plugin(FakeAgentPresets, preset).await()
|
|
182
|
+
// A settings-owning row must register the namespace before the update.
|
|
183
|
+
await ctx.plugin({ apply }).await()
|
|
184
|
+
const namespace = nsBrand('context-compression')
|
|
185
|
+
await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 70 } })
|
|
186
|
+
|
|
187
|
+
const bundle = ctx.plugin({ apply: (child) => {
|
|
188
|
+
apply(child, { presetOverlay: true })
|
|
189
|
+
} })
|
|
190
|
+
await bundle.await()
|
|
191
|
+
|
|
192
|
+
const service = ctx.agentPresets as unknown as OverlayableAgentPresets
|
|
193
|
+
const first = await service.mount({})
|
|
194
|
+
expect(await readFile(first.path, 'utf8')).toContain('thresholdRatio: 0.7')
|
|
195
|
+
expect(await service.standingKeyFor()).toBe(first.path)
|
|
196
|
+
|
|
197
|
+
// Same character length, different content: the generated identity and
|
|
198
|
+
// standing composition generation must both move to the new threshold.
|
|
199
|
+
await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 80 } })
|
|
200
|
+
const second = await service.mount({})
|
|
201
|
+
expect(second.path).not.toBe(first.path)
|
|
202
|
+
expect(await readFile(second.path, 'utf8')).toContain('thresholdRatio: 0.8')
|
|
203
|
+
expect(await service.standingKeyFor()).toBe(second.path)
|
|
204
|
+
await bundle.dispose()
|
|
205
|
+
})
|
|
206
|
+
})
|
|
@@ -14,7 +14,7 @@ import type { ContextCompressionSettings } from '../src/profiles.ts'
|
|
|
14
14
|
* locally before the commit, so a second field write never erases the first.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
interface FormStub {
|
|
17
|
+
interface FormStub {
|
|
18
18
|
form: Record<string, unknown>
|
|
19
19
|
/** Whole-doc commits the fake Host accepted. */
|
|
20
20
|
readonly commits: Record<string, unknown>[]
|