test(session-query): pin the persisted-corruption wrapping branch
The retired subagent list path was the only caller exercising inspectPersisted's corruption arm; cover it directly.
This commit is contained in:
parent
96e7c0496a
commit
ac1dffb809
1 changed files with 19 additions and 1 deletions
|
|
@ -3,7 +3,7 @@ import { describe, expect, it, vi } from 'vitest'
|
|||
import { Context, type Fiber } from 'cordis'
|
||||
import SessionStore, { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session'
|
||||
import type { SessionEvent, SessionHeader, SessionId as SessionIdType } from '@deepseek-ai/dsh-session'
|
||||
import SessionPersistence, { SessionPersistenceRevision } from '@deepseek-ai/dsh-session-persistence'
|
||||
import SessionPersistence, { SessionPersistenceCorruptionError, SessionPersistenceRevision } from '@deepseek-ai/dsh-session-persistence'
|
||||
import SessionQueryService, {
|
||||
SESSION_QUERY_DEFAULT_PERSISTED_INSPECT_CONCURRENCY,
|
||||
type SessionEventSurface,
|
||||
|
|
@ -1114,6 +1114,24 @@ describe('session-query exact reads', () => {
|
|||
await expect(ctx.sessionQuery.listEvents(SessionId('durable'))).rejects.toThrow(expectCode('SESSION_QUERY_PERSISTENCE_FAILED'))
|
||||
})
|
||||
|
||||
it('wraps persisted corruption as SESSION_QUERY_CORRUPT_SESSION with its cause preserved', async () => {
|
||||
const durable = header('durable-corrupt')
|
||||
TestPersistence.reset([{ meta: durable, events: eventLog() }])
|
||||
const ctx = await liveContext()
|
||||
await ctx.plugin(TestPersistence)
|
||||
const corruption = new SessionPersistenceCorruptionError(
|
||||
'stored prefix failed validation',
|
||||
{ cause: new Error('torn final record') },
|
||||
)
|
||||
TestPersistence.inspectFailure = corruption
|
||||
|
||||
await expect(ctx.sessionQuery.readSession(durable.id)).rejects.toMatchObject({
|
||||
code: 'SESSION_QUERY_CORRUPT_SESSION',
|
||||
message: `stored session "${durable.id}" is corrupt: stored prefix failed validation`,
|
||||
cause: corruption,
|
||||
})
|
||||
})
|
||||
|
||||
it('reports absent sessions, persisted load failures, and persisted header conflicts', async () => {
|
||||
const durable = header('durable')
|
||||
TestPersistence.reset([{ meta: durable, events: eventLog() }])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue