relayburn-sdk: reader cleanup safe subset (#346)#352
Conversation
Three safe reader-module cleanups flagged in #346: - Collapse three near-identical helpers in reader/claude.rs (string_field, first_nonempty_string, first_string_field) into one parameterized helper `string_field(obj, keys, require_nonempty)`. All 39 callsites updated. - Simplify the two-arm verb() match in reader/classifier.rs by hoisting the prefix/normalized logic above the body. - Extract the duplicated fallback block in reader/git.rs:resolve_uncached into a small closure. No behavior change. The riskier subset of #346 (parser duplication, dead `let _ =` audit in codex.rs) is deferred. 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)
📝 WalkthroughWalkthroughRefactors three independent reader modules: simplifies bash classifier verb normalization, consolidates alias-aware multi-key field access and updates many Claude parser sites with tests, and centralizes git resolver fallback behavior. ChangesBash Classifier Verb Logic
Claude JSONL Field Parsing
Git Resolver Fallback Handling
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/relayburn-sdk/src/reader/claude.rs`:
- Around line 345-346: The parser still only looks up "sessionId" and
"timestamp" keys, so alias-only records using "session_id" or "ts" are dropped;
update all mirror entry points (the user/system/incremental parsing branches
that currently assign session_id and timestamp via string_field) to accept both
aliases by changing the lookup arrays to include both variants (e.g.,
string_field(obj, &["sessionId", "session_id"], false) and string_field(obj,
&["timestamp", "ts"], false)); propagate this same change through the code paths
that lead into record_root, the explicit relationship collection, compaction
emission, and the tool-result event emission so alias-only records reach the
downstream handlers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 12ee7a08-b27c-4beb-8d88-5481e3d621de
📒 Files selected for processing (3)
crates/relayburn-sdk/src/reader/classifier.rscrates/relayburn-sdk/src/reader/claude.rscrates/relayburn-sdk/src/reader/git.rs
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/relayburn-sdk/src/reader/claude.rs`:
- Around line 2886-2894: The string_field function currently returns the first
string value even if it's empty when require_nonempty is false, which allows a
blank primary key to mask a populated alias; change the logic in string_field to
prefer non-empty values across the provided keys: iterate keys, if you find a
non-empty string return it immediately; if you encounter an empty string
remember it (e.g., first_empty) but keep searching; after the loop return the
remembered empty string only if no non-empty was found and require_nonempty is
false; keep require_nonempty=true behavior to only accept non-empty strings. Use
the existing symbols string_field, obj.get(...).and_then(Value::as_str), and
require_nonempty to locate and implement this change.
- Around line 1971-1977: In record_evidence_from_line, propagate any
sourceVersion aliases into evidence.source_version instead of reading only the
literal "version" key: call string_field with the unified alias set (e.g.,
SOURCE_VERSION_KEYS or a new SOURCE_VERSION_KEYS constant) and assign its result
to evidence.source_version; locate the existing code that seeds
evidence.source_version from the literal "version" and replace it so it uses
string_field(lo, SOURCE_VERSION_KEYS, true) (keeping the same nil-check
semantics) so files emitting "version"/"sourceVersion"/"source_version" all
populate evidence.source_version consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2f1a7db8-2b9b-4a0b-be45-eb7e70dfa70f
📒 Files selected for processing (1)
crates/relayburn-sdk/src/reader/claude.rs
Remaining reader-module cleanups deferred from #352: - codex.rs / opencode.rs: replace the manual repack of the incremental result with `From<ParseCodexIncrementalResult> for ParseCodexResult` (and the opencode equivalent), and have `parse_*_session` delegate via `.map(...::from)`. - codex.rs: drop the two `let _ = (...)` blocks at the tail of `parse_codex_buffer`. The audit confirms each `committed_*` snapshot is read by either the resume state or the emitted records, so the trailing working values are genuinely dead and removing the silencing blocks introduces no compiler warnings. - codex.rs: rename `memchr_newline` to `find_newline` so the name no longer implies a `memchr`-crate optimization that isn't there. The claude.rs parser-duplication item from #346 stays deferred: the non-incremental `ParseState` emits in-progress turns (records with `stop_reason.is_none()`), while `run_incremental` deliberately defers them to keep the next call's start cursor honest. Collapsing the two paths needs a flag on `run_incremental` and broader fixture validation; out of scope for this safe-subset PR. https://claude.ai/code/session_01GHEd4Sv87QoUTd1BN6FbAF Co-authored-by: Claude <noreply@anthropic.com>
Summary
Three safe reader-module cleanups flagged in #346:
string_field/first_nonempty_string/first_string_fieldhelpers inreader/claude.rsinto one parameterized helperstring_field(obj, keys, require_nonempty). All 39 callsites updated.verb()match inreader/classifier.rsby hoisting the prefix/normalized logic above the body.reader/git.rs:resolve_uncachedinto a small closure.No behavior change; this is dedup. The riskier subset of #346 (parser duplication, dead
let _audit incodex.rs) is deferred.3 files changed, +62/-81 (net -19 LOC).
Test plan
cargo build --workspace --all-targetscleancargo test --workspacepasses (729/729)cargo clippy --workspace --all-targetsno new warnings🤖 Generated with Claude Code