Skip to content

refactor(llm-access): remove dead pub fns with zero workspace callers#3

Merged
acking-you merged 1 commit into
masterfrom
refactor/llm-access-dead-code
May 30, 2026
Merged

refactor(llm-access): remove dead pub fns with zero workspace callers#3
acking-you merged 1 commit into
masterfrom
refactor/llm-access-dead-code

Conversation

@acking-you
Copy link
Copy Markdown
Owner

Summary

First refactor step of the incremental llm-access* cleanup (after PR #2 got
CI green): remove pub fn that have zero callers anywhere in the workspace.

These crates were extracted from the backend, so their public surface is wider
than what is actually wired up. Library pub items are part of the public API,
so the dead-code lint never flags them even when nothing uses them. An audit
cross-referenced every pub item against every first-party crate (including
inline tests) and found 16 pub fn with zero references beyond their own
definition.

What changed

Removed (each verified zero references workspace-wide):

crate / file functions
llm-access-codex/request.rs ensure_supported_gateway_path, extract_presented_key, extract_query_param
llm-access-kiro/auth_file.rs resolve_auths_dir, save_auth_record, load_auth_records, delete_auth_record (file-based auth CRUD; the live service is DB-backed)
llm-access-kiro/status.rs load_persisted_status_cache_from_dir, persist_status_cache_to_dir, merge_newer_account_statuses, ready_status_entry, error_status_entry, disabled_status_entry
llm-access-kiro/anthropic/mod.rs supported_model_ids
llm-access-kiro/anthropic/converter.rs classify_tool_name_rewrite_reason
llm-access-kiro/billable_multipliers.rs canonicalize_kiro_billable_model_multipliers_override_json

Plus the imports orphaned by those deletions (not_found, std::env,
anyhow::Result). Net: +2 / −257 across 6 files.

Verification

  • cargo clippy -p llm-access-codex -p llm-access-kiro -- -D warnings: clean. Also confirmed clippy reports zero private/pub(crate) dead code in these crates, so the 16 zero-caller pub fn are the complete dead set.
  • Reverse-dependency build (llm-access binary + llm-access-store) compiles — proves none of the removed fns had a hidden macro / trait-dispatch caller that grep would miss.
  • 79 codex + 160 kiro tests pass.

Scoped intentionally to verified-zero-caller free functions. uses==1 items
(re-export-only types/consts) are a possible follow-up, kept out to keep this
PR small and obviously-correct.

Audit of `pub` items across the llm-access* crates (cross-referenced against
every first-party crate, incl. inline tests) found 16 `pub fn` with zero
callers anywhere in the workspace. On master these are masked from the
dead-code lint only because they are public API; nothing actually uses them.

Removed (verified zero references workspace-wide):
- llm-access-codex/request.rs: ensure_supported_gateway_path,
  extract_presented_key, extract_query_param
- llm-access-kiro/auth_file.rs: resolve_auths_dir, save_auth_record,
  load_auth_records, delete_auth_record (file-based auth CRUD; the live
  service is DB-backed)
- llm-access-kiro/status.rs: load_persisted_status_cache_from_dir,
  persist_status_cache_to_dir, merge_newer_account_statuses,
  ready_status_entry, error_status_entry, disabled_status_entry
- llm-access-kiro/anthropic/mod.rs: supported_model_ids
- llm-access-kiro/anthropic/converter.rs: classify_tool_name_rewrite_reason
- llm-access-kiro/billable_multipliers.rs:
  canonicalize_kiro_billable_model_multipliers_override_json

Also drops the imports orphaned by the above (not_found in request.rs,
std::env in auth_file.rs, anyhow::Result in status.rs).

clippy reported zero private/pub(crate) dead code, so this is the complete
zero-caller set. Verified: clippy -D warnings clean on codex+kiro, the
reverse-dep build (llm-access binary + llm-access-store) compiles (proving no
macro/trait-dispatch hidden callers), and 79 codex + 160 kiro tests pass.

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

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request performs a code cleanup by removing several unused functions, helper methods, and imports across the llm-access-codex and llm-access-kiro crates. Specifically, it removes unused utility functions related to request parsing, authentication file handling, status caching, and model/tool name processing. There are no review comments, so I have no feedback to provide.

@acking-you acking-you merged commit c7cde5e into master May 30, 2026
2 checks passed
acking-you added a commit that referenced this pull request May 30, 2026
…#4)

* refactor(llm-access-codex): split request.rs into request/ submodules

Break the 3886-line request.rs into a request/mod.rs facade plus 9
concern-focused submodules (prepare, policy, last_message, headers,
native_responses, normalization, tools, chat_completions, path), following
the agreed module style:

- mod.rs convention (matches the rest of the workspace).
- No `use super::*` in submodules: each imports its deps explicitly from
  their origin. No `pub use X::*` facade globs: the parent re-exports only
  the 12 items used outside the module, by name.
- Minimal visibility: items crossing a module boundary are `pub` with a
  detailed `///` doc; file-internal helpers stay private. No `pub(crate)`.
- Tests inlined: the 2 adapt_openai_chat_completions_request unit tests move
  into chat_completions.rs (so the fn under test needs no extra exposure);
  the 8 pipeline integration tests stay in mod.rs against the public API.
  prepare_gateway_request / read_gateway_request_body are #[cfg(test)] (only
  reachable from tests), so they're gated accordingly.

Also removes 2 dead pub fns PR #3 missed because grep -w could not tell them
apart from admin's same-named fns: codex normalize_name / normalize_status
(zero workspace callers; admin has its own), plus the 2 now-orphan
LLM_GATEWAY_KEY_STATUS_* consts they used.

No behavior change: clippy -D warnings clean, 79 codex tests pass, and the
reverse-dep build (llm-access binary + llm-access-store) compiles against the
narrowed public surface.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(llm-access-codex): truncate mcp tool names on a UTF-8 char boundary

`String::truncate` panics when the byte index splits a multi-byte UTF-8
character. A tool name with Unicode after the `mcp__` prefix could exceed
MAX_OPENAI_TOOL_NAME_LEN bytes and crash the request handler on truncate.
Use char-based truncation (`chars().take(..).collect()`), matching the
fallback path already in the same fn. ASCII-identical; multi-byte-safe.

Addresses a PR review finding from gemini-code-assist.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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