Repository navigation
fix(contracts): mark foreign execution and device mutation destructive - #1904
Merged
Merged
Conversation
MCP annotations derived destructiveHint only from mayDiscardData, so tools that run the analysis target or a caller-selected executable (capture_process_scenario, observe_native_calls) and tools that change an attached Android device (install/uninstall/push/start/stop) advertised destructiveHint: false. Add explicit executesForeignCode and mutatesDevice effect flags, audit them across all 170 tool effect records, and derive destructiveHint = mayDiscardData || executesForeignCode || mutatesDevice. readOnlyHint semantics are unchanged. Hopper/Ghidra metadata writers (set_address_name, set_addresses_names, set_bookmark, set_comment, set_inline_comment, annotate_native_function) can replace or clear existing analyst names and comments, so they now declare mayDiscardData as well. A contract test pins the destructive set and requires every tool whose description mentions running, launching, executing, starting, installing or uninstalling to declare one of the new flags or carry a reasoned exception, so wording and effects cannot silently drift. The binary_session effects output schema carries the new flags.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
Owner
|
Welcome to REA, @larinyo. Your ToolEffects change makes MCP’s destructive hint account for running caller-selected code and changing an attached Android device, and the catalog tests pin those cases. Thanks for making the effects explicit; clients can use the hint when deciding whether to prompt. |
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
MCP
destructiveHintwas derived only frommayDiscardData. As a result, tools that run the analysis target or an executable the caller selected (capture_process_scenario,observe_native_calls) and tools that change an attached Android device (install_adb_package,uninstall_adb_package,push_adb_file,start_adb_app,start_adb_activity,stop_adb_app) advertiseddestructiveHint: false. Clients use that hint to decide whether to prompt, so these tools could be auto-approved as "safe".Problem and expected behavior
tools/listreportscapture_process_scenariowithdestructiveHint: false, even though it runs a caller-chosen program.destructiveHint = mayDiscardData || executesForeignCode || mutatesDevice.readOnlyHintsemantics are unchanged.Change and scope
ToolEffectsgainsexecutesForeignCodeandmutatesDevice, both documented in code. All 170 tool effect records were audited.executesForeignCode:capture_process_scenario,observe_native_calls;capture_browser_scenario,capture_electron_scenario,capture_native_ui_scenario. These three were already destructive throughmayDiscardData.mutatesDevice: the six ADB tools listed above.set_address_name,set_addresses_names,set_bookmark,set_comment,set_inline_commentandannotate_native_functionnow declaremayDiscardData: true. They can replace or clear existing analyst names and comments in the Hopper/Ghidra session database, which is data the caller cannot recover from REA. This flips theirdestructiveHintto true and is a judgment call separate from the execution/device fix. If maintainers prefer to keep metadata writers non-destructive, these six hunks can be dropped without affecting the rest. Those tools are not in the drift test's pinned set, so dropping them needs only a catalog regeneration.src/contracts/toolEffects.test.ts:destructiveHintmust follow from each flag on its own;binary_sessioneffects output schema carries the new flags, anddocs/mcp-contracts.mddocuments them.writesCallerPath, or any execution or approval policy.Contract and boundary impact
src/contracts/toolEffects.ts.destructiveHint: falsetotruefor 14 tools (8 through the new flags, 6 throughmayDiscardData). Thebinary_sessioneffects record gains two boolean fields.destructiveHintwill now prompt for these tools..cache/, untracked). The product catalog check passed.Evidence and regression coverage
src/contracts/toolEffects.test.ts(new),tests/boundary/mcp/toolResult.test.ts,tests/boundary/mcp/toolSchemaValidity.test.ts.destructiveHint: falsefor the tools listed above.Validation performed
npx vitest run src/contracts tests/boundary/mcp(afternpm run buildandnpm run mcp-catalog:generate): 103 files, 414 passed, 5 skipped.npm run test:fast: 378 files, 4338 passed, 6 skipped.npm run docs:check: passed.npx tsc --noEmit: clean.npx oxlint: 0 errors.npm run verify:module-boundaries: passed.npm run format: no changes.Compatibility, safety, and release
destructiveHint: falsewill now prompt for these 14 tools, which is the purpose of the change.Limits / not verified