Skip to content

chore: sweep dead code and small defects across core, config, typeshed, testkit, workspace - #139

Merged
sims1253 merged 8 commits into
mainfrom
cleanup/small-crates-dead-code
Aug 31, 2026
Merged

sims1253 merged 8 commits into
mainfrom
cleanup/small-crates-dead-code

Conversation

@sims1253

@sims1253 sims1253 commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

Sweeps dead code and small defects across five crates. Every deletion was grepped across the whole workspace first. Only two changes alter behavior: the poisoned-cache recovery and the async decoder cap. Both have changelog entries. The rest is internal cleanup.

Changes

ry-core

  • Delete RType::with_members. Zero callers anywhere.
  • Drop the unused _src parameter from RParser::span and its 36 call sites.
  • Rewrite byte_col_to_char_col with char_indices().take_while(...).count(). The old loop carried a let _ = ch; wart.

ry-config

  • Delete config_hash. Zero callers. serde_json stays a dependency: baseline.rs uses it.
  • Make DEFAULT_MAX_SERIALIZED_BYTES and the three DEFAULT_INDEX_* constants private. They are only used in-crate.
  • Fix the stray interior spaces in the InvalidIndex error message.
  • Remove the crate-level #![allow(clippy::collapsible_if)] and collapse the two nested ifs it was masking.
  • diagnostic_path now borrows the caller's &Path instead of allocating a PathBuf just to strip_prefix.

ry-typeshed

  • Delete BAYES_JSON (deprecated alias) and FunctionSigWithKey. Zero consumers.
  • Make the 34 *_JSON embeds private. SOURCE stays public: ry-cli reads it.
  • Rewrite load_package: an explicit is_known_package check, then the map build, then the lookup. The old let _ = PACKAGE_SPECS.iter().find(...)? was a find used only to early-return.
  • Trim the stale comment about past load_base().expect() callers.
  • Demote discover_stub_files and load_stub_file to private. Their docs claimed external tools use them; the CLI goes through validate_stub_dirs instead. Docs now state what they do.

ry-testkit

  • Delete JsonRpcProcess::child_id. Zero callers.
  • Keep one copy of the publication_mark doc comment. It was pasted twice.
  • decode_async now enforces MAX_MESSAGE_BYTES on headers, mirroring decode_blocking. Two new tests cover the oversized-header rejection and the happy path. This required a test-only tokio rt/macros dev-dependency.

ry-workspace

  • serialized_inventory recovers from a poisoned mutex via unwrap_or_else(|poisoned| poisoned.into_inner()). A panic elsewhere no longer cascade-panics the LSP. The cache guards no invariant, so recovery is safe.
  • Extract decode_capped and a Compression tag. The three near-identical bzip2/gzip/xz arms collapse into one match.
  • Move the misplaced SourceBindings doc paragraph onto source_package_dynamic_bindings, which lacked a doc. The orphaned summary sentence stays with the struct.
  • Demote is_file_eligible_with_excludes to private. Only in-crate callers exist; external code uses is_file_eligible.
  • Bind the S3method generic name once instead of computing args.first().and_then(static_name) twice.

CHANGELOG

Two ### Fixed entries under ## [Unreleased]: the poisoned-cache recovery and the async decoder cap.

Verification

  • cargo fmt --check -p ry-core -p ry-config -p ry-typeshed -p ry-testkit -p ry-workspace — clean.
  • cargo clippy -p <crate> --all-targets -- -D warnings for all five crates — no warnings.
  • cargo test -p <crate> for all five crates — 92, 31, 25, 17, and 10 tests pass, 0 failures.
  • cargo check --workspace — clean.
  • cargo check -p ry-cli -p ry-lsp — clean, proving no cross-crate breakage.

Summary by CodeRabbit

  • Bug Fixes

    • Improved language-server recovery when internal worker synchronization encounters an error.
    • Added protection against oversized asynchronous JSON-RPC messages, with clear rejection of messages exceeding 16 MiB.
    • Preserved reliable message framing and end-of-file handling during JSON-RPC communication.
  • Refactoring

    • Improved internal configuration, parsing, workspace, and type-handling code without changing expected behavior.
    • Reduced exposure of internal implementation details for greater API stability.

@coderabbitai

coderabbitai Bot commented Aug 31, 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: ASSERTIVE

Plan: Team

Run ID: 692572ac-3510-4b10-aa9b-a587cd53e530

📥 Commits

Reviewing files that changed from the base of the PR and between 95a4913 and d99429f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • CHANGELOG.md
  • crates/ry-config/src/baseline.rs
  • crates/ry-config/src/config.rs
  • crates/ry-config/src/lib.rs
  • crates/ry-core/src/parser.rs
  • crates/ry-core/src/types.rs
  • crates/ry-testkit/Cargo.toml
  • crates/ry-testkit/src/json_rpc.rs
  • crates/ry-testkit/src/lsp_session.rs
  • crates/ry-typeshed/src/lib.rs
  • crates/ry-workspace/src/lib.rs
  • crates/ry-workspace/src/packages.rs
