Skip to content

relayburn: mechanical Rust cleanup (clippy + dedup + dead code)#330

Merged
willwashburn merged 1 commit intomainfrom
rust-mechanical-cleanup
May 7, 2026
Merged

relayburn: mechanical Rust cleanup (clippy + dedup + dead code)#330
willwashburn merged 1 commit intomainfrom
rust-mechanical-cleanup

Conversation

@willwashburn
Copy link
Copy Markdown
Member

Summary

Mechanical Rust cleanup. No behavior change — pure cleanup that drops the workspace clippy warning count from 28 → 17 and removes ~90 LOC of duplication and dead code.

  • Replace io::Error::new(io::ErrorKind::Other, e) with io::Error::other(e) (×6).
  • Drop redundant Ok(Ledger::open(opts)?) wrapping (×2).
  • Misc clippy fixes: Some(0), .is_multiple_of(3), .as_deref().
  • Consolidate four byte-identical copies of format_with_commas (findings, tool_call_patterns, tool_output_bloat, ghost_surface) into a new analyze::util module.
  • Delete confirmed-dead ledger::reader::lookup_content_fingerprint and commands::not_yet_implemented.
  • Drop incorrect #[allow(dead_code)] on writer::debug_now — it IS called from ledger.rs.
  • Drop the stale GlobalArgs clippy allow now that Wave 2 D1–D8 consumes both ledger_path and no_color.

This is the lowest-risk slice of a larger Rust review punch list (perf wins, async hygiene, SQL filter pushdown, std::env::set_var removal, date-math consolidation) — those land separately.

Test plan

  • cargo build --workspace --all-targets clean
  • cargo test --workspace passes (729 tests, 0 failures)
  • cargo clippy --workspace --all-targets warning count drops from 28 → 17

🤖 Generated with Claude Code

Pure cleanup, no behavior change. Drops the workspace clippy warning
count from 28 to 17 and removes ~90 LOC of duplication and dead code.

- relayburn-cli: replace `io::Error::new(io::ErrorKind::Other, e)` with
  `io::Error::other(e)` (×6 in render/error.rs, render/json.rs,
  commands/overhead.rs).
- relayburn-cli: collapse redundant `Ok(Ledger::open(opts)?)` to plain
  `Ledger::open(opts)` in commands/{ingest,mcp_server}.rs (the SDK verb
  already returns `anyhow::Result`).
- relayburn-cli: `Some(n) if n == 0` → `Some(0)`, `% 3 == 0` →
  `.is_multiple_of(3)` in commands/{ingest,overhead}.rs.
- relayburn-sdk: `t.files_touched.as_ref().map(|v| v.as_slice())` →
  `.as_deref()` in reader/claude.rs.
- relayburn-sdk: consolidate four byte-identical copies of
  `format_with_commas` (findings, tool_call_patterns, tool_output_bloat,
  ghost_surface) into a new `analyze::util` module.
- relayburn-sdk: delete `lookup_content_fingerprint` from
  ledger/reader.rs — `#[allow(dead_code)]` and confirmed unused.
- relayburn-cli: delete `not_yet_implemented` from commands/mod.rs —
  `#[allow(dead_code)]` and not called now that all Wave 2 D1–D8
  presenters have landed.
- relayburn-sdk: drop incorrect `#[allow(dead_code)]` on
  `writer::debug_now` — it IS called from ledger.rs (twice).
- relayburn-cli: drop the stale `#[allow(dead_code)]` on `GlobalArgs`
  now that Wave 2 consumes both `ledger_path` and `no_color`.

This is the lowest-risk slice of a larger Rust review punch list
(perf wins, async hygiene, SQL filter pushdown, env-var removal, etc.) —
those land separately.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

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: 940bba8d-f1a2-49cc-98b7-781205cd570c

📥 Commits

Reviewing files that changed from the base of the PR and between e3feb7b and 8c33211.

📒 Files selected for processing (16)
  • crates/relayburn-cli/src/cli.rs
  • crates/relayburn-cli/src/commands/ingest.rs
  • crates/relayburn-cli/src/commands/mcp_server.rs
  • crates/relayburn-cli/src/commands/mod.rs
  • crates/relayburn-cli/src/commands/overhead.rs
  • crates/relayburn-cli/src/render/error.rs
  • crates/relayburn-cli/src/render/json.rs
  • crates/relayburn-sdk/src/analyze.rs
  • crates/relayburn-sdk/src/analyze/findings.rs
  • crates/relayburn-sdk/src/analyze/ghost_surface.rs
  • crates/relayburn-sdk/src/analyze/tool_call_patterns.rs
  • crates/relayburn-sdk/src/analyze/tool_output_bloat.rs
  • crates/relayburn-sdk/src/analyze/util.rs
  • crates/relayburn-sdk/src/ledger/reader.rs
  • crates/relayburn-sdk/src/ledger/writer.rs
  • crates/relayburn-sdk/src/reader/claude.rs
