Skip to content

refactor(sdk): drop workspace-wide dead_code/unused_imports allows#429

Merged
willwashburn merged 3 commits into
mainfrom
claude/sweet-bohr-BIJao
May 24, 2026
Merged

refactor(sdk): drop workspace-wide dead_code/unused_imports allows#429
willwashburn merged 3 commits into
mainfrom
claude/sweet-bohr-BIJao

Conversation

@willwashburn

Copy link
Copy Markdown
Member

Summary

Closes #336.

  • Removes #[allow(dead_code, unused_imports)] from the four absorbed module roots (analyze.rs, ingest.rs, ledger.rs, reader.rs) and the per-mod #[allow(unused_imports)] on the lib.rs verb mods. Resolves the ~130 warnings that surfaced by trimming inner-module-root re-export chains, deleting dead items, and #[cfg(test)]-gating test-only helpers.
  • Addresses the confirmed-dead candidates from the issue: deletes provider_for_turn / resolve_turn_provider aliases, inlines the severity_from_usd_pub visibility-laundering wrapper (now pub(crate) severity_from_usd), and drops Fidelity::classify (tests use classify_fidelity directly).
  • state.rs run_reset and summary.rs --by-* flag stubs called out in the issue are already implemented on main, so no change there.
  • Net diff: −2,899 / +91 lines across 27 files, including removal of the unused reader/opencode_stream.rs (1.6k lines) and the bulk of ingest/reingest.rs. lib.rs (the published SDK surface) is unchanged.

Test plan

  • cargo build --workspace — 0 warnings (down from 130 after the blanket allows were dropped)
  • cargo test --workspace — 10 binaries, 775 tests pass
  • cargo check -p relayburn-sdk-node -p relayburn-cli — downstream consumers compile against the unchanged SDK surface
  • pnpm run test — Node SDK facade + MCP tests pass (napi-not-built skips are standard locally)
  • Spot-checked clippy: pre-existing style lints dropped from 163 → 24; the remainder (too_many_arguments, large_enum_variant, etc.) are unrelated to dead-code/unused-imports and out of scope

https://claude.ai/code/session_01WavFVyZAAyiSmWaktaXsmD


Generated by Claude Code

claude added 2 commits May 24, 2026 16:44
…ed-dead items

Remove `#![allow(dead_code, unused_imports)]` from the four absorbed module
roots (analyze, ingest, ledger, reader) and the per-mod `#[allow(unused_imports)]`
on the lib.rs verb mods. Address the confirmed-dead candidates from issue #336:

- Delete `provider_for_turn` / `resolve_turn_provider` aliases (`provider_for`
  is the canonical entry point and the aliases had no callers).
- Inline the `severity_from_usd_pub` visibility-laundering wrapper —
  `severity_from_usd` is now `pub(crate)` and `tool_call_patterns` calls it
  directly.
- Delete `Fidelity::classify`; its only callers were the file's own tests,
  which now use `classify_fidelity` directly.

Follow-up fall-out triage from the blanket-allow removal is staged in a
subsequent commit.

https://claude.ai/code/session_01WavFVyZAAyiSmWaktaXsmD
After dropping `#![allow(dead_code, unused_imports)]` from the four
absorbed module roots, ~130 warnings surfaced. Resolve them by trimming
inner-module-root re-export chains down to what `lib.rs` actually
publishes, deleting items confirmed dead across SDK + CLI + node, and
gating test-only helpers with `#[cfg(test)]`. No change to the SDK's
external surface in `lib.rs`.

- Trimmed `pub use` lists in `analyze.rs`, `ingest.rs`, `ledger.rs`,
  `reader.rs` to only the items re-exported by `lib.rs` or consumed by a
  sibling submodule.
- Deleted dead helpers: `provider_for_model`, `flatten_value`,
  `stringify_measured_content`, `merge_content_by_order`,
  `ghost_findings_to_waste_findings`, `DetectGhostSurfaceOptions`,
  `OpencodeStreamCursor`, `resolve_pending_stamps_for_session` wrapper,
  `FIRST_PARTY_TABLES`, the unused `tokenizer` field on
  `ParseOptions`/`ParseIncrementalOptions`, and `Cursors::{get,remove}`.
