Repository navigation
fix(studio): classify destructive tool approvals by name tokens - #2230
Merged
Merged
Conversation
peppescg
force-pushed
the
fix/studio-approval-destructive-2224
branch
from
October 10, 2026 09:24
828e44d to
3b2b7b1
Compare
peppescg
force-pushed
the
fix/studio-approval-destructive-2224
branch
from
October 11, 2026 14:57
3b2b7b1 to
b9a094f
Compare
peppescg
force-pushed
the
fix/studio-approval-destructive-2224
branch
from
October 11, 2026 15:48
b9a094f to
97bf12c
Compare
peppescg
force-pushed
the
fix/studio-approval-destructive-2224
branch
from
October 13, 2026 13:29
97bf12c to
c8e609c
Compare
peppescg
force-pushed
the
fix/studio-approval-destructive-2224
branch
from
October 14, 2026 08:44
c8e609c to
722398a
Compare
kantord
force-pushed
the
fix/studio-approval-destructive-2224
branch
2 times, most recently
from
October 14, 2026 08:59
ed35206 to
3aa95f4
Compare
Pin the destructive and warning treatment of the approval card, icon, and badge for names the word-boundary classifier already gets right, before the classifier changes. Refs #2224 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The approval card chose its destructive treatment with a word-boundary regex, and `\b` does not split camelCase or snake_case, so DeleteFile, delete_file, removeBranch, and drop_table got the warning card and badge. Split the tool name into ASCII alphanumeric segments, each kept whole and also split at case boundaries, and match whole tokens against the same seven verbs. Verbs inside longer words (confirm, format, dropdown, deleted_items_report) still read as warnings, and every name the old regex classified as destructive still is. The permission ask carries no structured risk signal, so the tool name remains the only input. Closes #2224 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The word-boundary regex this classifier replaced matched case-insensitively with the u flag, which folds ſ (U+017F) to s and the Kelvin sign (U+212A) to k, so deſtroy and revoKe were destructive under the old regex but not under the ASCII tokenizer. The superset claim did not hold for them. Tool names are now NFKC-normalized before they are split, so those letters, and fullwidth letters, read as their ASCII forms. The exhaustive no-regression check gains both letters and the fragments that combine with them into verbs, and the named cases cover them directly. Refs #2224 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
An MCP tool is named mcp__<server>__<tool>, and the token classifier read the server segment too, so every tool from a server named, say, remove_bg (mcp__remove_bg__preview) got the red destructive card. The server name is configuration, not an action. The classifier now judges only the tool part when the server segment is a valid server name ([A-Za-z0-9_]+, split at the first __ as the daemon does). Any other shape is judged whole, so no name the old word-boundary regex flagged loses its red card; a new exhaustive check over MCP-shaped names proves it, and fails if the server-name guard is dropped. rmdir deletes a directory, but it was pinned amber only because the old regex could not see it inside the word. It is now a destructive verb, and its two amber pins (classifier and card tone) move to the destructive lists. Every other pinned colour is unchanged. The Studio operating page lists rmdir and explains the MCP rule. Refs #2224 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…verb NFKC normalization made ſ and the Kelvin sign read as s and k, but it also turns characters such as fullwidth x, the fi ligature, circled digits, ª, and superscript digits into ASCII letters and digits. Beside a verb they then fused into one token, so xdelete, ①delete, and x²rm, red under the old word-boundary regex, turned amber. The classifier now reads the action both as written and normalized, and is destructive if either form has a verb token. The exhaustive superset check gains a fullwidth letter and a circled digit. Refs #2224 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
kantord
force-pushed
the
fix/studio-approval-destructive-2224
branch
from
October 14, 2026 09:00
3aa95f4 to
b3e484b
Compare
kantord
approved these changes
Oct 14, 2026
kantord
left a comment
Member
There was a problem hiding this comment.
note: as per discussion, the logic of matching text to determine the danger level will be removed from the FE code in a follow up. approving this just in the interest of aligning the current implementation with the prototypes, fixing the actual technical issues is anoterh follow-up
Member
|
Post-merge review follow-ups for this PR. No blockers or regressions found. The one item worth tracking was filed here:
Other candidate findings (verb-list gaps, homoglyph names, the duplicated Fully or partially written by an AI agent. |
Merged
2 tasks
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
This fixes the tone of the chat approval card (#2224, part of #2210). The card used a word-boundary regex on the tool name to choose between the destructive (red) and warning (amber) treatments.
\bdoesn't split camelCase or snake_case, soDeleteFile,delete_file,removeBranch, anddrop_tablegot the amber card and badge. The card now matches whole name tokens against the same seven verbs. Every name the old regex classified as destructive still is, and verbs inside longer words (confirm,format,dropdown,deleted_items_report) still read as warnings.What changed
features/chat/destructive-tool.ts(new) holds a pure classifier,isDestructiveToolName, and its tokeniser,toolNameTokens:_(including MCP'sserver__tool),-,.,/,:, and spaces.removeBranch,DeleteFile,HTTPDelete,v2Delete.delete,remove,drop,revoke,destroy,purge, orrm. That's the same verb set as before.approval-panel.tsxcallsisDestructiveToolNameinstead of the regex. Nothing else in the card changes.user-docs/operating/studio.mdsays when the card is red, and that the color comes from the tool name only.Structured risk signal
Scope item 2 asked whether the permission ask carries a structured risk signal. It doesn't.
PermissionAskincontracts/proto/mecatl/v1/harness.protoandPermissionAskEventPayloadin the published SDK (0.4.0) carryaskId,tool,args,reason,callId, and an optionalguardrailscope. Theguardrail.kindfield isaction,result_release, orunknown, which describes what an approval releases, not how risky it is. MCP tool annotations such asdestructiveHintaren't forwarded in the ask. The tool name is still the only input. If the daemon adds a risk field later, it should take precedence and this classifier becomes the fallback.Visible change
Approval cards for tools whose name has a destructive verb as a camelCase, PascalCase, snake_case, or MCP-style word now use the destructive treatment: red border and tint, red shield icon, and red badge. Before, they used the warning treatment. Other cards are pixel-identical, including
Edit(amber) andrm(red).Differences from the prototype
stack-08,apps/web/src/features/chat/approval-panel.tsx) exports the same word-boundary regex asdestructiveTool, andapproval-detail-panel.tsxreuses it. So the prototype has the same bug, and this PR deliberately classifies differently:delete_file,DeleteFile, and the other names in the tests are red in Studio and amber in the prototype. The treatment itself (classes and tokens) is unchanged. When the prototype's approval panels are ported (Studio alignment: chat UI from the prototype on Studio's chat logic #2207), they should callisDestructiveToolNameinstead of importing the regex.No regression
Pinning tests
approval-panel.test.tsxwas committed first, alone (963264cce), against the unchanged panel. It rendersApprovalPaneland reads the tone from the card, the icon, and the badge together, and it fails on a mixed tone. It pins 34 names:delete,DELETE,rm,RM,Remove file,git rm,rm -rf,delete-file,fs.delete,mcp/delete, andserver:dropBash,Edit,Read,Write,PresentPlan,confirm,format,term,dropdown,deleted_items_report,rmdir,undelete, andremovalAll 34 pass on the base and on the fix, unchanged.
New tests
approval-panel.test.tsxadds 7 bug cases (additions only):DeleteFile,delete_file,RemoveBranch,removeBranch,drop_table,revokeToken, andgithub__delete_branchrender destructive.destructive-tool.test.ts(77 tests):ReMove), and 21 it missed, including every name the issue listsRead,Edit,deleted_items_report, andBash, and the false-positive guardsconfirm,format,term,terminal,dropdown,farm,purgeable,dropbox_upload, andlist_removed_filesProof that the tests catch the bug
With
isDestructiveToolNametemporarily switched back to the old regex, 28 tests fail: the 7 panel bug cases and the 21 classifier names the old regex misses. Every pinning test, false-positive guard, and the superset check still pass. Three more mutations were each caught:deleteGates
e9c216aa1828e44de4task studio:check, webtask studio:check, servertask studio:browserLint, typecheck, and the generated-artifact check pass on both.
task docspasses on the head. The browser journeys and the screenshots ran ondc99b41e7, which differs from the head only in where one test row sits indestructive-tool.test.ts.Modified tests
None. Every test file that existed on
mainis unchanged.approval-panel.test.tsxis new in the pinning commit, and the fix commit only adds a block to it.Screenshots
Captured with a throwaway Playwright journey (Chromium, not committed). It uses the offline BFF fixtures from
e2e/fixtures.ts, the same session, tool-call, andpermission.askframes ase2e/chat-approval.spec.ts, a fixed clock (2026-09-25 12:30 UTC),Europe/Rome, and en-US. Each card was shot at desktop 1280×800 and mobile 390×844, in light and dark, as the card alone (2× upscale) and as the full page. Before ismain(e9c216aa1) and after is this PR's head (828e44de4). Each tree was captured twice, and the two runs matched pixel for pixel. Every pair was pixel-compared, and red boxes mark the regions that differ. Only thedelete_filecard differs. On each full page, the differing pixels are exactly those of the card. TheEditandrmpairs are pixel-identical. Desktop composites are downscaled to 1600px wide.delete_file(was amber, now red)Intended change: the card, shield icon, and tool badge take the destructive treatment. Nothing outside the card changes.
Dark, mobile, and full page
Card, desktop, dark:
Card, mobile, light:
Card, mobile, dark:
Full page, desktop, light:
Full page, desktop, dark:
Full page, mobile, light:
Full page, mobile, dark:
Edit(amber, unchanged)Unchanged: pixel-identical before and after.
Dark, mobile, and full page
Card, desktop, dark:
Card, mobile, light:
Card, mobile, dark:
Full page, desktop, light:
Full page, desktop, dark:
Full page, mobile, light:
Full page, mobile, dark:
rm(red, unchanged)Unchanged: pixel-identical before and after.
Dark, mobile, and full page
Card, desktop, dark:
Card, mobile, light:
Card, mobile, dark:
Full page, desktop, light:
Full page, desktop, dark:
Full page, mobile, light:
Full page, mobile, dark:
Review fixes
Fixes from the final regression and security review of the stack (stack #2227). Each one comes with a test that fails without the fix.
uflag, which folds ſ (U+017F) to s and the Kelvin sign K (U+212A) to k. SodeſtroyandrevoKewere red under the old regex but amber under the ASCII tokenizer. Tool names are now NFKC-normalized before they are split, so those letters, and fullwidth letters, read as their ASCII forms. The exhaustive no-regression check gains both letters, plus the fragments that combine with them into verbs. On the old code, six tests fail, including the exhaustive check, which fails ondeſtroy. (1af49eb4d)mcp__<server>__<tool>, so every tool from a server calledremove_bggot the red card, for examplemcp__remove_bg__preview. The classifier now judges only the tool part when the server segment is a valid server name ([A-Za-z0-9_]+, split at the first__, as the daemon splits it). Any other shape is judged whole.\bregex could never match inside one. A new exhaustive check over MCP-shaped names proves that no name the old regex flagged loses its red card. It also fails if the server-name guard is removed. (a9e6ecd94)rmdiris now red (minor).rmdirdeletes a directory. It was pinned amber only because the old regex couldn't seerminside the word, so the pin recorded a false negative, not a decision. It is now a destructive verb, and its two amber pins (classifier and card tone) move to the destructive lists. Every other pinned colour is unchanged. (a9e6ecd94)rmdirand explains the MCP rule.task studio:checktask studio:browsertask docs:checkScreenshots: Before is
a9cc2a4c5(the NFKC change has no visible effect on these names), After isa8bf32036. Each tree was captured twice, and both captures were pixel-identical. Only thermdirandmcp__remove_bg__previewcards change.delete_file,Edit, andmcp__remove_bg__delete_imageare pixel-identical before and after. The prototype still uses the old word-boundary regex, so it shows the same tones as Before for these names. Its column shows its approval card for layout reference only.rmdir(was amber, now red):mcp__remove_bg__preview(was red because of its server name, now amber):Dark, mobile, full page with prototype, and unchanged cards
Re-verification (2026-10-11)
xdelete,①deleteandx²rmwent from red (old regex) to amber. The classifier now reads the action both as written and normalized. (722398adb) Tests: six new destructive cases, and a fullwidth letter and a circled digit in the exhaustive superset check (7 tests fail without the fix). No visible change for ordinary names.Gates on the restacked head
722398adb:studio:checkpasses (web 1,042, server 210 tests). At the stack top (#2256):studio:browser118 passed, 30 skipped; themecated --mockintegration suite 8 passed. The browser suite takes 5.3 minutes on a CI runner.Commit hashes cited earlier in this body predate the restacks; the current commits keep the same subjects. Hashes in Review fixes are updated.
Closes #2224
🤖 Generated with Claude Code