Files
deepseek-harness/packages/api/job-controller/tests/built-lib.e2e.ts
T
Yichen Jiang 2c0ca45f76 fix(jobs): carry the projection kind as an open string on the wire
JobView.kind was typed as the merge-extensible JobKind, so the job-controller program, which compiles only the merges it can see, generated a strict codec of bash | subagent for job.rows and job.observe. The first pwsh, pty-send, or workflow job failed frame validation on both ends and the browser dropped the whole roster. The projection now carries kind as a string; JobSpec.kind keeps the Host-side JobKind. A built-artifact smoke parses a pty-send row through the generated schemas, and the seam spec pins the open type.
2026-09-04 12:10:22 +08:00

43 lines
1.8 KiB
TypeScript

import { existsSync } from 'node:fs'
import { join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
import { describe, expect, it } from 'vitest'
/**
* Built-artifact smoke for the generated job Remote codecs. This package's
* program compiles only the `JobKindMap` merges it can see (`bash`,
* `subagent`), while the Host registers `pwsh`, `pty-send`, and every other
* producer kind, so the wire projection's `kind` must reach the codec as an
* open string rather than the literal union this program observes.
*/
const artifact = join(fileURLToPath(new URL('..', import.meta.url)), 'lib/typert.host.js')
interface BuiltInvocation {
readonly method: string
readonly result: { readonly schema: { safeParse(value: unknown): { success: boolean } } }
}
const row = {
id: 'pty-send-1',
kind: 'pty-send',
label: 'send',
status: 'running',
startedAt: 1,
output: { total: 0, earliest: 0 },
}
describe.skipIf(!existsSync(artifact))('job Remote built codecs', () => {
it('accept a row whose kind this program never compiled, and still reject a status outside the lifecycle', async () => {
const { TYPERT } = await import(pathToFileURL(artifact).href) as { TYPERT: { invocations: readonly BuiltInvocation[] } }
const schemaOf = (method: string): BuiltInvocation['result']['schema'] => {
const invocation = TYPERT.invocations.find(candidate => candidate.method === method)
if (invocation === undefined) throw new Error(`no generated job.${method} invocation`)
return invocation.result.schema
}
expect(schemaOf('rows').safeParse({ type: 'rows', jobs: [row] }).success).toBe(true)
expect(schemaOf('observe').safeParse({ type: 'opened', job: row, from: 0 }).success).toBe(true)
expect(schemaOf('observe').safeParse({ type: 'status', job: { ...row, status: 'paused' } }).success).toBe(false)
})
})