test: simplify DSH SDK route evidence
This commit is contained in:
1 parent
40f6205cdf
commit
54e908df52
2 files changed
+11
-37
No files matched your search
@@ -89,7 +89,6 @@ interface SdkScenario {
|
||||
dshSdkChild?: {
|
||||
config: string
|
||||
sessionRoot: string
|
||||
expectedRoute: Readonly<Record<string, unknown>>
|
||||
}
|
||||
/** Cwd-relative files whose final contents are part of the scenario contract. */
|
||||
expectedFiles?: Readonly<Record<string, string>>
|
||||
@@ -133,12 +132,6 @@ const SCENARIOS: SdkScenario[] = [
|
||||
dshSdkChild: {
|
||||
config: dshSdkChildConfig,
|
||||
sessionRoot: '.child-dsh/sessions',
|
||||
expectedRoute: {
|
||||
provider: 'mock',
|
||||
model: 'mock-routed',
|
||||
reasoningEffort: 'max',
|
||||
maxTokens: 777,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -223,17 +216,6 @@ function assembledSystem(log: PersistedLog): string {
|
||||
return system
|
||||
}
|
||||
|
||||
function assembledRequestConfig(log: PersistedLog): Record<string, unknown> {
|
||||
const event = log.content.trimEnd().split('\n')
|
||||
.map(line => JSON.parse(line) as { type?: string; data?: { header?: { config?: unknown } } })
|
||||
.find(candidate => candidate.type === 'request/header')
|
||||
const config = event?.data?.header?.config
|
||||
if (typeof config !== 'object' || config === null || Array.isArray(config)) {
|
||||
throw new Error('session log has no request/header config')
|
||||
}
|
||||
return config as Record<string, unknown>
|
||||
}
|
||||
|
||||
function assembledRuntimeContexts(log: PersistedLog): string[] {
|
||||
return log.content.trimEnd().split('\n').flatMap((line) => {
|
||||
const event = JSON.parse(line) as {
|
||||
@@ -543,11 +525,6 @@ describe('TypeScript SDK snapshots over the jsonrpc runtime', () => {
|
||||
for (const clause of scenario.runtimeContext.includes) expect(system).not.toContain(clause)
|
||||
}
|
||||
}
|
||||
if (scenario.dshSdkChild !== undefined) {
|
||||
const child = ordered[1]
|
||||
if (child === undefined) throw new Error(`${scenario.name} has no child session log`)
|
||||
expect(assembledRequestConfig(child)).toEqual(scenario.dshSdkChild.expectedRoute)
|
||||
}
|
||||
if (scenario.children > 0 && scenario.dshSdkChild === undefined) {
|
||||
expect(notifications.some(n => n.method === 'subagent.started')).toBe(true)
|
||||
expect(notifications.some(n => n.method === 'subagent.finished')).toBe(true)
|
||||
|
||||
@@ -885,26 +885,23 @@ describe('HarnessSdkJsonRpcServer', () => {
|
||||
},
|
||||
)
|
||||
|
||||
it.each(['', 42])(
|
||||
'rejects invalid initialize reasoningEffort %j at the wire boundary',
|
||||
async (reasoningEffort) => {
|
||||
const storageDir = await mkdtemp(join(tmpdir(), 'dsh-jsonrpc-invalid-reasoning-'))
|
||||
const ctx = await makeHarness(storageDir)
|
||||
try {
|
||||
const server = new HarnessSdkJsonRpcServer(ctx, new FakeTransport())
|
||||
it('rejects malformed initialize reasoningEffort values at the wire boundary', async () => {
|
||||
const ctx = new Context()
|
||||
const server = new HarnessSdkJsonRpcServer(ctx, new FakeTransport())
|
||||
try {
|
||||
for (const reasoningEffort of ['', 42]) {
|
||||
await expect(server.handleRequest('initialize', {
|
||||
cwd: storageDir,
|
||||
cwd: '.',
|
||||
provider: 'deepseek-official',
|
||||
model: 'model',
|
||||
reasoningEffort,
|
||||
})).rejects.toThrow('initialize reasoningEffort must be a non-empty string')
|
||||
await server.shutdown()
|
||||
} finally {
|
||||
await ctx.fiber.dispose()
|
||||
await rm(storageDir, { recursive: true, force: true })
|
||||
}
|
||||
},
|
||||
)
|
||||
await server.shutdown()
|
||||
} finally {
|
||||
await ctx.fiber.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
it('rejects an unavailable exact model during initialize', async () => {
|
||||
const storageDir = await mkdtemp(join(tmpdir(), 'dsh-jsonrpc-invalid-route-'))
|
||||
|
||||
Reference in new issue
Block a user