Files
Ncurator/tests/case/unit/message-log-annotations.test.ts
Yoan Huang 5803e78033 refactor(ai): drop discard/run-digest/scope-decision, keep cache+compaction
Remove context-scope decision, partner/run digest paths, and related tests/docs.
Human history projection now floors on compaction checkpoints only.
Live continuation/resume/compaction cases passed on qwen3.8-flash; compaction live scored 90 in ai-test.md.
2026-09-12 13:57:14 +08:00

54 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import type { ChatMessageLogRecord } from '../../../src/shared/types'
import { snapshotMessageLogBookmarks } from '../../harness/backend/messageLogAnnotations'
const record = (
seq: number,
entry: ChatMessageLogRecord['entry']
): ChatMessageLogRecord => ({
id: `id-${seq}`,
partnerId: 'partner-a',
runId: 'run-a',
seq,
entry,
createdAt: seq
})
describe('message log annotation snapshots', () => {
it('keeps compaction bookmarks without prompt text', () => {
const snapshots = snapshotMessageLogBookmarks([
record(1, { kind: 'user', content: 'hello', input: 'hello', context: { selectedReferences: [], attachments: [] } }),
record(2, {
kind: 'annotation',
eventType: 'compaction_checkpoint',
payload: {
compactBlockId: 'c1',
throughSeq: 1,
sourceMessageCount: 4,
summary: '## 目标\n写周报'
}
}),
record(3, {
kind: 'annotation',
eventType: 'plan_updated',
payload: { plan: [{ title: '写周报', status: 'done' }] }
})
])
expect(snapshots).toEqual([
{
partnerId: 'partner-a',
seq: 2,
runId: 'run-a',
createdAt: 2,
eventType: 'compaction_checkpoint',
throughSeq: 1,
compactBlockId: 'c1',
sourceMessageCount: 4,
summaryChars: '## 目标\n写周报'.length
}
])
expect(JSON.stringify(snapshots)).not.toContain('写周报')
})
})