relayburn-reader: port Claude Code parser (#255)#293
Conversation
PRs #262 and #265 already landed `parse_claude_session`, `parse_claude_session_incremental`, and `reconcile_claude_session_relationships`. This commit closes out the issue's acceptance gate by porting the remaining `claude.test.ts` cases into Rust so the suite gates on the same shared fixtures the TS reader gates on. Adds 35 new lib tests under `mod tests` in `crates/relayburn-reader/src/claude.rs`, covering the rest of the top `describe('parseClaudeSession', ...)` block, the user-turn block sizing tests (issue #2), the content-capture matrix, and the full fork / continuation reconciliation suite (#112) — including in-memory evidence pairs that exercise the `reconcile_claude_session_relationships` dedup paths. Two judgment calls: - The TS user-turn cases assert exact cl100k token counts (e.g. 4 for "please fix the build"). The Rust port has not wired cl100k yet (#246 tracks it; `HeuristicCounter` is the default), so the Rust test asserts the heuristic shape (`ceil(byte_len/4)`) plus the positive-on-both-sides invariant from the ±5% cl100k reconciliation test, with comments pointing at the cl100k follow-up. - The TS dedup test imports a hash builder from `@relayburn/ledger` via a comment workaround. The Rust test reproduces the canonical key inline (source + sessionId + relationshipType + relatedSessionId + agentId + parentToolUseId) — exactly what the TS test does — to avoid a cross-crate test dependency. `cargo test -p relayburn-reader` passes 199 tests (51 in `claude::`). `cargo test --workspace` and `pnpm run build && pnpm run test` (873 TS tests) both green; clippy + fmt clean on the new code. Closes #255. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds 1,160 lines of conformance test cases to the Claude session parser ( ChangesClaude Parser Conformance Tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
packages/reader/src/claude.test.tscases into nativecargo testassertions so the Rust port now gates on the same sharedtests/fixtures/claude/JSONL inputs as the TS suite.reconcile_claude_session_relationships.Test plan
cargo test -p relayburn-reader(199 pass; 51 inclaude::)cargo build --workspacecleancargo test --workspacegreenpnpm run build && pnpm run test(873 TS tests still pass)cargo fmt --checkandcargo clippy --testsclean on the new code (pre-existing warnings on this file untouched)Closes #255.