Skip to content

ADFA-7299: SQLite debugger asks before the first write to a Room database - #2313

Open
davidschachterADFA wants to merge 4 commits into
sqlite-debugger/ADFA-7298from
sqlite-debugger/ADFA-7299
Open

davidschachterADFA wants to merge 4 commits into
sqlite-debugger/ADFA-7298from
sqlite-debugger/ADFA-7299

Conversation

@davidschachterADFA

@davidschachterADFA davidschachterADFA commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

ADFA-7299

Phase 2, P2-4 of the SQLite debugger (ADFA-7131 comment 41476, decision D6): the first execute on a Room database waits for an acknowledgement. Stacked on #2312 (P2-3, ADFA-7298); merge it after #2312.

What it does (subprojects/sqlite-debugger, Kotlin only)

  • Room records changes with TEMP triggers on its own connection, which a write on the server's connection does not fire, so its observers (Flow, LiveData, Paging, InvalidationTracker) miss the change and a screen can show stale data. The SQLite debugger does not make Room refresh: it must not change how the app behaves.
  • execute looks for room_master_table on the read-only connection. On a Room database it runs nothing and returns an error naming the risk, with details {room: true, acknowledge_with: "acknowledge_room"}, until the call is repeated with acknowledge_room: true.
  • The acknowledgement is kept per database path for the life of DatabaseTools (one per app process), so later writes to that database run without asking and the check is not run again. A database without room_master_table never asks.
  • acknowledge_room must be a boolean; it is checked before the engine is called.
  • The README and execute's description and input schema are updated.

Limits: a database without Room's table is checked on every execute (one indexed read of sqlite_master); an acknowledgement outlives a database the app deletes and recreates under the same path.

Commits: fb55fbc (the cloud session's c07fbf3, cherry-picked onto #2312's branch; conflicts with #2312's last_insert_rowid in execute's result and the README's execute paragraph, resolved to keep both), 1f695c4 (its Room test helper built ExecuteResult(1), which no longer compiled after last_insert_rowid; a test line over ktlint's 140 columns wrapped), 43d9da5 (merge of #2312 at 8c2f6ac; this PR's own diff unchanged).

Tests

  • Local, at 43d9da5: :subprojects:sqlite-debugger:testDebugUnitTest (125), :plugin-api:testDebugUnitTest (251) with apiCheck, spotlessCheck and assembleV8Debug pass. test.sh with the system JDK: ASan+UBSan 15919 checks, TSan 15909, JNI 319, 0 failures (no native change in this PR).
  • From the cloud session: revert proofs: never refusing fails aRoomDatabaseRefusesTheFirstWriteWithAWarningAndRunsNothing and anAcknowledgementCoversOnlyItsOwnDatabaseAndOnlyThisServerProcess; not remembering the acknowledgement fails anAcknowledgedRoomWriteRunsAndLaterWritesRunWithoutAsking. One P2-3 test now counts the read-only connection execute opens.

Not done here: the device checks: by direct MCP calls on the Galaxy J7 (ADFA-7299 comment 41562), and through the Agent on the Note 20 with P2-5 (ADFA-7300).

No screens added or changed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn


Code Reviewer: Code Reviewer couldn't review this pull request
The pull request author does not have access to AI for the associated Atlassian organization.

claude and others added 3 commits November 24, 2026 23:37
…om database

Phase 2, P2-4 (ADFA-7131 comment 41476, decision D6). On P2-3.

- Room records changes with TEMP triggers on its own connection, which
  a write on the server's connection does not fire, so its observers
  miss the change and a screen can show stale data. The debugger does
  not make Room refresh: it must not change how the app behaves.
- execute looks for room_master_table on the read-only connection. On a
  Room database it runs nothing and returns an error naming the risk,
  with details {room: true, acknowledge_with: "acknowledge_room"}, until
  the call is repeated with acknowledge_room: true.
- The acknowledgement is kept per database path for the life of
  DatabaseTools (one per app process), so later writes to that
  database run without asking and the check is not run again. A
  database without room_master_table never asks.
- acknowledge_room must be a boolean; it is checked before the engine.
- README and execute's description and input schema updated.

Limits: a database without Room's table is checked on every execute
(one indexed read of sqlite_master); an acknowledgement outlives a
database the app deletes and recreates under the same path.

Tests: DatabaseToolsTest, McpProtocolTest and EventDecoderTest pass
(119), compiled with the Kotlin compiler outside Gradle. One P2-3 test
now counts the read-only connection execute opens. Revert proofs:
never refusing fails aRoomDatabaseRefusesTheFirstWrite... and
anAcknowledgementCoversOnlyItsOwnDatabase...; not remembering the
acknowledgement fails anAcknowledgedRoomWriteRunsAndLaterWritesRun...
Not run here: Gradle, spotlessCheck, a device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
(cherry picked from commit c07fbf3)
…sult

c07fbf3 was written on P2-3 before execute returned last_insert_rowid
(b73b9f7), so its Room test helper built ExecuteResult(1) and no longer
compiled; it now passes lastInsertRowid = null. Its one-line fake answer
in the acknowledgement test exceeded ktlint's 140 columns, which
spotlessApply cannot fix; it is wrapped. Tests only, no behaviour change.

:subprojects:sqlite-debugger:testDebugUnitTest 125 tests pass,
assembleDebug passes, spotlessApply leaves nothing to change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…gger/ADFA-7299

Brings P2-3's 8c2f6ac (execute reports rowid 0; INT64_MIN stands for
"no row inserted") into this stacked branch.

One conflict, in the README's execute paragraph: P2-3 changed its
last_insert_rowid sentence, and this PR removed "(the Room warning is
ADFA-7299)" from it, as its own bullet now covers the Room warning. The
resolution keeps P2-3's paragraph without that parenthesis, followed by
this PR's Room bullet. Outside the README this PR's own diff is unchanged
(+/- lines of `git diff b73b9f7 1f695c4` and `git diff
sqlite-debugger/ADFA-7298 HEAD` identical); in the README its own changes
are the same two (the parenthesis removed, the Room bullet added).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

…gger/ADFA-7299

Brings P2-3's fix for CodeRabbit's flag-PRAGMA finding into this stacked
branch: every PRAGMA that takes a value is refused except schema reads and
user_version on execute's connection (d7c5350), and execute's writable
connection enforces foreign keys (01413e0).

Two conflicts, both resolved to keep both sides: in DatabaseTools.kt,
P2-3's new READ_PRAGMAS_NOTE beside this PR's ROOM_DESCRIPTION and
ROOM_WARNING, and execute's description with P2-3's new text plus this
PR's "$ROOM_DESCRIPTION"; in the README, P2-3's rewritten read-only and
execute paragraphs (the latter without "(the Room warning is
ADFA-7299)", as this PR's Room bullet covers it), then the Room bullet.
Outside those two files this PR's own diff is unchanged (+/- lines of
`git diff 8c2f6ac 43d9da5` and `git diff sqlite-debugger/ADFA-7298
HEAD` identical); in them its own changes are the same as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Nov 25, 2026
Brings #2313 at 09939db (with #2312 at 01413e0: the PRAGMA allowlist and
foreign keys on execute's connection) into the temporary branch for the
device checks. No conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants