diff --git a/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts b/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts index 684080da8e..9f21df99fd 100644 --- a/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts +++ b/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts @@ -1906,6 +1906,26 @@ describe('PythonCodeRuntime — programs and bindings', () => { expect(result.logs).toEqual(['committed']) }, 15_000) + it('skips the hold for a zero-content open continuation', async () => { + // An empty open continuation bills 0 and is NOT pushed into the held + // fragment array (an empty fragment contributes nothing to the merged + // entry, and holding it would let a forged empty-open flood grow host + // memory without touching the ledger). + const { runtime } = await setup({ maxLogBytes: 64 }) + const result = await runtime.run({ + program: [ + 'import os', + "os.write(3, b'{\"type\":\"log\",\"text\":\"x\",\"open\":true}\\n')", + "os.write(3, b'{\"type\":\"log\",\"text\":\"\",\"open\":true}\\n')", + "os.write(3, b'{\"type\":\"log\",\"text\":\"y\"}\\n')", + 'return "done"', + ].join('\n'), + bindings: [], + }) + expect(result.error).toBeUndefined() + expect(result.logs).toEqual(['xy']) + }, 15_000) + it('bounds a forged open-frame flood against the log budget', async () => { // The open hold must be bounded by the ledger: without the exact-cost check // a forged open flood would grow the held fragment without touching