- Removed `reader/opencode_stream.rs` (1.6k lines, unused) and the bulk
  of `ingest/reingest.rs`; retained `derive_codex_session_id` because
  `ingest/ingest.rs` consumes it.
- Gated test-only items behind `#[cfg(test)]`: `attribute_claude_md`
  scaffolding, `extend_default_rules`, `infer_outcome`,
  `compute_one_shot_rate`, gap-warning reset helpers,
  `ingest_claude_projects`, `LedgerLayout::under`, `turn_id_fingerprint`,
  `parse_codex_session`, `parse_opencode_session`, etc.
- Swapped a handful of test imports onto direct module paths so the
  facade `pub use` lines could go.

`cargo build --workspace` is warning-free; `cargo test --workspace`
passes (10 binaries, 775 tests).

https://claude.ai/code/session_01WavFVyZAAyiSmWaktaXsmD
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e4fa7a1d-a88f-422d-946d-c1b991379819

📥 Commits

Reviewing files that changed from the base of the PR and between dc4caec and c4fe06f.

📒 Files selected for processing (2)
  • crates/relayburn-sdk/src/analyze/claude_md.rs
  • crates/relayburn-sdk/src/analyze/provider_reattribution.rs

📝 Walkthrough

Walkthrough

This PR implements systematic API hygiene cleanup across the relayburn-sdk by removing blanket compiler lint suppressions, narrowing public re-export surfaces, gating test-only code, and removing dead functions per issue #336. The reader module's OpenCode streaming ingestion is eliminated entirely, parser APIs are consolidated around incremental paths, and the analyze and ingest modules tighten their public surfaces while properly isolating test-only helpers.

Changes

Rust Hygiene: Remove Lint Suppressions and Narrow Public APIs

Layer / File(s) Summary
Reader Module: Remove Streaming, Gate Test APIs, Simplify Parsers
src/reader.rs, src/reader/claude.rs, src/reader/codex.rs, src/reader/opencode.rs, src/reader/fidelity.rs, src/reader/user_turn.rs, src/reader/opencode_stream.rs (removed)
OpenCode streaming ingestion module is entirely removed. Codex and Opencode non-incremental parsing APIs are gated to test-only. Claude parser's tokenizer configuration field is removed, forcing heuristic token counting. Fidelity::classify method is removed, consolidating to free function. User turn stringify_measured_content helper removed. Reader re-exports narrowed to incremental-focused parsing paths.
Analyze Module: Tighten Re-exports, Gate Test Helpers, Remove Dead Functions
src/analyze.rs, src/analyze/claude_md.rs, src/analyze/fidelity.rs, src/analyze/findings.rs, src/analyze/ghost_surface.rs, src/analyze/pricing.rs, src/analyze/provider.rs, src/analyze/provider_reattribution.rs, src/analyze/quality.rs, src/analyze/tool_call_patterns.rs, src/analyze/tool_output_bloat.rs
Crate-level #![allow(dead_code, unused_imports)] removed. Public re-exports narrowed across all submodules: claude_md, fidelity, findings, ghost_surface, pricing, provider, quality, replacement_savings, tool_call_patterns, tool_output_bloat. Test-only input structs and helper functions gated behind #[cfg(test)]. Dead provider aliases (provider_for_turn, resolve_turn_provider) and unused helpers (flatten_value, ghost_findings_to_waste_findings) removed.
Ingest Module: Remove Reingest Workflow, Gate Test Helpers, Narrow Re-exports
src/ingest.rs, src/ingest/cursors.rs, src/ingest/gap.rs, src/ingest/ingest.rs, src/ingest/reingest.rs, src/ingest/pending_stamps.rs, src/ingest/gap_warning_tests.rs, src/ingest/orchestration_tests.rs
Crate-level #![allow(dead_code, unused_imports)] removed. Full reingest_missing_content workflow removed from reingest.rs; only derive_codex_session_id filename derivation retained. Test-only gap-tracking helpers and ingest_claude_projects gated behind #[cfg(test)]. OpencodeStreamCursor wrapper removed from cursor schema. Re-exports for cursors, gap helpers, reingest, walk APIs removed. Convenience wrapper resolve_pending_stamps_for_session removed. Test file imports reorganized.
Ledger Schema and Layout Test-Gating
src/ledger.rs, src/ledger/schema.rs, src/ledger/fingerprint.rs
FIRST_PARTY_TABLES public constant removed from schema. LedgerLayout struct gated to #[cfg(test)]. Fingerprint tests module gated to #[cfg(test)]. Ledger.rs imports/re-exports reorganized with test-specific path handling.
Root Module: Remove Lint Suppressions and Reorganize Verb Wiring
src/lib.rs
#[allow(unused_imports)] attributes removed from verb module declarations. Handpicked re-exports for export_verbs, ingest_verb, query_verbs introduced to replace blanket suppression.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • AgentWorkforce/burn#348: Directly related gap writer override re-export gating pattern (restore_ingest_gap_writer/set_ingest_gap_writer behind cfg(any(test, feature = "test-utils"))).
  • AgentWorkforce/burn#302: Prior ingest verb surface introduction; this PR's ingest.rs re-export narrowing directly impacts those APIs' accessibility.
  • AgentWorkforce/burn#305: Prior modification to analyze.rs that added the same lint-suppression attribute and re-export wiring that this PR now removes.

