Repository navigation
fix(dash): recognize real built-in tools the removal allowlist was missing - #327
OsherElhadad wants to merge 2 commits into
Conversation
…ssing The dashboard's tool-inventory suggestion engine and the exclude/include control plane both defer to dash.IsBuiltinTool to decide whether a declaration is one of Claude Code's own tools, which may never be silently removed by a non-manager. The allowlist behind it had not kept up: ArtifactComments, ArtifactData, ArtifactCheck, SendFeedback, ReadMcpResourceTool, ReadMcpResourceDirTool, ListMcpResourcesTool and DesignSync were all missing. DesignSync is the most consequential: verified live by reading a real captured request body (Claude Code 2.1.283), its schema names the /design-sync skill and the claude.ai/design login flow that grants it, so it is unmistakably a genuine built-in, not a third-party MCP tool. It was previously used in this file's own test suite as an example of an obviously-fake name; that assumption no longer holds. On the current production snapshot it is also the single largest misclassified item: declared, unused, by 1,592 of 1,959 tool-bearing sessions across every one of 18 tenants, projected at $208 of a $560 total. Before this fix, a non-manager account could exclude any of these eight names via POST /api/toolfilter with no warning at all, contradicting the route's own stated guarantee that a built-in offers no such switch to anybody. Verified against a live hosted instance: the exclusion now returns 403 for a non-manager, and a manager's own exclude/include cycle correctly toggles requests.filtered_decl_tokens (2057, matching DesignSync's own declared weight) on and off across real sessions. Signed-off-by: Osher-Elhadad <[email protected]>
OsherElhadad
left a comment
There was a problem hiding this comment.
Independent review (REV) — PR #327
Reproduced everything below myself, in my own worktree (wt2/rev), against no live service —
offline httptest-based fixtures only (proxy.ctlFixture), plus a direct SQL scan of the
read-only snapshot. No spend.
Verified correct
- The 403 bug is real and this fix closes it. I wrote a standalone test
(TestRevDesignSyncCannotBeDroppedByNonManager, not committed) exercising all 8 added names
throughPOST /api/toolfilter. Againstmain(git stashoftoolremoval.go/accounting_test.go)
all 8 succeed with200for a non-manager — the bug reproduces exactly as claimed. Against this
branch, all 8 correctly 403. Restored the stash afterward; worktree is clean. go test ./dash/... -run TestBuiltinClassification -v→ PASS.go test -race ./dash/... ./apply/...→ PASS (489.7s + 16.9s), full output captured.- All 8 names are real, independently confirmed, not just via this harness's own subagent
tool-restriction metadata (which does listArtifactComments/ArtifactData/ArtifactCheckas
names distinct fromArtifact) but via Anthropic's own published Agent SDK docs (queried
through context7):ListMcpResourcesTool,ReadMcpResourceTool, andReadMcpResourceDir
(Python tool nameReadMcpResourceDirTool) are all named there as three separate tools.
DesignSyncandSendFeedbackare confirmed via the community-maintained
Piebald-AI/claude-code-system-promptsmirror (tool-description-designsync.md,
tool-description-sendfeedback-drafting-guidance.md) — their captured content matches the PR's
description ofDesignSyncalmost verbatim (the/design-syncskill, theclaude.ai/design
login flow). Also confirmed viagit log -pthatDesignSyncreally was the pre-existing test's
"obviously fake" example (git blame shows it unchanged since the table's introduction) — the PR's
narrative is accurate, not embellished. - This is latent, not active — confirmed independently, not just taken from PROGRESS.md: I ran
SELECT COUNT(*), SUM(filtered_decl_tokens) FROM requests WHERE filtered_decl_tokens > 0against
the read-only snapshot and got0. Zero requests in the full 264,163-row corpus have ever had
a declaration filtered. The PR body should say this explicitly — right now a reader has no way
to tell "$208 of $560 projected" apart from realized historical loss. Non-blocking, but please add
a line before merge.
Non-blocking but real: the comment's stated reason for listing ReadMcpResourceDirTool AND
ListMcpResourcesTool is wrong
The code comment says: "docs and captured traffic disagree on the directory-listing tool's name
(ReadMcpResourceDirTool vs ListMcpResourcesTool)". That's not what's happening — they are not
two names for one tool. Per Anthropic's own SDK docs:
ListMcpResourcesTool— lists resources across servers (or one named server).ReadMcpResourceTool— reads one resource by URI.ReadMcpResourceDir/ReadMcpResourceDirTool— lists the children of one directory resource
(resources/directory/read) — a third, distinct operation.
All three deserve to be in the allowlist (confirmed above), so the classification is correct —
but the justification comment is factually wrong and will mislead the next person who reads it.
Please fix the comment to say "three distinct MCP resource tools" rather than "docs disagree."
The bigger, structural point (not blocking this PR, but please file a follow-up issue)
This is the second stale-allowlist incident on this exact file (the prior test already had a
now-outdated "obviously fake" example baked in). There is no programmatic source of truth
anywhere in this repo for Claude Code's built-in tool set — I grepped for a capability/manifest
endpoint, a wire-capture fixture, anything — and found nothing (grep -rniE "capabilit|tool.?manifest|tool.?catalog" across the repo, find for fixtures/golden files: no
hits). builtinTools is, and will remain, hand-maintained. Adding 8 names fixes today's drift;
it does not fix the class of bug, and TestBuiltinClassification only pins today's fixed cases —
it can't fail when Claude Code ships tool #9. I'd recommend (separately, not in this PR): capture a
real tool-declaration manifest as a versioned testdata fixture (CC version pinned, like the PR
author already did by hand for this fix) and add a test that fails when a name in that fixture is
absent from builtinTools. That turns "read a live captured request body" from a one-off audit
into a repeatable regression gate.
Verdict
Passes. The fix is correct, narrowly scoped, well-verified, and every claim I checked held up
(with the one comment-accuracy nit above). I'd merge once: (1) the PR body states the
latent-not-active finding, (2) the ReadMcpResourceDirTool/ListMcpResourcesTool comment is
corrected. Neither blocks review approval; both are quick text edits. The hand-maintained-allowlist
structural issue should be a tracked follow-up issue, not a blocker on this PR.
Per review on #327: ListMcpResourcesTool, ReadMcpResourceTool and ReadMcpResourceDirTool are three distinct Agent SDK operations (list across servers, read one resource by URI, list one directory resource's children), not two names for the same directory-listing tool as the comment previously claimed. All three were already correctly allow-listed; only the reasoning in the comment was wrong. Signed-off-by: Osher-Elhadad <[email protected]>
|
Thanks for the independent verification and the two catches — both fixed:
Agreed on the follow-up issue for a versioned wire-capture fixture + drift-detecting test for |
OsherElhadad
left a comment
There was a problem hiding this comment.
Both fixes verified: PR body now states the latent-not-active finding plainly, and ec2774d corrects the ReadMcpResourceDirTool/ListMcpResourcesTool comment to describe three distinct operations rather than two disagreeing names — matches what I confirmed against the Agent SDK docs. Re-ran go test ./dash/... -run TestBuiltinClassification -v: PASS. This passes review (GitHub won't let me self-approve under the shared account, but there is nothing outstanding from me).
|
Closing: #746 fixed the same issue. This PR targets #328, the built-in tools missing from the removal allowlist. #746 (merged as d08eff8, commit 5899cb3) classifies 8 real Claude Code tools as built-in and closed #328. If this PR has a tool that #746 does not cover, please open a short follow-up PR on top of main. |
Summary
dash.IsBuiltinTool(backed bybuiltinToolsindash/toolremoval.go) is the onlything that stops a non-manager account from excluding one of Claude Code's own
tools via the dashboard's exclude/include control (
POST /api/toolfilter) with nowarning, and it stops the suggestion engine from ever recommending removal of one.
The allowlist was stale. Eight real, current tool names were missing:
ArtifactComments,ArtifactData,ArtifactCheck,SendFeedback,ReadMcpResourceTool,ReadMcpResourceDirTool,ListMcpResourcesTool, andDesignSync.DesignSyncis the one worth spelling out. It is Claude Code's ownclaude.ai/designbridge, used through the/design-syncskill — confirmed byreading its actual declared JSON schema off a live captured request body against
Claude Code 2.1.283 (its description names the skill and the
claude.ailoginflow that grants it, which nothing else could fabricate). This file's own test
suite previously used
DesignSyncas the example of an obviously-fake tool namefor coverage of the non-builtin path; that assumption predates this tool's
existence (or the coincidence of a later one shipping under the same name) and no
longer holds.
On the current production snapshot analysed for this audit,
DesignSyncis alsothe single largest misclassified item: declared, and never once invoked, by 1,592
of 1,959 tool-bearing sessions, across every one of 18 tenants, over 38.6 days —
$208 of a $560 total projected saving the (correctly cautious) suggestion engine
was offering across the fleet.
This is a latent defect, not an active one — zero real harm has occurred to date.
SELECT COUNT(*) FROM requests WHERE filtered_decl_tokens > 0over the full264,163-row production snapshot returns 0: no tenant has ever configured a
removal list at all, so the declaration filter has never fired for anyone, and no
account has actually excluded one of these misclassified built-ins. The $208/$560
figures are what the suggestion engine WOULD have offered and what a user COULD
have broken, not anything that happened. The risk this closes is prospective.
What changed
dash/toolremoval.go: added the eight names tobuiltinTools, each commentedwith how it was verified.
dash/accounting_test.go: added the eight names toTestBuiltinClassification'stable (all expecting
builtin=true), flipped the pre-existingDesignSynccase from false to true, and replaced its "obviously fake" example with a new
placeholder name (
AcmeWidgetTool) so that branch of coverage isn't lost.dash/toolremoval.go: corrected the comment onthe three MCP-resource tools — they are three distinct Agent SDK operations
(list across servers / read one resource by URI / list one directory
resource's children), not two names for the same tool as the comment
originally claimed. Classification was already correct; only the reasoning
in the comment was wrong.
No other files touched.
Test plan
CGO_ENABLED=1 go test ./dash/... -run TestBuiltinClassification -v— passCGO_ENABLED=1 go test -race ./dash/... ./apply/...— pass (full suite,both packages, race detector on)
worktree, own ports, own already-authorized gateway credential — never the
live service or its credentials):
POST /api/toolfilterexcludingDesignSyncnow returns403with the existing "breaks the agent" message (previously it silentlysucceeded, before this fix).
requests.filtered_decl_tokensreads exactly
2057, matchingDesignSync's own measured per-occurrencetoken weight, on both requests of the session that followed the exclude.
GET /api/toolfilterafter exclude reportsrealized: {reads: 4114, cache_write_tokens: 2057, cache_read_tokens: 2057, usd: 0.00278}— the exactaccounting the code promises (one cold-start write, one cache-read re-use).
includeon the same account: the next session'sfiltered_decl_tokensreturns to0— confirmed reversible.filtered_decl_tokens=0,confirming the filter is genuinely off until configured.
Untested: whether
permissions.deny(the settings.json mechanism the dashboard'sown removal-command suggestion emits for a
client_tool) still works the same wayfor these now-reclassified builtins — not exercised here, since a builtin's
removal command intentionally isn't offered to a non-manager at all.
Closes #328