dsh-context-compression-improved 0.9.9 → 0.10.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/CHANGELOG.md +5 -1
- package/CHANGELOG.zh.md +2 -0
- package/README.de.md +1 -1
- package/README.es.md +1 -1
- package/README.fr.md +1 -1
- package/README.it.md +1 -1
- package/README.ja.md +1 -1
- package/README.ko.md +1 -1
- package/README.md +2 -2
- package/README.ru.md +1 -1
- package/README.zh.md +2 -2
- package/package.json +6 -6
- package/packages/selector/dsh.plugin.json +2 -2
- package/packages/selector/lib/savings-integral.js +2 -0
- package/packages/selector/package.json +22 -22
- package/packages/selector/src/runtime/stats-sync.ts +5 -0
- package/packages/selector/tests/public/package-contract.client.spec.ts +4 -4
- package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +46 -46
- package/packages/selector/tests/runtime/monitor.spec.ts +3 -3
- package/packages/selector/tests/runtime/stats-backfill.spec.ts +22 -1
- package/scripts/hosts.mjs +1 -1
|
@@ -327,9 +327,9 @@ describe('drsTotalsFragment(浮窗三值 DRS 主源,每次全量重导)', () =>
|
|
|
327
327
|
const index = {
|
|
328
328
|
sessionId: 's1', basis: 'ds-token', syncedAt: 'x', maxSeq: 100, turnCount: 2, segments: 5, turns: [],
|
|
329
329
|
pairs: [
|
|
330
|
-
{ seq: 8, startSeq: 1, endSeq: 3, aTokens: 500, bTokens: 100, kind: 'compress' as const, turn: 1, step: 1 },
|
|
331
|
-
{ seq: 20, startSeq: 12, endSeq: 14, aTokens: 300, bTokens: 40, kind: 'compress' as const, turn: 1, step: 2 },
|
|
332
|
-
{ seq: 30, startSeq: 18, endSeq: 18, aTokens: 0, bTokens: 60, kind: 'recall' as const, turn: 2, step: 1 },
|
|
330
|
+
{ seq: 8, startSeq: 1, endSeq: 3, aTokens: 500, bTokens: 100, kind: 'compress' as const, turn: 1, step: 1, live: 1 as const },
|
|
331
|
+
{ seq: 20, startSeq: 12, endSeq: 14, aTokens: 300, bTokens: 40, kind: 'compress' as const, turn: 1, step: 2, live: 1 as const },
|
|
332
|
+
{ seq: 30, startSeq: 18, endSeq: 18, aTokens: 0, bTokens: 60, kind: 'recall' as const, turn: 2, step: 1, live: 1 as const },
|
|
333
333
|
],
|
|
334
334
|
}
|
|
335
335
|
|
|
@@ -15,7 +15,8 @@ import { join } from 'node:path'
|
|
|
15
15
|
import { DatabaseSync } from 'node:sqlite'
|
|
16
16
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
17
17
|
import zlib from 'node:zlib'
|
|
18
|
-
import { StatsStore, openStatsDatabase } from '../../src/runtime/stats-db.ts'
|
|
18
|
+
import { StatsStore, openStatsDatabase, ensureStatsStore, closeStatsStore } from '../../src/runtime/stats-db.ts'
|
|
19
|
+
import { claimFromLand } from '../../src/runtime/stats-sync.ts'
|
|
19
20
|
import {
|
|
20
21
|
backfillViaSessionFiles,
|
|
21
22
|
backfillViaSessionQuery,
|
|
@@ -186,6 +187,26 @@ describe('stats-backfill 双后端一致性与幂等(T23)', () => {
|
|
|
186
187
|
bag.store.close()
|
|
187
188
|
})
|
|
188
189
|
|
|
190
|
+
it('护栏自 land 点生效(审查 M2 回归):claimFromLand 后无 usage 也拦停回填双计', async () => {
|
|
191
|
+
const feed = buildFeed()
|
|
192
|
+
const dir = tempDir('land-guard')
|
|
193
|
+
const store = await ensureStatsStore(join(dir, 'stats.sqlite'))
|
|
194
|
+
if (store === null) throw new Error('no sqlite driver in this environment')
|
|
195
|
+
// 旧实现:此路径不写 sessions 行 → 回填以 component='projection' 另键双计;新实现 land 同点抢 source='live'。
|
|
196
|
+
claimFromLand({ sessionId: 's1', component: 'fresh', tokensBefore: 500, tokensAfter: 100, basis: 'characters', replacementSeq: 2 })
|
|
197
|
+
const res = await backfillViaSessionQuery(store, fakeSessionQuery(new Map([['s1', { version: 6, events: feed }]])))
|
|
198
|
+
expect(res.sessions).toBe(0)
|
|
199
|
+
expect(res.claimsAdded).toBe(0)
|
|
200
|
+
expect(res.skipped).toBe(1)
|
|
201
|
+
// claims 仅剩 live 那一条(投影零污染)
|
|
202
|
+
const rows = dumpClaims(join(dir, 'stats.sqlite'))
|
|
203
|
+
expect(rows).toHaveLength(1)
|
|
204
|
+
expect(rows[0]).toMatchObject({ kind: 'saving', component: 'fresh' })
|
|
205
|
+
const record = store.getSessionRecord('s1')
|
|
206
|
+
expect(record?.source).toBe('live')
|
|
207
|
+
closeStatsStore()
|
|
208
|
+
})
|
|
209
|
+
|
|
189
210
|
it('回填只读:会话源文件 mtime/size 与目录内容不因回填变化', async () => {
|
|
190
211
|
const feed = buildFeed()
|
|
191
212
|
const home = tempDir('readonly')
|
package/scripts/hosts.mjs
CHANGED