Poem

🐰 Hop along the narrowing path,
Dead code cleared by hygiene's wrath,
Test gates rise, lint suppression gone,
Incremental parsers march on.
OpenCode streams drift away — cleaner APIs today!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: removing workspace-wide dead_code/unused_imports allow attributes and resolving the resulting warnings.
Description check ✅ Passed The description is directly related to the changeset, explaining the removal of blanket allows, listing the addressed dead items, and providing test results.
Linked Issues check ✅ Passed The PR addresses all primary objectives from issue #336: removes top-level allows from module roots, gates test-only items with #[cfg(test)], deletes confirmed-dead candidates (provider_for_turn, resolve_turn_provider, severity_from_usd_pub, Fidelity::classify), and maintains downstream compatibility.
Out of Scope Changes check ✅ Passed All changes align with the stated objectives: removing dead-code/unused-imports allows, trimming re-export chains, deleting unused items, and gating test-only helpers. The removal of opencode_stream.rs and reingest.rs are part of the confirmed-dead cleanup.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/sweet-bohr-BIJao

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/relayburn-sdk/src/analyze/provider_reattribution.rs (1)

133-140: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

extend_default_rules is #[cfg(test)] but documented as a public extension helper

crates/relayburn-sdk/src/analyze/provider_reattribution.rs module docs (lines 13-15) present extend_default_rules as the way to extend the default provider rules, but the function itself is gated behind #[cfg(test)] (lines ~24-32 / decl ~134). In non-test builds the helper isn’t available, so downstream callers following the docs can’t compile (and the rustdoc reference is effectively invalid).

