Skip to content

Use VecDeque for Sandbox log tails - #504

Open
jiang1997 wants to merge 1 commit into
Ephemeral-AI-Lab:mainfrom
jiang1997:fix/sandbox-log-ring
Open

jiang1997 wants to merge 1 commit into
Ephemeral-AI-Lab:mainfrom
jiang1997:fix/sandbox-log-ring

Conversation

@jiang1997

@jiang1997 jiang1997 commented Oct 29, 2026 •

Copy link
Copy Markdown

Sandbox::log_tail previously appended each incoming chunk to a Vec and drained excess bytes from the front, repeatedly shifting retained data once the buffer filled.

Use VecDeque to discard old bytes without shifting the retained suffix. When a chunk reaches or exceeds the byte cap, replace the buffer with that chunk's suffix.

Add tests covering capacity boundaries, repeated wraps, interleaved stdout/stderr, fragmented frames, binary bytes, and malformed responses with zero capacity.

Validation: all 3 tests in engine_log_tail pass on macOS with Rust 1.85.1; git diff --check passes.

Production LOC: 102831 -> 102838 (delta +7)
Scope: core 38395 -> 38395; engine 61777 -> 61784; api 2659 -> 2659.
Method: tools/production_loc.py --root --json on archived first-parent and staged trees, using the same counter from 582bc78.
Reference absent (retired R9c; last counted 65,417 at tree 498dd1917812).

Keep the last cap bytes without repeatedly shifting retained data.

Production LOC: 102831 -> 102838 (delta +7)
Scope: core 38395 -> 38395; engine 61777 -> 61784; api 2659 -> 2659.
Method: tools/production_loc.py --root <snapshot> --json on archived
first-parent and staged trees, using the same counter from 582bc78.
Reference absent (retired R9c; last counted 65,417 at tree 498dd19).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant