Skip to content

ADFA-7138: Rewrite opted-in apps to requery and add the SQLite debugger to debug builds - #2262

Open
davidschachterADFA wants to merge 230 commits into
stagefrom
sqlite-debugger/ADFA-7138
Open

davidschachterADFA wants to merge 230 commits into
stagefrom
sqlite-debugger/ADFA-7138

Conversation

@davidschachterADFA

@davidschachterADFA davidschachterADFA commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

ADFA-7138

Code on the Go's Gradle plugin moves an opted-in app to requery at build time and adds the SQLite debugger to its debug builds. Opt-in: cogo.sqliteDebugger=true in the project's gradle.properties. Design, rules and known limits: gradle-plugin/docs/sqlite-rewrite.md.

Stack: on stage. #2259 was squash-merged into stage as 122cc41 on 2026-11-24 (GitHub then moved this PR's base to stage), #2260 as acca2c3 and #2261 as ade5cc2 on 2026-11-25, so this PR is the last of the stack. Merge order: #2259, then #2260, then #2261 (all three merged), then this PR. In git it depends only on #2259, but the SQLite debugger AAR it bundles from its own tree sends the endpoint only once #2260 is in, and step 4 of the README's "Turning it on in an app" needs #2260 and #2261. Merged last, the opt-in works end to end as it lands. Stage at 759474f and the fixes for Daniel's #2259 review are merged up into this PR through #2259 (7570c49, no conflicts; earlier, 4bb66f7 for stage at 5a49afd, a91559d for ea79020, and 3dc0d01 for #2259's README change); each merge left this PR's own diff unchanged. After the squash, CLAUDE.md's squash recipe was applied: 662206a merges #2259's final head ba78ebb (stage at b5931b2 and the fixes for CodeRabbit's review of 2026-11-22), with no conflicts, and 6cbe9c2 merges origin/stage at 122cc41. Its four conflicts (ARCHITECTURE.md, CLAUDE.md, AndroidModuleConf.kt and the SQLite debugger's README) are lines both #2259 and this PR change; stage's side of each is exactly #2259's version, so each is resolved to this PR's side, and the merged tree equals 662206a's. This PR's own diff is unchanged: the +/- lines of git diff ee7fa6f36 0b4ebca2c and git diff origin/stage 6cbe9c243 are identical. 8bd3e26 then merges origin/stage at acca2c3, bringing #2260 into this branch for the first time. Only the two README conflicts listed below occurred, resolved as described there with #2261 not yet merged: #2260's two component items, then this PR's wiring item; and in "Not done yet" #2260's and this PR's items dropped, #2261's item and the introducing sentence kept. This PR's own diff is unchanged (README included). 008d135 then merges origin/stage at ade5cc2 (#2261): only the two README conflicts below, resolved as described there (#2261's DebuggerEndpointService item after #2260's two, then this PR's wiring item; in "Not done yet" the last items and the introducing sentence dropped). Outside the README this PR's own diff is unchanged; in the README the only change is the dropped introducing sentence. The head is 008d135; CI passes there. The fixes for Hal's review (below) are 5540ee5..0b4ebca. CodeOnTheGo allows only squash merges and deletes the head branch on merge: once #2259 is squashed, this PR's base moves to stage while its branch still carries #2259's original commits. Before this PR merges, merge origin/stage into it, resolve to this PR's side only the conflicts that duplicate the squashed PRs, and prove nothing else changed (CLAUDE.md's squash recipe; no rebase).

README conflicts (resolved): merging #2260 and #2261 into this PR conflicted in two places in subprojects/sqlite-debugger/README.md, and in no other file; 8bd3e26 and 008d135 resolved them as follows, so the README is now final.

  1. The component list, after the DebuggerStartup item. ADFA-7137: Store the SQLite debugger's port and token reported by the app #2260 adds three items there (EndpointBroadcast, the Code on the Go side and DebuggerEndpointService), and this PR adds the "Gradle plugin wiring (ADFA-7138)" item at the same place. Keep all four: ADFA-7137: Store the SQLite debugger's port and token reported by the app #2260's three, then the wiring item.
  2. The "Not done yet" list. ADFA-7137: Store the SQLite debugger's port and token reported by the app #2260, ADFA-7139: Plugin API for the SQLite debugger endpoints #2261 and this PR each delete a different item. Drop all three items and the sentence that introduces them ("These are outside this module and come in the PRs stacked on it:"). Keep the paragraph about device runs that follows them. Step 4 of "Turning it on in an app" already describes the endpoint (ADFA-7137: Store the SQLite debugger's port and token reported by the app #2260) and AI-Agent-MCP (ADFA-7139: Plugin API for the SQLite debugger endpoints #2261), so the README is then consistent.

