refactor(quarantine): unify tool-policy decision logic across entrypoints#529
Merged
Merged
Conversation
…ints Follow-up to #526 and #527, addressing review concerns. call_tool_* variants and direct mode (#526) duplicated the pending/changed TOOL_QUARANTINED payload and independently derived config-denial — a second source of truth that could drift from isToolCallable/blockedToolMessage. - Extract toolPendingApprovalResult/toolChangedApprovalResult/toolPolicyJSONResult as the single source of truth; call_tool_* and direct mode both use them. - Add MCPProxyServer.isToolConfigDenied as the one config-denial authority (prefers live runtime config, falls back to stored server config); both blockedToolMessage and the direct evaluator route through it. - captureOutputSchemaJSON (#527) returns "" on marshal failure instead of baking an error payload into the contract hash (which would spuriously flip the tool to "changed"). - Consolidate the three JSON normalizers (runtime.normalizeJSON, core.normalizeRawJSON) onto a single exported hash.NormalizeJSON. Net -33 lines. Behavior-preserving: the approval-hash stability canary and all direct/call_tool/quarantine tests pass unchanged; adds drift-guard tests for the shared builders and NormalizeJSON.
Deploying mcpproxy-docs with
|
| Latest commit: |
2c7ef4e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5eeb2372.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://followup-quarantine-callabil.mcpproxy-docs.pages.dev |
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 26432262885 --repo smart-mcp-proxy/mcpproxy-go
|
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.
Summary
Follow-up to #526 (direct-mode callability) and #527 (output-schema approval hash), addressing the maintainability concerns raised in review. Behavior-preserving cleanup — no functional change for users.
Motivation
TOOL_QUARANTINEDpending/changed payload, separate fromhandleCallToolVariantandisToolCallable/blockedToolMessage. Three sources of truth drift over time — exactly the kind of gap that could letcall_tool_*and direct mode disagree on policy.captureOutputSchemaJSONbaked a marshal-error JSON payload into the contract hash on failure, and added a third copy of "canonical JSON" normalization.Changes
toolPendingApprovalResult/toolChangedApprovalResult/toolPolicyJSONResult(mcp_tool_policy_result.go). Bothcall_tool_*and direct mode now call them, so the two entrypoints return byte-identical responses and can't drift.MCPProxyServer.isToolConfigDenied— prefers the live runtime config (the same sourceisToolCallableconsults), falls back to the stored server config when the runtime is unavailable (unit tests).blockedToolMessageand the direct-mode evaluator both route through it, removing the divergentserverConfig.IsToolAllowedByConfigpath.captureOutputSchemaJSONreturns""on marshal failure instead of an error-keyed JSON object, so a transient marshal blip can't spuriously flip a tool tochanged.runtime.normalizeJSONandcore.normalizeRawJSONonto a single exportedhash.NormalizeJSON.Net −33 lines.
Validation
TestCalculateToolApprovalHash_Stability) passes unchanged — the shared normalizer is byte-identical to the originals.TestToolPendingApprovalResult_Shape,TestToolChangedApprovalResult_Shape,TestNormalizeJSON.