test(code-runtime-python): give the first-fragment cap a discriminating case; dedupe the note

The review's warning: the one-byte overflow case ran through the CHILD ledger
(print path), so the host's first-fragment cap (logBudget - 1) never executed,
and the sub-2-byte guard test does not discriminate logBudget from
logBudget - 1 (a reverted cap still trips the guard). The frame is now forged
on fd 3, so a reverted cap of logBudget admits it and flushes it at settlement
— verified to turn the test red.

The review's dedupe suggestion: the split-billing arithmetic was stated in both
notes; the settlement note's Decision paragraph now links to the fd-3 protocol
note's wire-contract section (one home per fact), paired and re-recorded.
This commit is contained in:
Chinesezjc
2026-08-31 15:04:43 +08:00
committed by Tianyi Cui
parent c7d2d4b8b5
commit 371303822f
4 changed files with 9 additions and 6 deletions
@@ -1961,11 +1961,14 @@ describe('PythonCodeRuntime — programs and bindings', () => {
// The review's arithmetic check: an open frame whose full JSON cost is 63
// (maxLogBytes: 64 -> ledger 63) must be rejected by the first-fragment
// cap logBudget - 1 (62), not admitted with a bill of 64 that pushes the
// ledger negative.
// ledger negative. The frame is FORGED on fd 3 so the child ledger cannot
// truncate first: a reverted cap of logBudget (63) would admit the frame,
// hold it, and flush it at settlement, so the marker assertion fails.
const { runtime } = await setup({ maxLogBytes: 64 })
const result = await runtime.run({
program: [
"print('x' * 61, end='', flush=True)",
'import os',
"os.write(3, ('{\"type\":\"log\",\"text\":\"' + 'x' * 61 + '\",\"open\":true}\\n').encode())",
'return "done"',
].join('\n'),
bindings: [],