mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-11 04:00:38 +00:00
fix(code-runtime-python): reject a non-integer maxLogBytes/maxValueBytes at load
The child reads these byte budgets through int(...), which silently floors a float, so maxLogBytes: 3.5 would truncate at 3 bytes child-side while the host meters and marks at 3.5 — the two sides enforcing different public config. Gate them to integers at load, as the worker backend does; correct the stale comment that claimed the int()-truncated caps needed no gate. Adds a regression test.
This commit is contained in:
@@ -68,6 +68,18 @@ describe('PythonCodeRuntime — seam descriptors and misuse', () => {
|
||||
.rejects.toThrow(/cpuSeconds must be a positive integer, got 1.5/)
|
||||
})
|
||||
|
||||
it('rejects a non-integer byte budget at load (the child int()-truncates it)', async () => {
|
||||
// maxLogBytes/maxValueBytes cross to the child, which reads them through
|
||||
// int(...): a float would floor there while the host meters the fraction, so
|
||||
// the two sides would enforce different public config. Reject at load.
|
||||
const ctxLog = new Context()
|
||||
await expect(ctxLog.plugin(PythonCodeRuntime, { maxLogBytes: 3.5 }))
|
||||
.rejects.toThrow(/maxLogBytes must be a positive integer/)
|
||||
const ctxValue = new Context()
|
||||
await expect(ctxValue.plugin(PythonCodeRuntime, { maxValueBytes: 1024.5 }))
|
||||
.rejects.toThrow(/maxValueBytes must be a positive integer/)
|
||||
})
|
||||
|
||||
it('rejects finite numeric config that cannot cross as an exact rlimit integer', async () => {
|
||||
// `Number.isFinite` and `Number.isInteger` both admit values that cannot
|
||||
// round-trip. `addressSpaceMb: 1e308` overflows to `Infinity` once multiplied
|
||||
|
||||
Reference in New Issue
Block a user