test(code-runtime-python): make the stray-seal copy-volume bound discriminate

The stray-sealing regression test asserted copied < 2 MiB — about 4x the
defended sealed shape, so reverting the seal to a re-merge (or removing it)
left the test green. Measured both shapes as the fd-3 sibling does: the sealed
shape copies ~120 KB, the re-merge shape ~538 KB. Tighten the bound to 256 KiB,
which sits between them, and record the measurements in the comment and the
Agent Note so the fail-before claim holds.
This commit is contained in:
Chinesezjc
2026-08-31 14:22:37 +08:00
committed by Tianyi Cui
parent e76b3baf9e
commit 45814baf26
4 changed files with 14 additions and 7 deletions
@@ -3157,9 +3157,16 @@ describe('PythonCodeRuntime — hostile peer', () => {
// length depends on pipe coalescing, but it is one entry and non-empty.
expect(result.logs.length).toBe(1)
expect((result.logs[0] as string).length).toBeGreaterThan(0)
// Sealing keeps each byte copied a bounded number of times; re-merging the
// whole residual per threshold would push the total far past this.
expect(copied).toBeLessThan(2 * 1024 * 1024)
// Sealing appends a finished block rather than re-merging everything held, so
// each byte is copied a bounded number of times. Re-merging the whole
// residual at every seal threshold instead makes the cumulative copy volume
// quadratic. Measured like the fd-3 sibling above rather than reasoned about:
// this sealed shape copies about 120 KB for 60000 trickled bytes, the
// re-merging shape about 538 KB (the stray path adds one whole-residual
// concat at the terminating newline over the fd-3 sibling's 119/540, landing
// at the same order). 256 KiB sits between them with margin on both sides, so
// reverting the seal to a re-merge turns this assertion red.
expect(copied).toBeLessThan(256 * 1024)
}, 40_000)
it('caps a huge exception diagnostic child-side before it crosses the wire', async () => {