refactor(engine): reduce complexity of collect_allowed_tools in src/engine.rs#1454
Merged
jamesadevine merged 2 commits intoJul 15, 2026
Conversation
Extract collect_extension_tools, mcp_server_has_backing_server, add_mcp_server_tools, and build_bash_command_list from the monolithic collect_allowed_tools function. Before: single ~90-line function with three nested loops and two in-line match arms (estimated cognitive complexity ~20). After: collect_allowed_tools is a 25-line coordinator; each concern is named and independently testable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jamesadevine
marked this pull request as ready for review
July 13, 2026 11:03
Collaborator
|
@copilot resolve the merge conflicts in this pull request |
…exity-collect-allowed-tools-a958d533e77a3bf6 # Conflicts: # src/engine.rs Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
Contributor
Merge conflicts resolved in e480c75. The only conflict was in |
jamesadevine
deleted the
refactor/reduce-complexity-collect-allowed-tools-a958d533e77a3bf6
branch
July 15, 2026 09:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was complex
collect_allowed_toolsinsrc/engine.rswas a ~90-line monolithic function with three distinct concerns packed together, resulting in three nested loops and two inlinematcharms (estimated cognitive complexity ~20):extension_declarations → copilot_allow_toolswith a dedup checkmatchto decide whether a config has a backing MCPG servermatcharm onfront_matter.tools.bashWhat changed
Extracted four named helpers, leaving
collect_allowed_toolsas a 25-line coordinator:collect_extension_toolsmcp_server_has_backing_serverMcpConfighave a container or URL?add_mcp_server_toolsbuild_bash_command_listNo public API signatures changed. Behaviour is identical.
Complexity
Verification
cargo test— all tests passcargo clippy --all-targets --all-features— zero warningsWarning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comSee Network Configuration for more information.