Make extend_default_rules available in normal builds (remove/adjust #[cfg(test)]), or update the docs/examples to use an always-available alternative (e.g., default_rules().to_vec() + extend(...)) instead.

🤖 Prompt for 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.

In `@crates/relayburn-sdk/src/analyze/provider_reattribution.rs` around lines 133
- 140, The doc examples advertise extend_default_rules but the function is
currently gated with #[cfg(test)] so it’s unavailable in non-test builds; either
remove the #[cfg(test)] from extend_default_rules in provider_reattribution.rs
so the helper is public for normal builds (keeping its signature: pub fn
extend_default_rules<I>(extra: I) -> Vec<ProviderRule> where I:
IntoIterator<Item = ProviderRule>), or update the module docs to show the
always-available alternative using default_rules().to_vec() and Vec::extend
instead; pick one fix and make the code/docs consistent (references:
extend_default_rules, default_rules, ProviderRule in provider_reattribution.rs).
🤖 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/analyze/claude_md.rs`:
- Around line 310-313: The doc comment on attribute_claude_md_refs links to the
test-only function attribute_claude_md, which will be absent in non-test builds
and breaks rustdoc links; update the docs for attribute_claude_md_refs to remove
the intra-doc link and refer to "attribute_claude_md" as plain text (or wrap
that sentence in a cfg(test)/doc-specific cfg_attr so the link is emitted only
when attribute_claude_md exists). Locate the `attribute_claude_md_refs` doc
string and either replace `[`attribute_claude_md`]` with unlinked plain text or
conditionally emit the sentence using cfg_attr(docsrs, cfg(test)) as
appropriate.

In `@crates/relayburn-sdk/src/reader/claude.rs`:
- Around line 49-53: The evidence field is incorrectly hidden behind
#[cfg(test)], breaking downstream APIs like parse_claude_session and
reconcile_claude_session_relationships that expect ClaudeRelationshipEvidence;
remove the #[cfg(test)] gating from the pub evidence: ClaudeRelationshipEvidence
field(s) (and any other similarly guarded evidence fields around the same
struct, e.g., the second occurrence at lines ~121-122) so
ParseResult/ParseIncrementalResult exposes evidence in non-test builds and
callers can reconcile across files.

---

Outside diff comments:
In `@crates/relayburn-sdk/src/analyze/provider_reattribution.rs`:
- Around line 133-140: The doc examples advertise extend_default_rules but the
function is currently gated with #[cfg(test)] so it’s unavailable in non-test
builds; either remove the #[cfg(test)] from extend_default_rules in
provider_reattribution.rs so the helper is public for normal builds (keeping its
signature: pub fn extend_default_rules<I>(extra: I) -> Vec<ProviderRule> where
I: IntoIterator<Item = ProviderRule>), or update the module docs to show the
always-available alternative using default_rules().to_vec() and Vec::extend
instead; pick one fix and make the code/docs consistent (references:
extend_default_rules, default_rules, ProviderRule in provider_reattribution.rs).
🪄 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: 31ddf9ce-bd14-471e-be67-d6b6bc55b4a2

📥 Commits

Reviewing files that changed from the base of the PR and between 1f0c28a and dc4caec.

📒 Files selected for processing (31)
  • crates/relayburn-sdk/src/analyze.rs
  • crates/relayburn-sdk/src/analyze/claude_md.rs
  • crates/relayburn-sdk/src/analyze/fidelity.rs
  • crates/relayburn-sdk/src/analyze/findings.rs
  • crates/relayburn-sdk/src/analyze/ghost_surface.rs
  • crates/relayburn-sdk/src/analyze/pricing.rs
  • crates/relayburn-sdk/src/analyze/provider.rs
  • crates/relayburn-sdk/src/analyze/provider_reattribution.rs
  • crates/relayburn-sdk/src/analyze/quality.rs
  • crates/relayburn-sdk/src/analyze/tool_call_patterns.rs
  • crates/relayburn-sdk/src/analyze/tool_output_bloat.rs
  • crates/relayburn-sdk/src/ingest.rs
  • crates/relayburn-sdk/src/ingest/cursors.rs
  • crates/relayburn-sdk/src/ingest/gap.rs
  • crates/relayburn-sdk/src/ingest/gap_warning_tests.rs
  • crates/relayburn-sdk/src/ingest/ingest.rs
  • crates/relayburn-sdk/src/ingest/orchestration_tests.rs
  • crates/relayburn-sdk/src/ingest/pending_stamps.rs
  • crates/relayburn-sdk/src/ingest/reingest.rs
  • crates/relayburn-sdk/src/ledger.rs
  • crates/relayburn-sdk/src/ledger/fingerprint.rs
  • crates/relayburn-sdk/src/ledger/schema.rs
  • crates/relayburn-sdk/src/lib.rs
  • crates/relayburn-sdk/src/reader.rs
  • crates/relayburn-sdk/src/reader/claude.rs
  • crates/relayburn-sdk/src/reader/codex.rs
  • crates/relayburn-sdk/src/reader/fidelity.rs
  • crates/relayburn-sdk/src/reader/opencode.rs
  • crates/relayburn-sdk/src/reader/opencode_stream.rs
  • crates/relayburn-sdk/src/reader/opencode_stream/tests.rs
  • crates/relayburn-sdk/src/reader/user_turn.rs
💤 Files with no reviewable changes (9)
  • crates/relayburn-sdk/src/reader/opencode_stream/tests.rs
  • crates/relayburn-sdk/src/ledger/schema.rs
  • crates/relayburn-sdk/src/lib.rs
  • crates/relayburn-sdk/src/reader/user_turn.rs
  • crates/relayburn-sdk/src/ingest/pending_stamps.rs
  • crates/relayburn-sdk/src/analyze/pricing.rs
  • crates/relayburn-sdk/src/analyze/ghost_surface.rs
  • crates/relayburn-sdk/src/analyze/provider.rs
  • crates/relayburn-sdk/src/reader/opencode_stream.rs

Comment thread crates/relayburn-sdk/src/analyze/claude_md.rs
Comment on lines +49 to 53
/// Read by the in-crate test suite to verify the From<ParseIncrementalResult>
/// conversion preserves evidence. Production callers consume the incremental
/// result directly and access `evidence` from there.
#[cfg(test)]
pub evidence: ClaudeRelationshipEvidence,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don't hide reconciliation evidence from release builds.

parse_claude_session is still part of the exported Claude surface in crates/relayburn-sdk/src/reader.rs (Lines 43-48), and reconcile_claude_session_relationships still takes ClaudeRelationshipEvidence. Gating ParseResult::evidence behind #[cfg(test)] means release callers can no longer do a full parse and then reconcile across files, while the in-crate tests keep passing because they still compile with the field present.

Suggested fix
 pub struct ParseResult {
     pub turns: Vec<TurnRecord>,
     pub content: Vec<ContentRecord>,
     pub events: Vec<CompactionEvent>,
     pub relationships: Vec<SessionRelationshipRecord>,
     pub tool_result_events: Vec<ToolResultEventRecord>,
     pub user_turns: Vec<UserTurnRecord>,
-    #[cfg(test)]
     pub evidence: ClaudeRelationshipEvidence,
 }
@@
 impl From<ParseIncrementalResult> for ParseResult {
     fn from(r: ParseIncrementalResult) -> Self {
         Self {
             turns: r.turns,
             content: r.content,
             events: r.events,
             relationships: r.relationships,
             tool_result_events: r.tool_result_events,
             user_turns: r.user_turns,
-            #[cfg(test)]
             evidence: r.evidence,
         }
     }
 }

Also applies to: 121-122

🤖 Prompt for 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.

In `@crates/relayburn-sdk/src/reader/claude.rs` around lines 49 - 53, The evidence
field is incorrectly hidden behind #[cfg(test)], breaking downstream APIs like
parse_claude_session and reconcile_claude_session_relationships that expect
ClaudeRelationshipEvidence; remove the #[cfg(test)] gating from the pub
evidence: ClaudeRelationshipEvidence field(s) (and any other similarly guarded
evidence fields around the same struct, e.g., the second occurrence at lines
~121-122) so ParseResult/ParseIncrementalResult exposes evidence in non-test
builds and callers can reconcile across files.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 31 files

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

`attribute_claude_md` and `extend_default_rules` are now `#[cfg(test)]`,
so their non-test consumers' intra-doc links resolve to nothing in a
default `cargo doc` build.

- `attribute_claude_md_refs` doc: drop the link; describe the function
  on its own terms.
- `provider_reattribution` module doc: point at `default_rules` plus a
  manual `Vec` spread instead of the test-only convenience.

https://claude.ai/code/session_01WavFVyZAAyiSmWaktaXsmD
@willwashburn willwashburn merged commit 708f630 into main May 24, 2026
12 checks passed
@willwashburn willwashburn deleted the claude/sweet-bohr-BIJao branch May 24, 2026 21:06
willwashburn pushed a commit that referenced this pull request May 25, 2026
Main released 2.10.0 (hotspots MCP rollup #424), 2.10.1 (#427 +
pending-stamp refactor #428), and the workspace-wide dead_code/
unused_imports cleanup #429. The latter removed ingest_claude_projects
from the public re-export and switched orchestration_tests to
`crate::ingest::ingest::*` deep imports.

Conflict resolution:
- crates/relayburn-sdk/src/ingest.rs: keep main's narrowed re-export
  (no ingest_claude_projects) and add ingest_claude_transcript_path.
- crates/relayburn-sdk/src/ingest/orchestration_tests.rs: keep main's
  deep imports and add ingest_claude_transcript_path next to its
  sibling verbs.
- CHANGELOG.md: slot this branch's items under [Unreleased] above
  main's new 2.10.0 release section.

https://claude.ai/code/session_011ubB69Zxijqb1BsYVYL9iQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust hygiene: remove workspace-wide #![allow(dead_code, unused_imports)]

2 participants