Skip to content

Avoid discarded repository allocations in Rust guard - #16401

Merged
lpcox merged 3 commits into
mainfrom
copilot/rust-guard-add-extract-repo-id-helper
Nov 12, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/rust-guard-add-extract-repo-id-helper

Conversation

Copilot AI commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Repository ID extraction allocates owner and repo strings even when callers discard them. Scope inference also duplicates field lookups.

  • Repository IDs: Add extract_repo_id and use it at ID-only call sites.
  • Scope inference: Use shared field constants and get_str_or, preserving organization alias precedence.
  • Regression coverage: Check missing, empty, and non-string fields and organization alias fallbacks.

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Add extract_repo_id helper to avoid discarded owner/repo allocations Avoid discarded repository allocations in Rust guard Nov 12, 2026
Copilot AI requested a review from lpcox November 12, 2026 16:16
@lpcox
lpcox marked this pull request as ready for review November 12, 2026 16:25
Copilot AI adaptive review requested due to automatic review settings November 12, 2026 16:25

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.

🟢 Approval recommended

No active review issues are recorded for the repository-labeling allocation optimization.

No open issues 🎉

What changed in this PR

Reduces unnecessary string allocations in the GitHub Rust guard’s repository-labeling paths, addressing #16386 while preserving scope-inference behavior.

Changes:

  • Adds extract_repo_id and uses it where callers need only the combined repository ID.
  • Reuses shared field constants and get_str_or in scope inference.
  • Adds regression tests for missing, empty, and non-string fields and organization alias precedence.
File Description
guards/​github-guard/​rust-guard/​src/​lib.rs Updates ID-only callers, simplifies field access, and tests organization fallbacks.
guards/​github-guard/​rust-guard/​src/​labels/​response_paths.rs Uses the ID-only helper for file-response path labeling.
guards/​github-guard/​rust-guard/​src/​labels/​response_items.rs Uses the ID-only helper for file-response item labeling.
guards/​github-guard/​rust-guard/​src/​labels/​mod.rs Re-exports the helpers needed by lib.rs.
guards/​github-guard/​rust-guard/​src/​labels/​helpers.rs Adds extract_repo_id and tests equivalence with existing extraction behavior.
guards/​github-guard/​rust-guard/​src/​labels/​constants.rs Adds the shared ORGANIZATION_NAME field constant.

Review effort: Balanced (auto)

@lpcox

lpcox commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and resolve conflicts

…d-extract-repo-id-helper

# Conflicts:
#	guards/github-guard/rust-guard/src/labels/helpers.rs
#	guards/github-guard/rust-guard/src/labels/mod.rs
#	guards/github-guard/rust-guard/src/lib.rs

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

Copilot AI commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main and resolve conflicts

Merged main and resolved the conflicts in commit 26356ac. Rust guard tests and make agent-finished passed.

@lpcox
lpcox merged commit 55813d3 into main Nov 12, 2026
30 checks passed
@lpcox
lpcox deleted the copilot/rust-guard-add-extract-repo-id-helper branch November 12, 2026 17:50
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: add extract_repo_id helper to avoid discarded owner/repo allocations

3 participants