dsh-context-compression-improved 0.5.5 → 0.6.0
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/README.md +10 -1
- package/package.json +162 -160
- package/packages/selector/README.md +6 -1
- package/packages/selector/README.zh.md +6 -1
- package/packages/selector/lib/advisor-state.js +1 -1
- package/packages/selector/lib/client.d.ts +19 -104
- package/packages/selector/lib/client.js +42 -5
- package/packages/selector/lib/index.d.ts +9 -0
- package/packages/selector/lib/index.js +18 -50
- package/packages/selector/lib/profiles.d.ts +105 -0
- package/packages/selector/lib/pruner.js +3 -2
- package/packages/selector/package.json +114 -114
- package/packages/selector/src/client/index.ts +71 -8
- package/packages/selector/src/index.ts +35 -86
- package/packages/selector/src/pruner.ts +12 -3
- package/packages/selector/src/runtime/config.ts +1 -1
- package/packages/selector/tests/code-skeleton.client.spec.ts +93 -90
- package/packages/selector/tests/custom-contract.client.spec.ts +19 -1
- package/packages/selector/tests/helpers/legacy-namespace.ts +31 -0
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +206 -206
- package/packages/selector/tests/preset-options-write.client.spec.ts +63 -82
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +206 -201
- package/packages/selector/tests/public/package-contract.client.spec.ts +2 -2
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +3 -2
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +20 -17
- package/packages/selector/tests/settings-seat.client.spec.ts +2 -2
- package/packages/selector/tests/standing-generation.host.spec.ts +704 -697
|
@@ -1,201 +1,206 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
2
|
-
import { tmpdir } from 'node:os'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
|
-
import { pathToFileURL } from 'node:url'
|
|
5
|
-
import { Context } from '@deepseek-ai/cordis'
|
|
6
|
-
import Group from '@deepseek-ai/cordis-plugin-group'
|
|
7
|
-
import Include from '@deepseek-ai/cordis-plugin-include'
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
runtime.
|
|
82
|
-
runtime.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
await runtime.plugin(
|
|
86
|
-
await runtime.plugin(
|
|
87
|
-
await runtime.plugin(
|
|
88
|
-
await runtime.plugin(
|
|
89
|
-
await runtime.plugin(
|
|
90
|
-
await runtime.plugin(
|
|
91
|
-
await runtime.plugin(
|
|
92
|
-
await runtime.plugin(
|
|
93
|
-
await runtime.plugin(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
expect(
|
|
128
|
-
expect(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
expect(
|
|
135
|
-
expect(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
expect(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
expect(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
})
|
|
1
|
+
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { pathToFileURL } from 'node:url'
|
|
5
|
+
import { Context } from '@deepseek-ai/cordis'
|
|
6
|
+
import Group from '@deepseek-ai/cordis-plugin-group'
|
|
7
|
+
import Include from '@deepseek-ai/cordis-plugin-include'
|
|
8
|
+
import { Config } from '../src/index.ts'
|
|
9
|
+
import Loader from '@deepseek-ai/cordis-plugin-loader'
|
|
10
|
+
import AgentRegistry, { type Agent } from '@deepseek-ai/dsh-agent'
|
|
11
|
+
import AgentLoop from '@deepseek-ai/dsh-agent-loop'
|
|
12
|
+
import AgentPresets, { COMPOSITION_FILE } from '@deepseek-ai/dsh-agent-presets'
|
|
13
|
+
import CommandRuntime from '@deepseek-ai/dsh-commands'
|
|
14
|
+
import LlmRuntime from '@deepseek-ai/dsh-llm'
|
|
15
|
+
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
|
|
16
|
+
import { scopeOf } from '@deepseek-ai/dsh-scope'
|
|
17
|
+
import {
|
|
18
|
+
SettingsProvider,
|
|
19
|
+
type SettingsNamespace,
|
|
20
|
+
} from '@deepseek-ai/dsh-settings'
|
|
21
|
+
import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
|
|
22
|
+
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
|
|
23
|
+
import TokenMeter from '@deepseek-ai/dsh-token-meter'
|
|
24
|
+
import ToolRuntime from '@deepseek-ai/dsh-tools'
|
|
25
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
26
|
+
import { apply } from '../src/index.ts'
|
|
27
|
+
import { LegacyNamespaceRegistrar } from './helpers/legacy-namespace.ts'
|
|
28
|
+
|
|
29
|
+
// 0.1.5 removed the settingsNamespace() wrapper; namespaces are validated at runtime.
|
|
30
|
+
const nsBrand = (value: string): SettingsNamespace => value as unknown as SettingsNamespace
|
|
31
|
+
|
|
32
|
+
const CORDIS_ORIGINAL = Symbol.for('cordis.original')
|
|
33
|
+
type Traceable = { [CORDIS_ORIGINAL]?: unknown }
|
|
34
|
+
|
|
35
|
+
let ctx: Context | undefined
|
|
36
|
+
let root: string | undefined
|
|
37
|
+
|
|
38
|
+
afterEach(async () => {
|
|
39
|
+
await ctx?.fiber.dispose()
|
|
40
|
+
ctx = undefined
|
|
41
|
+
if (root !== undefined) await rm(root, { recursive: true, force: true })
|
|
42
|
+
root = undefined
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
class MemorySettings extends SettingsProvider {
|
|
46
|
+
readonly writable = true
|
|
47
|
+
|
|
48
|
+
protected load(): Promise<Record<string, unknown>> {
|
|
49
|
+
return Promise.resolve({})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected persist(_ns: SettingsNamespace, _section: Record<string, unknown>): Promise<void> {
|
|
53
|
+
return Promise.resolve()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface CustomSettings {
|
|
58
|
+
profile: string
|
|
59
|
+
custom: {
|
|
60
|
+
history: { trigger: number }
|
|
61
|
+
tailTrim: { enabled: boolean; trigger: number }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function createPresetRoot(): Promise<string> {
|
|
66
|
+
root = await mkdtemp(join(tmpdir(), 'dsh-selector-loader-e2e-'))
|
|
67
|
+
const marker = join(root, 'marker.mjs')
|
|
68
|
+
await writeFile(marker, 'export function apply() {}\n')
|
|
69
|
+
const source = `- id: source-marker\n name: ${JSON.stringify(marker)}\n`
|
|
70
|
+
for (const id of ['standard', 'custom', 'minimal']) {
|
|
71
|
+
const directory = join(root, id)
|
|
72
|
+
await mkdir(directory)
|
|
73
|
+
await writeFile(join(directory, COMPOSITION_FILE), source)
|
|
74
|
+
}
|
|
75
|
+
return root
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function harness(): Promise<Context> {
|
|
79
|
+
const presets = await createPresetRoot()
|
|
80
|
+
const runtime = new Context()
|
|
81
|
+
runtime.baseUrl = `${pathToFileURL(presets).href}/`
|
|
82
|
+
await runtime.plugin(Loader).await()
|
|
83
|
+
runtime.loader.builtins.include = Include
|
|
84
|
+
runtime.loader.builtins.group = Group
|
|
85
|
+
await runtime.plugin(LlmRuntime).await()
|
|
86
|
+
await runtime.plugin(SessionStore).await()
|
|
87
|
+
await runtime.plugin(SystemPrompt).await()
|
|
88
|
+
await runtime.plugin(ToolRuntime).await()
|
|
89
|
+
await runtime.plugin(AgentRegistry).await()
|
|
90
|
+
await runtime.plugin(AgentLoop).await()
|
|
91
|
+
await runtime.plugin(CommandRuntime).await()
|
|
92
|
+
await runtime.plugin(SessionProjectionRegistry).await()
|
|
93
|
+
await runtime.plugin(TokenMeter).await()
|
|
94
|
+
await runtime.plugin(MemorySettings).await()
|
|
95
|
+
await runtime.plugin(AgentPresets, {
|
|
96
|
+
default: 'standard',
|
|
97
|
+
roots: [{ path: presets, trust: 'system' }],
|
|
98
|
+
includeShippedRoot: false,
|
|
99
|
+
includeUserRoot: false,
|
|
100
|
+
})
|
|
101
|
+
await runtime.plugin({
|
|
102
|
+
apply: (selectorCtx) => {
|
|
103
|
+
apply(selectorCtx, { presetOverlay: true })
|
|
104
|
+
},
|
|
105
|
+
}).await()
|
|
106
|
+
ctx = runtime
|
|
107
|
+
return runtime
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function agentOn(runtime: Context, sessionId: string, preset: string): Promise<Agent> {
|
|
111
|
+
const handle = await runtime.agents.create({
|
|
112
|
+
sessionId: SessionId(sessionId),
|
|
113
|
+
setup: async agentCtx => void await runtime.agentPresets.mount(agentCtx, preset),
|
|
114
|
+
})
|
|
115
|
+
return handle.agent
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function hasCompressionRetrieve(runtime: Context, agent: Agent): boolean {
|
|
119
|
+
return runtime.tools.get('context_compression_retrieve', scopeOf(agent.ctx)) !== undefined
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function hasCompactCommand(runtime: Context, agent: Agent): boolean {
|
|
123
|
+
return runtime.commands.list(agent).some(command => command.name === 'compact')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function expectCompleteCompressionStack(runtime: Context, agent: Agent): void {
|
|
127
|
+
expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeDefined()
|
|
128
|
+
expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeDefined()
|
|
129
|
+
expect(hasCompressionRetrieve(runtime, agent)).toBe(true)
|
|
130
|
+
expect(hasCompactCommand(runtime, agent)).toBe(true)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function expectNoCompressionStack(runtime: Context, agent: Agent): void {
|
|
134
|
+
expect(runtime.agentPresets.serviceFor(agent, 'toolResultPruner')).toBeUndefined()
|
|
135
|
+
expect(runtime.agentPresets.serviceFor(agent, 'compaction')).toBeUndefined()
|
|
136
|
+
expect(hasCompressionRetrieve(runtime, agent)).toBe(false)
|
|
137
|
+
expect(hasCompactCommand(runtime, agent)).toBe(false)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
describe('standalone selector Bundle through the real preset Loader', () => {
|
|
141
|
+
it('mounts the complete stack without changing source preset authoring', async () => {
|
|
142
|
+
const runtime = await harness()
|
|
143
|
+
const source = await runtime.agentPresets.resolve('standard')
|
|
144
|
+
const sourceText = await runtime.agentPresets.read('standard')
|
|
145
|
+
|
|
146
|
+
const agent = await agentOn(runtime, 'selector-loader-standard', 'standard')
|
|
147
|
+
|
|
148
|
+
expectCompleteCompressionStack(runtime, agent)
|
|
149
|
+
expect((await runtime.agentPresets.resolve('standard')).path).toBe(source.path)
|
|
150
|
+
expect(await runtime.agentPresets.read('standard')).toBe(sourceText)
|
|
151
|
+
expect(sourceText).not.toContain('tool-result-pruner')
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('keeps compression across preset changes and excludes only exact Minimal', async () => {
|
|
155
|
+
const runtime = await harness()
|
|
156
|
+
const agent = await agentOn(runtime, 'selector-loader-switch', 'standard')
|
|
157
|
+
expectCompleteCompressionStack(runtime, agent)
|
|
158
|
+
|
|
159
|
+
await runtime.agentPresets.recompose(agent.ctx, 'minimal')
|
|
160
|
+
expectNoCompressionStack(runtime, agent)
|
|
161
|
+
|
|
162
|
+
// `custom` deliberately contains the same source rows as Minimal. Its id,
|
|
163
|
+
// not its copied contents, decides the one documented exception.
|
|
164
|
+
await runtime.agentPresets.recompose(agent.ctx, 'custom')
|
|
165
|
+
expectCompleteCompressionStack(runtime, agent)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('gives a child the parent\'s exact compression service instances', async () => {
|
|
169
|
+
const runtime = await harness()
|
|
170
|
+
const parent = await agentOn(runtime, 'selector-loader-parent', 'standard')
|
|
171
|
+
const childHandle = await runtime.agents.create({
|
|
172
|
+
sessionId: SessionId('selector-loader-child'),
|
|
173
|
+
setup: childCtx => void runtime.agentPresets.composeFrom(childCtx, parent.ctx),
|
|
174
|
+
})
|
|
175
|
+
const child = childHandle.agent
|
|
176
|
+
|
|
177
|
+
const parentPruner = runtime.agentPresets.serviceFor(parent, 'toolResultPruner')
|
|
178
|
+
const childPruner = runtime.agentPresets.serviceFor(child, 'toolResultPruner')
|
|
179
|
+
const parentCompaction = runtime.agentPresets.serviceFor(parent, 'compaction')
|
|
180
|
+
const childCompaction = runtime.agentPresets.serviceFor(child, 'compaction')
|
|
181
|
+
expect(parentPruner).toBeDefined()
|
|
182
|
+
expect(parentCompaction).toBeDefined()
|
|
183
|
+
expect(Object.is(
|
|
184
|
+
(childPruner as Traceable)[CORDIS_ORIGINAL],
|
|
185
|
+
(parentPruner as Traceable)[CORDIS_ORIGINAL],
|
|
186
|
+
)).toBe(true)
|
|
187
|
+
expect(Object.is(
|
|
188
|
+
(childCompaction as Traceable)[CORDIS_ORIGINAL],
|
|
189
|
+
(parentCompaction as Traceable)[CORDIS_ORIGINAL],
|
|
190
|
+
)).toBe(true)
|
|
191
|
+
expect(hasCompressionRetrieve(runtime, child)).toBe(true)
|
|
192
|
+
expect(hasCompactCommand(runtime, child)).toBe(true)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it('carries the daily Custom defaults on the bundle entry config schema', async () => {
|
|
196
|
+
// 0.1.7: there is no plugin-owned settings row publishing defaults — the
|
|
197
|
+
// volatile `settings` field's schema defaults ARE the daily Custom doc the
|
|
198
|
+
// loader resolves into every composition.
|
|
199
|
+
const settings = (Config({ presetOverlay: true }).settings as unknown as {
|
|
200
|
+
get(): CustomSettings
|
|
201
|
+
}).get()
|
|
202
|
+
|
|
203
|
+
expect(settings.custom.history.trigger).toBe(500_000)
|
|
204
|
+
expect(settings.custom.tailTrim).toEqual({ enabled: false, trigger: 700_000 })
|
|
205
|
+
})
|
|
206
|
+
})
|
|
@@ -19,9 +19,9 @@ describe('standalone package contract', () => {
|
|
|
19
19
|
expect(Object.keys(selector.peerDependencies ?? {})).not.toContain('dsh-context-compression-improved-runtime')
|
|
20
20
|
expect(Object.keys(selector.peerDependencies ?? {})).not.toContain('@deepseek-ai/dsh-compaction-tool-result-pruner')
|
|
21
21
|
expect(selector.peerDependencies?.['@deepseek-ai/dsh-compaction-basic'])
|
|
22
|
-
.toBe('>=0.1.
|
|
22
|
+
.toBe('>=0.1.7-rc.1 <0.2.0-0')
|
|
23
23
|
expect(selector.peerDependencies?.['@deepseek-ai/dsh-command-compact'])
|
|
24
|
-
.toBe('>=0.1.
|
|
24
|
+
.toBe('>=0.1.7-rc.1 <0.2.0-0')
|
|
25
25
|
expect(selector.publishConfig?.tag).toBe('latest')
|
|
26
26
|
expect(existsSync(resolve(root, '../runtime/package.json'))).toBe(false)
|
|
27
27
|
})
|
|
@@ -31,6 +31,7 @@ import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
|
|
|
31
31
|
import TokenMeter from '@deepseek-ai/dsh-token-meter'
|
|
32
32
|
import ToolRuntime from '@deepseek-ai/dsh-tools'
|
|
33
33
|
import * as SelectorHost from '../../src/index.ts'
|
|
34
|
+
import { LegacyNamespaceRegistrar } from '../helpers/legacy-namespace.ts'
|
|
34
35
|
import ToolResultPruner, {
|
|
35
36
|
CONTEXT_COMPRESSION_SETTINGS_NAMESPACE,
|
|
36
37
|
} from '../../src/pruner.ts'
|
|
@@ -135,7 +136,7 @@ function appendToolTurn(session: Session, turn: number, text: string): void {
|
|
|
135
136
|
*/
|
|
136
137
|
async function gatedSettings(ctx: Context): Promise<void> {
|
|
137
138
|
await ctx.plugin(TestSettings).await()
|
|
138
|
-
await ctx.plugin(
|
|
139
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
139
140
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
140
141
|
profile: 'tokenpilot-inspired',
|
|
141
142
|
presetOptions: { reviewMode: true, reviewHighImpactTokens: 1 },
|
|
@@ -207,7 +208,7 @@ describe('advice never withholds (retired review gate)', () => {
|
|
|
207
208
|
it('keeps the automatic path identical when no legacy gate key is present', async () => {
|
|
208
209
|
const ctx = await runtimeContext()
|
|
209
210
|
await ctx.plugin(TestSettings).await()
|
|
210
|
-
await ctx.plugin(
|
|
211
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
211
212
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
212
213
|
profile: 'tokenpilot-inspired',
|
|
213
214
|
})
|
|
@@ -36,6 +36,7 @@ import ToolRuntime from '@deepseek-ai/dsh-tools'
|
|
|
36
36
|
import { CompactionId } from '@deepseek-ai/dsh-compaction'
|
|
37
37
|
import InvariantRegistry from '@deepseek-ai/dsh-invariants'
|
|
38
38
|
import * as SelectorHost from '../../../src/index.ts'
|
|
39
|
+
import { LegacyNamespaceRegistrar } from '../../helpers/legacy-namespace.ts'
|
|
39
40
|
import * as RuntimeInvariant from '../../../src/invariant.ts'
|
|
40
41
|
import { sessionEvents } from '../../../src/runtime/session-events.ts'
|
|
41
42
|
import ToolResultPruner, {
|
|
@@ -424,7 +425,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
424
425
|
// replacement → audit record) without ever touching the replacement text.
|
|
425
426
|
const ctx = await runtimeContext()
|
|
426
427
|
await ctx.plugin(TestSettings).await()
|
|
427
|
-
await ctx.plugin(
|
|
428
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
428
429
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
429
430
|
profile: 'balanced',
|
|
430
431
|
codeSkeleton: { enabled: true },
|
|
@@ -589,7 +590,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
589
590
|
it('moves the capacity-pressure gate with the frozen Auto Compact threshold', async () => {
|
|
590
591
|
const ctx = await runtimeContext()
|
|
591
592
|
await ctx.plugin(TestSettings).await()
|
|
592
|
-
await ctx.plugin(
|
|
593
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
593
594
|
const audit = captureAudit(ctx)
|
|
594
595
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
595
596
|
|
|
@@ -625,7 +626,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
625
626
|
it('ages History earlier when the frozen Auto Compact threshold is low', async () => {
|
|
626
627
|
const ctx = await runtimeContext()
|
|
627
628
|
await ctx.plugin(TestSettings).await()
|
|
628
|
-
await ctx.plugin(
|
|
629
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
629
630
|
const audit = captureAudit(ctx)
|
|
630
631
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
631
632
|
|
|
@@ -659,7 +660,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
659
660
|
it('freezes the generation-owned threshold over later global settings changes', async () => {
|
|
660
661
|
const ctx = await runtimeContext()
|
|
661
662
|
await ctx.plugin(TestSettings).await()
|
|
662
|
-
await ctx.plugin(
|
|
663
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
663
664
|
const audit = captureAudit(ctx)
|
|
664
665
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
665
666
|
// The preset overlay captured 70% into this generation's deployment
|
|
@@ -695,7 +696,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
695
696
|
it('fails open to a lossless frozen policy when stored settings are malformed', async () => {
|
|
696
697
|
const ctx = await runtimeContext()
|
|
697
698
|
await ctx.plugin(TestSettings).await()
|
|
698
|
-
await ctx.plugin(
|
|
699
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
699
700
|
const audit = captureAudit(ctx)
|
|
700
701
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
701
702
|
// A hand-edited store can surface a document the schema rejects (unknown
|
|
@@ -745,7 +746,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
745
746
|
])('fails open to a lossless frozen policy when the stored document carries %s', async (label, malformed) => {
|
|
746
747
|
const ctx = await runtimeContext()
|
|
747
748
|
await ctx.plugin(TestSettings).await()
|
|
748
|
-
await ctx.plugin(
|
|
749
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
749
750
|
const audit = captureAudit(ctx)
|
|
750
751
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
751
752
|
// Schemastery `.default(...)` would silently replace these present-but-null
|
|
@@ -782,7 +783,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
782
783
|
|
|
783
784
|
const ctx = await runtimeContext()
|
|
784
785
|
await ctx.plugin(TestSettings).await()
|
|
785
|
-
await ctx.plugin(
|
|
786
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
786
787
|
const audit = captureAudit(ctx)
|
|
787
788
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
788
789
|
const malformed = {
|
|
@@ -882,7 +883,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
882
883
|
it('audits the Auto Compact coordination block on policy resolution', async () => {
|
|
883
884
|
const ctx = await runtimeContext()
|
|
884
885
|
await ctx.plugin(TestSettings).await()
|
|
885
|
-
await ctx.plugin(
|
|
886
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
886
887
|
const audit = captureAudit(ctx)
|
|
887
888
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
888
889
|
await ctx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
|
|
@@ -919,6 +920,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
919
920
|
const overrideCtx = await runtimeContext()
|
|
920
921
|
await overrideCtx.plugin(TestSettings).await()
|
|
921
922
|
await overrideCtx.plugin(SelectorHost).await()
|
|
923
|
+
await overrideCtx.plugin(LegacyNamespaceRegistrar).await()
|
|
922
924
|
const overrideAudit = captureAudit(overrideCtx)
|
|
923
925
|
await overrideCtx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
|
|
924
926
|
await overrideCtx.plugin(ToolResultPruner, {
|
|
@@ -944,6 +946,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
944
946
|
const mixedCtx = await runtimeContext()
|
|
945
947
|
await mixedCtx.plugin(TestSettings).await()
|
|
946
948
|
await mixedCtx.plugin(SelectorHost).await()
|
|
949
|
+
await mixedCtx.plugin(LegacyNamespaceRegistrar).await()
|
|
947
950
|
const mixedAudit = captureAudit(mixedCtx)
|
|
948
951
|
await mixedCtx.settings.update(namespace, { autoCompact: { thresholdPercent: 73 } })
|
|
949
952
|
await mixedCtx.plugin(ToolResultPruner, {
|
|
@@ -979,7 +982,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
979
982
|
it('freezes the Auto Compact threshold per Session and applies new values only to new Sessions', async () => {
|
|
980
983
|
const ctx = await runtimeContext()
|
|
981
984
|
await ctx.plugin(TestSettings).await()
|
|
982
|
-
await ctx.plugin(
|
|
985
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
983
986
|
const audit = captureAudit(ctx)
|
|
984
987
|
const namespace = nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE)
|
|
985
988
|
await ctx.plugin(ToolResultPruner, { profile: 'balanced' }).await()
|
|
@@ -1503,7 +1506,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1503
1506
|
it('still commits unlinked Custom History batches at the minimum reclaim', async () => {
|
|
1504
1507
|
const ctx = await runtimeContext()
|
|
1505
1508
|
await ctx.plugin(TestSettings).await()
|
|
1506
|
-
await ctx.plugin(
|
|
1509
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1507
1510
|
const audit = captureAudit(ctx)
|
|
1508
1511
|
// A protected token tail larger than the trigger leaves the linked-style
|
|
1509
1512
|
// whole-excess demand unreachable; Custom stays manual and must still
|
|
@@ -1689,7 +1692,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1689
1692
|
const ctx = new Context()
|
|
1690
1693
|
activeContexts.push(ctx)
|
|
1691
1694
|
await ctx.plugin(TestSettings).await()
|
|
1692
|
-
await ctx.plugin(
|
|
1695
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1693
1696
|
await ctx.plugin(SessionStore).await()
|
|
1694
1697
|
await ctx.plugin(SystemPrompt).await()
|
|
1695
1698
|
await ctx.plugin(ToolRuntime).await()
|
|
@@ -1751,7 +1754,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1751
1754
|
const ctx = new Context()
|
|
1752
1755
|
activeContexts.push(ctx)
|
|
1753
1756
|
await ctx.plugin(TestSettings).await()
|
|
1754
|
-
await ctx.plugin(
|
|
1757
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1755
1758
|
await ctx.plugin(SessionStore).await()
|
|
1756
1759
|
await ctx.plugin(SystemPrompt).await()
|
|
1757
1760
|
await ctx.plugin(ToolRuntime).await()
|
|
@@ -1848,7 +1851,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1848
1851
|
const ctx = new Context()
|
|
1849
1852
|
activeContexts.push(ctx)
|
|
1850
1853
|
await ctx.plugin(TestSettings).await()
|
|
1851
|
-
await ctx.plugin(
|
|
1854
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1852
1855
|
await ctx.plugin(SessionStore).await()
|
|
1853
1856
|
await ctx.plugin(SystemPrompt).await()
|
|
1854
1857
|
await ctx.plugin(ToolRuntime).await()
|
|
@@ -1941,7 +1944,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
1941
1944
|
const ctx = new Context()
|
|
1942
1945
|
activeContexts.push(ctx)
|
|
1943
1946
|
await ctx.plugin(TestSettings).await()
|
|
1944
|
-
await ctx.plugin(
|
|
1947
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
1945
1948
|
await ctx.plugin(SessionStore).await()
|
|
1946
1949
|
await ctx.plugin(InvariantRegistry).await()
|
|
1947
1950
|
await ctx.plugin(RuntimeInvariant).await()
|
|
@@ -2121,7 +2124,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
2121
2124
|
const ctx = new Context()
|
|
2122
2125
|
activeContexts.push(ctx)
|
|
2123
2126
|
await ctx.plugin(TestSettings).await()
|
|
2124
|
-
await ctx.plugin(
|
|
2127
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
2125
2128
|
await ctx.plugin(LlmRuntime).await()
|
|
2126
2129
|
await ctx.plugin(SessionStore).await()
|
|
2127
2130
|
await ctx.plugin(SystemPrompt).await()
|
|
@@ -2568,7 +2571,7 @@ describe('standalone runtime on published Harness APIs', () => {
|
|
|
2568
2571
|
it('never TailTrims a tool group whose results carry images', async () => {
|
|
2569
2572
|
const ctx = await runtimeContext()
|
|
2570
2573
|
await ctx.plugin(TestSettings).await()
|
|
2571
|
-
await ctx.plugin(
|
|
2574
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
2572
2575
|
const audit = captureAudit(ctx)
|
|
2573
2576
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
2574
2577
|
profile: 'custom',
|
|
@@ -2660,7 +2663,7 @@ describe('character basis / model-id independence', () => {
|
|
|
2660
2663
|
async function characterBasisContext(): Promise<Context> {
|
|
2661
2664
|
const ctx = await runtimeContext()
|
|
2662
2665
|
await ctx.plugin(TestSettings).await()
|
|
2663
|
-
await ctx.plugin(
|
|
2666
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
2664
2667
|
await ctx.settings.update(nsBrand(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE), {
|
|
2665
2668
|
profile: 'balanced',
|
|
2666
2669
|
codeSkeleton: { enabled: true },
|