Skip to content

rust-guard: make LogLevel private and deduplicate extract_repo_info call#3710

Merged
lpcox merged 2 commits intomainfrom
copilot/rust-guard-remove-unused-loglevel
Apr 13, 2026
Merged

rust-guard: make LogLevel private and deduplicate extract_repo_info call#3710
lpcox merged 2 commits intomainfrom
copilot/rust-guard-remove-unused-loglevel

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

Two small code-quality fixes in the Rust guard crate identified by the automated Rust Guard Improver.

Changes

  • lib.rs — Remove pub from LogLevel enum. The type is only used by the private fn log() helper in the same file; marking it public suppressed the compiler's dead_code lint and falsely signaled external use intent.

    // before
    pub enum LogLevel {}
    
    // after
    enum LogLevel {}
  • labels/response_paths.rs — Collapse two consecutive extract_repo_info calls in the get_file_contents arm into one, matching the pattern used by every other arm in the file.

    // before
    let (_arg_owner, _arg_repo, arg_repo_full) = extract_repo_info(tool_args);
    let (arg_owner, arg_repo, _)               = extract_repo_info(tool_args);
    
    // after
    let (arg_owner, arg_repo, arg_repo_full) = extract_repo_info(tool_args);

    Eliminates a redundant JSON parse (relevant in WASM where allocations are expensive) and makes the binding origin unambiguous.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /tmp/go-build3085697790/b514/launcher.test /tmp/go-build3085697790/b514/launcher.test -test.testlogfile=/tmp/go-build3085697790/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build3085697790/b460/vet.cfg g_.a ache/go/1.25.8/x64/src/net x_amd64/vet 7479662/b151/ resolver/unix (dns block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build3085697790/b496/config.test /tmp/go-build3085697790/b496/config.test -test.testlogfile=/tmp/go-build3085697790/b496/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build3085697790/b398/vet.cfg @v1.1.3/cpu/x86/go1.25.8 om/tetratelabs/w-c=4 x_amd64/vet --gdwarf-5 (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build3085697790/b514/launcher.test /tmp/go-build3085697790/b514/launcher.test -test.testlogfile=/tmp/go-build3085697790/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build3085697790/b460/vet.cfg g_.a ache/go/1.25.8/x64/src/net x_amd64/vet 7479662/b151/ resolver/unix (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build3085697790/b514/launcher.test /tmp/go-build3085697790/b514/launcher.test -test.testlogfile=/tmp/go-build3085697790/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build3085697790/b460/vet.cfg g_.a ache/go/1.25.8/x64/src/net x_amd64/vet 7479662/b151/ resolver/unix (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build3085697790/b523/mcp.test /tmp/go-build3085697790/b523/mcp.test -test.testlogfile=/tmp/go-build3085697790/b523/testlog.txt -test.paniconexit0 -test.timeout=10m0s -I .cfg om/modelcontextprotocol/go-sdk@v1.5.0/internal/jsonrpc2/frame.go x_amd64/vet --gdwarf-5 g/grpc/grpclog/i-qE -o x_amd64/vet .cfg�� 7479662/b465/_pkg_.a -trimpath x_amd64/vet -p /cobra -lang=go1.24 x_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Remove unused public LogLevel enum from Rust Guard rust-guard: make LogLevel private and deduplicate extract_repo_info call Apr 13, 2026
Copilot AI requested a review from lpcox April 13, 2026 14:57
@lpcox lpcox marked this pull request as ready for review April 13, 2026 14:58
Copilot AI review requested due to automatic review settings April 13, 2026 14:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR applies two small internal refactors to the github-guard Rust WASM guard crate to better reflect intended API visibility and remove a redundant extract_repo_info call in the response labeling logic.

Changes:

  • Make LogLevel private in src/lib.rs since it’s only used by the file-local logging helpers.
  • Deduplicate consecutive extract_repo_info(tool_args) calls in the "get_file_contents" arm in labels/response_paths.rs to avoid redundant work and align with the file’s existing pattern.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/lib.rs Makes the internal LogLevel enum non-public to avoid signaling external API intent.
guards/github-guard/rust-guard/src/labels/response_paths.rs Removes a redundant extract_repo_info call in the get_file_contents labeling path.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@lpcox lpcox merged commit 20a28d2 into main Apr 13, 2026
22 checks passed
@lpcox lpcox deleted the copilot/rust-guard-remove-unused-loglevel branch April 13, 2026 15:28
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-guard] Rust Guard: LogLevel enum is pub but never used outside lib.rs

3 participants