Skip to content

rust-guard: dedupe PR/issue response-path setup and add gist/notification path-label tests - #8778

Merged
lpcox merged 3 commits into
mainfrom
copilot/rust-guard-extract-shared-setup
Jul 6, 2026
Merged

rust-guard: dedupe PR/issue response-path setup and add gist/notification path-label tests#8778
lpcox merged 3 commits into
mainfrom
copilot/rust-guard-extract-shared-setup

Conversation

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

label_response_paths had duplicated PR/issue collection setup logic, creating a divergence risk for repo scope, secrecy defaults, and empty-search handling. It also lacked direct tests for list_gists secrecy branching and list_notifications label semantics in the path-labeling codepath.

  • Refactor: shared repo-item collection context

    • Added RepoItemsContext + resolve_repo_item_context(...) in response_paths.rs.
    • Centralized extraction of:
      • items + items_path
      • repo scope fallback from args/query
      • default_repo / default_repo_private
      • default secrecy behavior for non-search vs search tools
      • bounded item iteration (limit_items_with_log)
    • Reused this helper in both PR and issue arms to remove duplicated setup while preserving per-item labeling behavior.
  • Coverage: path-label tests for gists and notifications

    • Added targeted unit tests in response_paths.rs for:
      • public gist → empty secrecy
      • private gist → private_user_label()
      • notifications → private-user secrecy + empty integrity
  • Code shape / readability

    • Kept per-item PR/issue integrity and description logic unchanged.
    • Added helper-level docs clarifying tool_name vs search_tool_name semantics.
if let Some(repo_item_ctx) = resolve_repo_item_context(
    tool_name,
    tool_args,
    &actual_response,
    "search_pull_requests",
    "list_pull_requests",
    ctx,
) {
    for (i, item) in repo_item_ctx.limited_items.iter().enumerate() {
        // existing per-item PR labeling logic
    }
}

Copilot AI changed the title [WIP] Extract shared setup context for PR/issues arms and add list_gists tests rust-guard: dedupe PR/issue response-path setup and add gist/notification path-label tests Jul 6, 2026
Copilot AI requested a review from lpcox July 6, 2026 13:02
Copilot finished work on behalf of lpcox July 6, 2026 13:02
@lpcox
lpcox marked this pull request as ready for review July 6, 2026 13:03
Copilot AI review requested due to automatic review settings July 6, 2026 13:03

Copilot AI 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.

Pull request overview

This PR refactors the Rust guard’s path-labeling logic to remove duplicated PR/issue response setup and adds unit tests covering previously untested secrecy/integrity behaviors for gists and notifications. This reduces divergence risk in repo-scope/secrecy defaults while improving confidence in response-path labeling for additional GitHub API collection tools.

Changes:

  • Introduced RepoItemsContext and resolve_repo_item_context(...) to centralize shared PR/issue collection extraction, repo-scope fallback, default secrecy selection, and bounded iteration.
  • Updated PR and issue labeling arms to consume the shared context helper while preserving per-item labeling behavior.
  • Added unit tests validating list_gists secrecy branching (public vs private) and list_notifications secrecy/integrity semantics.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/response_paths.rs Deduplicates PR/issue response collection setup via a shared helper and adds gist/notification path-label unit tests.

Review details

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Low

@lpcox
lpcox merged commit 7f5c999 into main Jul 6, 2026
38 checks passed
@lpcox
lpcox deleted the copilot/rust-guard-extract-shared-setup branch July 6, 2026 13:07
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: Extract shared setup context for PR/issues arms + add list_gists tests

3 participants