Commit 6a6263a
* relayburn-sdk: collapse parse_claude_session onto run_incremental (#346)
Last remaining cleanup from #346: the non-incremental claude parser kept
its own `ParseState` machinery in parallel with `run_incremental`, both
reading the same JSONL shape but along separate codepaths. PR #371
deferred this because the two paths disagreed on trailing in-progress
turns (incremental skips them; non-incremental emits them).
This commit adds an `emit_in_progress` flag to `run_incremental`:
- false (incremental callers): keep the existing "back up end_offset to
the earliest in-progress message and skip those turns" behavior, so
the next resume call re-reads them.
- true (full-parse caller): use `cursor_offset` for end_offset and emit
every working record. This matches the prior `ParseState::finish`
output, including assistants without a `stop_reason`.
`parse_claude_session_with_counter` now builds a
`ParseIncrementalOptions { start_offset: Some(0), .. }` and calls
`run_incremental(.., true)`, then converts via a new
`From<ParseIncrementalResult> for ParseResult`. The ParseState struct,
its impl, the `record_root` / `collect_explicit_claude_relationships`
non-incremental helpers, and `derive_file_session_id` are gone — net
-374 LoC in claude.rs.
The full workspace test suite (claude reader + 600+ other tests) passes
unchanged, validating that the single-shot output matches what
`ParseState` produced.
* relayburn-sdk: emit final unterminated line in single-shot claude parse
Devin Review flagged that switching `parse_claude_session_with_counter` to
delegate to `run_incremental` regressed one edge case: the prior
`ParseState` path used `BufReader::read_line`, which surfaces the final
line at EOF even without a trailing `\n`. `run_incremental`'s
`read_until(b'\n')` loop guards against partial trailing lines because
the incremental caller resumes at `cursor_offset` next tick — but a
single-shot full parse has no next tick, so a syntactically complete
final JSON line lacking `\n` (mid-write truncation, unflushed writer)
was silently dropped.
Fix: gate the partial-line `break` on `!emit_in_progress`. When the
single-shot caller asks us to emit in-progress records, treat a
non-newline-terminated tail as a complete line and bump `cursor_offset`
past its body so the per-record offset filters still admit it.
Regression test `full_parse_emits_final_line_without_trailing_newline`
writes simple-turn.jsonl with the trailing `\n` stripped and asserts the
turn still lands.
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 632a0b3 commit 6a6263a
2 files changed
Lines changed: 143 additions & 480 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
7 | 15 | | |
8 | 16 | | |
9 | 17 | | |
| |||
0 commit comments