Repository navigation
ADFA-7300: AI-Agent-MCP switch to let the Agent change app databases - #178
davidschachterADFA wants to merge 6 commits into
Conversation
Phase 2, P2-5 (ADFA-7131 comment 41476, decision D14). On #166 (sqlite-debugger/ADFA-7139 at 38b5268). Needs CodeOnTheGo P2-3 and P2-4 (execute, acknowledge_room) on the device. - The automatic SQLite debugger entry has no settings, so nothing could switch its execute on. David chose one switch (2026-11-25): "Let the Agent change app databases" at the top of the MCP servers screen, off by default, for every app (McpServerStore.allowDatabaseWrites). It tells the change listeners, so the Agent's tool list follows. - ReadOnlyTrust.WRITE_TOOLS ("execute") is offered only while it is on, and never declared read-only, whatever hint the server sends (isReadOnly). So AI-Core asks before every call and never offers Always Allow for it. - Tooltip entry and long-press wiring for the switch; README, ai-agent-mcp.html, the in-IDE help and the plugin tooltip updated. - Version 2.1.0 / versionCode 4 (MINOR, on #166's 2.0.0 / 3). With the switch on, each app offers five tools; in compact mode (4) AI-Core drops the first app's get_events (README). Tests: WriteToolTest (off by default even claiming the hint; on: asks and not read-only; off again; listeners told; a hand-added server's execute stays ordinary) and three ReadOnlyHintParsingTest cases. Not run here: no Android SDK or AndroidX (dl.google.com is blocked), so neither Gradle nor these tests ran. ReadOnlyTrust and McpTool were compiled alone with a scratch check of the same rules (8 checks pass; isReadOnly without the WRITE_TOOLS exclusion fails "execute never read-only"). The addons check passes. Not run: testDebugUnitTest, assemblePlugin, the device check, font scale 1.0 and 2.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
…he switch is off On a Note 20 (2026-11-25), with "Let the Agent change app databases" off, the Agent was asked to add a row. The SQLite debugger's query description says "Writes are refused: use execute", but execute was not offered, so the model asked to run sqlite3 on the app's database through run_shell_command instead. The shell would not reach another app's private files, and the call needs approval each time, but the user was never told about the switch. While an app's entry lists execute and the switch keeps it off, that entry's query description now ends with a sentence saying the user can switch writes on in the MCP servers screen (the switch's own label, from strings.xml), and that the databases must not be changed any other way. ReadOnlyTrust.needsWriteSwitchHint decides it; a hand-added server's text and a debugger without execute are left as they were. The README's writes paragraph says so. stringsXmlContext moves from AppEndpointReasonTest to the shared test helpers, so WriteToolTest checks the shipped words too. The version stays 2.1.0 (this PR already raised it). Tests: four new WriteToolTest cases (switch off: the hint, with the exact text; switch on: none; no execute: none; hand-added: passed through). Revert proof: with only the hint in describe() removed, "with the switch off, query says how writes get allowed" fails (ComparisonFailure). Full testDebugUnitTest 362 (358 before), assemblePlugin, and the addons check pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… one The Note 20 rerun at 29cbd00 (2026-11-25), switch off: asked to add a row, the model asked for the shell (declined), then sent an INSERT through the app's query tool. SQLite refused it ("not authorized"), and AI-Core, whose rule replaces any answer after a failed call, showed only "I couldn't complete that, the last action failed. See the details above." So the switch sentence in query's description never reached the user. When a call to an app's query fails with SQLite's refusal of a write ("not authorized" from the read-only connection's authorizer, or "attempt to write a readonly database"), and the switch keeps execute off, the failure's text now ends with the same sentence as the description (ReadOnlyTrust.isWriteRefusal; McpToolSource.errorWithHint). That text is what AI-Core shows as the details, so the user reads how to allow writes. Other failures, the switch on, and hand-added servers are left as they were. FakeMcpServer can answer a tool with isError. The README says so. Tests: three new WriteToolTest cases (switch off: the refusal gets the sentence; switch on: passed through; another failure: passed through). Revert proof: with errorWithHint bypassed, "with the switch off, a write refused through query says how writes get allowed" fails (ComparisonFailure). Full testDebugUnitTest 365, assemblePlugin, and the addons check pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
Review of #178 at 4e2c0e7376. Stack: addons #166 (ADFA-7139) <- #178 (this, top); claims checked at this head.
NITPICK - 2 inline, not listed
Verdict: COMMENT. This PR is authored by the account posting the review, and GitHub refuses APPROVE and REQUEST_CHANGES on your own PR. Severity rules: CodeOnTheGo REVIEW.md and CLAUDE.md (a ticket moves to QA with no outstanding critical, high or medium findings); addons has no written rule, so the default applied.
Generated by Claude Code
… it was setAllowDatabaseWrites only logged a failed commit. SharedPreferences keeps the new value in memory when its disk write fails, so the switch looked saved and the session acted on it, and after a restart the old value came back: writes switched off could be on again (#178 review, comment 4713233488). The old value is now put back in memory, nothing is told of a change, and the settings screen sets the switch back and says the setting could not be saved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
isWriteRefusal also matches a refused BEGIN, SAVEPOINT, ATTACH or setting PRAGMA, which execute refuses too, so the hint then names a switch that would not help (#178 review, comment 4713233478). The server reports every refusal as SQLite's "not authorized", so the KDoc now says so and why it is accepted, rather than copying the server's rules here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…gger/ADFA-7302 Brings in the #178 review fixes (the writes switch save, the hint KDoc). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
|
@hal-eisen-adfa New commits since you were asked to review, for the 2026-11-26 review's two NITPICKs:
Each has a reply in its thread. The description lists the tests. The version stays 2.1.0/4, already bumped in this PR. #184 merges these. |
…d Code on the Go 26.49 #166 merged main at 7c7e333 (main's plugin-api.jar, which has the SQLite debugger API from stage) and raised plugin.min_ide_version from 26.48 to 26.49, because 26.48 was released before CodeOnTheGo#2261 merged. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…d Code on the Go 26.49 #178 merged #166 at 265fd64, which merged main at 7c7e333 (main's plugin-api.jar, which has the SQLite debugger API from stage) and raised plugin.min_ide_version from 26.48 to 26.49, because 26.48 was released before CodeOnTheGo#2261 merged. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
|
@hal-eisen-adfa c5caa68 merges #166 at 265fd64 into this PR. That brings main and |
ADFA-7300
Phase 2, P2-5 of the SQLite debugger (ADFA-7131 comment 41476, decision D14): AI-Agent-MCP lets the Agent use the debugger's
executetool, behind one switch, with the user's approval on every call. Stacked on #166 (sqlite-debugger/ADFA-7139); merge it after #166. On the device it needs CodeOnTheGo P2-3 (#2312,execute) and P2-4 (#2313,acknowledge_room).What it does (
plugins/AI-Agent-MCP)executeon. David chose one switch (2026-11-25, ADFA-7300 comment 41560): "Let the Agent change app databases" at the top of the MCP servers screen, off by default, for every app (McpServerStore.allowDatabaseWrites). Changing it tells the change listeners, so the Agent's tool list follows.ReadOnlyTrust.WRITE_TOOLS(execute) is offered only while the switch is on, and is never declared read-only, whatever hint the server sends (isReadOnly). So AI-Core asks before every call and never offers Always Allow for it.ai-agent-mcp.html, the in-IDE help and the plugin tooltip are updated.get_events(README).querydescription ends with a sentence saying the user can switch writes on in the MCP servers screen (the switch's own label), and that the databases must not be changed any other way (ReadOnlyTrust.needsWriteSwitchHint, 29cbd00). On the Note 20, told only "use execute", a tool it didn't have, the model asked to runsqlite3in the shell instead. The shell can't reach another app's private files, but the user was never told about the switch.querywhile the switch is off ("not authorized", or a read-only database), the same sentence follows the failure's text (ReadOnlyTrust.isWriteRefusal, 4e2c0e7). AI-Core shows that text as the details, and it replaces the Agent's own answer after a failed call with "I couldn't complete that, the last action failed" (ADFA-7318). So the details are the one place the user is sure to see it. It also matches a refused BEGIN, SAVEPOINT, ATTACH or setting PRAGMA, whichexecuterefuses too, so there the sentence names a switch that would not help. Accepted, and said in the KDoc (3ef6bac): the server reports every refusal as SQLite's plain "not authorized", and copying its authorizer's rules into the plugin would drift.Tests (local)
plugin.min_ide_version26.49; no conflicts; this PR's own diff is unchanged, same patch-id):testDebugUnitTest366, 0 failures;assemblePluginand the addons check pass; the.cgprecords 26.49 to 26.99.testDebugUnitTest366, 0 failures;assemblePluginand the addons check pass.WriteToolTestcase: with every commit failing, the switch stays off, in memory too, and no listener is told; then it saves.testDebugUnitTest365, 0 failures. New: threeWriteToolTestcases: switch off, a refused write's text gets the sentence; switch on, it passes through; another failure passes through. Revert proof: witherrorWithHintbypassed, "with the switch off, a write refused through query says how writes get allowed" fails.assemblePluginand the addons check pass.testDebugUnitTest362, 0 failures. New: fourWriteToolTestcases: switch off gives the hint, with the exact text; switch on gives none; a debugger withoutexecutegives none; a hand-added server's text passes through. Revert proof: with only the hint indescribe()removed, "with the switch off, query says how writes get allowed" fails.assemblePluginand the addons check pass.testDebugUnitTest: 358 tests in 69 classes, 0 failures. New:WriteToolTest(5: off by default even claiming the hint; on: offered, asks every time, not read-only; off again; listeners told; a hand-added server'sexecutestays an ordinary tool) and threeReadOnlyHintParsingTestcases (executeoff unless writes are allowed; never read-only; allowing writes switches on no other tool).WRITE_TOOLSexclusion inReadOnlyTrust.isReadOnly, two tests fail: "execute is never read-only, even claiming the hint" (assertFalse(ReadOnlyTrust.isReadOnly(...))) and "with the switch on execute is offered, asks every time and is not read-only" (assertTrue(execute.requiresApproval())).assemblePlugin:ai-agent-mcp.cgp, 10.3 MB, version 2.1.0. The addons check passes.Device (Note 20, Code on the Go C-d-1125-0922 with P2-3 and P2-4, 2026-11-25; ADFA-7300 comment 41577):
execute, and nothing was written. With it on, the app offers 5.executedialog offered only Run Now and Decline, with no Always Allow. After Decline, nothing was written. After approval, the row was written, and it shows in the app before and after a restart.acknowledge_room: truein its firstexecutecall (David: that's acceptable, P2-4 stays as it is). The Agent's answer mentioned the Room caveat after the write.query(refused). AI-Core showed only its stock failure line, so the description's sentence didn't reach the user. 4e2c0e7 puts the sentence in the failure's text. A fourth run checked it on the device (ADFA-7300 comment 41587): the refused INSERT's details end with the sentence, which names "Let the Agent change app databases". Nothing was written.No other screens changed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn