mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 02:57:36 +00:00
test: consolidate refusal cases and repair boundary coverage (#33098)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -147,8 +147,9 @@ describe('completed context clear projections', () => {
|
||||
|
||||
it('includes new sends but excludes older unknown sends even at the current fence', () => {
|
||||
const currentSend = { ...oldSend, clientMessageId: 'new-send', acceptedSequence: 6 }
|
||||
const boundarySend = { ...oldSend, clientMessageId: 'boundary-send', acceptedSequence: 5 }
|
||||
const rows = [user, clear, row(7, { kind: 'turn', turnId: 'new-turn', state: 'running' })]
|
||||
expect(agentSessionCurrentContextRows(rows, [oldSend, currentSend])).toEqual({
|
||||
expect(agentSessionCurrentContextRows(rows, [oldSend, boundarySend, currentSend])).toEqual({
|
||||
items: [rows[2]],
|
||||
submissions: [currentSend]
|
||||
})
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { MAX_CONTEXT_CATEGORIES, MAX_CONTEXT_MODEL_ID_CHARS } from './agent-session-context-usage'
|
||||
import {
|
||||
MAX_CONTEXT_CATEGORIES,
|
||||
MAX_CONTEXT_CATEGORY_NAME_CHARS,
|
||||
MAX_CONTEXT_MODEL_ID_CHARS
|
||||
} from './agent-session-context-usage'
|
||||
import {
|
||||
AgentSessionContextUsageSchema,
|
||||
isAdmissibleAgentSessionContextUsage
|
||||
@@ -32,8 +36,18 @@ describe('context usage admission', () => {
|
||||
capturedAt: 1
|
||||
}
|
||||
},
|
||||
{ used: report, future: { retained: true } }
|
||||
])('accepts canonical facts and leaves additive fields untouched (%j)', (value) => {
|
||||
{ used: report, future: { retained: true } },
|
||||
{
|
||||
used: {
|
||||
...report,
|
||||
model: 'x'.repeat(MAX_CONTEXT_MODEL_ID_CHARS),
|
||||
categories: Array.from({ length: MAX_CONTEXT_CATEGORIES }, () => ({
|
||||
name: 'x'.repeat(MAX_CONTEXT_CATEGORY_NAME_CHARS),
|
||||
tokens: 0
|
||||
}))
|
||||
}
|
||||
}
|
||||
])('accepts canonical facts and leaves inputs untouched (%j)', (value) => {
|
||||
const original = structuredClone(value)
|
||||
expect(isAdmissibleAgentSessionContextUsage(value)).toBe(true)
|
||||
expect(AgentSessionContextUsageSchema.safeParse(value).success).toBe(true)
|
||||
@@ -51,6 +65,12 @@ describe('context usage admission', () => {
|
||||
{
|
||||
used: { ...report, categories: Array(MAX_CONTEXT_CATEGORIES + 1).fill(report.categories[0]) }
|
||||
},
|
||||
{
|
||||
used: {
|
||||
...report,
|
||||
categories: [{ name: 'x'.repeat(MAX_CONTEXT_CATEGORY_NAME_CHARS + 1), tokens: 0 }]
|
||||
}
|
||||
},
|
||||
{ used: { ...report, categories: [{ name: 'messages', tokens: null }] } }
|
||||
])('rejects malformed facts and bounds just like parsing (%j)', (value) => {
|
||||
expect(isAdmissibleAgentSessionContextUsage(value)).toBe(false)
|
||||
|
||||
@@ -9,16 +9,6 @@ describe('definitive agent-session create refusals', () => {
|
||||
expect(isDefinitiveAgentSessionCreateRefusal('agent_session_ownership_unknown')).toBe(false)
|
||||
})
|
||||
|
||||
it('leaves transport failures, timeouts and a missing code unknown', () => {
|
||||
expect(isDefinitiveAgentSessionCreateRefusal('runtime_error')).toBe(false)
|
||||
expect(isDefinitiveAgentSessionCreateRefusal('remote_runtime_unavailable')).toBe(false)
|
||||
expect(isDefinitiveAgentSessionCreateRefusal('timeout')).toBe(false)
|
||||
expect(isDefinitiveAgentSessionCreateRefusal('runtime_timeout')).toBe(false)
|
||||
expect(isDefinitiveAgentSessionCreateRefusal(undefined)).toBe(false)
|
||||
expect(isDefinitiveAgentSessionCreateRefusal(null)).toBe(false)
|
||||
expect(isDefinitiveAgentSessionCreateRefusal('')).toBe(false)
|
||||
})
|
||||
|
||||
it('counts a method an old host never registered as definitive', () => {
|
||||
expect(isDefinitiveAgentSessionCreateRefusal('method_not_found')).toBe(true)
|
||||
})
|
||||
@@ -41,6 +31,9 @@ describe('definitive agent-session create refusals', () => {
|
||||
|
||||
// Pins the RPC half (round-2 S5): transport and client-minted codes never allow a fallback.
|
||||
it.each([
|
||||
'runtime_error',
|
||||
'timeout',
|
||||
'',
|
||||
'runtime_unavailable',
|
||||
'remote_runtime_unavailable',
|
||||
'runtime_timeout',
|
||||
|
||||
Reference in New Issue
Block a user