Skip to content

fix(dash): recognize real built-in tools the removal allowlist was missing - #327

Closed
OsherElhadad wants to merge 2 commits into
mainfrom
night0928/a2-work
Closed

OsherElhadad wants to merge 2 commits into
mainfrom
night0928/a2-work

Conversation

@OsherElhadad

@OsherElhadad OsherElhadad commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

dash.IsBuiltinTool (backed by builtinTools in dash/toolremoval.go) is the only
thing 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 no
warning, 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, and
DesignSync.

DesignSync is the one worth spelling out. It is Claude Code's own
claude.ai/design bridge, used through the /design-sync skill — confirmed by
reading 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.ai login
flow that grants it, which nothing else could fabricate). This file's own test
suite previously used DesignSync as the example of an obviously-fake tool name
for 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, DesignSync is also
the 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 > 0 over the full
264,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 to builtinTools, each commented
    with how it was verified.
  • dash/accounting_test.go: added the eight names to TestBuiltinClassification's
    table (all expecting builtin=true), flipped the pre-existing DesignSync
    case from false to true, and replaced its "obviously fake" example with a new
    placeholder name (AcmeWidgetTool) so that branch of coverage isn't lost.
  • (follow-up commit, from review) dash/toolremoval.go: corrected the comment on
    the 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 — pass
  • CGO_ENABLED=1 go test -race ./dash/... ./apply/... — pass (full suite,
    both packages, race detector on)
  • Live end-to-end verification against a throwaway hosted instance (own
    worktree, own ports, own already-authorized gateway credential — never the
    live service or its credentials):
    • A non-manager POST /api/toolfilter excluding DesignSync now returns
      403 with the existing "breaks the agent" message (previously it silently
      succeeded, before this fix).
    • A manager's own exclude → real Claude Code session → requests.filtered_decl_tokens
      reads exactly 2057, matching DesignSync's own measured per-occurrence
      token weight, on both requests of the session that followed the exclude.
    • GET /api/toolfilter after exclude reports realized: {reads: 4114, cache_write_tokens: 2057, cache_read_tokens: 2057, usd: 0.00278} — the exact
      accounting the code promises (one cold-start write, one cache-read re-use).
    • Re-include on the same account: the next session's
      filtered_decl_tokens returns to 0 — confirmed reversible.
    • All prior requests (before the exclude) show filtered_decl_tokens=0,
      confirming the filter is genuinely off until configured.

Untested: whether permissions.deny (the settings.json mechanism the dashboard's
own removal-command suggestion emits for a client_tool) still works the same way
for 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

…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 OsherElhadad left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
    through POST /api/toolfilter. Against main (git stash of toolremoval.go/accounting_test.go)
    all 8 succeed with 200 for 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 list ArtifactComments/ArtifactData/ArtifactCheck as
    names distinct from Artifact) but via Anthropic's own published Agent SDK docs (queried
    through context7): ListMcpResourcesTool, ReadMcpResourceTool, and ReadMcpResourceDir
    (Python tool name ReadMcpResourceDirTool) are all named there as three separate tools.
    DesignSync and SendFeedback are confirmed via the community-maintained
    Piebald-AI/claude-code-system-prompts mirror (tool-description-designsync.md,
    tool-description-sendfeedback-drafting-guidance.md) — their captured content matches the PR's
    description of DesignSync almost verbatim (the /design-sync skill, the claude.ai/design
    login flow). Also confirmed via git log -p that DesignSync really 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 > 0 against
    the read-only snapshot and got 0. 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]>
@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Thanks for the independent verification and the two catches — both fixed:

  1. PR body now states plainly, up front, that this is latent not active: SELECT COUNT(*) FROM requests WHERE filtered_decl_tokens > 0 = 0 over the full snapshot, no tenant has ever configured a removal list, so no real harm has occurred — the $208/$560 figures are prospective (what the suggestion engine would have offered / what a user could have broken), not realized.

  2. Fixed the comment's reasoning in ec2774d: ListMcpResourcesTool / ReadMcpResourceTool / ReadMcpResourceDirTool are three distinct operations, not two names for one — updated to say so. Classification was already correct (all three belong in the allowlist); only the "captured traffic and docs disagree" reasoning was wrong, per your read of the Agent SDK docs.

Agreed on the follow-up issue for a versioned wire-capture fixture + drift-detecting test for builtinTools — will file it separately rather than scope-creep this PR.

@OsherElhadad OsherElhadad left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@amiddavid

Copy link
Copy Markdown
Collaborator

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.

@amiddavid amiddavid closed this Oct 27, 2026
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Stale built-in-tool allowlist lets non-managers exclude real Claude Code tools unwarned

2 participants