💤 Files with no reviewable changes (3)
  • crates/ry-testkit/src/lsp_session.rs
  • crates/ry-config/src/lib.rs
  • crates/ry-core/src/types.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The PR removes unused public APIs, simplifies parser and package metadata code, limits async JSON-RPC headers to 16 MiB, and recovers workspace caches from poisoned mutexes. It also centralizes capped decompression and updates the changelog.

Changes

Configuration cleanup

Layer / File(s) Summary
Configuration paths and internal APIs
crates/ry-config/src/baseline.rs, crates/ry-config/src/config.rs, crates/ry-config/src/lib.rs
Configuration path handling now uses borrowed paths. Default constants are private, config_hash is removed, and the lint allowance is deleted.

Parser and type API cleanup

Layer / File(s) Summary
Parser span handling and type construction
crates/ry-core/src/parser.rs, crates/ry-core/src/types.rs
Parser span calls no longer pass unused source text. Character-column conversion uses iterators. The permissive RType::with_members method is removed.

Async JSON-RPC limits

Layer / File(s) Summary
Bounded async decoding and tests
crates/ry-testkit/Cargo.toml, crates/ry-testkit/src/json_rpc.rs, CHANGELOG.md
Async header reads enforce the 16 MiB limit. Tests cover oversized headers and framed messages. child_id is removed.

Workspace resilience

Layer / File(s) Summary
Cache recovery and capped decompression
crates/ry-workspace/src/lib.rs, CHANGELOG.md
Serialized-inventory cache locks recover from poisoning. Bzip2, gzip, and XZ decoding use shared capped-decode outcomes. Documentation is moved to the relevant binding function.

Typeshed and package metadata

Layer / File(s) Summary
Private vendored data and metadata helpers
crates/ry-typeshed/src/lib.rs, crates/ry-workspace/src/packages.rs
Vendored JSON constants and stub helpers become private. BAYES_JSON and FunctionSigWithKey are removed. Known-package checks and S3 generic extraction are simplified.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to d9942

This PR removes unused internal code and narrows APIs while adding bounded async decoding and poisoned-cache recovery; the reported checks pass, and no actionable merge-blocking risk remains after normal checks and review.

Poem

A rabbit checks the cache at dawn

Poisoned locks are safely gone
Headers stop at sixteen MiB
Parsers hop more simply
Private names hide in the burrow

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 44 functions across 7 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the pull request's main focus: removing dead code and fixing small defects across the affected crates.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 47.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 44 functions across 7 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cleanup/small-crates-dead-code

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — all 13 files of this cleanup sweep, with every deletion and visibility demotion grepped workspace-wide and both behavioral changes traced, built, and tested locally.

  • ry-core: RType::with_members deleted (zero references repo-wide, fuzz/ and editors/ included); RParser::span drops its unused _src parameter across all call sites; byte_col_to_char_col rewritten as a semantically identical take_while().count().
  • ry-config: dead config_hash removed (serde_json correctly retained — baseline.rs still uses it); DEFAULT_MAX_SERIALIZED_BYTES and the three DEFAULT_INDEX_* constants privatized; InvalidIndex message interior spaces fixed (nothing pinned the old string); the collapsible_if allow is gone with the one masked nest collapsed; diagnostic_path borrows the caller's &Path with unchanged semantics.
  • ry-typeshed: BAYES_JSON and FunctionSigWithKey deleted (zero consumers); the 34 *_JSON embeds privatized while SOURCE correctly stays pub (ry-cli reads it, main.rs:1124); load_package's is_known_package gate is semantically identical to the old find(...)?; discover_stub_files/load_stub_file demoted to private — the CLI's validator goes through validate_stub_dirs (main.rs:1164), so the old "public so tools use it" doc was indeed stale.
  • ry-testkit: child_id deleted; decode_async now enforces the same 16 MiB header cap as decode_blocking. The cap arithmetic checks out (per-line take(remaining + 1), header_bytes <= MAX invariant prevents underflow, exactly-at-cap headers still pass, and the body remains bounded by the shared checked_length). Both new tests are meaningful — without the fix, the reject test would surface UnexpectedEof rather than InvalidData.
  • ry-workspace: poisoned-mutex recovery on both serialized_inventory lock sites (the cache guards no invariant, so into_inner() is sound); the three bzip2/gzip/xz arms collapse into Compression + decode_capped with byte-identical behavior (same magic bytes, same read_cap, same degraded/empty mapping); the SourceBindings doc paragraph moved to its real owner; is_file_eligible_with_excludes privatized; the S3method generic is bound once with the necessary clones.
  • Verification run locally: cargo check --workspace --all-targets clean (proves no cross-crate breakage from the demotions), 175 tests across the five crates with 0 failures including the two new async decoder tests, cargo clippy --all-targets -- -D warnings clean on all five, cargo fmt --check clean. The public-API reductions carry no semver exposure: ry-testkit and ry-workspace are publish = false, and the rest land inside the unreleased 0.9.0.

Pullfrog  | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

@sims1253
sims1253 merged commit 8577b2d into main Aug 31, 2026
18 of 19 checks passed
@sims1253
sims1253 deleted the cleanup/small-crates-dead-code branch August 31, 2026 21:00
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