Skip to content

[Repo Assist] fix(rust-guard): merge double extract_repo_info call; remove stale #[allow(dead_code)] attrs#2334

Closed
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/fix-issue-2226-rust-guard-cleanups-aff190465fdae3e6
Closed

[Repo Assist] fix(rust-guard): merge double extract_repo_info call; remove stale #[allow(dead_code)] attrs#2334
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/fix-issue-2226-rust-guard-cleanups-aff190465fdae3e6

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated PR from Repo Assist.

Closes #2226.

Summary

Two small, low-risk cleanups to the Rust guard identified in issue #2226.

Change 1: response_paths.rs — merge double extract_repo_info call (perf)

Task 8 – Performance: The "get_file_contents" branch called extract_repo_info(tool_args) twice on consecutive lines, each time discarding half the returned tuple:

// Before (two calls, two redundant heap allocations)
let (_arg_owner, _arg_repo, arg_repo_full) = extract_repo_info(tool_args);
let (arg_owner, arg_repo, _)              = extract_repo_info(tool_args);

// After (one call, consistent with every other branch in the same match)
let (arg_owner, arg_repo, arg_repo_full) = extract_repo_info(tool_args);

Each call allocates three String values. Merging into one call eliminates the redundant allocation and makes get_file_contents consistent with every other branch in the same match (list_pull_requests, list_issues, list_commits, list_releases, get_repository_tree, etc. all call extract_repo_info exactly once).

Change 2: lib.rs — remove six stale #[allow(dead_code)] annotations (code quality)

Task 10 – Take the Repository Forward: All six items are actively called via crate:: paths from submodules and therefore would never trigger the dead_code lint:

Item Active callers
pub fn invoke_backend permissions.rs:159
pub enum LogLevel variant uses in log() and log_debug/info/warn/error
fn log_debug permissions.rs, labels/helpers.rs
fn log_info labels/response_items.rs, labels/response_paths.rs, labels/helpers.rs
fn log_warn labels/helpers.rs, labels/backend.rs
fn log_error labels/backend.rs, lib.rs

The annotations were added as defensive scaffolding when the logging and backend infrastructure had no callers. Now that all label modules are wired up, the suppressions are stale noise that masks future legitimate dead-code warnings.

Trade-offs

  • Both changes are purely mechanical — no behavioural difference.
  • The double-call fix eliminates 3 redundant String heap allocations on every get_file_contents response label call.

Test Status

Check Result
cargo check --target wasm32-wasip1 ✅ Clean (0 warnings, 0 errors)
WASM release build (./build.sh) ✅ Successful — 265 KB
Go unit tests ⚠️ Infrastructure unavailable (Go 1.25.0 toolchain not reachable in this env) — changes are Rust-only and do not affect Go code

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

…ad_code attrs

Fixes #2226.

Change 1: response_paths.rs - merge double extract_repo_info (perf)

The "get_file_contents" branch called extract_repo_info(tool_args) twice
in consecutive lines, each time discarding half the returned tuple. Each
call allocates three String values. Merging into one call eliminates the
redundant allocation and makes this branch consistent with every other
branch in the same match (list_pull_requests, list_issues, list_commits,
list_releases, get_repository_tree, etc., all call extract_repo_info once).

Change 2: lib.rs - remove six stale #[allow(dead_code)] annotations

All six items are actively called via crate:: paths from submodules:
- invoke_backend  -- permissions.rs:159
- LogLevel enum   -- lib.rs variant uses in log()
- log_debug       -- permissions.rs, labels/helpers.rs
- log_info        -- labels/response_items.rs, response_paths.rs, helpers.rs
- log_warn        -- labels/helpers.rs, labels/backend.rs
- log_error       -- labels/backend.rs, lib.rs

The annotations were added as defensive scaffolding when the logging and
backend infrastructure had no callers. Now that all label modules are wired
up, the suppressions are stale noise that masks future legitimate warnings.

Test Status:
- cargo check --target wasm32-wasip1: clean (0 warnings, 0 errors)
- WASM build (./build.sh): successful, 265 KB
- Go tests: infrastructure unavailable (Go 1.25.0 toolchain not reachable)
  Changes are Rust-only; Go code unaffected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rust-guard] Rust Guard: Fix double extract_repo_info call + remove stale dead_code annotations in lib.rs

1 participant