Repository navigation
fix: serialize per-server tool-approval writes so baselines and approvals are complete (UX-02) - #1571
Merged
Merged
Conversation
…X-02) Discovery passes and operator approvals wrote the same tool-approval records without per-server mutual exclusion. A pass holding a stale copy of a record wrote it back over a fresher approval (or a baseline decision taken from a stale snapshot filed already-approved tools as pending), and the stranded pending records then survived reload and restart. - per-server mutex (sync.Map server -> *sync.Mutex) covers checkToolApprovals end to end: gate read, prior-record snapshot, isBaselinePass and all writes - ApproveTools / ApproveAllTools / server-approval baseline promotion, BlockTools / BlockAllTools, tool enable toggles, removed-tool deletes and the QuarantineServer storage flip take the same lock - baseline promotion re-reads each record under the lock (approveToolsLocked) and never promotes a record that turned "changed" - passes also read the storage quarantine flag and fail closed when it cannot be read, so a server quarantined mid-flight is never auto-baselined - the scanner's baseline+blocks commit runs under the lock through an optional ToolApprovalLocker capability - SSE events and the reindex goroutine run after the lock is released; the lock is never held across LoadConfiguredServers, HandleUpstreamServerChange or UnquarantineServer
…-02) tools/approve and security/approve read the approval records back after the write and add approved_count, blocked_count, still_pending, still_changed and held_tools. tools/approve's approved now counts requested tools that actually read approved and lists the rest in not_approved. status stays "approved". review approve and security approve print the counts and warn on stderr when any tool still needs review.
…put (UX-02 review)
…cannot be read back (UX-02 review)
…unts on tools/approve table output (UX-02 review)
Deploying mcpproxy-docs with
|
| Latest commit: |
3797afb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://28f7266d.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-qa070-ux02-approval-lock.mcpproxy-docs.pages.dev |
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 38114556864 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This was referenced Oct 11, 2026
fix: serialize per-server tool-approval writes so baselines and approvals are complete (UX-02)
#1555
Closed
Merged
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.
Impact
UX-02 (QA 0.70.0, P1). After a trusted baseline or an approval, some tools stayed
pending. Users had finished review but could not call the tools they had picked. The approval response still saidstatus: approvedand gave no sign that the decision was incomplete.Cause
Tool-approval records for one server have several writers, and none of them was mutually exclusive with the others. The writers are discovery passes (
checkToolApprovals, reached from the reactive connect, boot and post-reload sweeps,HandleUpstreamServerChangeand the approval reindex), operator approve/block/toggle, server-approval baseline promotion (QuarantineServer(false)→approveBaselineToolsForServer) and the scanner's baseline+blocks commit. Each one reads a record, decides, then writes the whole record back. A pass holding a stale copy could therefore overwrite a fresher approval withpending. A pass could also decideisBaselinePassfrom a stale snapshot and file already-approved tools as new pending tools. Once a server has a baseline, no later pass promotes stranded records, so they persisted across reload and restart. Full diagnosis is indocs/qa/0.70.0-ux-2026-10-10/remediation/diagnosis-wf_b479d8a8.json.On current main, 1f5acb6 (UX-12) added a global
captureSnapMuthat already serializes discovery passes with each other, so the cold-start repro no longer strands tools live. Operator writes, baseline promotion and the scanner block write still race a pass, and the deterministic tests below reproduce that.Change (minimal scope)
internal/runtime/tool_approval_lock.go, async.Mapof server →*sync.Mutex):checkToolApprovalsread-modify-write, including the gate/quarantine read and theisBaselinePassdecision.ApproveTools,ApproveAllTools,approveBaselineToolsForServer,BlockTools,BlockAllToolsand the tool enable toggles take it.approveToolsLocked, which re-reads each record and never promotes one that is nowchanged.QuarantineServerstorage flip takes the lock. A pass also reads the storage quarantine flag and fails closed if it cannot read it, so a server being quarantined is never baseline-approved.SaveIntegrityBaselineWithBlocksruns under the lock through an optionalToolApprovalLockercapability, and removed-tool deletes take it too.LoadConfiguredServers,HandleUpstreamServerChange,SaveConfigurationorUnquarantineServer. SSE events and the reindex goroutine run after it is released.tools/approveandsecurity/approveread the records back and addapproved_count,blocked_count,still_pending,still_changedandheld_tools.tools/approvealso addsnot_approved, and itsapprovednow counts requested tools that actually read approved. If the read-back fails, the response setsoutcome_unavailable: trueinstead of reporting counts it cannot know.statuskeeps its meaning.mcpproxy review approveandmcpproxy security approveprint the counts and warn on stderr when anything is still held, so JSON/YAML stdout stays parseable.Not included on purpose: binding approvals to reviewed definitions, capture-order inventories, Web UI state changes and macOS tray changes (see follow-ups). No new dependencies, no change to any built-in tool schema and no storage format change. The diff is about 1.1k lines, roughly 470 of them tests.
Compatibility
All response fields are additive, and
status: "approved"is unchanged. One existing field changes value:tools/approve'sapprovedused to echo the request length and now counts what applied. CLI table lines gain a counts suffix.Verification
TestCheckToolApprovals_OverlappingBaselinePasses_NoStrandedPending,TestApproveTools_DuringDiscoveryPass_ApprovalNotLost,TestQuarantineServer_FlipWaitsForInFlightPassandTestWithToolApprovalLock_WaitsForInFlightPassfail. With the lock they pass, also under-race -count=3.go test -race -tags server -timeout 20m -skip "E2E|Binary|MCPProtocol|TestInfoEndpoint|TestGracefulShutdownNoPanic|TestSocketInfoEndpoint" ./internal/server/... ./internal/httpapi/... ./internal/runtime/... ./internal/security/scanner/... ./cmd/mcpproxy/passes.golangci-lint run --config .github/.golangci.yml ./...and the same with--build-tags serverreport no issues in changed files.make buildfrom the final head:mcpproxy review approve large-review --yes --force --all --except <15 delete_*>: 6/6 runs gave 165 approved and enabled, 15 approved and disabled, 0 pending, immediately and after 60s.mcpproxy review approve large-review --yes: 165 + 15 blocked. The state held after 120s, 3× discover-tools, a rescan, a hot reload, disable/enable and a restart.call_tool_readexecutes the read tools, andretrieve_toolsreturns them.changedandpendingand are refused. After an explicitPOST /quarantine, nothing is exposed.github-copilot/gpt-6.1-sol, read-only. Rounds 1–4 found reporting gaps, all fixed. Round 5 returned VERDICT: PASS at the final head.docs/qa/0.70.0-ux-2026-10-10/remediation/evidence/ux02c/EVIDENCE.md, kept in the main checkout and not part of this diff.Supersedes #1555
Known follow-ups (out of scope, filed)
🤖 Generated with Claude Code