fix(agent-manager): bounded cold-start scan drops a complete line when the tail window starts on a line boundary
Problem
When IncrementalJsonlSummary.readBounded (packages/agent-manager/src/utils/IncrementalJsonlSummary.ts) does a bounded cold-start scan of a large file, it always sets entry.discarding = true at the start of the tail window:
const tailStart = size - tailBytes;
entry.offset = tailStart;
// tailStart may fall mid-line; lines are only folded from their first byte
entry.discarding = true;
If tailStart falls exactly on the first byte of a line, i.e. the byte at tailStart - 1 is \n, that complete line is discarded as if it were a partial line. So one real entry at the start of the tail window is silently dropped from the summary.
Found while implementing #279. The tests there work around it by widening the tail window by one byte (a tailWindow() helper).
Impact
It loses at most one line per bounded scan. It can matter when that line is the only occurrence of a "latest" field in the tail, e.g. the last user message or last entry type.
Proposed fix
Set discarding only when the tail window starts mid-line: read the byte at tailStart - 1 and set discarding = byte !== 0x0a. The head/tail split and the skip() contract stay as they are.
Acceptance criteria
- [ ] A unit test puts the tail window exactly at a line boundary and asserts that the first tail line is folded (it fails before the fix).
- [ ] A test with the tail window mid-line still discards the partial line.
- [ ] The
tailWindow()+1-byte workaround in the #279 tests is removed, or no longer needed, and those tests still pass. - [ ] The bounded-vs-full-parse equivalence tests pass for Claude, Codex, Pi, Grok and Copilot.