Skip to content

Commit 6a6263a

Browse files
willwashburnclaude
andauthored
relayburn-sdk: collapse parse_claude_session onto run_incremental (#346) (#417)
* 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

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ Cross-package release notes for relayburn. Package changelogs contain package-le
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- `relayburn-sdk`: `parse_claude_session` now delegates to the incremental
10+
parser with `start_offset = 0`, dropping the duplicate `ParseState`
11+
codepath. Behavior is unchanged — trailing in-progress turns and final
12+
JSON lines lacking a trailing newline still surface in the single-shot
13+
output.
14+
715
## [2.8.3] - 2026-05-11
816

917
### Changed

0 commit comments

Comments
 (0)