💤 Files with no reviewable changes (4)
  • crates/relayburn-sdk/src/ledger/reader.rs
  • crates/relayburn-sdk/src/ledger/writer.rs
  • crates/relayburn-cli/src/commands/mod.rs
  • crates/relayburn-cli/src/cli.rs

📝 Walkthrough

Walkthrough

This PR consolidates the burn CLI by introducing a centralized GlobalArgs struct for global flags (--json, --ledger-path, --no-color), fleshes out complete typed clap argument structures for all subcommands, extracts a shared format_with_commas utility in the SDK, and simplifies error handling and dead code across multiple modules.

Changes

CLI Consolidation

Layer / File(s) Summary
Global Arguments & Command Enum
crates/relayburn-cli/src/cli.rs
Introduces GlobalArgs struct bundling global flags and Args as the clap root with globals() helper. Defines Command enum with typed variants: Summary(SummaryArgs), Hotspots(HotspotsArgs), Overhead(OverheadArgs), Compare(CompareArgs), Run(RunArgs), State(StateArgs), Ingest(IngestArgs), McpServer(McpServerArgs).
Subcommand Argument Types
crates/relayburn-cli/src/cli.rs
Adds clap-derived structs for each subcommand: IngestArgs (with --watch/--hook mutual exclusivity), McpServerArgs (--session-id, --debug), RunArgs (positional harness, repeatable --tag, trailing args), CompareArgs (filters and toggles), OverheadArgs/OverheadTrimArgs, and complete StateArgs with nested StateSubcommand (Status/Rebuild/Prune/Reset).
Handler Integration
crates/relayburn-cli/src/commands/ingest.rs, crates/relayburn-cli/src/commands/mcp_server.rs
Both handlers now accept globals: &GlobalArgs and use Ledger::open(opts) directly (removing redundant Ok() wrapper). Ingest renders summary to stdout (one-shot) or stderr (watch/hook) based on mode.
Cleanup
crates/relayburn-cli/src/commands/mod.rs
Removes shared not_yet_implemented stub helper; module now only re-exports subcommand modules.

SDK Utility Extraction

Layer / File(s) Summary
Shared Formatting Utility
crates/relayburn-sdk/src/analyze/util.rs
Introduces new internal pub(crate) fn format_with_commas(n: u64) -> String for thousands-separator formatting (comma insertion every three digits from the end).
Analyzer Integration
crates/relayburn-sdk/src/analyze.rs
Declares internal mod util; without exporting it.
Finding Detectors
crates/relayburn-sdk/src/analyze/findings.rs, crates/relayburn-sdk/src/analyze/ghost_surface.rs, crates/relayburn-sdk/src/analyze/tool_call_patterns.rs, crates/relayburn-sdk/src/analyze/tool_output_bloat.rs
All now import format_with_commas from super::util, removing duplicate local implementations. Call sites (e.g., formatting token counts in WasteFinding.detail) remain unchanged.

Error & Code Cleanup

Layer / File(s) Summary
Error Handling Simplification
crates/relayburn-cli/src/commands/overhead.rs, crates/relayburn-cli/src/render/error.rs, crates/relayburn-cli/src/render/json.rs
Replaces verbose io::Error::new(io::ErrorKind::Other, e) with concise io::Error::other(e) in JSON serialization error paths. Control flow and output behavior unchanged.
Dead Code Removal
crates/relayburn-sdk/src/ledger/reader.rs, crates/relayburn-sdk/src/ledger/writer.rs
Removes unused lookup_content_fingerprint function and unused #[allow(dead_code)] attribute.
Test Modernization
crates/relayburn-sdk/src/reader/claude.rs
Updates files_touched_excludes_grep_and_bash assertion to use as_deref() instead of `as_ref().map(

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related issues

  • AgentWorkforce/burn#240: The PR implements major parts of the Rust rewrite roadmap—centralized clap-based CLI, complete argument structures for all subcommands, and SDK utility extraction—directly advancing the epic's objectives.

Possibly related PRs

  • AgentWorkforce/burn#318: Both PRs convert Command::Run into Run(RunArgs) and wire the burn run driver with harness adapter integration.
  • AgentWorkforce/burn#313: Both PRs implement the typed burn state clap subcommand with StateArgs and nested state subcommand wiring.
  • AgentWorkforce/burn#319: Both PRs implement identical burn ingest and burn mcp-server CLI surfaces and command handler signatures.

Poem

🐰 Global flags now bundled tight,
Commands typed with clap's delight,
Utilities shared, no duplication,
Error paths find simplification—
The CLI hops toward its final form!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'relayburn: mechanical Rust cleanup (clippy + dedup + dead code)' clearly and concisely summarizes the main change: a mechanical cleanup addressing clippy warnings, code deduplication, and dead code removal.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, detailing specific cleanup activities (io::Error replacements, dead code removal, code consolidation) with test results confirming no behavior changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 rust-mechanical-cleanup

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

@willwashburn willwashburn merged commit c871a04 into main May 7, 2026
8 checks passed
@willwashburn willwashburn deleted the rust-mechanical-cleanup branch May 7, 2026 03:30
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.

1 participant