chore(session): scope history reader exemptions to tests

This commit is contained in:
_Kerman
2026-09-09 12:55:32 +08:00
parent 37abcb74c5
commit 8f986c8da6
170 changed files with 72 additions and 1070 deletions
@@ -625,7 +625,6 @@ describe('pressure measurement and retention', () => {
await expect(compactIfNeeded(compact, session, 'context-overflow')).resolves.toBeNull()
expect(session.surface.replaceGeneration).toBe(generation)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/start')).toBe(false)
})
@@ -647,7 +646,6 @@ describe('pressure measurement and retention', () => {
const compact = service(compactConfig, ctx)
const session = conversation(4, undefined, 'SYSTEM HEAD')
const [head, firstUser] = session.surface.nodes
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.eventAt(head!)?.type).toBe('system/message')
const range = selectCompactableRange(session, ctx.tokenMeter.measure(session), compactConfig.retainTokens!)
@@ -891,11 +889,9 @@ describe('optional model-free tool-result pruning', () => {
expect(await compactIfNeeded(compact, session)).not.toBeNull()
expect(compact.calls).toHaveLength(1)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const original = session.snapshotEvents().find(event => event.type === 'tool/result')
expect(original?.type === 'tool/result' && original.data.message.content[0].content[0])
.toEqual({ type: 'text', text: 'X'.repeat(3_000) })
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().filter(event =>
event.type === 'tool/result' && event.surfaceOp !== 'append')).toHaveLength(0)
})
@@ -922,7 +918,6 @@ describe('compaction region transaction', () => {
expect(result.shadowedTokenCount).toBeGreaterThan(0)
expect(compact.calls[0]).toMatchObject({ signal: SIGNAL })
expect(summarizedText(compact.calls[0]!.input)).toContain('fixture user 1')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const summary = session.snapshotEvents().findLast(event => event.type === 'compaction/summary')
expect(summary?.data).toMatchObject({
shadowedSeqs: result.shadowedSeqs,
@@ -939,7 +934,6 @@ describe('compaction region transaction', () => {
expect(head.content[0]?.type === 'text' ? head.content[0].text : '').toContain('<compacted-summary>')
expect(head.content.at(-1)).toEqual({ type: 'text', text: '</compacted-summary>' })
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const replay = Session.create(SessionId('replay'), session.snapshotEvents())
expect(replay.deriveMessages()).toEqual(session.deriveMessages())
})
@@ -964,7 +958,6 @@ describe('compaction region transaction', () => {
const compact = service()
const emptyHead = conversation(3, undefined, '')
const emptyNodes = emptyHead.surface.nodes
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(emptyHead.eventAt(emptyNodes[0]!)?.type).toBe('system/message')
await compact.compactRegion(emptyNodes[1]!, emptyNodes[2]!, agent(emptyHead, MODEL), SIGNAL)
expect(compact.calls[0]!.input.messages[0]).toMatchObject({ role: 'user' })
@@ -986,7 +979,6 @@ describe('compaction region transaction', () => {
.rejects.toThrow(/node 0 holds the system prompt/)
expect(session.surface.nodes).toEqual(nodes)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const end = session.snapshotEvents().findLast(event => event.type === 'compaction/end')
expect(end?.type === 'compaction/end' && end.data.error).toBeDefined()
})
@@ -1100,7 +1092,6 @@ describe('compaction region transaction', () => {
agent(session, MODEL),
)).rejects.toThrow('summary unavailable')
expect(session.surface.nodes).toEqual(before)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().findLast(event => event.type === 'compaction/end')?.data)
.toMatchObject({ error: 'summary unavailable' })
})
@@ -1115,7 +1106,6 @@ describe('compaction region transaction', () => {
nodes[2]!,
agent(session, MODEL),
)).rejects.toBe('plain failure')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().findLast(event => event.type === 'compaction/end')?.data)
.toMatchObject({ error: 'plain failure' })
})
@@ -1136,7 +1126,6 @@ describe('compaction region transaction', () => {
nodes[2]!,
agent(session, MODEL),
)).resolves.toMatchObject({ shadowedSeqs: nodes.slice(0, 3) })
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(true)
})
@@ -1156,7 +1145,6 @@ describe('compaction region transaction', () => {
nodes[2]!,
agent(session, MODEL),
)).rejects.toThrow(/session surface changed/)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(false)
})
@@ -1174,7 +1162,6 @@ describe('compaction region transaction', () => {
nodes[2]!,
agent(session, MODEL),
)).rejects.toThrow(/summary is not smaller/)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(false)
})
@@ -1448,7 +1435,6 @@ describe('default one-shot summarizer', () => {
const session = conversation(3, 'large history '.repeat(500))
const nodes = session.surface.nodes
await compact.compactRegion(nodes[0]!, nodes[3]!, agent(session, MODEL), SIGNAL)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().findLast(event => event.type === 'compaction/summary')?.data).toMatchObject({
summary: [{ type: 'text', text: 'routed summary' }],
llmStreamCall: true,
@@ -1575,7 +1561,6 @@ describe('automatic listener and loader composition', () => {
next: () => Promise<RequestErrorAction> = () => Promise.resolve(undefined),
): Promise<boolean> {
const failure: LlmFailure = { message: error.message, code: error.code ?? 'UNKNOWN' }
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const turn = owner.session.snapshotEvents().findLast(event => event.type === 'turn/start')?.data.turn ?? 1
return agentEvents(ctx, owner).waterfall(
'agent/request-error',
@@ -1596,12 +1581,10 @@ describe('automatic listener and loader composition', () => {
})
const pressured = conversation(4)
await preStep(ctx, agent(pressured, 'unconfigured-agent-fallback'))
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(pressured.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(true)
const small = conversation(1)
await preStep(ctx, agent(small, MODEL))
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(small.snapshotEvents().some(event => event.type === 'compaction/start')).toBe(false)
expect(compact.calls).toHaveLength(1)
})
@@ -1619,7 +1602,6 @@ describe('automatic listener and loader composition', () => {
.resolves.toEqual({ kind: 'enter', messages: [] })
expect(compactIfNeeded).not.toHaveBeenCalled()
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(pressured.snapshotEvents().some(event => event.type === 'compaction/start')).toBe(false)
})
@@ -1636,7 +1618,6 @@ describe('automatic listener and loader composition', () => {
await expect(preStep(ctx, agent(session, MODEL))).resolves.toEqual({ kind: 'enter', messages: [] })
expect(warnings).toContainEqual(expect.stringContaining('temporary failure'))
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(false)
})
@@ -1696,7 +1677,6 @@ describe('automatic listener and loader composition', () => {
expect(decision).toBe(true)
expect(session.surface.replaceGeneration).toBe(beforeGeneration + 1)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(true)
expect(session.surface.nodes).toContain(retainedSeq)
})
@@ -1716,7 +1696,6 @@ describe('automatic listener and loader composition', () => {
expect(await recover(ctx, agent(session, MODEL), overflow())).toBe(true)
expect(session.surface.replaceGeneration).toBe(1)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(false)
expect(compact.calls).toHaveLength(0)
})
@@ -1735,7 +1714,6 @@ describe('automatic listener and loader composition', () => {
const session = toolConversation()
expect(await recover(ctx, agent(session, MODEL), overflow())).toBe(true)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(true)
expect(compact.calls).toHaveLength(1)
expect(summarizedText(compact.calls[0]!.input)).toContain('tool result middle pruned')
@@ -1759,9 +1737,7 @@ describe('automatic listener and loader composition', () => {
expect(await recover(ctx, agent(session, MODEL), overflow())).toBe(true)
expect(session.surface.replaceGeneration).toBe(1)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().filter(event => event.type === 'tool/result')).toHaveLength(2)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().findLast(event => event.type === 'compaction/end')?.data)
.toMatchObject({ error: 'summary unavailable after prune' })
expect(warnings).toContainEqual(expect.stringContaining('retrying from the replacement surface'))
@@ -1964,11 +1940,9 @@ describe('automatic listener and loader composition', () => {
})
const session = conversation(4)
await preStep(ctx, agent(session, MODEL))
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const summaries = session.snapshotEvents().filter(event => event.type === 'compaction/summary').length
expect(summaries).toBe(1)
expect(await recover(ctx, agent(session, MODEL), overflow())).toBe(false)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().filter(event => event.type === 'compaction/summary')).toHaveLength(summaries)
})
@@ -1981,7 +1955,6 @@ describe('automatic listener and loader composition', () => {
})
const session = conversation(4)
await preStep(ctx, agent(session, MODEL))
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/start')).toBe(false)
expect(await recover(ctx, agent(session, MODEL), overflow())).toBe(false)
})
@@ -2014,7 +1987,6 @@ describe('automatic listener and loader composition', () => {
const session = conversation(4)
await preStep(ctx, agent(session, MODEL))
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/start')).toBe(false)
expect(await recover(ctx, agent(session, MODEL), overflow())).toBe(false)
})
@@ -2156,7 +2128,6 @@ describe('route-priced image pressure', () => {
const result = await compact.compactIfNeeded(agent(session), 'pressure', SIGNAL)
expect(result).not.toBeNull()
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const summaryEvent = session.snapshotEvents().find(event => event.type === 'compaction/summary')
expect(summaryEvent).toBeDefined()
const shadowedHeuristic = before.nodes
@@ -212,7 +212,6 @@ function overflowHistorySeed(): readonly SessionEvent[] {
session.append('step/end', { turn, step: 1 })
session.append('turn/end', { turn, reason: { kind: 'completed' } })
}
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
return session.snapshotEvents()
}
@@ -231,9 +230,7 @@ describe('CBR-001: a real-loop checkpoint is a valid boundary on both sides', ()
await waitForIdle(ctx, agent)
expect(agent.session.requestHeader()?.config.model).toBe('mock')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(agent.session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(true)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(agent.session.snapshotEvents().at(-1)).toMatchObject({
type: 'turn/end',
data: { reason: { kind: 'completed' } },
@@ -250,7 +247,6 @@ describe('CBR-001: a real-loop checkpoint is a valid boundary on both sides', ()
agent.followup(createUserMessage({ content: [{ type: 'text', text: 'do tool work' }], source: { kind: 'user' } }))
await waitForIdle(ctx, agent)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const events = agent.session.snapshotEvents()
const compactStart = events.find(event => event.type === 'compaction/start')
expect(compactStart).toBeDefined()
@@ -283,7 +279,6 @@ describe('CBR-001: a real-loop checkpoint is a valid boundary on both sides', ()
agent.followup(createUserMessage({ content: [{ type: 'text', text: 'do a long multi-step task' }], source: { kind: 'user' } }))
await waitForIdle(ctx, agent)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const events = agent.session.snapshotEvents()
// A compaction ran: at least one checkpoint landed on the surface.
const checkpoints = events.filter(
@@ -352,7 +347,6 @@ describe('token pressure after loop-admitted system prompts', () => {
prompt = nextPrompt
agent.followup(createUserMessage({ content: [{ type: 'text', text: 'question' }], source: { kind: 'user' } }))
await agent.whenIdle()
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(agent.session.snapshotEvents().at(-1)).toMatchObject({
type: 'turn/end', data: { reason: { kind: 'completed' } },
})
@@ -360,13 +354,11 @@ describe('token pressure after loop-admitted system prompts', () => {
expect(measured.baseline).toEqual({ kind: 'usage', tokens: 1110, usage })
expect(measured.surfaceDeltaTokens).toBe(0)
expect(measured.totalTokens).toBe(1110)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const replay = Session.create(SessionId('prompt-pressure-replay'), agent.session.snapshotEvents())
expect(ctx.tokenMeter.measure(replay)).toMatchObject({
baseline: measured.baseline, surfaceDeltaTokens: 0, totalTokens: 1110, nodes: measured.nodes,
})
}
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const events = agent.session.snapshotEvents()
const prompts = events.filter(event => event.type === 'system/message')
expect(prompts[0]?.surfaceOp).toBe('append')
@@ -436,7 +428,6 @@ describe('context-overflow recovery across the real loop and compaction-basic',
expect(retry).toContain('RECOVERY CHECKPOINT')
expect(retry).not.toContain('OLD HISTORY SENTINEL')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const events = agent.session.snapshotEvents()
const stepStart = events.find(event =>
event.type === 'step/start' && event.data.turn === 3 && event.data.step === 1,
@@ -499,13 +490,10 @@ describe('context-overflow recovery across the real loop and compaction-basic',
expect(adapter.conversationRequests).toHaveLength(3)
expect(adapter.summaryRequests).toHaveLength(1)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(agent.session.snapshotEvents().filter(event => event.type === 'llm/retry').map(event => event.data))
.toEqual([expect.objectContaining({ turn: 3, step: 1, retry: 1, failure: { message: 'temporary provider outage', code: 'SERVER' } })])
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(agent.session.snapshotEvents().filter(event => event.type === 'turn/start').slice(-1).map(event => event.data.turn))
.toEqual([3])
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(agent.session.snapshotEvents().at(-1)).toMatchObject({
type: 'turn/end',
data: { reason: { kind: 'completed' } },
@@ -233,7 +233,6 @@ function detachedService(): { ctx: Context; compact: GatedCompactionEngine; flus
}
function compactEvents(session: Session): SessionEvent[] {
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
return session.snapshotEvents().filter(event => event.type.startsWith('compaction/'))
}
@@ -296,16 +295,13 @@ describe('compactNow through the real loop', () => {
const result = await compact.compactNow(agent, SIGNAL)
expect(result).not.toBeNull()
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const start = agent.session.snapshotEvents().findLast(event => event.type === 'compaction/start')
const injected = agent.inbox.nextStep.find(message =>
message.source.kind === 'plugin' && message.source.plugin === 'test')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const end = agent.session.snapshotEvents().findLast(event => event.type === 'compaction/end')
expect(start).toBeDefined()
expect(injected).toBeDefined()
expect(end).toBeDefined()
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(agent.session.snapshotEvents().some(event => event.type === 'user/message'
&& event.data.id === injected?.id)).toBe(false)
@@ -340,7 +336,6 @@ describe('compactNow through the real loop', () => {
expect(result).not.toBeNull()
expect(agent.session.deriveMessages()[0]?.role).toBe('system')
expect(derivedText(agent.session)[1]).toContain('checkpoint')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(agent.session.snapshotEvents().filter(event => event.type === 'user/message'
&& event.data.source.kind === 'plugin' && event.data.source.plugin === 'listener')).toHaveLength(0)
const types = compactEvents(agent.session).map(event => event.type)
@@ -361,7 +356,6 @@ describe('compactNow through the real loop', () => {
await agent.whenIdle()
expect(adapter.requests).toHaveLength(2)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(agent.session.snapshotEvents().some(event => event.type === 'compaction/start')).toBe(false)
})
@@ -412,18 +406,13 @@ describe('compactNow transaction and failure classification', () => {
expect(result).not.toBeNull()
expect(result?.sourceCommandId).toBe(commandId)
expect(flushes()).toBe(1)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().filter(event => event.type === 'turn/start').at(-1)?.data.turn).toBe(7)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const start = session.snapshotEvents().findLast(event => event.type === 'compaction/start')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const summaryEvent = session.snapshotEvents().findLast(event => event.type === 'compaction/summary')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const checkpoint = session.snapshotEvents().findLast(
(event): event is SessionEvent<'user/message'> => event.type === 'user/message'
&& isCompactCheckpointSource(event.data.source),
)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const end = session.snapshotEvents().findLast(event => event.type === 'compaction/end')
const correlated = { compactionId: result?.compactionId, sourceCommandId: commandId }
expect(start?.data).toEqual({ ...correlated, turn: null })
@@ -454,11 +443,8 @@ describe('compactNow transaction and failure classification', () => {
compactionId: CompactionId('stale-manual-compaction'),
turn: null,
})
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const reloaded = Session.create(SessionId('stale-orphan'), original.snapshotEvents())
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const boundary = reloaded.snapshotEvents().findLast(event => event.type === 'session/end-seed')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const orphan = reloaded.snapshotEvents().find(event => event.type === 'compaction/start')
const agent = fakeAgent(reloaded, () => () => undefined)
@@ -476,7 +462,6 @@ describe('compactNow transaction and failure classification', () => {
})
original.append('turn/start', { turn: 3 })
original.append('turn/end', { turn: 3, reason: { kind: 'interrupted' } })
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const reloaded = Session.create(SessionId('reloaded-orphan'), original.snapshotEvents())
const agent = fakeAgent(reloaded, () => () => undefined)
@@ -580,7 +565,6 @@ describe('compactNow transaction and failure classification', () => {
expect(session.surface.replaceGeneration).toBe(generation + 1)
expect(session.surface.nodes).not.toContain(head)
expect(compactEvents(session).map(event => event.type)).toEqual(['compaction/start', 'compaction/end'])
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'user/message'
&& isCompactCheckpointSource(event.data.source))).toBe(false)
})
@@ -600,7 +584,6 @@ describe('compactNow transaction and failure classification', () => {
expect(causeOf(error).message).toBe('boundary rejected')
vi.restoreAllMocks()
expect(flushes()).toBe(0)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().findLast(event => event.type.startsWith('compaction/'))?.type)
.toBe('compaction/summary')
expect(compactEvents(session).filter(event => event.type === 'compaction/start')).toHaveLength(1)
@@ -667,7 +650,6 @@ describe('compactNow transaction and failure classification', () => {
vi.restoreAllMocks()
expect(error.code).toBe('commit')
expect(released).toBe(1)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const end = session.snapshotEvents().findLast(event => event.type === 'compaction/end')
expect(end?.type === 'compaction/end' && end.data.error).toContain('summary record rejected')
expect(end?.type === 'compaction/end' && end.data.turn).toBeNull()
@@ -704,9 +686,7 @@ describe('compactNow transaction and failure classification', () => {
const result = await compact.compactNow(agent, SIGNAL)
expect(result).not.toBeNull()
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'turn/start')).toBe(false)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().find(event => event.type === 'compaction/start')?.data)
.toEqual({ compactionId: result?.compactionId, turn: null })
})
@@ -719,11 +699,8 @@ describe('compactNow transaction and failure classification', () => {
expect((await rejection(compact.compactNow(agent, SIGNAL))).code).toBe('persistence')
vi.restoreAllMocks()
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(true)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const start = session.snapshotEvents().findLast(event => event.type === 'compaction/start')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const end = session.snapshotEvents().findLast(event => event.type === 'compaction/end')
expect(end?.data).toEqual({ compactionId: start?.data.compactionId, turn: null })
})
@@ -740,7 +717,6 @@ describe('compactNow transaction and failure classification', () => {
const reserve = vi.fn(() => testCase.release)
const measure = vi.spyOn(ctx.tokenMeter, 'measure')
const agent = fakeAgent(testCase.session, reserve)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const before = testCase.session.snapshotEvents()
const reason = Object.freeze({ kind: 'cancelled', case: testCase.name })
const controller = new AbortController()
@@ -756,7 +732,6 @@ describe('compactNow transaction and failure classification', () => {
expect(reserve).not.toHaveBeenCalled()
expect(measure).not.toHaveBeenCalled()
expect(compact.calls).toHaveLength(0)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(testCase.session.snapshotEvents()).toEqual(before)
vi.restoreAllMocks()
}
@@ -806,7 +781,6 @@ describe('compactNow transaction and failure classification', () => {
await expect(compact.compactNow(agent, controller.signal)).rejects.toBe(reason)
expect(compactEvents(session).map(event => event.type)).toEqual(['compaction/start', 'compaction/end'])
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
expect(session.snapshotEvents().some(event => event.type === 'compaction/summary')).toBe(false)
})
@@ -851,7 +825,6 @@ describe('compactNow transaction and failure classification', () => {
await compact.compactNow(agent, SIGNAL)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const summary = session.snapshotEvents().find(event => event.type === 'compaction/summary')
expect(summary?.type === 'compaction/summary' && summary.data.rawOutput).toEqual(compact.rawOutput)
expect(summary?.type === 'compaction/summary' && summary.data.usage).toEqual(compact.usage)
@@ -867,9 +840,7 @@ describe('compactNow transaction and failure classification', () => {
await compact.compactNow(agent, SIGNAL)
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const start = session.snapshotEvents().findLast(event => event.type === 'compaction/start')
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
const end = session.snapshotEvents().findLast(event => event.type === 'compaction/end')
expect(start).toBeDefined()
expect(end).toBeDefined()