dsh-context-compression-improved 0.5.6 → 0.6.1
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 +9 -11
- 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 +21 -21
- 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 +37 -34
- 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 +12 -12
- package/packages/selector/tests/preset-options-write.client.spec.ts +63 -82
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +9 -4
- 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 +7 -0
|
@@ -6,82 +6,61 @@ import type { CompressionSelectorInjected } from '../src/client/CompressionProfi
|
|
|
6
6
|
import type { ContextCompressionSettings } from '../src/profiles.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* 0.1.7 contract: the compression document rides the entry config as ONE
|
|
10
|
+
* volatile whole-object field, so every write commits the full document
|
|
11
|
+
* through `configForms.set('settings', doc)`. The sibling-safety that the old
|
|
12
|
+
* path-addressed settings service provided is now enforced CLIENT-side:
|
|
13
|
+
* `planPresetOptionsOps` is still computed against the current doc and applied
|
|
14
|
+
* locally before the commit, so a second field write never erases the first.
|
|
13
15
|
*/
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
readonly
|
|
17
|
+
interface FormStub {
|
|
18
|
+
form: Record<string, unknown>
|
|
19
|
+
/** Whole-doc commits the fake Host accepted. */
|
|
20
|
+
readonly commits: Record<string, unknown>[]
|
|
21
|
+
/** Whole-doc writes the fake Host refused. */
|
|
22
|
+
readonly refused: Record<string, unknown>[]
|
|
19
23
|
readonly snapshot: () => Record<string, unknown>
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
function createScopeStub(initial: ContextCompressionSettings, commit = true): ScopeStub {
|
|
26
|
+
function createFormStub(initial: ContextCompressionSettings, commit = true): FormStub {
|
|
24
27
|
let revision = 1
|
|
25
|
-
let value: Record<string, unknown> = structuredClone(initial) as unknown as Record<string, unknown>
|
|
26
|
-
const
|
|
28
|
+
let value: Record<string, unknown> = { settings: structuredClone(initial) as unknown as Record<string, unknown> }
|
|
29
|
+
const commits: Record<string, unknown>[] = []
|
|
30
|
+
const refused: Record<string, unknown>[] = []
|
|
27
31
|
const listeners = new Set<() => void>()
|
|
28
|
-
const applyOps = (ops: readonly PathOp[]): void => {
|
|
29
|
-
for (const op of ops) {
|
|
30
|
-
const [head, ...rest] = op.path
|
|
31
|
-
if (head === undefined) continue
|
|
32
|
-
if (rest.length === 0) {
|
|
33
|
-
if (op.op === 'set') value = { ...value, [head]: op.value }
|
|
34
|
-
else delete value[head]
|
|
35
|
-
continue
|
|
36
|
-
}
|
|
37
|
-
const child = { ...(value[head] as Record<string, unknown> | undefined) }
|
|
38
|
-
const leaf = rest[rest.length - 1] as string
|
|
39
|
-
if (op.op === 'set') child[leaf] = op.value
|
|
40
|
-
else delete child[leaf]
|
|
41
|
-
value = { ...value, [head]: child }
|
|
42
|
-
}
|
|
43
|
-
revision += 1
|
|
44
|
-
for (const listener of listeners) listener()
|
|
45
|
-
}
|
|
46
32
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
commits,
|
|
34
|
+
refused,
|
|
35
|
+
snapshot: () => structuredClone(value.settings as Record<string, unknown>),
|
|
36
|
+
form: {
|
|
51
37
|
getSnapshot: () => ({
|
|
52
|
-
status: 'ready',
|
|
53
|
-
value: value as unknown as
|
|
54
|
-
base: undefined,
|
|
55
|
-
user: undefined,
|
|
38
|
+
status: 'ready' as const,
|
|
39
|
+
value: value as unknown as Record<string, unknown>,
|
|
56
40
|
revision,
|
|
57
41
|
writable: true,
|
|
58
|
-
|
|
42
|
+
base: undefined,
|
|
43
|
+
user: undefined,
|
|
44
|
+
mode: 'host' as const,
|
|
59
45
|
}),
|
|
60
46
|
subscribe: (listener: () => void) => {
|
|
61
47
|
listeners.add(listener)
|
|
62
48
|
return () => { listeners.delete(listener) }
|
|
63
49
|
},
|
|
64
|
-
set: (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return Promise.resolve()
|
|
75
|
-
},
|
|
76
|
-
mutate: (ops: readonly PathOp[]) => {
|
|
77
|
-
writes.push([...ops])
|
|
78
|
-
// A refused or lost write changes no document, so the revision the
|
|
79
|
-
// confirmation read fences on never moves.
|
|
80
|
-
if (commit) applyOps(ops)
|
|
81
|
-
return Promise.resolve()
|
|
50
|
+
set: (_field: string, doc: unknown) => {
|
|
51
|
+
if (!commit) {
|
|
52
|
+
refused.push(doc as Record<string, unknown>)
|
|
53
|
+
return Promise.resolve(false)
|
|
54
|
+
}
|
|
55
|
+
value = { settings: structuredClone(doc) as unknown as Record<string, unknown> }
|
|
56
|
+
revision += 1
|
|
57
|
+
commits.push({ settings: structuredClone(doc) as unknown as Record<string, unknown> })
|
|
58
|
+
for (const listener of listeners) listener()
|
|
59
|
+
return Promise.resolve(true)
|
|
82
60
|
},
|
|
61
|
+
unset: () => Promise.resolve(false),
|
|
83
62
|
},
|
|
84
|
-
} as
|
|
63
|
+
} as FormStub & { form: Record<string, unknown> }
|
|
85
64
|
}
|
|
86
65
|
|
|
87
66
|
const DEFAULT_CUSTOM = {
|
|
@@ -91,7 +70,7 @@ const DEFAULT_CUSTOM = {
|
|
|
91
70
|
aggregate: { enabled: true, trigger: 16_384, target: 8_192 },
|
|
92
71
|
history: {
|
|
93
72
|
enabled: true,
|
|
94
|
-
trigger:
|
|
73
|
+
trigger: 16_384,
|
|
95
74
|
keepRecentTurns: 2,
|
|
96
75
|
keepRecent: 16_384,
|
|
97
76
|
minReclaim: 8_192,
|
|
@@ -104,8 +83,7 @@ function bindInjected(
|
|
|
104
83
|
commit = true,
|
|
105
84
|
): {
|
|
106
85
|
injected: CompressionSelectorInjected
|
|
107
|
-
|
|
108
|
-
snapshot: () => Record<string, unknown>
|
|
86
|
+
stub: FormStub
|
|
109
87
|
} {
|
|
110
88
|
const settings: ContextCompressionSettings = {
|
|
111
89
|
profile: 'tokenpilot-inspired',
|
|
@@ -114,7 +92,7 @@ function bindInjected(
|
|
|
114
92
|
codeSkeleton: { enabled: false },
|
|
115
93
|
...(presetOptions === undefined ? {} : { presetOptions }),
|
|
116
94
|
}
|
|
117
|
-
const stub =
|
|
95
|
+
const stub = createFormStub(settings, commit)
|
|
118
96
|
let options: Record<string, unknown> | undefined
|
|
119
97
|
const ctx = {
|
|
120
98
|
slots: {
|
|
@@ -130,26 +108,26 @@ function bindInjected(
|
|
|
130
108
|
},
|
|
131
109
|
},
|
|
132
110
|
// apply consumes the services through their declarative-inject faces
|
|
133
|
-
// (ctx.locale / ctx.
|
|
111
|
+
// (ctx.locale / ctx.configForms), the same shape cordis binds on the host.
|
|
134
112
|
locale: { bind: () => (key: string) => key, register: () => {} },
|
|
135
|
-
|
|
113
|
+
configForms: { get: () => (stub.form as unknown as { getSnapshot(): unknown }) },
|
|
136
114
|
}
|
|
137
115
|
apply(ctx as never)
|
|
138
116
|
if (options === undefined) throw new Error('the settings card never registered')
|
|
139
117
|
const factory = options['inject'] as () => CompressionSelectorInjected
|
|
140
|
-
return { injected: factory(),
|
|
118
|
+
return { injected: factory(), stub }
|
|
141
119
|
}
|
|
142
120
|
|
|
143
|
-
describe('presetOptions writes
|
|
121
|
+
describe('presetOptions writes commit the whole doc through configForms', () => {
|
|
144
122
|
it('keeps the estimator channel when a provider is chosen afterwards', async () => {
|
|
145
|
-
const { injected,
|
|
123
|
+
const { injected, stub } = bindInjected({ estimatorMode: 'host' })
|
|
146
124
|
await injected.savePresetOptions({ estimatorProvider: 'local-35b' })
|
|
147
|
-
expect(snapshot()['presetOptions']).toEqual({ estimatorMode: 'host', estimatorProvider: 'local-35b' })
|
|
148
|
-
expect(
|
|
125
|
+
expect(stub.snapshot()['presetOptions']).toEqual({ estimatorMode: 'host', estimatorProvider: 'local-35b' })
|
|
126
|
+
expect(stub.commits.length).toBe(1)
|
|
149
127
|
})
|
|
150
128
|
|
|
151
129
|
it('treats a retired review-gate patch as a no-op instead of a write', async () => {
|
|
152
|
-
const { injected,
|
|
130
|
+
const { injected, stub } = bindInjected({ estimatorMode: 'host' })
|
|
153
131
|
// The patch surface no longer carries these keys, and the decoders accept
|
|
154
132
|
// them only so a legacy document keeps loading. Cast past the removed type
|
|
155
133
|
// so the test pins the RUNTIME behaviour: nothing is written.
|
|
@@ -159,12 +137,12 @@ describe('presetOptions writes are path-addressed', () => {
|
|
|
159
137
|
cacheHitDiscountAlpha: 0.2,
|
|
160
138
|
reviewHighImpactTokens: 6000,
|
|
161
139
|
} as unknown as Parameters<typeof injected.savePresetOptions>[0])
|
|
162
|
-
expect(
|
|
163
|
-
expect(snapshot()['presetOptions']).toEqual({ estimatorMode: 'host' })
|
|
140
|
+
expect(stub.commits.length).toBe(0)
|
|
141
|
+
expect(stub.snapshot()['presetOptions']).toEqual({ estimatorMode: 'host' })
|
|
164
142
|
})
|
|
165
143
|
|
|
166
|
-
it('never
|
|
167
|
-
const { injected,
|
|
144
|
+
it('never loses sibling overrides across whole-doc commits', async () => {
|
|
145
|
+
const { injected, stub } = bindInjected({
|
|
168
146
|
estimatorMode: 'direct',
|
|
169
147
|
estimatorBaseUrl: 'http://192.168.100.242:8200',
|
|
170
148
|
dedupeToolResults: false,
|
|
@@ -172,7 +150,7 @@ describe('presetOptions writes are path-addressed', () => {
|
|
|
172
150
|
})
|
|
173
151
|
await injected.savePresetOptions({ estimatorModel: 'Qwen3.6-35B-A3B' })
|
|
174
152
|
await injected.savePresetOptions({ estimatorProvider: 'local-35b' })
|
|
175
|
-
expect(snapshot()['presetOptions']).toEqual({
|
|
153
|
+
expect(stub.snapshot()['presetOptions']).toEqual({
|
|
176
154
|
estimatorMode: 'direct',
|
|
177
155
|
estimatorBaseUrl: 'http://192.168.100.242:8200',
|
|
178
156
|
dedupeToolResults: false,
|
|
@@ -180,22 +158,25 @@ describe('presetOptions writes are path-addressed', () => {
|
|
|
180
158
|
estimatorModel: 'Qwen3.6-35B-A3B',
|
|
181
159
|
estimatorProvider: 'local-35b',
|
|
182
160
|
})
|
|
183
|
-
|
|
184
|
-
|
|
161
|
+
// Two user actions, two whole-doc commits.
|
|
162
|
+
expect(stub.commits.length).toBe(2)
|
|
163
|
+
for (const doc of stub.commits) {
|
|
164
|
+
// Each commit carries the complete document under the volatile field.
|
|
165
|
+
expect(Object.keys(doc)).toEqual(['settings'])
|
|
185
166
|
}
|
|
186
167
|
})
|
|
187
168
|
|
|
188
169
|
it('clears exactly the field a patch names with undefined', async () => {
|
|
189
|
-
const { injected,
|
|
170
|
+
const { injected, stub } = bindInjected({ estimatorMode: 'direct', estimatorApiKey: 'sk-stored' })
|
|
190
171
|
await injected.savePresetOptions({ estimatorApiKey: undefined })
|
|
191
|
-
expect(snapshot()['presetOptions']).toEqual({ estimatorMode: 'direct' })
|
|
192
|
-
expect(writes).toEqual([[{ op: 'unset', path: ['presetOptions', 'estimatorApiKey'] }]])
|
|
172
|
+
expect(stub.snapshot()['presetOptions']).toEqual({ estimatorMode: 'direct' })
|
|
193
173
|
})
|
|
194
174
|
|
|
195
175
|
it('writes nothing when the patch already matches the stored section', async () => {
|
|
196
|
-
const { injected,
|
|
176
|
+
const { injected, stub } = bindInjected({ estimatorMode: 'host', estimatorProvider: 'local-35b' })
|
|
197
177
|
await injected.savePresetOptions({ estimatorMode: 'host' })
|
|
198
|
-
expect(
|
|
178
|
+
expect(stub.commits.length).toBe(0)
|
|
179
|
+
expect(stub.refused.length).toBe(0)
|
|
199
180
|
})
|
|
200
181
|
|
|
201
182
|
it('reports a save the Host did not commit', async () => {
|
|
@@ -5,6 +5,7 @@ import { pathToFileURL } from 'node:url'
|
|
|
5
5
|
import { Context } from '@deepseek-ai/cordis'
|
|
6
6
|
import Group from '@deepseek-ai/cordis-plugin-group'
|
|
7
7
|
import Include from '@deepseek-ai/cordis-plugin-include'
|
|
8
|
+
import { Config } from '../src/index.ts'
|
|
8
9
|
import Loader from '@deepseek-ai/cordis-plugin-loader'
|
|
9
10
|
import AgentRegistry, { type Agent } from '@deepseek-ai/dsh-agent'
|
|
10
11
|
import AgentLoop from '@deepseek-ai/dsh-agent-loop'
|
|
@@ -23,6 +24,7 @@ import TokenMeter from '@deepseek-ai/dsh-token-meter'
|
|
|
23
24
|
import ToolRuntime from '@deepseek-ai/dsh-tools'
|
|
24
25
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
25
26
|
import { apply } from '../src/index.ts'
|
|
27
|
+
import { LegacyNamespaceRegistrar } from './helpers/legacy-namespace.ts'
|
|
26
28
|
|
|
27
29
|
// 0.1.5 removed the settingsNamespace() wrapper; namespaces are validated at runtime.
|
|
28
30
|
const nsBrand = (value: string): SettingsNamespace => value as unknown as SettingsNamespace
|
|
@@ -190,10 +192,13 @@ describe('standalone selector Bundle through the real preset Loader', () => {
|
|
|
190
192
|
expect(hasCompactCommand(runtime, child)).toBe(true)
|
|
191
193
|
})
|
|
192
194
|
|
|
193
|
-
it('
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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()
|
|
197
202
|
|
|
198
203
|
expect(settings.custom.history.trigger).toBe(500_000)
|
|
199
204
|
expect(settings.custom.tailTrim).toEqual({ enabled: false, trigger: 700_000 })
|
|
@@ -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 },
|
|
@@ -41,7 +41,7 @@ function collectRegistrations(
|
|
|
41
41
|
const registrations: CapturedRegistration[] = []
|
|
42
42
|
const ctx = {
|
|
43
43
|
locale: { register: vi.fn(() => () => {}), bind: () => (key: string) => key },
|
|
44
|
-
|
|
44
|
+
configForms: { get: vi.fn(() => ({}) as never) },
|
|
45
45
|
slots: {
|
|
46
46
|
inject: (slot: string, factory: () => (() => void) | Generator<() => void>) => {
|
|
47
47
|
declared.push(slot)
|
|
@@ -65,7 +65,7 @@ function collectRegistrations(
|
|
|
65
65
|
|
|
66
66
|
describe('settings-seat contract (standalone settings.section only)', () => {
|
|
67
67
|
it('declares the services apply consumes (cordis waits; no lazy-get race)', () => {
|
|
68
|
-
expect(inject).toEqual(['slots', 'locale', '
|
|
68
|
+
expect(inject).toEqual(['slots', 'locale', 'configForms'])
|
|
69
69
|
})
|
|
70
70
|
|
|
71
71
|
it('injects exactly the settings.section seat and nothing else', () => {
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
standingStampMs,
|
|
32
32
|
standingStampMsAtWindow,
|
|
33
33
|
} from '../src/preset-overlay.ts'
|
|
34
|
+
import { LegacyNamespaceRegistrar } from './helpers/legacy-namespace.ts'
|
|
34
35
|
import type {
|
|
35
36
|
CompressionModulePaths,
|
|
36
37
|
OverlayableAgentPresets,
|
|
@@ -223,6 +224,7 @@ async function assertStandingSwitch(
|
|
|
223
224
|
await ctx.plugin(SessionProjectionRegistry).await()
|
|
224
225
|
await ctx.plugin(TokenMeter).await()
|
|
225
226
|
await ctx.plugin(MemorySettings).await()
|
|
227
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
226
228
|
await ctx.plugin({ apply }).await()
|
|
227
229
|
await ctx.plugin(AgentPresets, {
|
|
228
230
|
default: 'standard',
|
|
@@ -393,6 +395,7 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
|
|
|
393
395
|
await ctx.plugin(SessionProjectionRegistry).await()
|
|
394
396
|
await ctx.plugin(TokenMeter).await()
|
|
395
397
|
await ctx.plugin(MemorySettings).await()
|
|
398
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
396
399
|
await ctx.plugin({ apply }).await()
|
|
397
400
|
await ctx.plugin(AgentPresets, {
|
|
398
401
|
default: 'standard',
|
|
@@ -458,6 +461,7 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
|
|
|
458
461
|
await ctx.plugin(SessionProjectionRegistry).await()
|
|
459
462
|
await ctx.plugin(TokenMeter).await()
|
|
460
463
|
await ctx.plugin(MemorySettings).await()
|
|
464
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
461
465
|
await ctx.plugin({ apply }).await()
|
|
462
466
|
await ctx.plugin(AgentPresets, {
|
|
463
467
|
default: 'standard',
|
|
@@ -545,6 +549,7 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
|
|
|
545
549
|
await ctx.plugin(SessionProjectionRegistry).await()
|
|
546
550
|
await ctx.plugin(TokenMeter).await()
|
|
547
551
|
await ctx.plugin(MemorySettings).await()
|
|
552
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
548
553
|
await ctx.plugin({ apply }).await()
|
|
549
554
|
await ctx.plugin(AgentPresets, {
|
|
550
555
|
default: 'standard',
|
|
@@ -611,6 +616,7 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
|
|
|
611
616
|
await ctx.plugin(SessionProjectionRegistry).await()
|
|
612
617
|
await ctx.plugin(TokenMeter).await()
|
|
613
618
|
await ctx.plugin(MemorySettings).await()
|
|
619
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
614
620
|
await ctx.plugin({ apply }).await()
|
|
615
621
|
await ctx.plugin(AgentPresets, {
|
|
616
622
|
default: 'standard',
|
|
@@ -658,6 +664,7 @@ describe('real AgentPresets standing generations with the overlay threshold', ()
|
|
|
658
664
|
await ctx.plugin(SessionProjectionRegistry).await()
|
|
659
665
|
await ctx.plugin(TokenMeter).await()
|
|
660
666
|
await ctx.plugin(MemorySettings).await()
|
|
667
|
+
await ctx.plugin(LegacyNamespaceRegistrar).await()
|
|
661
668
|
await ctx.plugin({ apply }).await()
|
|
662
669
|
await ctx.plugin(AgentPresets, {
|
|
663
670
|
default: 'standard',
|