test: cover projection-aware session helpers

This commit is contained in:
_Kerman committed 2026-08-26 18:10:52 +08:00
1 parent 4c9fb910b1
commit bfb119850b
2 files changed
+17

No files matched your search

@@ -17,6 +17,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
import ToolRuntime from '@deepseek-ai/dsh-tools'
import AgentRegistry, { type Agent } from '@deepseek-ai/dsh-agent'
import AgentLoop from '@deepseek-ai/dsh-agent-loop'
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
import { TypertRemoteFailure, type RemoteFailure } from '@deepseek-ai/dsh-typert-protocol'
import { afterEach, describe, expect, it, vi } from 'vitest'
import AgentPresets, { COMPOSITION_FILE, METADATA_FILE } from '@deepseek-ai/dsh-agent-presets'
@@ -72,6 +73,7 @@ async function harness(
ctx.loader.builtins.include = Include
await ctx.plugin(LlmRuntime)
await ctx.plugin(SessionStore)
await ctx.plugin(SessionProjectionRegistry)
await ctx.plugin(SystemPrompt, { persona: '' })
await ctx.plugin(ToolRuntime)
await ctx.plugin(AgentRegistry)
@@ -89,6 +89,21 @@ describe('SessionObservationReader', () => {
await ctx.fiber.dispose()
})
it('omits prepared projections when the registry is absent', async () => {
const ctx = new Context()
await ctx.plugin(SessionStore)
const meta = header('prepared-without-projections')
ctx.provide('sessionPersistence', {
borrowSession: () => Promise.resolve(preparedSource(meta)),
} as never)
using observed = await new SessionObservationReader(ctx).read(meta.id)
expect(observed.source).toBe('prepared')
expect(observed.projections).toBeUndefined()
await ctx.fiber.dispose()
})
it('reference-counts prepared leases and rejects retention after disposal', async () => {
const ctx = new Context()
await ctx.plugin(SessionStore)