From 4f478969f52ad35b481ed1183f195a166e67dedc Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 9 Nov 2026 12:48:09 +0800 Subject: [PATCH] fix(ptc-python): reject unsupported completion discard --- packages/experimental/ptc-runtime-python/src/index.ts | 3 ++- packages/experimental/ptc-runtime-python/tests/runtime.spec.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/experimental/ptc-runtime-python/src/index.ts b/packages/experimental/ptc-runtime-python/src/index.ts index 1e12cd1e5f..a1e8b8556c 100644 --- a/packages/experimental/ptc-runtime-python/src/index.ts +++ b/packages/experimental/ptc-runtime-python/src/index.ts @@ -974,11 +974,12 @@ export class PythonPtcRuntime extends PtcRuntime { * Resolve authority, directory, and the configured wall deadline. * @param request - Program inputs and optional resolved sandbox authority; timeout overrides are unsupported. * @returns Complete inputs for the provider's run method. - * @throws When a requested timeout is unsupported, cwd is relative, or the provider is disposed. + * @throws When a requested timeout or completion-discard option is unsupported, cwd is relative, or the provider is disposed. */ resolve(request: PtcRunRequest): PtcRunSpec { if (this.disposed) throw new Error('dsh-ptc-runtime-python: resolve() after disposal') if (request.timeoutMs !== undefined) throw new Error('dsh-ptc-runtime-python: per-call timeout is unsupported') + if (request.discardCompletion === true) throw new Error('dsh-ptc-runtime-python: discardCompletion is unsupported') const sandboxPolicy = request.sandboxPolicy ?? this.ctx.sandboxPolicy.resolve() const cwd = request.cwd ?? sandboxPolicy.workspaceRoot if (!isAbsolute(cwd)) throw new Error('dsh-ptc-runtime-python: cwd must be absolute') diff --git a/packages/experimental/ptc-runtime-python/tests/runtime.spec.ts b/packages/experimental/ptc-runtime-python/tests/runtime.spec.ts index 29a547ae7a..cf28d3fc10 100644 --- a/packages/experimental/ptc-runtime-python/tests/runtime.spec.ts +++ b/packages/experimental/ptc-runtime-python/tests/runtime.spec.ts @@ -88,6 +88,8 @@ describe('PythonPtcRuntime — seam descriptors and misuse', () => { expect(() => runtime.resolve({ ...request, cwd: 'relative' })).toThrow('cwd must be absolute') expect(() => runtime.resolve({ ...request, timeoutMs: 1 })).toThrow('per-call timeout is unsupported') expect(() => runtime.resolve({ ...request, timeoutMs: null })).toThrow('per-call timeout is unsupported') + expect(() => runtime.resolve({ ...request, discardCompletion: true })).toThrow('discardCompletion is unsupported') + expect(runtime.resolve({ ...request, discardCompletion: false }).discardCompletion).toBe(false) const sandboxPolicy = { mode: 'danger-full-access' as const, workspaceRoot: cwd } expect(runtime.resolve({ ...request, sandboxPolicy }).sandboxPolicy).toBe(sandboxPolicy) await expect(runtime.run({ ...request, cwd, timeoutMs: 30_000 })).rejects.toThrow('run requires a resolved sandbox policy')