What it does

  • A class transform (AGP instrumentation, scope ALL, every variant) rewrites android.database.sqlite to requery: renames, String[] to Object[] descriptors, redirects to a small helper module (subprojects/sqlite-rewrite-runtime) for open flags, CancellationSignal (one forwarding listener per Android signal, held weakly, so every query sharing it is cancelled with it and a dropped signal leaves nothing behind), Context.openOrCreateDatabase/deleteDatabase and DatabaseUtils queries, and a build failure naming class, method and line for anything requery lacks (OpenParams, arrays of it included, COLLATE UNICODE and COLLATE LOCALIZED, found through SQL comments and quoted names but not in a custom collation such as UNICODE_CI, casts to Android's cursor classes, ...) or that the rename would break: a SQLiteCursor converted without a cast to AbstractCursor, AbstractWindowedCursor or CrossProcessCursor (returned, passed, called on or stored, including into an array of one of those classes, or into a row loaded from an array of them; a store into such an array fails only when the value is an SQLite cursor on every path where it is not null, and logs a warning naming class, method and line when it is one on some paths only, by David's decision); a SQLiteQueryBuilder subclass overriding the query overload that takes a CancellationSignal; a cursor driver that declares both query(CursorFactory, String[]) and query(CursorFactory, Object[]), which the retype would turn into two identical methods that D8 rejects with no class or line; and, under the FULL policy, a call on an owner the build cannot resolve whose name and descriptor match a member a rule changes or rejects in a renamed class another class can extend, and whose descriptor names an SQLite-related type (CursorWindow doesn't count: Android's kept AbstractWindowedCursor declares setWindow(CursorWindow) and mWindow too); other such matches only log a warning naming class, method and line. An instanceof guard excuses a cast only when it holds on every path to the cast. The helpers that replace Context.deleteDatabase and the like still throw a NullPointerException for a null Context, as the original call did. androidx's framework classes are rewritten too, so Room and WorkManager keep noBackupDirectory and allowDataLossOnRecovery. Strings are not rewritten: under the FULL policy, a string constant naming a renamed android.database.sqlite class logs a warning with class, method and line, as do descriptor forms such as [Landroid.database.sqlite.SQLiteDatabase;; a string that merely contains the name inside a longer one, such as com.android.database.sqlite.SQLiteDatabase, and kept classes such as SQLiteDatabaseLockedException are not reported.
  • The helper AAR (every variant) and the SQLite debugger AAR (debuggable variants only) are bundled in Code on the Go's assets and passed to Gradle like logsender; both plugins check the AAR property through one Project.requireSqliteAar. App init extracts each AAR to a temp file, syncs the file and renames it into place (a failed copy deletes the temp file, and any exception is logged so the rest of init still runs), so a build that starts meanwhile reads the previous complete AAR or the new one, never a half-written file; only a fresh install's very first extraction can still be missing when a build starts that early, and the not-found message then says to retry in a few seconds. Debuggable variants also get kotlin-stdlib, at the version Code on the Go's local Maven repository holds. A check task fails the build clearly when requery (from the project's libs/), androidx.sqlite or androidx.core (which requery uses for CancellationSignal) is missing.
  • Quick Build is off for opted-in projects. The status line reads "Quick Build: off while the SQLite debugger is on - tap for details", and a tap shows why (new strings quick_build_status_off_sqlite_debugger and quick_build_disabled_sqlite_debugger; the unused sqliteDebuggerMessage is gone). A Quick Build tap (the button, the status line, the dropdown row or the plugin API) doesn't ask "Replace the installed app?" when the opt-in will refuse the build, since nothing is installed then: after saving, it reads the provisioner's own check (GradleQuickBuildProvisioner.refusesForSqliteDebugger), and during a sync, or when the opt-in can't be read, it asks as before (3412fe0). By David's decision, a tap on the "tap for details" status line while Quick Build is greyed out (a release variant or a plugin project, since ADFA-6574: Disable Quick Build for release variants and plugin projects #2247) flashes why, as the button does. A rebuild refused because the opt-in was turned on during a live session ends in the same refused state, with no retry. A refused start shows the neutral hollow bolt (the SLOW tone), not the error glyph, and a plugin's startQuickBuild() ends as QuickBuildResult.Refused with the refusal's text (1954dcd). The tap belongs to the text it was bound for: when other text replaces the line, such as the indexing status the view model writes next, the line is plain text again and TalkBack no longer offers the action; the same text written again keeps the tap. The opt-in is decided for the module Quick Build builds (the first app module), as Gradle's findProperty decides it for that module: the Gradle user home, the module, the root, then each parent project nearest first (Gradle gives the root's value precedence over every parent's; 5540ee5), the first file that defines it winning; another app module's value does not affect Quick Build (6926346). The early refusal check runs only once the model is published, so a module's false beats a root true during a sync too (a root opt-in tapped during a sync then pays for staging before it is refused), and the check after the model wait always runs, so a module that a sync adds with the opt-in is refused instead of reaching Gradle. Quick Build watches every module's gradle.properties up to MODULE_SCAN_MAX_DEPTH (4) levels below the root, plus the Gradle user home's, so turning the opt-in on in one of them ends a live session.
  • scripts/check-release-apk-no-sqlite-debugger.sh checks that an APK carries no SQLite debugger. It runs on every push: SqliteReleaseApkTest (TestKit, in its own task, :gradle-plugin:sqliteReleaseApkTest) builds the functional tests' sample app with the opt-in, as a release minified with R8 and as debug, using the real SQLite debugger and rewrite-runtime AARs and requery 3.49.0 as a file dependency, and runs the script on both APKs. The release build must pass; the debug APK is the control and must fail on the provider and the .so. With R8, the dex class-prefix check can miss renamed classes, so the manifest and .so checks are the ones that must fail. A step in debug.yml's build_apk runs it, without the Maven signing key, adding about 2-3.5 minutes; the test needs JitPack at test time. New test-only catalog entry: tests-requery-sqliteAndroid.

Tests: rule tests on bytecode compiled from Java samples, run through a verifier and JVM linking against requery 3.49.0, android.jar and androidx; resolution of every member of the 10 renamed classes and of androidx.sqlite's framework classes; a real AGP build that transforms a local AAR and the injected helper; plugin TestKit tests (debuggable-only injection, missing AAR, missing requery, androidx.sqlite or androidx.core, Quick Build off); Quick Build tests of the opt-in rule, the refused start and rebuild, the status line and the watched files (the provisioner tests' shared double stubs the module directory the opt-in check reads); the release-APK script on fake and real APKs, and in SqliteReleaseApkTest on an R8 release and a debug build (checked once against a broken build that leaves the SQLite debugger in release: it fails with the .so and provider messages); the string-constant warning, and no report for a kept class. Also tested: a string that only contains a renamed name does not warn, while descriptor and array names still do; the SQLiteQueryBuilder signal override; a cast-free cursor conversion (the same class, rewritten where the rule is exempt, fails ASM's CheckClassAdapter and the JVM verifier); an instanceof guard that does not cover every path; a call on an unresolved owner; two queries sharing an Android signal; an AAR read while it is replaced; and the two Quick Build refusals during a sync. A failed AAR copy leaves the previous AAR and no temp file; an SQLite cursor stored into an array of an Android cursor class fails; an unresolvable owner whose member names no SQLite type only warns, and the warning reaches a real AGP build's log, while one whose member names an SQLite type still fails; the SQLite descriptor tokens and the split of the 34 inheritable members (6 fail, 28 warn) are pinned; an unresolvable windowed cursor's setWindow(CursorWindow) and mWindow only warn; the warning names the method and line, once per place; the rewrite tests find requery in a non-default Gradle user home; a dropped signal's forwarder is not kept, a live signal keeps its forwarder through a GC, and a collected forwarder is replaced. An SQLite cursor stored into an Android cursor array loaded from an array of them fails (a parameter, new X[2][2], a row of new X[2][], three dimensions, and an array initializer); a store into such an array that is null on the other path fails; an SQLiteCursor[] used as an AbstractCursor[] is not reported and, rewritten where the rule is exempt, does not verify (a known limit, pinned); an SQLite AAR extraction that throws a RuntimeException returns and keeps the previous AAR. A store whose value is an SQLite cursor on some paths only warns once per place and builds (a null-guarded array, correlated branches, a ternary, two stores on one line, a loop); one whose value is an SQLite cursor on every path where it is not null still fails (with null on the other path, and two cursors); a store into a row of an Android cursor array that is null on the other path fails, whichever path comes first. A row loaded from an SQLiteCursor[] counts as an SQLite cursor, so a[0] = b ? c : cs[0] fails, and returning or passing such a row as an AbstractCursor without a cast fails too. A row of an SQLiteCursor[][], or of a renamed subclass's array, is followed as an SQLiteCursor[], so return g[0][0] as an AbstractCursor fails the build, and a merge of an SQLiteCursor[] with a subclass's array of the same dimension keeps the tag, so storing its element into an AbstractCursor[] fails. A row of an SQLiteCursor[][][] is followed too, so return t[0][0][0] as an AbstractCursor fails. An SQLiteCursor[] merged with an Object[] or a two-dimensional array loses the tag, so storing its element into an AbstractCursor[] never fails the build, whichever branch comes first. SqliteRewriterMergeTest tests the interpreter's merge directly, because the build-level tests can't catch a wrong tag merge: the tag survives a merge with the same dimensions, in either order and with a subclass's array, and not one with other dimensions or with no tag. QuickBuildGreyedStatusLineTapTest covers the tap on the greyed status line, calling the internal onQuickBuildStatusLineTapped directly, with no reflection. The rewrite tests find their jars in the active Gradle user home, constructor references are not resolved through superclasses, the release-APK script check is bounded by its timeout, and the transform test checks this run's helper, not a cached one; SqliteReleaseApkTest's KDoc says it skips without its AAR paths unless CI is set. At a91559d (stage merged): :common 274. At e723fd8: :app 1795. At 2ae43d2: sqliteReleaseApkTest 1/1 and the three Quick Build :app test classes. At 7b270b4: :gradle-plugin:test 264 tests, 260 pass and 4 skipped (@Disabled on stage under ADFA-5459), and spotlessCheck; the commits after 2ae43d2 add tests, change KDoc and sqlite-rewrite.md, and move the merge code unchanged into a function the test can call. At ebe4eda: :quickbuild:core 1249 and :subprojects:sqlite-debugger 80 tests pass; neither module has changed since. The CodeRabbit fixes each add a test that fails without the fix: the comment and quoted COLLATE forms fail the build and UNICODE_CI does not; a driver declaring both query overloads fails with a message naming both; a helper that rebuilds each missing-member descriptor from its parts rejects (Q)V, which the old check passed; deleteDatabase with a null Context throws the NullPointerException; and the status-line tap is dropped by other text and kept by the same text, both in StatusLineTapBindingTest and, through the real EditorBottomSheet in Robolectric, in EditorBottomSheetStatusTapTest (918e5f7), which fails if either wiring call is removed. At bd26c30: :gradle-plugin:test 268 tests, 264 pass and 4 skipped, and spotlessCheck. At 918e5f7: EditorBottomSheetStatusTapTest 3/3, StatusLineTapBindingTest 2/2 and the three Quick Build :app test classes (38) pass, and spotlessCheck. At c284f2c (the CodeRabbit follow-ups): :gradle-plugin:test 269 tests, 265 pass and 4 skipped, and spotlessCheck; StatusLineTapBindingTest 4/4 and EditorBottomSheetStatusTapTest 4/4, a new test in each covering refusal, then indexing, then the restored refusal line. The full :app suite then crashed its test JVM (ADFA-7259): EditorBottomSheetStatusTapTest built the sheet outside a CoordinatorLayout, so the sheet's collector threw, and once another test had created an IDEApplication in the same JVM, IDEApplication and CredentialProtectedApplicationLoader passed the uncaught exception to each other until the stack overflowed and the errors filled the heap. f532ce6 places the sheet the way content_editor.xml does and keeps uncaught exceptions out of that loop (one on the main thread fails the test). At f532ce6: the full :app suite passes (1803 tests) with spotlessCheck, the two status-line classes pass in one Gradle call, removing either wiring call fails the tests named for it, and without the sheet's behavior all four tests fail instead of crashing the JVM. At 4bb66f7: :gradle-plugin:test 269 (4 skipped). At 3412fe0: QuickBuildReplaceQuestionTest 2/2 and QuickBuildTapSqliteDebuggerCheckTest 5/5 (the tap's check agrees with provision() for a root opt-in, a module opt-in, a module false over a root true and no opt-in, and says no during a sync), with five related Quick Build classes, 67 tests in all, and the full :app suite (1810 tests) with spotlessCheck; with the fix reverted, the tests named for it fail. The call inside launchTap needs EditorHandlerActivity and has no JVM test. At 87f3017, after the CodeRabbit review at 3412fe0: :gradle-plugin:test 278 (4 skipped), the full :app suite (1822 tests) and spotlessCheck pass; each behaviour fix adds tests that fail with that fix reverted (the opt-in lookup, OpenParams arrays, the two COLLATE forms, the world-access modes). At 4ff13a5, after the CodeRabbit review at 87f3017: :gradle-plugin:test 279 (4 skipped) and spotlessCheck pass; the new rules test (block and line comments, whitespace and 20,000 separate comments, up to 100,000 characters, before the name) fails with StackOverflowError with the fix reverted. At 7570c49 (the merge of Daniel's #2259 fixes and stage at 759474f): :gradle-plugin:test 279 (4 skipped), the full :app suite (1826 tests), :subprojects:sqlite-debugger (103) and spotlessCheck pass. At 008d135 (with #2261 merged in): :gradle-plugin:test 280 (4 skipped), :quickbuild:core 1250, the full :app suite (1907), :plugin-manager 274, :plugin-api 251 with apiCheck, :subprojects:sqlite-debugger 112 and spotlessCheck pass (a first run was killed by the out-of-memory killer while other builds held the memory; the rerun passed). At 8bd3e26 (with #2260 merged in): :gradle-plugin:test 280 (4 skipped), :quickbuild:core 1250, the full :app suite (1895, with #2260's tests), :subprojects:sqlite-debugger 112 and spotlessCheck pass. At 6cbe9c2 (the merge-up after #2259's squash): :gradle-plugin:test 280 (4 skipped), :quickbuild:core 1250, the full :app suite (1830), :subprojects:sqlite-debugger 108 and spotlessCheck pass. At 0b4ebca (Hal's review fixes; CI passes there): :gradle-plugin:test 280 (4 skipped), :quickbuild:core 1250, seven Quick Build :app classes (100 tests; the full :app suite ran at 6cbe9c2) and spotlessCheck pass; with each behaviour fix reverted, its tests fail (the opt-in order: 5 of 33; the refusal: the tone, tracker and coordinator cases; the Context check: the static-call case). CI runs test-sqlite-debugger and the APK build job, which includes the release-APK guard and, from #2259's f683484, the SQLite debugger's Kotlin tests; at c284f2c both passed.

Verified on a device (Galaxy Note 20, Android 13, arm64-v8a and armeabi-v7a; an app built on the host with this plugin through its init script), on earlier heads: SQLiteOpenHelper, Room with its default factory, WorkManager and Context.openOrCreateDatabase run on requery's SQLite 3.49.0 with no source change; WorkManager's work survives a force-stop; the SQLite debugger lists and queries all databases; the release build runs on requery and contains no SQLite debugger, and an R8 release build had none either. On 2026-11-21 the integration build C-d-1121-0125 (this PR at e7d0da9) built a test app with the opt-in inside Code on the Go on the Note 20, and the build output showed no rewrite warning or failure. On a release variant, tapping the greyed Quick Build button flashed why (#2247's text). The greyed status-line tap was not reached on the device: the "tap for details" line didn't appear without a running Quick Build session, and starting one would have replaced the installed app with a proxy app. That tap is covered only by its JVM test. On 2026-11-23 the integration build C-d-1122-2257 (this PR at 3dc0d01) built a test app with the opt-in on the Note 20: the build output showed no rewrite warning or failure, Quick Build refused with the "tap for details" line, and while other text was on the line, a tap on it did nothing. With the app installed by Run, tapping the line asked "Replace the installed app?" before the refusal, and Cancel hid the refusal; 3412fe0 fixes that. On 2026-11-24 the integration build C-d-1123-0926 (this PR at 87f3017) on the Note 20, with the app installed by Run, showed the refusal at once for a Quick Build toolbar tap and two status-line taps, with no "Replace the installed app?" question (logcat: DisabledBySqliteDebugger each time). After each refusal the toolbar button showed its error glyph (see Hal's review); 1954dcd fixes that, not yet rechecked on a device. Host build cost: about +4 s on a first debug build, nothing measurable cached. At 6e16bdb, a LeakCanary probe: two cursors sharing one Android signal both stop when the signal is cancelled (before or mid-read), and LeakCanary and a heap count find no retained forwarder, signal, cursor or activity.

Not verified: a project from the template built inside Code on the Go (needs the template line, dev-assets#80), build time on a phone, offline resolution of kotlin-stdlib on a device. The Quick Build status line was not checked at 2x font scale on a device (the refusal message was, on an earlier head, and was readable). 6858c9f, b68446b, 2ae43d2, f77079c, b9e037f and 7b270b4 (the SQLiteCursor[][] row and array-merge checks, the internal onQuickBuildStatusLineTapped, and the merge tests) and the CodeRabbit fixes b2d7bbe through 5407497 are not yet re-reviewed, nor are Hal's review fixes (5540ee5..0b4ebca). The status-line tap dropping when the indexing status replaces the line was not checked on a device (on 2026-11-23 and 2026-11-24 the Note 20 never showed an indexing line).

Known limits (accepted):

  • Quick Build's opt-in check takes a parent project's directory from the project model; for a parent the model lacks it uses the default directory layout, which misses a projectDir remapped in settings.gradle. A parent's gradle.properties is watched only when its directory holds a build script, so turning the opt-in on in one that does not ends a running session only at the next proxy app build (6926346).
  • Existing LOCALIZED indexes after an engine switch: both engines rebuild them only when the locale in android_metadata changes, so after the opt-in is turned on or off over existing data an indexed lookup can miss rows. The build warns at each COLLATE LOCALIZED string constant and says to run REINDEX LOCALIZED or start from an empty database; a schema from a prepackaged database file is not seen. Reasoned from AOSP and requery's code, not reproduced on a device (1651a0c).
  • An inherited query(CursorFactory, Object[]) is not checked: the duplicate-overload check reads only the class's own methods, so a retyped driver method can override a superclass's Object[] overload. Documented in sqlite-rewrite.md, not fixed: the check would need ancestor methods, which the class hierarchy lookup does not provide (bb6194e).
  • A Quick Build tap's opt-in check and the provisioner's read the same files a moment apart. A change to them in between (an external write, or a sync finishing) could let the provisioner build and install the proxy app without the "Replace the installed app?" question. The save that could write such a change runs before the check (3412fe0); the KDoc of replaceConfirmedUnlessRefused says so (acdca5a).
  • A refused start takes the SLOW tone, so getQuickBuildStatus() reports FULL_BUILD_NEXT and the toolbar's content description reads "next build is a full build"; neither names the refusal. A new tone, string and API value would (1954dcd).
  • androidTest classes are not rewritten (the transform is registered on each variant's instrumentation only), so an instrumented test that calls app code with SQLite types in its signatures can fail to link with a NoSuchMethodError. Read from the code, not run; sqlite-rewrite.md lists it (0b4ebca).
  • The array-store check is path-insensitive, so a store fails the build when the cursor is null on exactly the path where the array is set (a = null; c = null; if (b) a = p; else c = query(); a[0] = c), although that store never throws. A check that doesn't match paths can't avoid this; gradle-plugin/docs/sqlite-rewrite.md lists it.
  • An unresolvable owner whose member's descriptor names no SQLite type (for example SQLiteQueryBuilder.isDistinct()Z or SQLiteProgram.getUniqueId()I) only warns. So a call that is really broken fails at run time, and the build warning is easy to miss. gradle-plugin/docs/sqlite-rewrite.md states this trade-off.
  • An SQLiteCursor[] used without a cast as an AbstractCursor[], AbstractWindowedCursor[] or CrossProcessCursor[] (AbstractCursor[] a = new SQLiteCursor[1]) is not reported; a class that passes, returns or stores it as one then does not verify (a test pins this). It is rare, and gradle-plugin/docs/sqlite-rewrite.md lists it.
  • When an SQLiteCursor[] is merged with an Object[] or a two-dimensional array, a store of its element into an AbstractCursor[] warns that the value is an SQLite cursor on some paths only if the SQLiteCursor[] branch is analysed first, and says nothing with the other order. The build never fails wrongly either way. A test pins this, sqlite-rewrite.md says so, and David accepted it as LOW on 2026-11-21.
  • A cancel forwarder is held only through the Android signal's cancel listener. If something later replaces that listener (app code, or the framework when the same signal reaches an API the rewrite doesn't change, such as ContentResolver.query(..., signal)), the forwarder can be collected after a GC, and cancelling the signal then no longer stops the queries converted earlier. 6e16bdb's commit message and the docs state this. Holding each forwarder strongly from its converted signal would close the gap at a small cost per query.
  • Four rare false positives, listed in sqlite-rewrite.md (bd26c30): a custom CursorFactory that returns a non-requery cursor, followed by a cast to an Android cursor class, is rejected, because the cast check follows the static type from a renamed owner (a cast through Cursor or an instanceof guard avoids it); the COLLATE rule matches any string constant on purpose, to catch Room's generated SQL, so a quoted literal or a log message containing the phrase fails too; an instanceof guard covers the checked local only, not a copy of it; and a subclass that declares its own version of a member requery lacks is still rejected, because the check works on class names.
  • The build-failure rule also applies to library classes; decided on ADFA-7138 to keep it. The failure message says how to build without the SQLite debugger: set cogo.sqliteDebugger=false in the gradle.properties that defines it, or in one read earlier (Gradle user home, then the app module, the root, then its parent projects; 87f3017, order corrected in 5540ee5), since commenting the line out can expose another file's true (b2d7bbe and 5407497; the SQLite debugger's README and sqlite-rewrite.md say the same).

Hal's review (at 7570c49 on 2026-11-24, 8 threads, all answered): fixed, each behaviour fix with tests that fail with it reverted: the opt-in order now matches Gradle's, the root before parent projects (5540ee5); a refused start is neither shown nor reported as a failure (1954dcd); the unresolvable-owner Context check applies only to a virtual call (7e43c17); the unused one-argument isSqliteDebuggerEnabled is gone (38ee669). Documented as limits: the replace-question window (acdca5a) and androidTest classes (0b4ebca). Tickets: one onDebuggableVariants for every plugin (ADFA-7291), and a prefilter with a benchmark for the SQL text checks (ADFA-7292). CodeRabbit's parent-project thread on GradleQuickBuildProvisioner is superseded by 5540ee5.

CodeRabbit (review at 87f3017 on 2026-11-23, 1 item, answered): fixed in 4ff13a5. A block comment of about 4,096 characters or more after COLLATE overflowed the stack and ended the build (from 650d1fc); the same change covers a long whitespace run or thousands of comments before the name, which overflowed before 650d1fc too.

CodeRabbit (review at 3412fe0 on 2026-11-23, 9 items, all answered): 8 fixed: the opt-in decided for the module Quick Build builds, with parent projects and docs (6926346; the opt-out wording in 87f3017), OpenParams arrays (33c9bac), a quoted COLLATE name with no space (ae88e4f), a block comment ending at its first */ (650d1fc), the LOCALIZED index warning (1651a0c), Android's SecurityException for world-access modes (0a7a0b2); 1 documented as a known limit (inherited query overload, bb6194e).

CodeRabbit (review at 7b270b4, 13 threads, all answered): 6 fixed (b2d7bbe and 5407497 opt-out wording, ece7a67 COLLATE detection, 6f0ee16 duplicate query overloads, cb95693 descriptor check, e2690c8 null Context, d1f8094 status-line tap, tested through the sheet by 918e5f7). 7 answered without code: four are the rare false positives above, now documented (bd26c30); one is the forwarder's GC timing, already a known limit; one is a test-only field-lookup order; and one is the order-dependent warning David accepted as LOW. Follow-ups on 2026-11-22: the restored refusal line's tap (c284f2c), quoted COLLATE names that must end at their closing quote (f4cf4c3), the cast-workaround and subclass sentences in sqlite-rewrite.md (eec3d54) and its custom-factory sentence (9ff51c2) are fixed; the descriptor check is answered without code, since the entries are hand-written constants.

Docs: CLAUDE.md and ARCHITECTURE.md list :subprojects:sqlite-rewrite-runtime as a module without ABI flavors. The SQLite debugger's README says how to turn it on in an app. gradle-plugin/docs/sqlite-rewrite.md describes the release-APK guard and the string-constant warning, and records that COPY_FRAMES never lowers another plugin's frame mode: AGP 7.3.0, 8.8.2 and 9.3.1 replace the mode only with a higher one, and a scratch AGP 9.3.1 build with a second factory needing computed frames verified with no errors. It lists a known limit of its own: a cancelled query throws androidx.core's OperationCanceledException, which does not extend Android's, so a catch of android.os.OperationCanceledException no longer catches it; it gives the multi-catch an app can use with the SQLite debugger on and off. It also records the array-store check (through arrays of arrays, with null on one branch, failing for a value that is an SQLite cursor on every path and warning for one that is on some paths only) and its covariant-array limit (an SQLiteCursor[] passed or returned as an Android cursor array does not verify; stored into an array of those arrays, it throws ArrayStoreException), the getWindow() limit on an SQLiteCursor subclass the build cannot resolve, and which rule-table matches on an unresolvable class fail and which only warn.

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

davidschachterADFA and others added 30 commits November 11, 2026 17:08
sqlite-js 1.3.7 (Apache-2.0, with QuickJS/quickjs-ng amalgamated in
libs/quickjs.c, MIT), only the files the AAR build uses, with patches/
applied: 0001-0008 are the Termux package's (terminal-packages
packages/sqlite-js), 0009 makes each call measure its own thread's
stack, and 0010 adds sqlitejs_cancel_all(). 0001-0009 are sent upstream
as sqliteai/sqlite-js #11-#19.

vendor.sh rebuilds upstream/ and the license notices from the release
(checked against its SHA-256) and patches/, or with --check tells
whether they match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
The AAR the JavaScript-in-SQLite project template depends on:
libsqlitejs.so for arm64-v8a, armeabi-v7a and x86_64 (minSdk 26), and
SqliteJs: cancelAll(), libraryPath(), ENTRY_POINT (loads the functions
stored in js_functions on every connection) and
ENTRY_POINT_FOR_DEFINING. sqlitejs_android.c, ours, holds the JNI and
that entry point; the version script exports only the entry points and
JNI_OnLoad. Nothing in CoGo depends on the module.

AndroidModuleConf leaves it without the v7/v8 flavors, like
:plugin-api, since one AAR serves every ABI, and without core-library
desugaring, like :logsender, so apps need not enable it.

Tested in a trial app (requery 3.49.0, Room 2.8.4) on a Galaxy Note20
Ultra as a 64-bit and a 32-bit process: scalar and aggregate from DAOs,
deep recursion on pool threads, 32 parallel queries under WAL, and a
runaway query stopped by cancelAll() within 5 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
A manual workflow, like release-plugin-api.yml: checks the vendored
sqlite-js, builds the AAR from main, and replaces the moving
sqlite-js-latest release, from which dev-assets fetches it into the
template that uses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
Apps built with Code on the Go run on ARM phones, so the AAR no longer
carries x86_64. ADR 0005 says so. CLAUDE.md's ABI section now names the
two modules without v7/v8 flavors, as ARCHITECTURE.md and ADR 0005 do
(review of PR #2244, F07).

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

From the reviews of PR #2244 (independent F02, F03, F05, F06; CodeRabbit):
- ENTRY_POINT (sqlite3_sqlitejs_init, also the name SQLite derives from
  libsqlitejs.so) now loads sqlite-js alone. The old entry point loaded
  the functions stored in js_functions, which runs their code, so any
  database file the app opened ran its stored JavaScript at once.
  Loading them is now ENTRY_POINT_FOR_TRUSTED_DATABASE
  (sqlite3_sqlitejs_trusted_init), for databases the app made.
  ENTRY_POINT_FOR_DEFINING is gone: ENTRY_POINT does that job.
- The trusted entry point loads each stored function on its own, so one
  that fails is logged and skipped instead of dropping those after it.
- cancelAll()'s Javadoc and the README say it stops JavaScript in every
  query, so call it only for a known runaway and repeat it until the
  query ends.
- test.sh runs upstream's test suite with patches/, and glue_test.c,
  the first test of sqlitejs_android.c. test-sqlite-js.yml runs
  vendor.sh --check and test.sh on pull requests for this module.

glue_test.c passes 14 of 14; against the old glue 5 fail (stored
functions loaded by ENTRY_POINT, functions after a broken one dropped).
The AAR builds and exports the two entry points, sqlite3_js_init and
JNI_OnLoad. Not run on a device.

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

release-sqlite-js.yml deleted the release and its tag before making the
new one, so a failed upload left dev-assets nothing to fetch. It now
uploads the new assets over the old ones, putting the old ones back if
that fails, then moves the tag and the notes. The release is created and
kept with --latest=false, so it never becomes the repository's latest
release (CodeRabbit, PR #2244).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
vendor.sh built LICENSE.quickjs with sort -u in the machine's locale, so
the new test-sqlite-js workflow's vendor.sh --check failed on the runner:
en_US.UTF-8 and C order "2017" and "2017-2018" differently. It now sorts
with LC_ALL=C, and upstream/LICENSE.quickjs and the META-INF notice are
regenerated; only the order of their copyright lines changes. --check
passes under C, C.UTF-8 and en_US.UTF-8.

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

From CodeRabbit's review of the previous commits:
- The trusted entry point returned silently when it could not list the
  stored functions (busy, out of memory, an odd table), opening the
  connection with some or none of them. Each failure is now logged; the
  connection still opens. It first looks js_functions up in
  sqlite_master, so a database without stored functions makes SQLite
  log no "no such table" error on each connection, as it did.
- release-sqlite-js.yml moves the tag and edits the notes in the same
  guarded sequence as the upload. If any step fails, the previous
  assets and tag are put back.

glue_test.c passes 16 of 16; the two new tests fail on the previous
glue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
Patches 0002, 0003, 0004 and 0010 are regenerated after three reviews:
the independent reviews of terminal-packages #6 and of this PR, and
CodeRabbit's review of this PR.
- 0002: garbage is collected before the memory limit fills. Running
  out of memory through small allocations reports "out of memory".
- 0003: the README says TEMP views and triggers can call the js_*
  functions.
- 0004: db.exec throws for a buffer it cannot read instead of binding
  NULL. A typed array's own offset and length are used, not properties
  a script defines.
- 0010: a cancel also interrupts the cancelled call's statement, so a
  runaway JavaScript collation stops. Before, nothing could stop one.

The other patches change only in their headers and line numbers.
upstream/ is regenerated with vendor.sh, and vendor.sh --check passes.
SqliteJs.cancelAll() and the README say a cancel interrupts the
statement too.

Tested:
- test.sh: upstream's suite passes 16 of 16, and the glue test 16 of 16.
- In the work repo, the same suite passes under ASan and UBSan with
  leak checking, and each new test fails without its fix.
- The AAR builds for arm64-v8a and armeabi-v7a.

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

From CodeRabbit's review: under bash -e, a failed restore of the
previous assets stopped the rollback before it put the tag back, so the
tag could name the new build while the release held the old one. Each
restore is now attempted, reported if it fails, and the step still
fails.

Checked with gh stubbed out: when the update fails and the asset restore
fails, the tag restore still runs and the step exits 1.

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

From CodeRabbit's review of the vendored patches:
- The trusted entry point looks up js_functions with COLLATE NOCASE, as
  SQLite resolves a table name, so a table named JS_FUNCTIONS loads. A
  new glue test, now 18 of 18, fails without it.
- Patch 0010's Cancel all test cancels once the JavaScript under test
  has called started(), an SQL function, instead of after a fixed
  200 ms. A slow start can no longer end the test at its alarm. It still
  hangs without the fix it tests.
- SqliteJs.cancelAll() and the README now say two more things. An
  interrupted INSERT, UPDATE or DELETE in an explicit transaction rolls
  the whole transaction back. And a cancel reaches SQL that JavaScript
  runs through db.exec only when that SQL returns to JavaScript.

Tested:
- test.sh: upstream's suite passes 16 of 16, also under ASan and UBSan
  in the work repo, and the glue test 18 of 18.
- vendor.sh --check passes.
- The AAR builds with the new lookup for arm64-v8a and armeabi-v7a.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
A run that stops during `gh release upload --clobber` can leave an asset
missing. The next run then failed at the backup download ("no assets match
the file pattern") before it uploaded anything, so re-running could not
repair the release. The step now backs up only the assets that exist and
puts the previous ones back only when it has both.

Tested with a stub gh over a fake release: both assets missing now ends with
the new pair and the tag moved (before: exit 1 at the download); the other
five cases are unchanged. Checked against gh 2.46: download fails only when
no pattern matches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
Upstream merged our patches 0001 to 0009 (sqliteai/sqlite-js #11 to #19)
on 2026-11-12, with fixes of its own. One fixes a bug in our 0002: a
memory limit lowered under memory that is garbage left the connection
out of memory until the limit was raised again (ef06558).

upstream/ is now sqlite-js main at c8ae85a, the same source as the Termux
package 1.3.7-p20261112, with one patch: 0001, sqlitejs_cancel_all(), our
old 0010 rebased. Its test now fails with a message when the JavaScript
under test has not started within 10 seconds, instead of cancelling
anyway, and uses upstream's watchdog thread instead of alarm(). The patch
is offered upstream in sqliteai/sqlite-js issue 20.

vendor.sh, test.sh and test-sqlite-js.yml take the commit (COMMIT, URL)
instead of the release tag. vendor.sh --check passes; test.sh passes:
upstream's suite 16 of 16 with Cancel all, glue_test 18 of 18. The
upstream suite with the patch also passes under ASan + UBSan; without the
patch's sqlite3_interrupt() its collation case runs until the watchdog,
and with started() never called the worker fails with its message. The
native library builds with NDK 29 for arm64-v8a and armeabi-v7a, with no
warnings in sqlitejs.c or sqlitejs_android.c, and exports the same four
symbols.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
Upstream released 1.4.0 and 1.4.1 on 2026-11-12, after c8ae85a. Both
contain it, and 1.4.1 differs from it in src/ and libs/ only in
SQLITE_JS_VERSION, so js_version() now reports 1.4.1. vendor.sh, test.sh
and test-sqlite-js.yml take the release's archive again (VERSION,
SHA256, URL). Patch 0001 is unchanged but for its context.

The scripts now take the archive's one top directory whatever its name
(tar --strip-components=1). They named it after COMMIT, so the README's
"point URL at its tag again" would have failed: a tag's archive unpacks
to sqlite-js-<tag> (independent review). The README says how to vendor
a release, and a commit between releases.

vendor.sh --check passes on the 1.4.1 archive (SHA-256 d45d394f...3078).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
…ng a cancel

A cancelAll() that landed while another thread opened a connection made
that connection fail to load sqlite-js (SQLITE_NOMEM), so a Room query
on a new pool connection failed (independent review). Setting up the
runtime runs JavaScript of its own, which the interrupt handler stopped.
Patch 0001 now cancels only JavaScript inside a call (js_enter), and its
Cancel all test opens 200 connections while another thread cancels
without pause: the first one failed before.

A cancel that lands while the trusted entry point loads a stored
function stops that function's code the same way, and the function was
then missing from the connection for good. load_stored_function now
tries such a load again, up to three tries in all; its stored code runs
again each time. glue_test.c stores a function whose code cancels the
first time it loads: it loads on the second try, and with one try it is
missing. The README and SqliteJs's Javadoc say both.

test.sh passes: upstream's suite 16 of 16, glue_test 22 of 22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
0002, after CodeRabbit's review: code that called itself without end
crashed the process instead of failing with "Maximum call stack size
exceeded" in two cases.
- On a thread with less than 64 KB of stack left, js_enter kept the
  connection's 1 MB size rather than the room it measured. It now keeps
  any measurement, and 1 rather than 0, which turns the check off.
- On the main thread, RLIMIT_STACK was counted from where the first
  measurement was taken. Loaded 2 MB deep, the extension allowed 10.2 MB
  of an 8 MB stack. It is now counted from the stack's top, as the
  kernel counts it.

0003, after the independent review of terminal-packages #6: garbage
could leave an allocation that fits in the memory limit failing on every
try. After 40 MB of cyclic garbage, new ArrayBuffer(30 MB) failed under
the 64 MB default. And after a limit was lowered to 32 MB above the
garbage, new ArrayBuffer(16 MB) failed. The extension now collects
after any "out of memory" error and whenever a limit is set.

Each patch adds tests to upstream's suite that fail without it. The
suite passes 16 of 16 with all three patches, also under ASan and UBSan,
and test.sh's glue_test 22 of 22. The NDK 29 build for arm64-v8a and
armeabi-v7a has no warnings outside QuickJS and exports the same four
symbols. Both fixes are offered upstream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
gh release create makes a draft and publishes it once its assets are
uploaded. A first run that stopped during that upload left a draft:
the next run found it, skipped the create, and failed fetching its tag,
which a draft does not have yet. Every re-run then failed (independent
review). The step now deletes a draft release, which dev-assets cannot
fetch from, and creates the release again.

Tested with a stub gh over a fake release, eight cases. The draft case
failed with a 404 before, and now ends with the new assets and tag. The
other seven are unchanged: no release, normal, upload fails, tag update
fails, both assets missing, one missing, and upload fails with both
missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
Spotless wraps the cancelAll() Javadoc paragraph, which the previous
commits lengthened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
CodeRabbit: SQLite keeps an interrupt in effect while any statement of
the connection runs, and a db.exec result set that JavaScript keeps open
is a running statement. After cancelAll() stopped JavaScript that kept
one in a global, every later statement on that connection failed with
"interrupted", until the connection closed. A stored function whose code
kept one could not load on any of its three tries. sqlite3_interrupt()
does the same, without our cancel patch.

Patch 0004 lists each connection's result sets. When the outermost call
into JavaScript returns on an interrupted connection, it finalizes those
still open. Reading on from one that JavaScript kept throws
"interrupted". Reproduced on the host, with a cancel and with
sqlite3_interrupt(): every later statement failed before, and all run
after.

Upstream's Interrupt test interrupts code that keeps a result set, in a
global and as garbage, and fails without the patch. glue_test.c stores a
function whose code keeps one and cancels the first time it loads. It
loads on its second try, and the connection runs SQL afterwards; without
the patch, those three checks fail.

test.sh passes: upstream's suite 16 of 16, also under ASan and UBSan,
and glue_test 26 of 26. The NDK 29 build for arm64-v8a and armeabi-v7a
has no warnings outside QuickJS and exports the same four symbols.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
…on old SQLite

CodeRabbit, on 0004:
- 0005: finalizing a result set that is computing a JavaScript window
  function runs the function's final, whose js_leave() ended the result
  sets again on the interrupted connection, finalizing the same statement
  twice. Under ASan that is a use after free in sqlite3VdbeMemFinalize,
  reproduced on the host. Each statement is now taken from its result set
  before it is finalized, the list is walked again from its head after
  each one, and a nested call does nothing. Upstream's Interrupt test now
  keeps a result set computing a window function; it fails under ASan
  without 0005.
- 0006: on SQLite before 3.41, which has no sqlite3_is_interrupted(),
  0004 never ran, though a cancel still interrupts the connection. The
  interrupt handler now records the interrupt it sends. Built to report
  SQLite 3.40, a cancel of JavaScript that keeps a result set left every
  later statement failing before 0006, and not after.

test.sh passes: upstream's suite 16 of 16, also under ASan and UBSan,
and glue_test 26 of 26. The NDK 29 build for both ABIs has no warnings
outside QuickJS and exports the same four symbols.

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

CodeRabbit, two more cases on SQLite before 3.41, both in patch 0007:
- Ending result sets after a cancel can run a window or aggregate
  function's final, which begins after the cancel, so nothing stopped
  it: a final that never ended hung the cancelled query. The interrupt
  handler now stops any JavaScript while result sets are being ended.
- A direct sqlite3_interrupt() that reached a db.exec statement's SQL,
  with another result set kept open, went unseen. A result set whose
  step returns SQLITE_INTERRUPT now records it.

Checked with the patched source built to report SQLite 3.40: the endless
final hung before and ends after, and a direct interrupt during
db.exec's SQL, caught or not, left later statements failing before and
not after. Still unseen before 3.41, and said in the README: an
interrupt that never reaches the SQL that JavaScript runs. Android's
cancelling never calls sqlite3_interrupt(), and cancelAll() is covered.

test.sh passes: upstream's suite 16 of 16, also under ASan and UBSan,
and glue_test 26 of 26. The NDK 29 build for both ABIs has no warnings
outside QuickJS and exports the same four symbols.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
- 0009: a result set's SQLITE_INTERRUPT now counts as an interrupt only
  before SQLite 3.41. A progress handler that stops a statement, as
  Android's cancelling does, gives the same code and interrupts nothing
  else, yet it ended the result sets earlier calls kept, on any SQLite.
- 0008: the Interrupt test's "garbage" result set was freed by
  reference counting, so the case passed without 0004. It is now a
  reference cycle, and fails on 1.4.1 without 0004. Also pushed to
  sqliteai/sqlite-js#24.
- Tests for 0006, 0007 and 0009, which had none: glue_test.c cancels
  JavaScript that keeps a result set, then a kept window function whose
  final never ends, then has a progress handler stop a statement. test.sh
  runs it twice, the second time with sqlitejs.c built to report SQLite
  3.40. Without 0009 the progress-handler check fails; without 0007 the
  3.40 run hangs until the test's 30 s alarm; without 0006 seven checks
  fail in the 3.40 run.
- README: a cancel ends every result set open on the connection, not
  only the stopped call's. And on any SQLite, an sqlite3_interrupt() that
  lands while no JavaScript runs leaves the connection failing while
  JavaScript keeps a result set, so finish result sets before a call
  returns. Reproduced on 3.49: every later statement fails, and
  sqlite3_close returns SQLITE_BUSY.

test.sh passes: upstream's suite 16 of 16, also under ASan and UBSan,
and glue_test 34 of 34 in both runs. The NDK 29 build for both ABIs has
no warnings outside QuickJS and exports the same four symbols.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
CodeRabbit: the case that 0007's record of a step's SQLITE_INTERRUPT is
for had no automated test. glue_test.c now keeps a result set, has
another thread call sqlite3_interrupt() while db.exec runs a query that
never ends otherwise, and checks that the connection runs SQL and that
the kept result set was ended. In the run as SQLite 3.40, those checks
fail without the record. The checks that a kept result set was ended
now tell an ended one (caught in JavaScript: "ended: interrupted") from
a connection that is still interrupted, whose error is the same word.

test.sh passes: upstream's suite 16 of 16, and glue_test 37 of 37 in
both runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
… and its server

sqlitedbg.h is what the extension implements and its JNI layer calls;
DebugEngine.kt is what the server (ADFA-7136) builds against, with a fake
for JVM tests. Not yet built by Gradle: the module has no build file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
McpHttp.kt and McpProtocol.kt from Local Store Server Combined with only the
package, server name, title, instructions and 401 texts changed.
McpProtocolTest.kt still names that project's tools and does not compile;
ADFA-7136 rewrites it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
Module build file modelled on sqlite-js (no ABI flavors, both ABIs, no STL,
16 KiB pages), plus Kotlin at API 2.0 for apps built with CoGo. Registered in
settings, modulesWithoutAbiFlavors and disableCoreLibDesugaringForModules.
The CMake file arrives with the extension in the next commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
Binds 127.0.0.1 on port 0 with a new token per process start, and serves
list_databases, list_connections, get_schema, query, explain_query_plan,
get_stats, integrity_check and get_events against DebugEngine. JVM tests
run against FakeDebugEngine (51 pass). DebuggerStartup.kt and the manifest
are Android-only and not yet compiled. Formatting follows in its own commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
sqlitedbg.c implements sqlitedbg.h as a loadable-extension client. Per-connection
state is freed only from the xDestroy of sqlitedbg_connection_id; the trace CLOSE
event only marks it closing. Events live in a ring of records in their exported
layout. Server connections are recognised by a thread-local flag set around
sqlitedbg_open_server's own open.

test.sh builds SQLite 3.49.1 from the amalgamation (pinned) and runs
sqlitedbg_test.c under ASan+UBSan and under TSan. The same run writes or checks
the fixture the EventDecoder JVM test reads.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
sqlitedbg_jni.c registers NativeBridge's natives from JNI_OnLoad (the version script
exports nothing else) and reaches SQLite only through the extension's api table.
ServerConnection.query steps the statement in C, binds args by type, applies
QueryLimits, and stops at the deadline through a progress handler on the server
connection. EventDecoder mirrors the exported record layout and is tested against
the fixture the host C test writes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
davidschachterADFA and others added 4 commits November 23, 2026 12:39
Each tool call of a JSON-RPC batch started its own 50 s deadline, so one POST
of up to 32 slow calls could hold the tool lock for about 27 minutes (32 x 50 s),
long after the client stopped waiting. The server still accepts protocol
versions 2025-03-26 and 2024-11-05 (McpProtocol.VERSIONS), which allow batches.

McpProtocol takes postTimeLimitMs (and a clock), fixes one deadline when post()
starts and hands it to every tool call of the batch: McpTool.run now gets
(args, deadlineMs), null when the protocol sets no limit, and then the tool
starts its own as before. DatabaseTools.Call uses the POST's deadline;
DebuggerStartup passes DatabaseTools.DEADLINE_MS. A call that starts after
the deadline fails at once with the existing time-limit error, because the
engine refuses to start a query past its deadline (sqlitedbg_jni.c,
bridge_query: "the time limit passed before the query started"). A single
call gets the same limit as before. The README, the KDoc and the
NON_WAL_NOTE wording now say the limit belongs to the POST.

Checked: McpTool is built only in DatabaseTools and the tests; McpProtocol only
in DebuggerStartup and the tests. Accepted limits: list_databases,
list_connections and get_events run no SQL and still answer after the
deadline; that the client's 60 s limit is per request, so per POST, is an
assumption not checked against a client.

Tests: McpProtocolTest, every call of a batch sees the POST's deadline, a
later POST a new one, and null without a limit. DatabaseToolsTest, with the
fake clock and a fake engine whose queries take 20 s and stop at the
deadline: a batch of five ends after exactly DEADLINE_MS, the late calls
fail with the time-limit error and never start; a single call and a later POST
keep a full deadline. With only the fix reverted (the Call uses its own
clock() + DEADLINE_MS and the protocol passes null) two tests fail:
"one deadline for the POST, not one per call expected:<50000> but was:<100000>"
and "expected:<[6000, 6000, 6000]> but was:<[null, null, null]>"; the
single-call test passes, as it pins unchanged behaviour.

Review thread 4659142372 (Daniel)

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

g_next_seq restarts at 1 in every process. After the app restarted, an agent
passing its old `next` got events [] and dropped 0 when `after` was at or past
the new count, and silently skipped the first `after` events when it was below.

Contract now: every get_events result carries `run`, a random UUID fixed for
the process (DebugEngine.runId; NativeDebugEngine makes it once per process in
its companion). get_events takes an optional `run`; one that differs from the
current reads from the start (as after 0) and the result has reset: true. An
`after` at or past g_next_seq also resets, which catches a client that sends no
run. That check lives in C, because only C knows the newest number assigned:
sqlitedbg_read_events does it under g_lock and reports
sqlitedbg_read_result.reset, which the JNI layer returns as a fourth long
(Kotlin allocates 4) and EventBatch.reset carries. `after` equal to the newest
seq is a caught-up reader and gets no reset. The struct sqlitedbg_read_result
changed, so SQLITEDBG_INTERFACE_VERSION is 2. sqlitedbg_event_record is
unchanged, so events.bin and events.tsv are too (test.sh checks them).
Tool description, input schema and README updated.

Accepted limit, in the README: a client that sends no run and holds a cursor
from an earlier process that is still below the new process's count gets no
reset and misses those events; `after` alone cannot tell them apart.
AI-Agent-MCP does not keep the cursor (the model passes `after` itself), so
addons need no change (taken from the brief; the addons code was not read).

Tests: C, test_cursor_reset (after one past the newest, far past it and
UINT64_MAX reset and read everything; caught up does not; the cursor the reset
returned is valid). Kotlin, DatabaseToolsTest: a run mismatch, a matching run,
after past the newest, the caught-up case, and a simulated restart
(FakeDebugEngine.restartProcess); NativeDebugEngineTest: runId is a UUID shared
by instances.

Revert proof. C, with the reset block removed: "FAIL sqlitedbg_test.c:478:
b.reset == 1 (0 vs 1)" and "b.count == stored (0 vs 128)" for each of the three
cursors, 12 failures. Kotlin, with the run check and the reset flag removed:
getEventsWithAnotherRunReadsFromTheStartAndSaysReset (assertTrue at line 950),
getEventsWithACursorPastTheNewestSaysResetEvenWithoutARun (line 960) and
anAgentWithACursorFromBeforeAnAppRestart... (line 975) fail with a bare
AssertionError.

Review thread 4659142347 (Daniel)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…138: Daniel's #2259 review fixes and stage at 759474f

Brings in #2259's merge of stage (f21b3ac: ADFA-6967 #2273, ADFA-3570
#2242, ADFA-5763 #2279) and #2259's seven fixes for Daniel's review
(f6de53d through ee7fa6f). No conflicts. This PR's own diff is
unchanged (its added and removed lines are identical before and after).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Brings in ADFA-7258 (#2301), which waits for the editor's async layout in
IDEEditorAccessibilityTest. stage requires a PR to be up to date before
it merges. No conflicts; the only file stage changed is that test.

This PR's own diff is unchanged.

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

@hal-eisen-adfa hal-eisen-adfa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review of #2262 at 7570c494a (effort high), requested over Daniel-ADFA's approval at 5407497bf, 39 commits earlier.

Stack: stage <- #2259 (ADFA-7135) <- #2262. #2260 <- #2261 branch off #2259 separately. Nothing is based on #2262, so its head is the tip, and claims were checked there.

IMPORTANT

  • QuickBuildProjectSupport.kt:108 - the opt-in order ranks parent projects above the root; Gradle does the reverse
  • QuickBuildStatus.kt:27 - a refusal still reads as a failure in the toolbar tone and the plugin run tracker

MINOR

  • QuickBuildAction.kt:240 - the skipped replace question can let a later non-refused provision install silently (PLAUSIBLE)
  • SqliteRewritePlugin.kt:45 - androidTest classes are not rewritten (PLAUSIBLE)
  • SqliteRewriter.kt:714 - the Context-method check fails static and interface calls that cannot be Context

NITPICK - 3 inline, not listed

Prior unresolved threads, checked at head:

  • SqliteRewriter.kt:1142 (cursor cast with a custom factory): accepted limit. The doc sentence CodeRabbit asked for is at sqlite-rewrite.md:216 and :278.
  • SqliteRewriteRulesTest.kt:17 (descriptor syntax): (Q)V is now rejected (cb95693). The rest was declined as hand-written literals. That is reasonable.
  • GradleQuickBuildProvisioner.kt:625 (parent-project opt-in): parents are now read, but in the wrong order relative to the root. See the first IMPORTANT above. QuickBuildTapSqliteDebuggerCheckTest.kt:195 "a parent's false overrides the root's true" pins the wrong behaviour.

Not posted: re-extracting both AARs on every start matches the logsender and cogo-plugin.jar pattern beside them. The new ASM catalog entries are compileOnly and the transform needs them.

Rules: REVIEW.md, and CLAUDE.md's QA gate (no critical, high or medium findings). The two IMPORTANT findings block that gate.

davidschachterADFA and others added 19 commits November 24, 2026 13:12
Brings ADFA-7274 (#2303, package name change dialog: MainActivity,
PackageNameChangeDialogFragment, GeneralPreferences, strings.xml) and
ADFA-7244 (#2299, spotless-apply workflow). None touches this module.

This PR's own diff is unchanged. Checked: the +/- lines of
`git diff 8ab2028 4fc9885` (old merge-base to the previous head) and of
`git diff origin/stage HEAD` after the merge are identical (6686 lines each,
sorted and compared with cmp).

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

Failure: bridge_query returned early when the deadline had already passed,
when GetStringChars failed, and when prepare_one failed, all before the
sqlitedbg_end_transaction backstop at its end. A transaction left open on
the server connection stayed open after such a call.

Fix: the three early returns now go to the `done` label, so the backstop runs.
A failing rollback does not replace the original error: throw_engine
returns when an exception is already pending.

Checked: the other return NULL paths in bridge_query already reach `done`.

Tests (JniQueryTest, Helper.autocommit = sqlite3_get_autocommit): a
transaction is opened with sqlite3_exec on a writable server connection
(outside the query path; the read-only authorizer refuses BEGIN there), then a
syntax error, a second statement, a NUL, a missing table and a past deadline
each leave it closed, and a refused rollback keeps the syntax error. The
GetStringChars failure has no test (it needs an out-of-memory JVM).
With only the fix reverted, 10 checks fail, first
"rolled back after a failed prepare: SELEKT 1: 0 vs 1" and
"rolled back after a deadline already past: 0 vs 1"; the rest follow
because BEGIN then runs inside the open transaction. test.sh passes with it.

CodeRabbit thread PRRT_kwDONcONtM66nRMs (F03)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Failure: JNI_OnLoad checked the class globals and the UTF-8 string together
and only after that made the g_utf8_name global ref, which it never checked;
a failed lookup left the next call running with a pending exception.

Fix: each class lookup, the UTF-8 name and its global ref are checked in turn
and return JNI_ERR at the first failure; the local ref of the name is freed.
The method id lookups after them were already checked as a group.

Checked: test.sh builds the library with -Wall -Wextra -Werror and the JNI test
passes (205 checks, 0 failures). No test: a failing FindClass or
NewGlobalRef needs a JVM that fails on demand.

CodeRabbit thread PRRT_kwDONcONtM66nRMz (F05)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
The comment said only "what sqlite3_open_v2 returns". In sqlitedbg.c a failure
of PRAGMA query_only, of the authorizer or of the busy timeout closes the
connection (sqlite3_close_v2), sets *db to NULL and returns that code; so does
a failed open itself. The comment now says so.

Checked against sqlitedbg_open_server in sqlitedbg.c. Comment only, no test.

CodeRabbit thread PRRT_kwDONcONtM66nRM1 (F06)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…e, module, root, then parents

Quick Build read cogo.sqliteDebugger from the module, then each parent
project, then the root. Gradle gives the root's value precedence over every
parent's, so with root=false and group=true Gradle's build rewrote nothing
while Quick Build refused, and with root=true and group=false the reverse:
Quick Build ran on a project the plugin had moved to requery.

propertyDirs now returns module, root, then parents nearest first; the user
home stays first. KDoc, the provisioner's log text and KDoc, the rewriter's
WAY_OUT message, sqlite-rewrite.md and the sqlite-debugger README state the
new order.

Checked: the main session ran Gradle 8.14.4 on a three-level project
(:group:app): root false + group true gives false; root true + group false
gives true; root true + group false + module false gives false; no root
value + group false gives false. The user home overriding all of them is
from the Gradle docs, not run. QuickBuildProjectLayout (quickbuild/core) only
decides which gradle.properties files invalidate a session, not their
precedence, so it needs no change.

Tests: QuickBuildProjectSupportTest (order of propertyDirs, and the four
Gradle cases above through isSqliteDebuggerEnabled), and
QuickBuildTapSqliteDebuggerCheckTest, where "a parent's false overrides the
root's true" becomes "the root's true outranks a parent's false" plus the
mirror case. With the old order restored, 5 of these fail (for example "the
root's true outranks a parent's false": expected: true but was : false).

Review thread 4675254921 (Hal)

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

When the SQLite debugger refused a Quick Build start, QuickBuildTone.toTone()
mapped Hidden(lastStartFailed = true) to ERROR without reading startRefused.
The toolbar showed the error glyph (seen on a Note 20 on 2026-11-24), a
plugin's getQuickBuildStatus() returned ERROR, and QuickBuildRunTracker
returned Failed("Quick Build could not start.") with no reason.

A refused start now maps to QuickBuildTone.SLOW, and the tracker returns
QuickBuildResult.Refused(reason) with the refusal's own text
(quick_build_disabled_sqlite_debugger, the string the status line and Build
Output already use; PluginQuickBuildCoordinator passes it in, so no new
string). SLOW fits best of the existing tones: the hollow bolt reads as "still
the Quick Build button, but not ready and fast", and its tint is neutral.
READY would show the filled bolt in colorSuccess ("all good"), RECONNECTING the
sync glyph (work in progress), ERROR the fault.

Checked end to end: the plugin's startQuickBuild() now completes with
Refused(reason), the API's result for "Quick Build never started", and
getQuickBuildStatus() returns FULL_BUILD_NEXT for SLOW. That state's wording
("the next Quick Build is a full build") is not exact for a refusal, and the
toolbar's content description for SLOW says the same (cd_quick_build_slow);
both are left as they are, as separate tones would need new strings and an
API value. docs/PLUGIN_API_CHANGELOG.md records ABI additions and breaking
changes, and the refusal first appears in this PR (origin/stage has no
DisabledBySqliteDebugger), so there is no shipped behaviour to log.

Tests: QuickBuildToneTest, QuickBuildRunTrackerTest and
PluginQuickBuildCoordinatorTest (the status flows through track() to the
plugin's result). With the fix reverted, the three fail: "expected: SLOW but
was : ERROR", and "expected: Refused(reason=off while the SQLite debugger is
on) but was : Failed(reason=Quick Build could not start., output=the log)".

Review thread 4675254932 (Hal)

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

decide() failed the build for any call whose owner cannot be resolved and
whose name and descriptor match Context.deleteDatabase or
openOrCreateDatabase, whatever the opcode. Context is a class, so only
INVOKEVIRTUAL can reach one; a static call such as
INVOKESTATIC com/vendor/Store.deleteDatabase(Ljava/lang/String;)Z on a library
that is missing from the classpath failed an app build for nothing. The check
now requires INVOKEVIRTUAL, beside the existing INVOKESPECIAL branch for
super calls.

Checked: decide() has two callers. Method handles reach it with their tag
mapped to an opcode (H_INVOKEVIRTUAL to INVOKEVIRTUAL), so a virtual method
reference on an unresolvable owner still fails (read from the code, not run);
a static handle no longer does, as for a static call. INVOKEINTERFACE cannot
name a class, so it is out too.

Tests: SqliteRewriterTest, a static call on an unresolvable owner rewrites
without failing, and a virtual call on another unresolvable owner still fails.
With the fix reverted, the static case fails: SqliteRewriteException: ...
go()Z (line 4): com/vendor/Store.deleteDatabase is a Context database method
if com/vendor/Store is a Context, but ... cannot be resolved.

Review thread 4675254944 (Hal)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Failure: get_stats reads the table list with a limit of MAX_ROWS (1000) rows
and then said "The database has N tables" with N the length of that list, so a
database with 1200 tables was reported as having 1000.

Fix: when the list holds MAX_ROWS names the message says "at least 1000 tables"
(a list of exactly 1000 is still a correct lower bound); a shorter list keeps
the exact wording.

Test (DatabaseToolsTest.getStatsSaysAtLeastWhenTheTableListHitTheCap, with the
fake engine, whose query applies the same maxRows cut as the native one): 1005
tables give "at least 1000", 999 give "999 tables". With only the fix reverted
it fails: "The database has 1000 tables; counts are given only under 10."

CodeRabbit thread PRRT_kwDONcONtM66nRM6 (F09)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Failure: McpHttp never sent "HTTP/1.1 100 Continue". A client that sends
"Expect: 100-continue" with its POST waits for it before sending the body,
and so stalls until its own timeout (how long depends on the client;
unverified).

Fix: once the head has passed auth and every check that can refuse before the
body (Host, Origin, path, token, and in readBody the Transfer-Encoding,
Content-Length and size checks), and just before the body is read, the server
writes "HTTP/1.1 100 Continue" and flushes, when the request asks for it
(value compared case-insensitively). A request refused earlier gets only its
final response. HTTP/1.0 requests are ignored. A Content-Length of 0 gets no
interim reply. A refusal that comes after the body (415 in handle) is not
covered: it needs the body read first. RFC 9110 section 10.1.1 (read from rfc-editor.org): the value is
case-insensitive, a server must ignore the expectation in an HTTP/1.0 request,
and may omit the 100 when it has already received the body.

Tests (McpProtocolTest, raw socket): with "Expect: 100-Continue" the interim
line arrives before the body is sent, then the body gets 200; without Expect
there is no interim line; a wrong token (401) and a body over the limit (413)
send only their final reply. With only the fix reverted,
httpAnswers100ContinueBeforeTheBodyWhenAsked fails with
"java.net.SocketTimeoutException: Read timed out" (McpProtocolTest.kt:564,
the read of the interim line); the other three pass either way, as intended.

CodeRabbit thread PRRT_kwDONcONtM66nRNA (F11)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Failure: in readChunked, after the zero-size chunk the trailer loop did
`shortLine(...) ?: break`, so end of stream there counted as the end of the
body. A request cut off after "0\r\n" was handled as if complete, while the
chunk size line already answered 400 for the same cut.

Fix: end of stream in the trailer section throws HttpError(400, "The request
ended early."), as the size line does.

Test (McpProtocolTest.httpChunkedBodyThatEndsInTheTrailerSectionIsA400): a
valid initialize request sent as one chunk, then "0\r\n", then the output is
shut down; expects 400. With only the fix reverted it fails: the server
answers "HTTP/1.1 200 OK" with a session id (the message of the failed
assertTrue is that whole reply).

Checked the other readers: shortLine(input, 2) after a chunk and
readExactly already throw 400 on end of stream.

CodeRabbit thread PRRT_kwDONcONtM66nRNE (F13)

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

Problem: FakeDebugEngine.openServerConnection throws for a path no app
connection has open before it records anything, and openedServerConnections
holds only successes. So the assertions that the engine was never asked to
open a path (isEmpty / emptyList) passed whether or not the server asked.

Change: openAttempts counts every call, before any refusal. DatabaseToolsTest
asserts it is 0 at the six sites that claim the engine was not asked (the
unknown-path listing, the bad-argument tools, two "Unknown database" cases,
the in-memory empty path, the bad paging arguments); the old assertions stay.

Checked: the six sites are every assertTrue(isEmpty) / assertEquals(emptyList)
of openedServerConnections in the file; the other uses assert sizes after a
successful open. Test-only change, no production code. Not run with a mutant
that opens anyway: the counter is incremented on the first line of the method,
so any call to it is counted.

CodeRabbit thread PRRT_kwDONcONtM66nRNF (F14)

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

Problem: the test helper waited for Thread.State.BLOCKED in an unbounded
loop, awaited its `holding` latch without a limit, and counted `release` down
only on the success path with plain join(). A failure in between (the queued
call never blocking, or an assertion) left the slow worker parked on
`release` and the test hanging.

Change: holding.await and the BLOCKED loop give up after 10 s with an
assertion; release.countDown() and both joins (10 s each) are in a finally,
joining only threads that were started; afterwards both threads must not be
alive. Test-only, no production code.

Checked: the four callers of the helper pass unchanged in
the full run of 108 tests.

CodeRabbit thread PRRT_kwDONcONtM66nRNI (F15)

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

Problem: httpAcceptBacksOffAfterFailuresAndKeepsServing slept 1200 ms and then
read a synchronizedList's size and iterated it without its lock, so a slow
machine could see fewer attempts than the sleeps need (and the iteration is
not atomic with the list's writer, as the Collections.synchronizedList docs
require for iteration).

Change: the test polls (bounded at 10 s, every 10 ms) until the fifth attempt
is recorded, then copies the list under synchronized(attempts) and checks the
gaps of the copy: 100, 200, 400 and now also 800 ms of back-off (the fourth
gap). The check that a spinning loop did not run is now the attempt count of
the copy being five or six, and the gaps.

Checked: the test passes in the full run (108 tests). Not run under load to
see the old version fail: unverified.

CodeRabbit thread PRRT_kwDONcONtM66nRNK (F17)

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

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

Problem: test/jni/helper.c opened the "app" connection with GetStringUTFChars,
which is modified UTF-8 (a NUL as C0 80, a character outside the BMP as two
three-byte surrogates), while the server is opened with real UTF-8 bytes from
String.getBytes; and it ignored sqlite3_open's result, so a failed open
returned a handle to a failed connection and the test went on.

Change: Helper.open takes the path as UTF-8 bytes (Java side
getBytes(UTF_8), native openBytes), opens it as such, closes and returns 0 on
a failed sqlite3_open, and Helper.open throws when it gets 0.

Checked: test.sh passes, JNI part 205 checks, 0 failures. All three callers of
Helper.open use ASCII paths today, so no check changes outcome; no test of a
non-BMP path (whether the host's file names take one depends on the JVM's
sun.jnu.encoding: unverified).

CodeRabbit thread PRRT_kwDONcONtM66nRNP (F18)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Problem: in JniQueryTest the check of the "N parameter(s) but M argument(s)"
message sat in the catch block of a try around the query, so if the query
ran and returned (no exception) the test passed without checking anything.

Change: a check(false, ...) after the query call in the try, so a successful
query fails the test.

Checked: the test passes against the real library (JNI part: 205 checks, 0
failures), where the query is refused with SQLITE_RANGE. Not run against a
mutant that accepts the mismatch: unverified.

CodeRabbit thread PRRT_kwDONcONtM66nRNX (F20)

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

The README and the tool descriptions called the 1.5 s (database not in WAL
mode) and 50 s statement limits plain limits. They are checked by the
progress handler every 1000 SQLite VM instructions (sqlite3_progress_handler(db,
1000, ...) in sqlitedbg_jni.c), so not while a statement waits in the busy
handler (SQLITEDBG_SERVER_BUSY_MS, 3000) and not inside one long instruction:
a result can arrive up to about 3 s late; the client waits 60 s.

Also documented: the column names are read before the first sqlite3_step
(sqlitedbg_jni.c), so a schema change by the app between prepare and first step
can return the old column set; and turning off bound-value recording after
the idle time goes through expireIdleClient, which takes the tools' lock that
a running query holds for up to 50 s, so it can be up to 50 s late.

The README gets three bullets before its "Limits" bullet; every
existing value is kept. NON_WAL_NOTE, the text of every tool that runs SQL, now
says "best effort" and "up to about 3 s longer" after its unchanged first
words (DatabaseToolsTest still checks them). Checked in the code as quoted
above; the claim that the progress handler does not run during the busy wait
is from SQLite's documented behaviour (it runs in the VM), not from a test.

CodeRabbit threads PRRT_kwDONcONtM66nRMj (F01), PRRT_kwDONcONtM66nRMo (F02),
PRRT_kwDONcONtM66nRMw (F04), PRRT_kwDONcONtM66nRM2 (F07)

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

isSqliteDebuggerEnabled(String?) had no production caller: the provisioner
calls the multi-file overload. Its parsing is the same Properties lookup
(value exactly "true") that the multi-file overload already runs, so the
function is deleted rather than kept private, and the parsing test now goes
through the multi-file overload with a real gradle.properties file. The null
case (no file) is covered by "the root gradle properties file is read, a
missing one is not an opt-in".

Checked: grep finds no other caller in app/ or quickbuild/. No behaviour
change, so no revert proof.

Tests: QuickBuildProjectSupportTest.

Review thread 4675254948 (Hal)

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

replaceConfirmedUnlessRefused skips "Replace the installed app?" on the tap's
own refusal check, and the provisioner decides again moments later. If the
model or gradle.properties changes between the two (a sync, or an edit), the
provisioner may not refuse and the app is replaced without the question. The
PR description already lists this window; the KDoc now says so. Comment only,
no code change, no tests.

Review thread 4675254937 (Hal)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
SqliteRewritePlugin registers the transform in onVariants on the variant's
own instrumentation (InstrumentationScope.ALL) and never on
variant.androidTest, so an androidTest component's classes keep Android's
SQLite types. An instrumented test that calls app code with SQLite types in
its signatures can fail to link (NoSuchMethodError). Added under Known limits
in sqlite-rewrite.md. Checked by reading the registration; not run on a device,
and nothing in the repo exercises it. Docs only, no tests.

Review thread 4675254941 (Hal)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Base automatically changed from sqlite-debugger/ADFA-7135 to stage November 24, 2026 23:13
davidschachterADFA and others added 4 commits November 24, 2026 15:15
…gger/ADFA-7138

#2259's final head, the one squash-merged into stage as 122cc41: stage at
b5931b2 (5bf99a1) and the fixes for CodeRabbit's review of 2026-11-22
(c78cc27..ba78ebb). This prepares the merge of origin/stage that comes
next, in which #2259's lines are then the same on both sides.

No conflicts (strings.xml and the SQLite debugger's README merged on their
own). This PR's own diff is unchanged: the +/- lines of
`git diff ee7fa6f 0b4ebca` and `git diff ba78ebb HEAD` are identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Stage now holds #2259 squash-merged (122cc41), and GitHub moved this PR's
base to stage while its branch still carried #2259's original commits.

Four conflicts, each in lines that both #2259 and this PR change:
ARCHITECTURE.md and CLAUDE.md (the module lists), AndroidModuleConf.kt
(the modules without ABI flavors) and the SQLite debugger's README
(add/add). Stage's side of each is exactly #2259's version at ba78ebb,
merged in the commit before, so each is resolved to this PR's side.
Stage's tree equals ba78ebb's, so the merged tree equals the previous
commit's (662206a), and this PR's own diff is unchanged: the +/- lines
of `git diff ee7fa6f 0b4ebca` and `git diff origin/stage HEAD` are
identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Stage now holds #2260 (ADFA-7137, the endpoint store and pairing),
squash-merged as acca2c3. This is the first time this branch has
#2260's changes.

Two conflicts, both in subprojects/sqlite-debugger/README.md and both the
ones this PR's description lists, resolved as it says with #2261 not yet
merged:
- The component list, after the DebuggerStartup item: #2260's two items
  (EndpointBroadcast and the Code on the Go side), then this PR's "Gradle
  plugin wiring" item. #2261 adds its item when it lands.
- "Not done yet": #2260 and this PR each delete their own item; #2261's
  item and the sentence that introduces the list stay until #2261 lands.

No other file conflicted. This PR's own diff is unchanged: the +/- lines of
`git diff 122cc41 6cbe9c2` and `git diff origin/stage HEAD` are
identical, the README's included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Stage now holds #2261 (ADFA-7139, the plugin API for endpoints),
squash-merged as ade5cc2, after #2259 and #2260. This PR is the last
of the stack.

Two conflicts, both in subprojects/sqlite-debugger/README.md and both the
ones this PR's description lists, resolved as it says:
- The component list, after the DebuggerStartup item: #2260's two items
  and #2261's DebuggerEndpointService item, then this PR's "Gradle plugin
  wiring" item.
- "Not done yet": #2261's item and this PR's are dropped, and so is the
  sentence that introduced the list ("These are outside this module and
  come in the PRs stacked on it:"), since no stacked PR is left. The
  paragraph about device runs stays.

No other file conflicted. Outside the README, this PR's own diff is
unchanged: the +/- lines of `git diff acca2c3 8bd3e26` and
`git diff origin/stage HEAD` without the README are identical. In the
README, the only change to this PR's diff is the removed introducing
sentence.

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.

4 participants