mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-11 04:00:38 +00:00
docs(code-runtime-python): align the en wire-contract section with the open flag; fix the case comment
The review's warning: the en README's inner 'Wire contract' section still described only the truncated flag while the zh counterpart (and the outer 'The wire' section) described open. The inner en section now matches. The exact-fit closing-line case comment described the buffered-chunks pre-check recipe while the program actually drives the scan pre-check; the comment now states the actual arithmetic and path (and the buffered variant was dropped — its writes coalesce into one call in the test environment, so it did not discriminate).
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/code-runtime/code-runtime-python/README.md
|
||||
README.md: 3734639760e51c31ee3ba467e57f7e025ef1907c
|
||||
README.md: 889776e03c7af250411fe7ff9663204febf1e1bf
|
||||
README.zh.md: 233cf01c3e1f8ad97f181e7f65ce009438e2366d
|
||||
|
||||
@@ -55,7 +55,7 @@ One direction of trust: the host treats every inbound frame as hostile (model co
|
||||
|
||||
### Wire contract
|
||||
|
||||
The frames are `boot` / `run` (host → child) and `boot-ack` / `call` / `log` / `done` plus one `reply` per call (child → host). The `log` frame's `truncated` flag marks the frame that IS the child ledger's truncation marker, so the host stops capturing at the same point the child did instead of inferring it from its own budget. `done.error.kind` is one of `exception`, `invalid-output`, `output-limit`; wall/CPU budgets, aborts, and substrate death are observed host-side, not carried as frames.
|
||||
The frames are `boot` / `run` (host → child) and `boot-ack` / `call` / `log` / `done` plus one `reply` per call (child → host). The `log` frame's `truncated` flag marks the frame that IS the child ledger's truncation marker, so the host stops capturing at the same point the child did instead of inferring it from its own budget. The `log` frame's `open` flag marks an unterminated line committed by an explicit flush: the host merges the next log frame into the same entry, so `print('a', end='', flush=True); print('b')` reads back as one `'ab'` entry rather than a fake newline (the split-billing arithmetic lives in the fd-3 protocol Agent Note's wire-contract section). `done.error.kind` is one of `exception`, `invalid-output`, `output-limit`; wall/CPU budgets, aborts, and substrate death are observed host-side, not carried as frames.
|
||||
|
||||
### Lossless JSON crossing
|
||||
|
||||
|
||||
@@ -1998,10 +1998,13 @@ describe('PythonCodeRuntime — programs and bindings', () => {
|
||||
it('does not over-reject an exact-fit closing line while an open entry accumulates', async () => {
|
||||
// The write-path pre-check's cheap bound used +3 (quotes + separator) even
|
||||
// while an open entry was accumulating, so an exact-fit merged TAIL was
|
||||
// truncated: print('a'*29, flush) bills 32 (ledger 31 left), then
|
||||
// print('b'*28, end=''); print('c') merges 29 more chars whose cheap bound
|
||||
// is 29, not 32 — the +3 form saw 28 + 1 + 3 = 32 > 31 and truncated a
|
||||
// line that fits (merged cost 2 + 58 + 1 = 61 <= 63).
|
||||
// truncated. The recipe below goes through the SCAN pre-check (the
|
||||
// newline-terminated write arrives with an empty pending buffer, so the
|
||||
// buffered-chunks branch is skipped): 'a'*29 flush bills 32 (ledger 31
|
||||
// left), then one write of 'b'*30 + newline merges 30 more chars whose
|
||||
// cheap bound is 30, not 33 — the +3 form saw 30 + 3 = 33 > 31, sliced to
|
||||
// a budget prefix, and pushed past the ledger, emitting the marker for a
|
||||
// line that fits (merged cost 2 + 59 + 1 = 62 <= 63).
|
||||
const { runtime } = await setup({ maxLogBytes: 64 })
|
||||
const result = await runtime.run({
|
||||
program: [
|
||||
@@ -2017,6 +2020,7 @@ describe('PythonCodeRuntime — programs and bindings', () => {
|
||||
expect(result.logs).toEqual(['a'.repeat(29) + 'b'.repeat(30)])
|
||||
}, 15_000)
|
||||
|
||||
|
||||
it('rejects a new open entry once the ledger has only two bytes left', async () => {
|
||||
// The jsonStringCostUpTo sub-2-byte guard: forged open frames drive the
|
||||
// host ledger down to 1 byte, then a new open entry's first-fragment cap
|
||||
|
||||
Reference in New Issue
Block a user