Repository navigation
ADFA-514: Move nav items add help to file tree page, Implement help section icon to file tree - #24
Merged
Merged
Conversation
…ection icon to file tree
…ection icon to file tree
jatezzz
pushed a commit
that referenced
this pull request
Jun 22, 2026
…ection icon to file tree (#24) * ADFA-514: Move nav items add help to file tree page, Implement help section icon to file tree * ADFA-514: Move nav items add help to file tree page, Implement help section icon to file tree * ADFA-514: Implement contact Code on the Go popup from file tree * resolve merge conflict
davidschachterADFA
added a commit
that referenced
this pull request
Nov 13, 2026
Upstream released 1.4.2 with App Dev For All's stack, garbage collection and interrupted result set fixes (sqliteai/sqlite-js #22 to #24) and the maintainer's fix for issue #25, and the terminal package moves to it with no patches. The pages now say: - top: they describe 1.4.2 and later. - functions: js_version() gives 1.4.2; js_set_max_stack_size allows at most 1 MB when the stack has no limit (ulimit -s unlimited); "What changed in sqlite-js 1.4" lists 1.4.2's five differences from 1.4.1. - javascript: a db.exec result set lasts only until the call into JavaScript that created it returns, and reading it later throws "The result set was closed when the call into JavaScript that created it returned", with a tested example; Variables says a variable cannot keep a result set open. test_examples.py: 66 of 66 on a host build of plain 1.4.2 (28 examples, 19 run twice, 19 links). On 1.4.1 the js_version and kept result set examples fail, as they should. Probed on 1.4.2: the PRAGMA claims hold, an INSERT without next() still adds nothing, a result set read to its end still gives next() false, and under ulimit -s unlimited the stack error names 1048576. CLAIMS.md records each check; the window function crash fix rests on 1.4.2's code and changelog, since the saved reproducer did not crash the 1.4.1 host build either. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
davidschachterADFA
added a commit
that referenced
this pull request
Nov 13, 2026
Upstream released 1.4.2 with our stack, garbage-collection and result-set patches merged (sqliteai/sqlite-js #22, with two maintainer commits, #23 and #24) and with a fix for the use after free we reported (#25). That fix also changes behaviour: a db.exec result set no longer outlives the call into JavaScript that created it, and reading one afterwards throws "The result set was closed when the call into JavaScript that created it returned". So patches 0002 to 0009 go: - 0002 to 0005 and 0008 are upstream, by patch-id identical except for 0002, which has the maintainer's two commits on top. - 0006, 0007 (its second half) and 0009 only told interrupts apart for result sets kept across calls, which 1.4.2 no longer allows. 0001 (sqlitejs_cancel_all, issue 20) is rebased: the same changes, with new context in the struct. A new 0002 keeps what 0006 and the first half of 0007 did for a cancel on SQLite before 3.41: ending a cancelled call's result sets runs the finals of the window and aggregate functions they were computing, each a call that begins after the cancel, which before 3.41 nothing else stops; and those result sets read on as "interrupted". It is narrowed to a cancelled call, since in 1.4.2 result sets are also ended on every normal return. The next commit updates the tests for 1.4.2. vendor.sh --check passes on the 1.4.2 archive (SHA-256 1aa4c566...cf24). The libs/ and license files are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
davidschachterADFA
added a commit
that referenced
this pull request
Nov 17, 2026
* ADFA-7082: Vendor sqlite-js 1.3.7 with our patches 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Build the sqlite-js AAR for apps in subprojects:sqlite-js 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Release the sqlite-js AAR to sqlite-js-latest 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Build the sqlite-js AAR for arm64-v8a and armeabi-v7a only 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Run no stored code by default; test sqlite-js on pull requests 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Update sqlite-js-latest in place, out of latest-release selection 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Sort the QuickJS copyright lines the same on every machine 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Log stored functions that cannot be listed; guard the tag 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the reviewed sqlite-js patches 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Put back both the assets and the tag if a release update fails 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Find js_functions in any case; sync the cancel test; doc caveats 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a re-run repair a release left without its assets 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor sqlite-js main with our changes merged, one patch left 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the sqlite-js 1.4.1 release 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a connection open, and its stored functions load, during 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Patch two stack-bound crashes and two garbage cases 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a re-run replace a release left as a draft 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * style: spotless reformat, no functional change Spotless wraps the cancelAll() Javadoc paragraph, which the previous commits lengthened. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: End the result sets an interrupted call leaves open 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Make ending result sets safe when it runs JavaScript, and 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Stop what ending result sets runs; count the interrupts db.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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Answer the independent review of patches 0004 to 0007 - 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Test a direct interrupt during db.exec with a result set kept 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the sqlite-js 1.4.2 release Upstream released 1.4.2 with our stack, garbage-collection and result-set patches merged (sqliteai/sqlite-js #22, with two maintainer commits, #23 and #24) and with a fix for the use after free we reported (#25). That fix also changes behaviour: a db.exec result set no longer outlives the call into JavaScript that created it, and reading one afterwards throws "The result set was closed when the call into JavaScript that created it returned". So patches 0002 to 0009 go: - 0002 to 0005 and 0008 are upstream, by patch-id identical except for 0002, which has the maintainer's two commits on top. - 0006, 0007 (its second half) and 0009 only told interrupts apart for result sets kept across calls, which 1.4.2 no longer allows. 0001 (sqlitejs_cancel_all, issue 20) is rebased: the same changes, with new context in the struct. A new 0002 keeps what 0006 and the first half of 0007 did for a cancel on SQLite before 3.41: ending a cancelled call's result sets runs the finals of the window and aggregate functions they were computing, each a call that begins after the cancel, which before 3.41 nothing else stops; and those result sets read on as "interrupted". It is narrowed to a cancelled call, since in 1.4.2 result sets are also ended on every normal return. The next commit updates the tests for 1.4.2. vendor.sh --check passes on the 1.4.2 archive (SHA-256 1aa4c566...cf24). The libs/ and license files are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Test sqlite-js 1.4.2's result-set rule and patch 0002 glue_test.c, for 1.4.2: - The progress-handler case kept a result set across calls, which 1.4.2 no longer allows. It now checks, within one call, that a statement a progress handler stopped (as Android's cancelling does) leaves the call's other result set readable, on any SQLite, and that the connection runs SQL afterwards. - A direct sqlite3_interrupt() before SQLite 3.41 shows nowhere, so its kept result set reads as one that outlived its call; on 3.41 and later, as interrupted. - The cleanup that read a kept result set after its call is gone: it now throws. test.sh and the README name patch 0002 for the run as on SQLite 3.40, and the README lists the two patches, states the 1.4.2 rule, and says the 1.4.2 build has not been run on a phone yet. test.sh: upstream's suite 17 of 17 (its 16 and 0001's Cancel all), and glue_test 37 of 37 both normally and as on SQLite 3.40. Without patch 0002, the normal run still passes 37 of 37, and the 3.40 run fails as expected: the kept result set after a cancel reads "The result set was closed ..." rather than "interrupted", and the window function whose final never ends hangs until the 30 s alarm stops the test. Both ABIs build with NDK 29, and libsqlitejs.so exports only JNI_OnLoad and the three entry points. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Keep a call's cancel for the finals its result sets run From the independent review of 3a5cb53 and 464e6e7 (no critical, high or medium findings; F01 to F05 low or nits). Patch 0002 told a cancelled call apart only once, in js_leave(), and each final that ending its result sets ran entered JavaScript as a new call with a new cancel epoch. So, before SQLite 3.41: - a cancel that landed while the result sets were ended stopped only the final then running, and the next final that never ended hung the statement (F01); - a cancel that landed just before the call returned let the call succeed with its finals skipped, on any SQLite (F02). Patch 0002 now keeps the call's epoch while its result sets are ended (js_enter), so a cancel during the call or the ending stops every final, and a late cancel fails the statement with an interrupt. The ending_cancelled flag and its interrupt-handler check are gone; the patch is 8 lines. upstream/ is regenerated with vendor.sh. glue_test.c, 44 tests (was 37): - 31: a cancelled call that keeps two result sets whose window finals never end (F03's case); - 33-34: the cancel lands during the first final of a call that returned normally (F01); - 36-37: a cancel that lands as the call returns fails it (F02); - 43: after a progress handler's stop, the kept result set reads as outliving its call, not as interrupted (F04; it passes without the fix too, as a guard against counting such a stop as an interrupt). test.sh: upstream's suite 17 of 17; the glue test 44 of 44 normally and as on SQLite 3.40. With the previous 0002, test 37 fails in the normal run and the 3.40 run hangs at test 34; with 0001 alone, test 37 fails, and the 3.40 run fails test 29 and hangs at test 31. README: what 0002 does now, and what the glue test covers (F05). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Say what a late cancel does to a call's finals From the independent review of 5b9b062 (no code defects; tests catch what they're named for and are not flaky in 120 runs on 2 cores and 16 on 1; two low findings and a nit): - F01: "those result sets read on as interrupted" holds only when the cancel came before the call returned. js_leave() decides that once, before ending them, so a cancel that lands while they are ended stops their finals but leaves the "closed" message. - F02: a cancel stops each final at QuickJS's next interrupt check. A final that never ends is stopped and the statement fails, but a short final can still run to its end, so "rather than skipping its finals" overstated it. The patch 0002 header and README say so; 5b9b062's message overstated both in the same way. Patch 0002's code is unchanged. - F03: test 36's final records that it ran, and a new test 38 checks that the late cancel stopped it before it did; test 37 is renamed to say its final is a long one. test.sh: upstream's suite 17 of 17; the glue test 45 of 45 normally and as on SQLite 3.40. With 0001 alone, tests 37 and 38 fail (the final ran to its end) and the 3.40 run fails 29 and hangs at 31; with the previous 0002, test 37 fails and the 3.40 run hangs at 34. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Read result sets as interrupted when the cancel lands while they are ended From CodeRabbit's review of 5b5cd20 (4570522172), the same gap the independent review noted as F01: js_leave() decides once, before ending a call's result sets, whether they read on as "interrupted". A cancel that landed while their finals ran stopped the finals but left the "closed when the call ... returned" message. Patch 0002 now has js_end_rowsets() number its passes and mark each result set with the pass that ended it. After the loop, where nothing runs JavaScript and so no final can have freed a listed result set, it marks that pass's result sets interrupted if the cancel epoch has moved. The README and the patch header say the message is "interrupted" whether the cancel came before the call returned or during the ending. glue_test.c: new test 36 reads both result sets after the cancel that lands during the ending, and expects "interrupted". test.sh: upstream's suite 17 of 17; the glue test 46 of 46 normally and as on SQLite 3.40, and the same under AddressSanitizer and UBSan. With the previous 0002, test 36 fails in both runs with the "closed" message. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Address review of the sqlite-js cancel patches Patch 0002 (rebuilt from upstream PR sqliteai/sqlite-js#33) now: - drops the redundant cancelled term from js_leave: the block after the loop in js_end_rowsets marks a cancelled call's result sets interrupted; - says only JavaScript the extension runs while it initialises a connection is exempt from a cancel, not js_init_table's stored functions; - initialises a rowset's end_pass where it is created; - documents sqlitejs_cancel_all in sqlitejs.h. upstream/ is regenerated with vendor.sh. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the sqlite-js 1.4.3 release, with no patches Upstream merged sqliteai/sqlite-js#33, our patches 0001 (cancel) and 0002 (a cancelled call's finals and result sets) unmodified, and released them in 1.4.3 with one fix of the maintainer's: a cancel no longer stops a stored function's code while js_init_table(1) loads it, as it already spared the JavaScript that loads the extension. Before, a cancel in flight left the connection without that function. Only that call is exempt: JavaScript the code runs through SQL is still cancelled. - upstream/ is plain 1.4.3; patches/ is gone. vendor.sh and test.sh apply any patches/ there may be later (nullglob). - The glue still loads a stored function up to three times, for the case 1.4.3 still cancels. glue_test.c: new test 20 checks that a cancel during a function's own load code does not stop it (fails on 1.4.2 with the two patches); the w and h tests now cancel JavaScript that the load code runs through SQL (they fail with one try). - README, SqliteJs.cancelAll() javadoc: a cancel interrupts the connection, so any other statement in progress on it fails too, and it spares loading stored functions. The README now says the 1.4.2 build passed on the phone and the 1.4.3 build has not run on one yet. test.sh: upstream's suite 17 of 17; glue test 50 of 50 normally and as on SQLite 3.40, and the same under ASan, LeakSanitizer and UBSan. vendor.sh --check passes. NDK 29 builds for both ABIs: no warnings, the same four exports, version string 1.4.3. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * style: spotless rewrap of the cancelAll() javadoc, no functional change Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Answer the independent review of the 1.4.3 move No correctness defects; two nits: - F01: two glue-test comments still credited "patch 0002" for what sqlite-js 1.4.3 now does. - F02: the v test assumed cancel_calls was still 0; it now resets it, as the w and h tests do. Glue test 50 of 50 normally and as on SQLite 3.40. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Record the phone run of the 1.4.3 build On the Note20, with an AAR built from 0c2e603: the trial app passes 7 of 7 as a 64-bit and as a 32-bit process, on a new and an existing database, and the template (dev-assets #79) stops its runaway query 11 to 12 ms after Cancel in its 64-bit and 32-bit debug builds and its release build. The README said the 1.4.3 build had not run on a phone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Answer CodeRabbit's full review of the sqlite-js module - release-sqlite-js.yml: when the release is missing but its tag is left behind, move the tag to the commit being built before creating the release, since gh release create reuses an existing tag and ignores --target. - glue_test.c: a worker thread that cannot start stops the run (exit 2), as a database that cannot open does, instead of returning SQLITE_ERROR, which the cancel checks accepted as a pass. - test.sh: upstream's test main leaves its "Memory" (leak) check out of its exit code, so any FAILED line in its output fails the run too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Take only a 404 for a missing sqlite-js release or tag The release step took any failed lookup for a missing release, so a passing API error could move the live release's tag before gh release create failed, and a failed tag lookup skipped the move the last commit added. exists() now answers 1 only for HTTP 404 and stops the job on any other error. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
davidschachterADFA
added a commit
that referenced
this pull request
Nov 17, 2026
* ADFA-7083: Add sqlite-js documentation pages (draft) Four Help+Manual style pages for documentation.db, under i/ and linked from the Terminal page: an overview with install, load and safety, the sqlite-js function reference, how SQL and JavaScript values convert and what the engine supports, and a JavaScript introduction. pages/*.md is the source. build.py turns it into the JSON facts that helpmanual-topic.peb renders; apply.py adds the rows to a copy of documentation.db in one transaction, compressed against its dictionary, and appends a link to i/terminal-top.html. Run on a copy of the current database: 4 rows added, 1 changed, integrity_check ok, rerun is idempotent. test_examples.py runs every SQL example and checks links against the sqlite-js 1.3.7-1 host build: 32 of 32 pass. Not verified yet: the technical claims (see CLAIMS.md for each and how it was checked), the pages in the app, and the phone install steps. The table of contents and search index are Help+Manual output and do not list the new pages yet. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Record phone check results in CLAIMS.md Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Credit quickjs-ng (MIT) and name the license files Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Fix what the accuracy review found Probed the host build of sqlite-js 1.3.7-1 for each claim CLAIMS.md rested on code or nothing: - js_ functions are blocked only in views and triggers stored in a database; TEMP ones can use them. - A redefinition must come before js_init_table(1), and replaces the stored version. - A BigInt result outside 64 bits wraps around silently (new tested example); NaN becomes NULL. - js_set_memory_limit rejects negatives; js_set_max_stack_size reads non-numeric text as 0, which turns the check off. - An aggregate over no rows returns NULL without running init or final. - "One kind of number" now allows for BigInt; the opening no longer says JavaScript is quicker than Java or Kotlin. CLAIMS.md records each probe; db.exec running readfile/writefile is now shown by output. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Record apt install from the stage repo Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Document db.exec's deferred run and silent errors, and 1.3.7-2 - db.exec runs its statement only at next() or toArray(); a new tested example shows that an INSERT without next() adds nothing. - A run-time error (a failed UNIQUE constraint, an integer overflow) makes next() return false and toArray() return the rows before it, with no error; SQL errors are reported (F20, filed on ADFA-7081). - js_set_max_stack_size: as in sqlite-js 1.3.7-2 (patch 0007), sizes the stack cannot hold are errors that name the largest size; 0 still turns the check off. Seven fixes, not six. These pages now describe 1.3.7-2, so they should ship with it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Say db.exec errors are thrown (sqlite-js 1.3.7-3), eight fixes Patch 0008 (terminal-packages PR #6, sqlite-js 1.3.7-3) makes next() and toArray() throw when the statement fails. Before it, next() returned false and toArray() returned the rows before the error. The javascript page now says so, with a tested example that catches a failed UNIQUE insert. The example fails on a host build without 0008. The functions page lists the eighth fix. CLAIMS.md: test_examples.py passes 35 of 35 on a host build of 1.3.7-4. Phone results: 1.3.7-2 passed 87 of 87, which closes the js_set_max_stack_size TODO. 1.3.7-3 and 1.3.7-4 passed 91 of 91 on aarch64 and on arm, run as a 32-bit process. README: the pages document 1.3.7-3 and later. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Address the reviews of PR 2241 Independent review and CodeRabbit: - Examples with const, let or class run inside braces, so a reader can run them again in the same session without `redeclaration of`. The intro and the javascript page say why. - The redefinition steps no longer end in js_init_table(1) failing: it runs once per session and fails if a stored function already exists. - Aggregate and window functions cannot see js_eval variables (said). - Months count from 0; true shows as 1; the stack-size summary says 0 is accepted; `.shell echo $PREFIX/lib/sqlite-js` from the sqlite3 prompt; the upstream address shown once; the top page names the version the pages describe and how to check it. - apply.py refuses a database below version 2, stamps LastChange's content-i and wholedb rows instead of adding rows, and only when something changed, so a second run changes nothing. The Terminal page's link gets a heading of its own, since its other sections start collapsed. - test_examples.py also runs each example that creates nothing a second time, checks the parent, prev and next links, and prints the right output on failure. test_examples.py: 64 of 64 on a 1.3.7-4 host build. The second-run checks failed on the five examples before the braces; a misspelled next link fails. apply.py on copies of documentation.db 3.0.0: the second run leaves the file byte-identical; a database declaring 1.9.0 is refused unchanged. All pages render with Pebble 4.1.1 from the resulting database. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Compare only the output of the run under test CodeRabbit on PR 2241: the second-run check compared the end of the combined output, so a repeat that printed nothing passed on the first run's output. test_examples.py now prints a boundary just before the run under test, in both runs, and compares only what follows it. Checked: CodeRabbit's example (a query that prints 42 once and nothing when repeated) passes the old check and fails the new one; the pages pass 64 of 64 on a 1.3.7-4 host build. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Describe sqlite-js 1.3.7-p20261112, built from upstream main The terminal package is now built from upstream's main branch of 2026-11-12 (c8ae85a), which merged our fixes, instead of 1.3.7 with patches. The pages said it was "version 1.3.7 of the upstream project with eight fixes, which were also sent to the upstream project". - Functions page: the last section compares with 1.3.7 and says the code is upstream's of 12 November 2026, with fixes from App Dev For All; js_version notes that the newer package still reports 1.3.7; and js_set_memory_limit says a limit below memory that variables still hold leaves no room until raised. - Overview page: 1.3.7-p20261112 is named as a later version, and the credits line no longer says "some fixes". - CLAIMS.md: each changed claim and its check. README.md: the version. Checked on host builds of 1.3.7-p20261112 and 1.3.7-5: test_examples.py passes 64 of 64 on both; the lowered-limit sentence holds on both; js_version() gives 1.3.7; dpkg sorts 1.3.7-p20261112 after 1.3.7-3. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Give the version as dpkg shows it, 1.3.7-p20261112-0 termux-packages appends -0 to a version that contains a hyphen, so the published package, and `dpkg -s sqlite-js`, show 1.3.7-p20261112-0. Stage's Packages index lists that for aarch64 and arm (CI run 43183024875). The overview page, the js_version note, README.md and the two CLAIMS.md rows now give that version, with that evidence. test_examples.py: 64 of 64 on the host build. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Describe sqlite-js 1.4.1, the release with our fixes Upstream released 1.4.0 and 1.4.1 on 2026-11-12. Both contain c8ae85a, and their C code differs from it only in the version string, so the terminal package moves to 1.4.1 (terminal-packages #6). That answers both comments from the independent review: - Overview page, README.md and CLAIMS.md: the pages now describe 1.4.1 and later. "1.3.7-3 and later" was wrong: 1.3.7-3 to 1.3.7-5 lack the fix for a lowered memory limit (upstream ef06558). - Functions page: js_version() gives 1.4.1, so the note that a newer package still reports 1.3.7 is gone. The last section is now "What changed in sqlite-js 1.4" and says that 1.4.0 includes our fixes. - CLAIMS.md: the probes that cited older builds were run again on 1.4.1, with the same results: redefinition, js_init_table(1) twice, js_set_max_stack_size's inputs and recursion, the held-memory limit, db.exec errors and variable sharing. test_examples.py: 64 of 64 on a host build of 1.4.1. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Note that the examples pass with the package's two patches The terminal package is 1.4.1 with two patches (terminal-packages #6): the stack check and garbage collection. test_examples.py passes 64 of 64 on a host build with them, as on 1.4.1 without them, and no page claim changes. CLAIMS says so. The pages and the test database are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Say that a PRAGMA can take effect in db.exec itself CodeRabbit: db.exec prepares its statement at once, and a PRAGMA that changes a setting of the connection takes effect then, without next() or toArray(). Checked on 1.4.1 (sqlite3 3.46.1): busy_timeout, foreign_keys and cache_size take effect, user_version and application_id do not. The JavaScript page and CLAIMS say so. test_examples.py passes 64 of 64, and the test database is rebuilt. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Say that only some PRAGMAs take effect in db.exec CodeRabbit: "a PRAGMA that changes a setting of the connection" was too broad. journal_mode is such a setting, and takes effect only when the statement is stepped: with the C API on SQLite 3.49.1, PRAGMA journal_mode=OFF prepared but not stepped leaves the mode delete. The page now says that some PRAGMAs take effect already in db.exec, and that which ones do depends on the PRAGMA; CLAIMS has the probe. test_examples.py passes 64 of 64, and the test database is rebuilt. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Say that PRAGMA foreign_keys does nothing inside a transaction CodeRabbit: the page gives PRAGMA foreign_keys = ON as an example of a PRAGMA that takes effect in db.exec, and SQLite makes it a no-op inside a transaction or savepoint, with no error. Checked on 1.4.1 (sqlite3 3.46.1): through db.exec it stays 0 after BEGIN or SAVEPOINT, and becomes 1 outside a transaction. The page now says to set it before BEGIN or SAVEPOINT, as CodeRabbit suggested; CLAIMS has the probe. test_examples.py passes 64 of 64, and the test database is rebuilt. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Let apply.py add the link to the current documentation.db The phone test found that apply.py failed on the database a current build ships (wholedb 2026-11-02). It reads i/terminal-top.html as JSON, the template context of databases up to 2026-10-16, but every page there is now a finished Help+Manual page (HTML). Those databases also store i/jstopics/<page>.js (365 of them), which the help viewer loads to move between pages. So even a terminal-top.html with the link would not show it in the app. apply.py now: - adds the section to the HTML page at the end of its topic body (before the skin's hmpagebody_scroller end), keeping the BOM; - adds it to a stored i/jstopics/terminal-top.js too, at the end of its hmBody string, escaped as Help+Manual writes it; - leaves JSON databases as before: the result is byte-identical, and the app renders their jstopics files from the page; - finds an existing section by its anchor, id="sqlite-js", so a second run changes nothing in either form. The new pages stay template contexts, which the app renders with helpmanual-topic.peb (id 3607 there), and their jstopics files are rendered from them. Checked on a copy of the phone's database: both files get the section, the jstopics file evaluates in Node with it at the end of hmBody, and a second run changes nothing. In the app on the phone, the Terminal page shows the section and its link opens the pages. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Keep the pages whole at font scale 2.0 Read through in the app on a phone at font scale 1.0 and 2.0. At 2.0, three long addresses ran off the right edge, and part of each was cut off: github.com/sqliteai/sqlite-js on the top page, the Apache license URL in the reference's credits, and the MDN guide's URL on the basics page. They are reworded to name the project, the license and the site without the long addresses. The license texts are installed with the package, as the credits say. The result-set table on the JavaScript page broke the method names mid-word, at 1.0 too ("toArra" / "y()"). It is now a list, which keeps each name whole at both scales. test_examples.py passes 64 of 64. CLAIMS records the phone check and the apply.py run on the current database. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Require helpmanual-jstopic.peb before adding the pages CodeRabbit: the app renders the new pages' jstopics files, which the help viewer loads to move between pages, with helpmanual-jstopic.peb, and answers 404 without it. apply.py checked only helpmanual-topic.peb, so it would add pages to a database where moving to them fails. It now refuses such a database. Checked: a copy of the current database without the template is refused and left unchanged; the current and the 3.0.0 databases still take the pages, and a second run changes nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Describe sqlite-js 1.4.2 Upstream released 1.4.2 with App Dev For All's stack, garbage collection and interrupted result set fixes (sqliteai/sqlite-js #22 to #24) and the maintainer's fix for issue #25, and the terminal package moves to it with no patches. The pages now say: - top: they describe 1.4.2 and later. - functions: js_version() gives 1.4.2; js_set_max_stack_size allows at most 1 MB when the stack has no limit (ulimit -s unlimited); "What changed in sqlite-js 1.4" lists 1.4.2's five differences from 1.4.1. - javascript: a db.exec result set lasts only until the call into JavaScript that created it returns, and reading it later throws "The result set was closed when the call into JavaScript that created it returned", with a tested example; Variables says a variable cannot keep a result set open. test_examples.py: 66 of 66 on a host build of plain 1.4.2 (28 examples, 19 run twice, 19 links). On 1.4.1 the js_version and kept result set examples fail, as they should. Probed on 1.4.2: the PRAGMA claims hold, an INSERT without next() still adds nothing, a result set read to its end still gives next() false, and under ulimit -s unlimited the stack error names 1048576. CLAIMS.md records each check; the window function crash fix rests on 1.4.2's code and changelog, since the saved reproducer did not crash the 1.4.1 host build either. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Say how long a result set lasts in nested calls From the independent review of 139870b (one medium finding, the rest low), each checked on the 1.4.2 host build: - F01 (medium): a result set made by a function that SQL in another call's db.exec runs lasts until that outer call returns, not until the function returns. The Run SQL section says so, and the Variables bullet and "What changed" item say "the outermost call". - F02: what still reports no more rows is a result set whose next() returned false, or whose toArray() ran. One whose rows were all read but whose next() never returned false throws in a later call. - F03: after Ctrl-C a kept result set throws "interrupted", not the "closed" message. - F04 to F06: CLAIMS.md records the window-function crash as reproduced (1.4.1 segfaults within 60 turns of the reviewer's probe; 1.4.2 passes), the 1.4.2 source and probes in its legend, and the 1.4.2 version check; README.md says 1.4.2 and later. test_examples.py: 66 of 66 on 1.4.2; on 1.4.1 the same 4 fail as before, as they should. build.py builds the pages. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Record the 1.4.2-1 package in CLAIMS.md The package is now 1.4.2-1: revision 1 ships its new tests and README. dpkg sorts 1.4.2-1 above 1.4.2, so the pages' "1.4.2 and later" still holds; on the phone, dpkg-query reports 1.4.2-1 after installing from stage. No page changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Document result sets that end after an error or a full read A result set read to its end still reports no more rows in a later call. A result set whose next() or toArray() threw also reports no more rows (next() false, toArray() []) with no error, so catch errors where they happen. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Record the 1.4.2-2 package in CLAIMS.md terminal-packages #6 revision 2 (the review's test fixes) is on stage, and the phone reports 1.4.2-2 after the upgrade from 1.4.2-1. The pages say 1.4.2 and later, so they are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Record the 1.4.2-3 package in CLAIMS.md Revision 3 of the sqlite-js terminal package carries the independent review's test fixes; its library is unchanged. Stage's 1.4.2-3 installs on the phone and reports that version. The package reaches main through terminal-packages #7, since #6 merged into an already-merged base. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7083: Record the production sqlite-js package in CLAIMS.md The terminal package is now in production (terminal-packages run 44014027669), byte-identical to stage's. Row 9 no longer says production gets it later: it records the install from production as the Steps to QA write it, with every scenario passing. Row 10 adds the production 1.4.2-3 and notes that #7 brought the package to main. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
davidschachterADFA
added a commit
that referenced
this pull request
Nov 24, 2026
…bug builds (#2259) * ADFA-7082: Vendor sqlite-js 1.3.7 with our patches 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Build the sqlite-js AAR for apps in subprojects:sqlite-js 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Release the sqlite-js AAR to sqlite-js-latest 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Build the sqlite-js AAR for arm64-v8a and armeabi-v7a only 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Run no stored code by default; test sqlite-js on pull requests 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Update sqlite-js-latest in place, out of latest-release selection 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Sort the QuickJS copyright lines the same on every machine 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Log stored functions that cannot be listed; guard the tag 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the reviewed sqlite-js patches 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Put back both the assets and the tag if a release update fails 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Find js_functions in any case; sync the cancel test; doc caveats 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a re-run repair a release left without its assets 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor sqlite-js main with our changes merged, one patch left 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the sqlite-js 1.4.1 release 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a connection open, and its stored functions load, during 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Patch two stack-bound crashes and two garbage cases 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a re-run replace a release left as a draft 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * style: spotless reformat, no functional change Spotless wraps the cancelAll() Javadoc paragraph, which the previous commits lengthened. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: End the result sets an interrupted call leaves open 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Make ending result sets safe when it runs JavaScript, and 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Stop what ending result sets runs; count the interrupts db.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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Answer the independent review of patches 0004 to 0007 - 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Test a direct interrupt during db.exec with a result set kept 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7135: Define the interface between the SQLite debugger extension 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: Copy the MCP server from ShareYourApps, renamed 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Add the sqlite-debugger module skeleton 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: MCP server with the eight read-only database tools 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 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Implement the SQLite debugger extension and its host tests 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Add the JNI layer and NativeDebugEngine 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * style: spotless reformat of the SQLite debugger module, no functional change Co-Authored-By: Claude Haiku 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Fix three review findings in the extension - read_events moves the cursor past dropped events when it copies nothing, so a drop is reported once. - An internal failure in sqlitedbg_extension_init is logged and the connection left untracked; the app's own sqlite3_open no longer fails because of it. - A trigger is told apart from app SQL by X differing from sqlite3_sql(P), not by a "--" prefix, so statements that start with a comment are expanded. test.sh builds the extension with SQLITEDBG_TEST for the failure hook. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: Document the SQLite debugger module Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: List sqlite-debugger among the modules without ABI flavors AndroidModuleConf.kt already excludes it; ARCHITECTURE.md and CLAUDE.md named only plugin-api and sqlite-js. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Never let the debugger crash or miss the host app's early connections - DebuggerStartup catches Throwable after the debuggable check, so a missing requery library (UnsatisfiedLinkError) disables the debugger instead of killing the app. The check itself still throws. - install() runs synchronously in onCreate; only the server start is on the thread, so connections opened in Application.onCreate are tracked. - McpHttp: connection and accept threads catch Throwable; an Error while handling a request is answered with a 500. - McpHttp: a failed accept sleeps 100 ms, doubling to 2 s while failures continue, and resets on success (no spin on EMFILE). Tests: an Error thrown by a tool gives HTTP 500 and the server keeps serving; a ServerSocket whose accept fails is retried with growing gaps, then serves. DebuggerStartup imports android.* and has no JVM test. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Keep read-only server connections from holding locks The read-only authorizer allowed BEGIN, SAVEPOINT and PRAGMA locking_mode, so a client could hold a lock on the app's database: BEGIN; SELECT left the app's INSERT failing with SQLITE_BUSY until ROLLBACK. - sqlitedbg.c: deny SQLITE_TRANSACTION, SQLITE_SAVEPOINT, PRAGMA locking_mode and PRAGMA busy_timeout (any form) on read-only server connections. - sqlitedbg_jni.c: bridge_query rolls back if the connection is not in autocommit when it returns (covers writable connections). - Host C test: each denied statement returns SQLITE_AUTH and the app can still write after a read on that connection. Without the authorizer change the test fails on all 8 statements (BEGIN and SAVEPOINT: "database is locked" for the app's INSERT). The backstop is tested with the JNI test. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Bound query results and report truncation per cell - M4: QueryLimits.maxTotalBytes (DatabaseTools passes 4 MiB). bridge_query counts the TEXT/BLOB bytes kept and 8 per number, and stops with hasMore before the row that would pass the budget; the first row always goes in so a page makes progress. The tool result text is serialised compact: it was sent twice, pretty and as structuredContent. - L11: the engine reports cut cells (QueryResult.truncatedCellIndexes, row * columns + column) instead of DatabaseTools guessing from size >= limit, so a BLOB of exactly maxBlobBytes is no longer flagged. - L12: get_schema and get_stats read sqlite_master (sqlite_schema needs 3.33). - L13: sqlite3_column_text/blob returning NULL (out of memory) is checked. JVM tests: blob at the limit vs one byte over, the budget pages a result of 3 MiB rows, sqlite_master in the SQL sent, compact result text. Each fails with its fix reverted. The native side (budget, cut cells) is tested by the JNI test in a later commit; L13 has no test (needs an allocation failure). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Drop stale server connections and stop expanding SQL when idle - M7: DatabaseTools cached a server connection per path forever, so after the app deleted and recreated its database the server read the old file. Each cached connection remembers the ids of the app connections to its path when it opened. Before each tool call it is closed and dropped when no live app connection has the path, or none of those ids is left. - L14: the first get_events turned on bound-value expansion until the server stopped, so every app statement was expanded twice forever. It now goes off 60 s after the last get_events call, checked on every tool call and by a daemon timer; the tool description says so. - L10 (one lock for all tool calls) is documented in the class KDoc. Tests: recreated database reopens (opened 2, closed 1), a connection survives while a seen app connection remains, a vanished path closes the cached one, and expansion stops after 60 s. Each fails with its fix reverted (expected 2 but was 1; expected 1 but was 0; "60 s after the last get_events"). Limit accepted: a database replaced in place while the same app connections stay open is not detected. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Test the JNI query path test.sh now also builds the JNI layer as it ships (libsqlitedbg.so without SQLITE_CORE, with the version script) against a requery-like libsqlite3x.so (amalgamation, THREADSAFE=2, all symbols exported) and runs src/test/jni/JniQueryTest.java on the host JVM through NativeBridge. It is skipped with a message when no JDK is on PATH. It uses Java stubs of NativeBridge and DebugEngineException (same names and native signatures) rather than compiling the Kotlin, so only a JDK is needed; test.sh fails if the native names in NativeBridge.kt and the stub differ. A change of a Kotlin parameter type alone is not caught. Covers: value types, paging and hasMore, the total-bytes budget (including "first row always goes in" and the budget stopping on a row boundary), per-cell truncation at, over and under the limit with row * columns + column indexes and a budget-dropped row's cells, bound types, the deadline giving SQLITE_INTERRUPT, refused writes giving SQLITE_AUTH, BEGIN/SAVEPOINT/PRAGMA refusals leaving the app able to write, and the rollback backstop. Checked to fail with each native fix reverted: budget (50 rows vs 4), cut cell indexes ([] vs [1, 3]), rollback backstop (app INSERT 5 vs 0, SQLITE_BUSY), authorizer (BEGIN: 0 vs 23), dropped row's cut cells ([0, 1] vs [0]). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Document the JNI test and the requery trace limit README: the JNI test and how it stands in for the Kotlin, and that requery's own sqlite3_trace (log.tag.SQLiteStatements or SQLiteTime VERBOSE) replaces ours on a connection, so its events stop. No code change for that. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7082: Vendor the sqlite-js 1.4.2 release Upstream released 1.4.2 with our stack, garbage-collection and result-set patches merged (sqliteai/sqlite-js #22, with two maintainer commits, #23 and #24) and with a fix for the use after free we reported (#25). That fix also changes behaviour: a db.exec result set no longer outlives the call into JavaScript that created it, and reading one afterwards throws "The result set was closed when the call into JavaScript that created it returned". So patches 0002 to 0009 go: - 0002 to 0005 and 0008 are upstream, by patch-id identical except for 0002, which has the maintainer's two commits on top. - 0006, 0007 (its second half) and 0009 only told interrupts apart for result sets kept across calls, which 1.4.2 no longer allows. 0001 (sqlitejs_cancel_all, issue 20) is rebased: the same changes, with new context in the struct. A new 0002 keeps what 0006 and the first half of 0007 did for a cancel on SQLite before 3.41: ending a cancelled call's result sets runs the finals of the window and aggregate functions they were computing, each a call that begins after the cancel, which before 3.41 nothing else stops; and those result sets read on as "interrupted". It is narrowed to a cancelled call, since in 1.4.2 result sets are also ended on every normal return. The next commit updates the tests for 1.4.2. vendor.sh --check passes on the 1.4.2 archive (SHA-256 1aa4c566...cf24). The libs/ and license files are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Test sqlite-js 1.4.2's result-set rule and patch 0002 glue_test.c, for 1.4.2: - The progress-handler case kept a result set across calls, which 1.4.2 no longer allows. It now checks, within one call, that a statement a progress handler stopped (as Android's cancelling does) leaves the call's other result set readable, on any SQLite, and that the connection runs SQL afterwards. - A direct sqlite3_interrupt() before SQLite 3.41 shows nowhere, so its kept result set reads as one that outlived its call; on 3.41 and later, as interrupted. - The cleanup that read a kept result set after its call is gone: it now throws. test.sh and the README name patch 0002 for the run as on SQLite 3.40, and the README lists the two patches, states the 1.4.2 rule, and says the 1.4.2 build has not been run on a phone yet. test.sh: upstream's suite 17 of 17 (its 16 and 0001's Cancel all), and glue_test 37 of 37 both normally and as on SQLite 3.40. Without patch 0002, the normal run still passes 37 of 37, and the 3.40 run fails as expected: the kept result set after a cancel reads "The result set was closed ..." rather than "interrupted", and the window function whose final never ends hangs until the 30 s alarm stops the test. Both ABIs build with NDK 29, and libsqlitejs.so exports only JNI_OnLoad and the three entry points. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Keep a call's cancel for the finals its result sets run From the independent review of 3a5cb5356 and 464e6e7ef (no critical, high or medium findings; F01 to F05 low or nits). Patch 0002 told a cancelled call apart only once, in js_leave(), and each final that ending its result sets ran entered JavaScript as a new call with a new cancel epoch. So, before SQLite 3.41: - a cancel that landed while the result sets were ended stopped only the final then running, and the next final that never ended hung the statement (F01); - a cancel that landed just before the call returned let the call succeed with its finals skipped, on any SQLite (F02). Patch 0002 now keeps the call's epoch while its result sets are ended (js_enter), so a cancel during the call or the ending stops every final, and a late cancel fails the statement with an interrupt. The ending_cancelled flag and its interrupt-handler check are gone; the patch is 8 lines. upstream/ is regenerated with vendor.sh. glue_test.c, 44 tests (was 37): - 31: a cancelled call that keeps two result sets whose window finals never end (F03's case); - 33-34: the cancel lands during the first final of a call that returned normally (F01); - 36-37: a cancel that lands as the call returns fails it (F02); - 43: after a progress handler's stop, the kept result set reads as outliving its call, not as interrupted (F04; it passes without the fix too, as a guard against counting such a stop as an interrupt). test.sh: upstream's suite 17 of 17; the glue test 44 of 44 normally and as on SQLite 3.40. With the previous 0002, test 37 fails in the normal run and the 3.40 run hangs at test 34; with 0001 alone, test 37 fails, and the 3.40 run fails test 29 and hangs at test 31. README: what 0002 does now, and what the glue test covers (F05). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Say what a late cancel does to a call's finals From the independent review of 5b9b062eb (no code defects; tests catch what they're named for and are not flaky in 120 runs on 2 cores and 16 on 1; two low findings and a nit): - F01: "those result sets read on as interrupted" holds only when the cancel came before the call returned. js_leave() decides that once, before ending them, so a cancel that lands while they are ended stops their finals but leaves the "closed" message. - F02: a cancel stops each final at QuickJS's next interrupt check. A final that never ends is stopped and the statement fails, but a short final can still run to its end, so "rather than skipping its finals" overstated it. The patch 0002 header and README say so; 5b9b062eb's message overstated both in the same way. Patch 0002's code is unchanged. - F03: test 36's final records that it ran, and a new test 38 checks that the late cancel stopped it before it did; test 37 is renamed to say its final is a long one. test.sh: upstream's suite 17 of 17; the glue test 45 of 45 normally and as on SQLite 3.40. With 0001 alone, tests 37 and 38 fail (the final ran to its end) and the 3.40 run fails 29 and hangs at 31; with the previous 0002, test 37 fails and the 3.40 run hangs at 34. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7135 Set the Kotlin JVM target on the compile tasks The root build sets jvmTarget 17 on every KotlinCompile task, which overrides the module's kotlin { compilerOptions } and made compileDebugKotlin fail against compileOptions' Java 1.8 ("Inconsistent JVM-target compatibility"). Setting it on the tasks keeps 1.8, as sqlite-js uses. First compile of the Android-only files (NativeDebugEngine.kt, DebuggerStartup.kt, sqlitedbg_jni.c, the manifest): with this change :subprojects:sqlite-debugger:assembleDebug builds both ABIs, the C compiles without warnings under -Wall -Wextra, libsqlitedbg.so exports only JNI_OnLoad, and testDebugUnitTest passes 56 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ADFA-7082: Read result sets as interrupted when the cancel lands while they are ended From CodeRabbit's review of 5b5cd201c (4570522172), the same gap the independent review noted as F01: js_leave() decides once, before ending a call's result sets, whether they read on as "interrupted". A cancel that landed while their finals ran stopped the finals but left the "closed when the call ... returned" message. Patch 0002 now has js_end_rowsets() number its passes and mark each result set with the pass that ended it. After the loop, where nothing runs JavaScript and so no final can have freed a listed result set, it marks that pass's result sets interrupted if the cancel epoch has moved. The README and the patch header say the message is "interrupted" whether the cancel came before the call returned or during the ending. glue_test.c: new test 36 reads both result sets after the cancel that lands during the ending, and expects "interrupted". test.sh: upstream's suite 17 of 17; the glue test 46 of 46 normally and as on SQLite 3.40, and the same under AddressSanitizer and UBSan. With the previous 0002, test 36 fails in both runs with the "closed" message. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Address review of the sqlite-js cancel patches Patch 0002 (rebuilt from upstream PR sqliteai/sqlite-js#33) now: - drops the redundant cancelled term from js_leave: the block after the loop in js_end_rowsets marks a cancelled call's result sets interrupted; - says only JavaScript the extension runs while it initialises a connection is exempt from a cancel, not js_init_table's stored functions; - initialises a rowset's end_pass where it is created; - documents sqlitejs_cancel_all in sqlitejs.h. upstream/ is regenerated with vendor.sh. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7136 Bound the request head and refuse before reading the body; say the server is read-only A local app could hold all 8 connection slots without authenticating: the 30 s timeout applied per read and the token was checked after the whole request. The head now has an overall deadline (5 s), and Host, Origin, path and token are checked before the body. The initialize instructions no longer mention a read-write mode that does not exist. Tests: sockets that send nothing or trickle bytes are closed within the deadline and the real client is then served; an unauthenticated request with an unsent body gets 401; the instructions do not mention read-write. All three fail with the fix reverted. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Refuse the process-wide heap limit and temp directory PRAGMAs on server connections SQLite applies hard_heap_limit, soft_heap_limit and temp_store_directory to the whole process, so a client's PRAGMA hard_heap_limit=1 could make the app's own connections fail with SQLITE_NOMEM. Test: each form (set and read) returns SQLITE_AUTH on a server connection; without the change all five return SQLITE_OK. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Give server connections a 3 s busy timeout With the app's database in rollback-journal mode, a server read failed at once with SQLITE_BUSY while the app held a write lock, exactly when the agent wants to look. The timeout is set in C and PRAGMA busy_timeout stays refused, so the client cannot change it. Test: an app connection holds BEGIN EXCLUSIVE; a server read waits about 500 ms and succeeds once it is released, and reports SQLITE_BUSY after about 3 s if it is not. Without the timeout the first read failed after 0 ms with SQLITE_BUSY. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Fail a query whose argument count differs from its parameter count Too few arguments left the missing parameters unbound, which SQLite reads as NULL, so the query ran and returned a plausible empty result. It now throws SQLITE_RANGE with a message naming both counts. Test (JniQueryTest, the real JNI query path on a host JVM, run by test.sh): zero args for one parameter and one for two give SQLITE_RANGE; the first expectation was NULL before, and both fail with the check disabled. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 List an open database once when the databases folder is reached through a link list_databases matched the files of the app's databases folder against connection paths as strings, so on a phone (/data/user/0/<pkg> against /data/data/<pkg>) every open database was listed again as available: false. Both sides are now canonicalised before matching; paths are reported as the connections gave them. Test: a folder listed through a symlink, and the reverse, list the open database once. Without the canonicalisation it was listed twice. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Run the sqlite-debugger host tests in CI test.sh (the extension's C tests under ASan/UBSan and TSan, and the JNI query test) ran in no workflow. The new workflow follows test-sqlite-js.yml and also triggers on the vendored SQLite headers test.sh compares against. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7082: Vendor the sqlite-js 1.4.3 release, with no patches Upstream merged sqliteai/sqlite-js#33, our patches 0001 (cancel) and 0002 (a cancelled call's finals and result sets) unmodified, and released them in 1.4.3 with one fix of the maintainer's: a cancel no longer stops a stored function's code while js_init_table(1) loads it, as it already spared the JavaScript that loads the extension. Before, a cancel in flight left the connection without that function. Only that call is exempt: JavaScript the code runs through SQL is still cancelled. - upstream/ is plain 1.4.3; patches/ is gone. vendor.sh and test.sh apply any patches/ there may be later (nullglob). - The glue still loads a stored function up to three times, for the case 1.4.3 still cancels. glue_test.c: new test 20 checks that a cancel during a function's own load code does not stop it (fails on 1.4.2 with the two patches); the w and h tests now cancel JavaScript that the load code runs through SQL (they fail with one try). - README, SqliteJs.cancelAll() javadoc: a cancel interrupts the connection, so any other statement in progress on it fails too, and it spares loading stored functions. The README now says the 1.4.2 build passed on the phone and the 1.4.3 build has not run on one yet. test.sh: upstream's suite 17 of 17; glue test 50 of 50 normally and as on SQLite 3.40, and the same under ASan, LeakSanitizer and UBSan. vendor.sh --check passes. NDK 29 builds for both ABIs: no warnings, the same four exports, version string 1.4.3. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * style: spotless rewrap of the cancelAll() javadoc, no functional change Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Answer the independent review of the 1.4.3 move No correctness defects; two nits: - F01: two glue-test comments still credited "patch 0002" for what sqlite-js 1.4.3 now does. - F02: the v test assumed cancel_calls was still 0; it now resets it, as the w and h tests do. Glue test 50 of 50 normally and as on SQLite 3.40. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Record the phone run of the 1.4.3 build On the Note20, with an AAR built from 0c2e603ee: the trial app passes 7 of 7 as a 64-bit and as a 32-bit process, on a new and an existing database, and the template (dev-assets #79) stops its runaway query 11 to 12 ms after Cancel in its 64-bit and 32-bit debug builds and its release build. The README said the 1.4.3 build had not run on a phone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7135: Correct two README lines the CI and device work made false "No workflow runs either yet" has been false since the test-sqlite-debugger workflow: it runs test.sh, the C and JNI tests. The JVM tests are still in no workflow, which the line now says. "Nothing has run in an app on a device" has been false since the device runs recorded on ADFA-7135. What is left is a device run of the current code, because those results predate the review fixes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Refuse SQL that holds more than one statement bridge_query prepared with no tail pointer, so SQLite compiled only the first statement: query with "SELECT 1; SELECT 2" ran the first, dropped the second and reported success, and explain_query_plan (which prefixes the client's SQL) did the same. A lone comment returned an empty result, and anything after a NUL character was dropped too, since SQLite reads no further. prepare_one now prepares the tail as well. Whitespace, comments and semicolons prepare to no statement and are accepted; anything else, including a tail that fails to prepare (the server's authorizer refuses a trailing write at prepare time), fails the call with SQLITE_ERROR, "the SQL holds more than one statement; run one statement per call". SQL with no statement, or with a NUL, fails with its own message. Every tool reaches SQLite through bridge_query, so this covers query and explain_query_plan; the other tools send fixed SQL, and get_stats builds its COUNT(*) from quoted table names, not client input. Preparing the tail is not running it: the only effects are those a PRAGMA can have at prepare time, under the same authorizer a client already meets by sending that statement alone. Test (JniQueryTest, the real JNI path on a host JVM, run by test.sh): two statements, a statement after a comment, a trailing DELETE, a trailing syntax error and EXPLAIN QUERY PLAN with a second statement give the more-than-one message; a lone comment, a lone semicolon and a NUL give theirs; trailing semicolons, whitespace, comments, an open comment and a leading comment still run. With the fix reverted the 8 refusal checks fail, each "null vs 1 the SQL holds ...": the call ran. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Say when a query ran out of time waiting for another tool call A query's 50 s deadline is set before runChecked waits for the tools' lock, so a call queued behind a slow one could fail with "the time limit passed before the query started" or "the query ran past its time limit", and the agent would read that as its own query being too slow. The deadline still starts before the wait (decided in review, so it bounds the wait for an answer once set); only the error changes. runChecked times its wait for the lock, and when the time ran out (SQLITE_INTERRUPT) after that wait took at least half of what the call had left, the message adds "(this call waited N s of its 50 s for another tool call to finish; tool calls run one at a time, so retry it)". Not counted: get_stats sets its deadline before its path check, which also takes the lock, so a wait there is not attributed. A tool call's first wait, in the idle check, comes before any deadline is set. Test (DatabaseToolsTest, fake clock): a second call takes the lock just after the query set its deadline, as a third concurrent call can, and holds it while the fake clock moves. A wait of 50.001 s and of 30 s each get the note; a 10 s wait followed by the query's own timeout does not. Without the fix the first two fail: expected "...started (this call waited 50.001 s of its 50 s ...)" but was "...started", and "the query ran past its time limit" with no note. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Start a tool call's time limit when the call begins The 50 s limit was meant to make the server give up before the client (60 s), so a timed-out call never leaves a query holding the lock after the client has stopped waiting. It did not: every call first waited for the lock in the idle check, and run() set its deadline only after that and the path check, so a call queued behind a slow one could run a full 50 s after the wait. Each tool call now gets a Call when it begins: its deadline (DEADLINE_MS, unchanged) and the time it has spent waiting for the lock. Every lock taken inside the call (idle check, path check, each query, get_stats included) goes through Call.locked, which adds the wait. The note from ff0bd0c6b now uses that total: when the time runs out after waits of at least half the limit, the error says the call waited N s for another tool call and should be retried. Test (DatabaseToolsTest, fake clock): a call starts while another holds the lock and waits for it in the idle check. After a 50.001 s wait a query fails with "the time limit passed before the query started (this call waited 50.001 s ...)"; after 30 s a query that then times out gets the note; get_stats after a 50 s wait fails the same way; a 10 s wait gets no note. Against ff0bd0c6b three fail: the 50.001 s query and get_stats succeed (AssertionError: {"isError":false,...}), and the 30 s case reads "the query ran past its time limit" with no note. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Let the query backstop's ROLLBACK past the server's authorizer After every query bridge_query ran ROLLBACK when the connection was not in autocommit, as a backstop for a transaction left open. On a read-only server connection, the kind every tool uses, the authorizer denies SQLITE_TRANSACTION, and SQLite authorizes ROLLBACK as that action: the ROLLBACK failed with "not authorized", its result was ignored, and the transaction and its lock on the app's database stayed. Nothing a client sends opens one today (BEGIN and SAVEPOINT are refused), so the backstop only mattered for a hole in the authorizer, and there it did nothing. sqlitedbg_end_transaction (sqlitedbg.h) now does the rollback. It sets a thread-local flag around its own sqlite3_exec("ROLLBACK"), and the authorizer lets SQLITE_TRANSACTION through only when that flag is set and the statement is ROLLBACK. A client's BEGIN, COMMIT, END and ROLLBACK are still refused, also while a transaction is open, and SAVEPOINT (with ROLLBACK TO) is untouched. bridge_query checks the result: a rollback that fails becomes the call's error, "a transaction was left open and rolling it back failed: <errmsg>", with ROLLBACK's code. If the query had already failed, that error is kept instead. The connection stays cached either way, so each later query tries the rollback again. Tests: - C (sqlitedbg_test.c, test_server_ends_transaction): a read-only server connection is put into a transaction holding a read lock by clearing the authorizer, running BEGIN and a SELECT, and putting the real authorizer back (a SQLITEDBG_TEST hook exposes it). The app's write gets SQLITE_BUSY. The client's ROLLBACK, COMMIT and BEGIN still get SQLITE_AUTH. sqlitedbg_end_transaction returns SQLITE_OK, the connection is back in autocommit, and the app can write. Afterwards the client's BEGIN and ROLLBACK are still refused. test_server_holds_no_locks also checks that COMMIT, END and ROLLBACK are refused. With the authorizer change reverted it fails with "sqlitedbg_end_transaction(srv) == SQLITE_OK (23 vs 0)", then autocommit stays 0 and the app's write is "database is locked". - JNI (JniQueryTest): a writable server connection holding BEGIN IMMEDIATE, with an authorizer that refuses ROLLBACK, fails the next query with "23 a transaction was left open and rolling it back failed: not authorized" while the app stays locked out. Once that authorizer is cleared, the next query rolls the transaction back and the app can write. With the old unchecked ROLLBACK restored it fails with "the failed rollback is reported: null vs 23 ...": the query returned as if nothing were wrong. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Say when get_schema cut a CREATE statement get_schema reads sqlite_master with a 64 KiB text limit but reported only truncated: result.hasMore, which means more rows exist. A view or trigger whose SQL is longer than 64 KiB came back as a prefix with truncated false, and an agent would read it as the full definition. Each entry now has truncated, true when a value in its row was cut. The result also has truncated_cells, the count of cut values, named as query names it. The top-level truncated is true when anything was cut or rows past the first 1000 were left out. The tool description gives the 64 KiB limit and the three fields. The limit is now a constant, MAX_SCHEMA_SQL_BYTES. The README's Limits paragraph says it too. Other tools checked: query already reports truncated_cells and has_more. explain_query_plan and integrity_check use the 4 KiB text limit and report neither, and were left alone: a plan line or an integrity message near 4 KiB, or more than 1000 of them, is not a realistic case, and integrity_check's ok compares against "ok", which a cut value cannot equal. get_stats reads only numbers and table names. Tests (DatabaseToolsTest with FakeDebugEngine): getSchemaSaysWhichCreateStatementWasCut gives get_schema a result whose view SQL is listed as cut. The top-level truncated is true, truncated_cells is 1, the view entry has truncated true, and the table entry has truncated false. getSchemaIsTruncatedPastMaxRowsEntries checks that 1001 entries still give truncated true with truncated_cells 0. getSchemaGroupsByType checks false and 0 when nothing is cut. With the reporting reverted the first fails with "a cut CREATE statement makes the result truncated", and the other two fail on the missing truncated_cells. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Say that functions the app adds to its own connections are missing Every tool runs on a server connection the SQLite debugger opens itself, never on an app connection, and SQLite registers functions per connection. So what the app adds to its own connections (requery's SQLiteCustomFunction and SQLiteCustomExtension, sqlite-js and its stored JavaScript functions) does not exist there: SELECT median(price) fails with "no such function: median" through query, and through explain_query_plan or a view, although the app's own queries run it. The query and explain_query_plan descriptions now say so, so the agent reads the rows or computes in plain SQL instead, and the README states the limit and why. No behaviour change. A test pins the phrase in both descriptions. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Name both limits that can leave get_schema entries out get_schema's description gave "past the first 1000 entries" as the only reason for the top-level truncated, but the 4 MiB result budget ends the result too, after about 64 CREATE statements of 64 KiB. The agent then saw truncated true with no entry cut, and get_schema has no offset. The description now names both limits and sends the agent to page through sqlite_master with query, reading a statement longer than query's 4096-byte TEXT limit in parts with substr. The README says the same. No behaviour change. The description test pins both causes and the way out; a new test shows the budget ends a get_schema result of 64 KiB statements with truncated true and truncated_cells 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Say that a full integrity_check fails on the app's index functions A full integrity_check evaluates the functions an index uses and fails with "unknown function" when the app added one to its own connections; quick_check does not. integrity_check's description and the README say so and name quick_check as the alternative. The description test pins the phrase. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Give get_schema's paging advice an ORDER BY and the right unit The advice to page through sqlite_master gave no ORDER BY, so pages could overlap or skip rows; it now says ORDER BY name. substr counts characters while the TEXT limit counts bytes, which the description and README now say. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Say which app functions make quick_check and integrity_check fail A CHECK constraint or a NOT NULL virtual generated column that calls an app function makes quick_check fail too; an index on an expression or a partial index whose WHERE calls one fails only the full integrity_check (verified with SQLite 3.46). Views, triggers and other generated columns fail neither. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Advise ORDER BY type, name to page through sqlite_master get_schema sorts by type, name, and a trigger can share a table's name, so ORDER BY name alone skips or repeats entries when paging with an offset. (type, name) is unique in sqlite_master. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Register consumer-rules.pro so an app's R8 keeps NativeBridge The file existed but no consumerProguardFiles line named it, so proguard.txt was missing from the AAR and an app's minified build could rename or strip the JNI-registered NativeBridge functions and the DebugEngineException constructor the native code calls. The rules cover every class sqlitedbg_jni.c looks up by name. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Refuse a server connection to a path the app no longer has open checkedPath and runChecked read separate connection snapshots, so a cache miss could open a server connection after the app closed its last connection to that path. Re-check against the snapshot taken under the lock and answer with the same unknown database error. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Bound a JSON-RPC batch by message count and reply size A batch kept every reply, each up to about 8 MiB, with no limit, all in the host app's heap. Refuse a batch of more than 32 messages whole (400, invalid request), and once a batch's replies reach …
davidschachterADFA
added a commit
that referenced
this pull request
Nov 25, 2026
… app (#2260) * ADFA-7082: Vendor sqlite-js 1.3.7 with our patches 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Build the sqlite-js AAR for apps in subprojects:sqlite-js 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Release the sqlite-js AAR to sqlite-js-latest 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Build the sqlite-js AAR for arm64-v8a and armeabi-v7a only 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Run no stored code by default; test sqlite-js on pull requests 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Update sqlite-js-latest in place, out of latest-release selection 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Sort the QuickJS copyright lines the same on every machine 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Log stored functions that cannot be listed; guard the tag 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the reviewed sqlite-js patches 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Put back both the assets and the tag if a release update fails 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Find js_functions in any case; sync the cancel test; doc caveats 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a re-run repair a release left without its assets 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor sqlite-js main with our changes merged, one patch left 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the sqlite-js 1.4.1 release 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a connection open, and its stored functions load, during 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Patch two stack-bound crashes and two garbage cases 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a re-run replace a release left as a draft 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * style: spotless reformat, no functional change Spotless wraps the cancelAll() Javadoc paragraph, which the previous commits lengthened. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: End the result sets an interrupted call leaves open 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Make ending result sets safe when it runs JavaScript, and 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Stop what ending result sets runs; count the interrupts db.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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Answer the independent review of patches 0004 to 0007 - 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Test a direct interrupt during db.exec with a result set kept 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7135: Define the interface between the SQLite debugger extension 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: Copy the MCP server from ShareYourApps, renamed 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Add the sqlite-debugger module skeleton 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: MCP server with the eight read-only database tools 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 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Implement the SQLite debugger extension and its host tests 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Add the JNI layer and NativeDebugEngine 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * style: spotless reformat of the SQLite debugger module, no functional change Co-Authored-By: Claude Haiku 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Fix three review findings in the extension - read_events moves the cursor past dropped events when it copies nothing, so a drop is reported once. - An internal failure in sqlitedbg_extension_init is logged and the connection left untracked; the app's own sqlite3_open no longer fails because of it. - A trigger is told apart from app SQL by X differing from sqlite3_sql(P), not by a "--" prefix, so statements that start with a comment are expanded. test.sh builds the extension with SQLITEDBG_TEST for the failure hook. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: Document the SQLite debugger module Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: List sqlite-debugger among the modules without ABI flavors AndroidModuleConf.kt already excludes it; ARCHITECTURE.md and CLAUDE.md named only plugin-api and sqlite-js. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Never let the debugger crash or miss the host app's early connections - DebuggerStartup catches Throwable after the debuggable check, so a missing requery library (UnsatisfiedLinkError) disables the debugger instead of killing the app. The check itself still throws. - install() runs synchronously in onCreate; only the server start is on the thread, so connections opened in Application.onCreate are tracked. - McpHttp: connection and accept threads catch Throwable; an Error while handling a request is answered with a 500. - McpHttp: a failed accept sleeps 100 ms, doubling to 2 s while failures continue, and resets on success (no spin on EMFILE). Tests: an Error thrown by a tool gives HTTP 500 and the server keeps serving; a ServerSocket whose accept fails is retried with growing gaps, then serves. DebuggerStartup imports android.* and has no JVM test. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Keep read-only server connections from holding locks The read-only authorizer allowed BEGIN, SAVEPOINT and PRAGMA locking_mode, so a client could hold a lock on the app's database: BEGIN; SELECT left the app's INSERT failing with SQLITE_BUSY until ROLLBACK. - sqlitedbg.c: deny SQLITE_TRANSACTION, SQLITE_SAVEPOINT, PRAGMA locking_mode and PRAGMA busy_timeout (any form) on read-only server connections. - sqlitedbg_jni.c: bridge_query rolls back if the connection is not in autocommit when it returns (covers writable connections). - Host C test: each denied statement returns SQLITE_AUTH and the app can still write after a read on that connection. Without the authorizer change the test fails on all 8 statements (BEGIN and SAVEPOINT: "database is locked" for the app's INSERT). The backstop is tested with the JNI test. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Bound query results and report truncation per cell - M4: QueryLimits.maxTotalBytes (DatabaseTools passes 4 MiB). bridge_query counts the TEXT/BLOB bytes kept and 8 per number, and stops with hasMore before the row that would pass the budget; the first row always goes in so a page makes progress. The tool result text is serialised compact: it was sent twice, pretty and as structuredContent. - L11: the engine reports cut cells (QueryResult.truncatedCellIndexes, row * columns + column) instead of DatabaseTools guessing from size >= limit, so a BLOB of exactly maxBlobBytes is no longer flagged. - L12: get_schema and get_stats read sqlite_master (sqlite_schema needs 3.33). - L13: sqlite3_column_text/blob returning NULL (out of memory) is checked. JVM tests: blob at the limit vs one byte over, the budget pages a result of 3 MiB rows, sqlite_master in the SQL sent, compact result text. Each fails with its fix reverted. The native side (budget, cut cells) is tested by the JNI test in a later commit; L13 has no test (needs an allocation failure). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Drop stale server connections and stop expanding SQL when idle - M7: DatabaseTools cached a server connection per path forever, so after the app deleted and recreated its database the server read the old file. Each cached connection remembers the ids of the app connections to its path when it opened. Before each tool call it is closed and dropped when no live app connection has the path, or none of those ids is left. - L14: the first get_events turned on bound-value expansion until the server stopped, so every app statement was expanded twice forever. It now goes off 60 s after the last get_events call, checked on every tool call and by a daemon timer; the tool description says so. - L10 (one lock for all tool calls) is documented in the class KDoc. Tests: recreated database reopens (opened 2, closed 1), a connection survives while a seen app connection remains, a vanished path closes the cached one, and expansion stops after 60 s. Each fails with its fix reverted (expected 2 but was 1; expected 1 but was 0; "60 s after the last get_events"). Limit accepted: a database replaced in place while the same app connections stay open is not detected. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Test the JNI query path test.sh now also builds the JNI layer as it ships (libsqlitedbg.so without SQLITE_CORE, with the version script) against a requery-like libsqlite3x.so (amalgamation, THREADSAFE=2, all symbols exported) and runs src/test/jni/JniQueryTest.java on the host JVM through NativeBridge. It is skipped with a message when no JDK is on PATH. It uses Java stubs of NativeBridge and DebugEngineException (same names and native signatures) rather than compiling the Kotlin, so only a JDK is needed; test.sh fails if the native names in NativeBridge.kt and the stub differ. A change of a Kotlin parameter type alone is not caught. Covers: value types, paging and hasMore, the total-bytes budget (including "first row always goes in" and the budget stopping on a row boundary), per-cell truncation at, over and under the limit with row * columns + column indexes and a budget-dropped row's cells, bound types, the deadline giving SQLITE_INTERRUPT, refused writes giving SQLITE_AUTH, BEGIN/SAVEPOINT/PRAGMA refusals leaving the app able to write, and the rollback backstop. Checked to fail with each native fix reverted: budget (50 rows vs 4), cut cell indexes ([] vs [1, 3]), rollback backstop (app INSERT 5 vs 0, SQLITE_BUSY), authorizer (BEGIN: 0 vs 23), dropped row's cut cells ([0, 1] vs [0]). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Document the JNI test and the requery trace limit README: the JNI test and how it stands in for the Kotlin, and that requery's own sqlite3_trace (log.tag.SQLiteStatements or SQLiteTime VERBOSE) replaces ours on a connection, so its events stop. No code change for that. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7082: Vendor the sqlite-js 1.4.2 release Upstream released 1.4.2 with our stack, garbage-collection and result-set patches merged (sqliteai/sqlite-js #22, with two maintainer commits, #23 and #24) and with a fix for the use after free we reported (#25). That fix also changes behaviour: a db.exec result set no longer outlives the call into JavaScript that created it, and reading one afterwards throws "The result set was closed when the call into JavaScript that created it returned". So patches 0002 to 0009 go: - 0002 to 0005 and 0008 are upstream, by patch-id identical except for 0002, which has the maintainer's two commits on top. - 0006, 0007 (its second half) and 0009 only told interrupts apart for result sets kept across calls, which 1.4.2 no longer allows. 0001 (sqlitejs_cancel_all, issue 20) is rebased: the same changes, with new context in the struct. A new 0002 keeps what 0006 and the first half of 0007 did for a cancel on SQLite before 3.41: ending a cancelled call's result sets runs the finals of the window and aggregate functions they were computing, each a call that begins after the cancel, which before 3.41 nothing else stops; and those result sets read on as "interrupted". It is narrowed to a cancelled call, since in 1.4.2 result sets are also ended on every normal return. The next commit updates the tests for 1.4.2. vendor.sh --check passes on the 1.4.2 archive (SHA-256 1aa4c566...cf24). The libs/ and license files are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Test sqlite-js 1.4.2's result-set rule and patch 0002 glue_test.c, for 1.4.2: - The progress-handler case kept a result set across calls, which 1.4.2 no longer allows. It now checks, within one call, that a statement a progress handler stopped (as Android's cancelling does) leaves the call's other result set readable, on any SQLite, and that the connection runs SQL afterwards. - A direct sqlite3_interrupt() before SQLite 3.41 shows nowhere, so its kept result set reads as one that outlived its call; on 3.41 and later, as interrupted. - The cleanup that read a kept result set after its call is gone: it now throws. test.sh and the README name patch 0002 for the run as on SQLite 3.40, and the README lists the two patches, states the 1.4.2 rule, and says the 1.4.2 build has not been run on a phone yet. test.sh: upstream's suite 17 of 17 (its 16 and 0001's Cancel all), and glue_test 37 of 37 both normally and as on SQLite 3.40. Without patch 0002, the normal run still passes 37 of 37, and the 3.40 run fails as expected: the kept result set after a cancel reads "The result set was closed ..." rather than "interrupted", and the window function whose final never ends hangs until the 30 s alarm stops the test. Both ABIs build with NDK 29, and libsqlitejs.so exports only JNI_OnLoad and the three entry points. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Keep a call's cancel for the finals its result sets run From the independent review of 3a5cb5356 and 464e6e7ef (no critical, high or medium findings; F01 to F05 low or nits). Patch 0002 told a cancelled call apart only once, in js_leave(), and each final that ending its result sets ran entered JavaScript as a new call with a new cancel epoch. So, before SQLite 3.41: - a cancel that landed while the result sets were ended stopped only the final then running, and the next final that never ended hung the statement (F01); - a cancel that landed just before the call returned let the call succeed with its finals skipped, on any SQLite (F02). Patch 0002 now keeps the call's epoch while its result sets are ended (js_enter), so a cancel during the call or the ending stops every final, and a late cancel fails the statement with an interrupt. The ending_cancelled flag and its interrupt-handler check are gone; the patch is 8 lines. upstream/ is regenerated with vendor.sh. glue_test.c, 44 tests (was 37): - 31: a cancelled call that keeps two result sets whose window finals never end (F03's case); - 33-34: the cancel lands during the first final of a call that returned normally (F01); - 36-37: a cancel that lands as the call returns fails it (F02); - 43: after a progress handler's stop, the kept result set reads as outliving its call, not as interrupted (F04; it passes without the fix too, as a guard against counting such a stop as an interrupt). test.sh: upstream's suite 17 of 17; the glue test 44 of 44 normally and as on SQLite 3.40. With the previous 0002, test 37 fails in the normal run and the 3.40 run hangs at test 34; with 0001 alone, test 37 fails, and the 3.40 run fails test 29 and hangs at test 31. README: what 0002 does now, and what the glue test covers (F05). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Say what a late cancel does to a call's finals From the independent review of 5b9b062eb (no code defects; tests catch what they're named for and are not flaky in 120 runs on 2 cores and 16 on 1; two low findings and a nit): - F01: "those result sets read on as interrupted" holds only when the cancel came before the call returned. js_leave() decides that once, before ending them, so a cancel that lands while they are ended stops their finals but leaves the "closed" message. - F02: a cancel stops each final at QuickJS's next interrupt check. A final that never ends is stopped and the statement fails, but a short final can still run to its end, so "rather than skipping its finals" overstated it. The patch 0002 header and README say so; 5b9b062eb's message overstated both in the same way. Patch 0002's code is unchanged. - F03: test 36's final records that it ran, and a new test 38 checks that the late cancel stopped it before it did; test 37 is renamed to say its final is a long one. test.sh: upstream's suite 17 of 17; the glue test 45 of 45 normally and as on SQLite 3.40. With 0001 alone, tests 37 and 38 fail (the final ran to its end) and the 3.40 run fails 29 and hangs at 31; with the previous 0002, test 37 fails and the 3.40 run hangs at 34. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7135 Set the Kotlin JVM target on the compile tasks The root build sets jvmTarget 17 on every KotlinCompile task, which overrides the module's kotlin { compilerOptions } and made compileDebugKotlin fail against compileOptions' Java 1.8 ("Inconsistent JVM-target compatibility"). Setting it on the tasks keeps 1.8, as sqlite-js uses. First compile of the Android-only files (NativeDebugEngine.kt, DebuggerStartup.kt, sqlitedbg_jni.c, the manifest): with this change :subprojects:sqlite-debugger:assembleDebug builds both ABIs, the C compiles without warnings under -Wall -Wextra, libsqlitedbg.so exports only JNI_OnLoad, and testDebugUnitTest passes 56 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ADFA-7082: Read result sets as interrupted when the cancel lands while they are ended From CodeRabbit's review of 5b5cd201c (4570522172), the same gap the independent review noted as F01: js_leave() decides once, before ending a call's result sets, whether they read on as "interrupted". A cancel that landed while their finals ran stopped the finals but left the "closed when the call ... returned" message. Patch 0002 now has js_end_rowsets() number its passes and mark each result set with the pass that ended it. After the loop, where nothing runs JavaScript and so no final can have freed a listed result set, it marks that pass's result sets interrupted if the cancel epoch has moved. The README and the patch header say the message is "interrupted" whether the cancel came before the call returned or during the ending. glue_test.c: new test 36 reads both result sets after the cancel that lands during the ending, and expects "interrupted". test.sh: upstream's suite 17 of 17; the glue test 46 of 46 normally and as on SQLite 3.40, and the same under AddressSanitizer and UBSan. With the previous 0002, test 36 fails in both runs with the "closed" message. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Address review of the sqlite-js cancel patches Patch 0002 (rebuilt from upstream PR sqliteai/sqlite-js#33) now: - drops the redundant cancelled term from js_leave: the block after the loop in js_end_rowsets marks a cancelled call's result sets interrupted; - says only JavaScript the extension runs while it initialises a connection is exempt from a cancel, not js_init_table's stored functions; - initialises a rowset's end_pass where it is created; - documents sqlitejs_cancel_all in sqlitejs.h. upstream/ is regenerated with vendor.sh. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7136 Bound the request head and refuse before reading the body; say the server is read-only A local app could hold all 8 connection slots without authenticating: the 30 s timeout applied per read and the token was checked after the whole request. The head now has an overall deadline (5 s), and Host, Origin, path and token are checked before the body. The initialize instructions no longer mention a read-write mode that does not exist. Tests: sockets that send nothing or trickle bytes are closed within the deadline and the real client is then served; an unauthenticated request with an unsent body gets 401; the instructions do not mention read-write. All three fail with the fix reverted. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Refuse the process-wide heap limit and temp directory PRAGMAs on server connections SQLite applies hard_heap_limit, soft_heap_limit and temp_store_directory to the whole process, so a client's PRAGMA hard_heap_limit=1 could make the app's own connections fail with SQLITE_NOMEM. Test: each form (set and read) returns SQLITE_AUTH on a server connection; without the change all five return SQLITE_OK. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Give server connections a 3 s busy timeout With the app's database in rollback-journal mode, a server read failed at once with SQLITE_BUSY while the app held a write lock, exactly when the agent wants to look. The timeout is set in C and PRAGMA busy_timeout stays refused, so the client cannot change it. Test: an app connection holds BEGIN EXCLUSIVE; a server read waits about 500 ms and succeeds once it is released, and reports SQLITE_BUSY after about 3 s if it is not. Without the timeout the first read failed after 0 ms with SQLITE_BUSY. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Fail a query whose argument count differs from its parameter count Too few arguments left the missing parameters unbound, which SQLite reads as NULL, so the query ran and returned a plausible empty result. It now throws SQLITE_RANGE with a message naming both counts. Test (JniQueryTest, the real JNI query path on a host JVM, run by test.sh): zero args for one parameter and one for two give SQLITE_RANGE; the first expectation was NULL before, and both fail with the check disabled. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 List an open database once when the databases folder is reached through a link list_databases matched the files of the app's databases folder against connection paths as strings, so on a phone (/data/user/0/<pkg> against /data/data/<pkg>) every open database was listed again as available: false. Both sides are now canonicalised before matching; paths are reported as the connections gave them. Test: a folder listed through a symlink, and the reverse, list the open database once. Without the canonicalisation it was listed twice. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Run the sqlite-debugger host tests in CI test.sh (the extension's C tests under ASan/UBSan and TSan, and the JNI query test) ran in no workflow. The new workflow follows test-sqlite-js.yml and also triggers on the vendored SQLite headers test.sh compares against. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Add debugger_endpoint_table and migration 5 to 6 The SQLite debugger in an app built by Code on the Go reports a token and a port; Code on the Go needs to keep them per app and per project. debugger_endpoint_table (RecentProjectRoomDatabase version 6) is keyed by application_id and holds project_location, token, port and updated_at. project_location is a foreign key to recent_project_table.location with ON DELETE CASCADE, so removing a project removes its endpoints, and ON UPDATE CASCADE, so renaming a project (which rewrites location) does not fail once an endpoint row exists. Room enables PRAGMA foreign_keys itself once the schema declares a foreign key, so no extra code is needed. The pairing upsert is INSERT OR IGNORE plus UPDATE in one transaction: minSdk 28 ships SQLite 3.22, which predates UPSERT (3.24). Tests: migration 5 to 6 on a v5 file opened through Room (projects kept, schema validated, cascade works on the migrated file); delete and rename cascades. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * style: spotless reformat, no functional change LaunchAppAction.kt was indented with spaces; the next commit edits it, which pulls the whole file under the Spotless ratchet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Pair apps with projects and receive their debugger endpoint Code on the Go must know which project an app belongs to before it accepts that app's debugger token and port, otherwise any app could register an endpoint. - A project-started install records (application ID, project) once the install succeeds. An existing pairing moves to the new project and its stale token and port are cleared. LaunchAppAction only adds a pairing when the app has none, and waits for it before launching. The Activity is not captured in the pairing lambda. - DebuggerEndpointReceiver (exported, action com.itsaky.androidide.SQLITE_DEBUGGER_ENDPOINT) stores the endpoint off the main thread. The token must be 1-128 URL-safe base64 characters and the port 1-65535. A broadcast from an unpaired app stores nothing. A database failure is logged, never thrown. - Sender identity: the app attaches an immutable PendingIntent, and the receiver trusts only its creatorPackage, which the framework sets and another app cannot forge, on every API level. A forged broadcast could otherwise point the AI Agent at another app's debugger server. Tests: DAO and repository (pairing rules, failures reported as false, move and clear on re-pairing); the receiver delivered through the framework under Robolectric (stored, unpaired app ignored, no PendingIntent ignored, malformed extras ignored); validation of token and port. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Send the debugger endpoint to Code on the Go once the server listens The library broadcasts its token and port on every process start, after the server listens, so a relaunched app (new port) updates its row. - The broadcast carries an immutable PendingIntent, so Code on the Go can identify the sender from its creatorPackage on every API level. - FLAG_INCLUDE_STOPPED_PACKAGES and FLAG_RECEIVER_FOREGROUND deliver it to Code on the Go when that is not running (cold start). - The library manifest declares <queries> for Code on the Go so the package is visible on API 30+. Code on the Go's receiver is declared in the app manifest, in the previous commit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Docs: describe the debugger endpoint and database version 6 The sqlite-debugger README describes the endpoint broadcast; ARCHITECTURE.md and the Room ADR name Recent Projects database version 6. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Clear pending installs on failure and pin the endpoint broadcast contract A failed or cancelled install left its pendingInstalls entry behind, so a later install of the same applicationId from an APK file was paired with the wrong project. The editor now tells the repository when an install ends without a launch, and entries older than five minutes are ignored as a backstop. Tests: a discarded note is not used, an expired note is not used, a recent note still pairs (the first two fail with the discard and the expiry removed). The broadcast extra names are consts in the library, and EndpointBroadcastTest (Robolectric) checks the sent action, package, extras and creatorPackage. The library is not on :app's classpath, so DebuggerEndpointContractTest in :app pins the same literals; each test names the other. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7082: Vendor the sqlite-js 1.4.3 release, with no patches Upstream merged sqliteai/sqlite-js#33, our patches 0001 (cancel) and 0002 (a cancelled call's finals and result sets) unmodified, and released them in 1.4.3 with one fix of the maintainer's: a cancel no longer stops a stored function's code while js_init_table(1) loads it, as it already spared the JavaScript that loads the extension. Before, a cancel in flight left the connection without that function. Only that call is exempt: JavaScript the code runs through SQL is still cancelled. - upstream/ is plain 1.4.3; patches/ is gone. vendor.sh and test.sh apply any patches/ there may be later (nullglob). - The glue still loads a stored function up to three times, for the case 1.4.3 still cancels. glue_test.c: new test 20 checks that a cancel during a function's own load code does not stop it (fails on 1.4.2 with the two patches); the w and h tests now cancel JavaScript that the load code runs through SQL (they fail with one try). - README, SqliteJs.cancelAll() javadoc: a cancel interrupts the connection, so any other statement in progress on it fails too, and it spares loading stored functions. The README now says the 1.4.2 build passed on the phone and the 1.4.3 build has not run on one yet. test.sh: upstream's suite 17 of 17; glue test 50 of 50 normally and as on SQLite 3.40, and the same under ASan, LeakSanitizer and UBSan. vendor.sh --check passes. NDK 29 builds for both ABIs: no warnings, the same four exports, version string 1.4.3. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * style: spotless rewrap of the cancelAll() javadoc, no functional change Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Answer the independent review of the 1.4.3 move No correctness defects; two nits: - F01: two glue-test comments still credited "patch 0002" for what sqlite-js 1.4.3 now does. - F02: the v test assumed cancel_calls was still 0; it now resets it, as the w and h tests do. Glue test 50 of 50 normally and as on SQLite 3.40. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Record the phone run of the 1.4.3 build On the Note20, with an AAR built from 0c2e603ee: the trial app passes 7 of 7 as a 64-bit and as a 32-bit process, on a new and an existing database, and the template (dev-assets #79) stops its runaway query 11 to 12 ms after Cancel in its 64-bit and 32-bit debug builds and its release build. The README said the 1.4.3 build had not run on a phone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7135: Correct two README lines the CI and device work made false "No workflow runs either yet" has been false since the test-sqlite-debugger workflow: it runs test.sh, the C and JNI tests. The JVM tests are still in no workflow, which the line now says. "Nothing has run in an app on a device" has been false since the device runs recorded on ADFA-7135. What is left is a device run of the current code, because those results predate the review fixes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Refuse SQL that holds more than one statement bridge_query prepared with no tail pointer, so SQLite compiled only the first statement: query with "SELECT 1; SELECT 2" ran the first, dropped the second and reported success, and explain_query_plan (which prefixes the client's SQL) did the same. A lone comment returned an empty result, and anything after a NUL character was dropped too, since SQLite reads no further. prepare_one now prepares the tail as well. Whitespace, comments and semicolons prepare to no statement and are accepted; anything else, including a tail that fails to prepare (the server's authorizer refuses a trailing write at prepare time), fails the call with SQLITE_ERROR, "the SQL holds more than one statement; run one statement per call". SQL with no statement, or with a NUL, fails with its own message. Every tool reaches SQLite through bridge_query, so this covers query and explain_query_plan; the other tools send fixed SQL, and get_stats builds its COUNT(*) from quoted table names, not client input. Preparing the tail is not running it: the only effects are those a PRAGMA can have at prepare time, under the same authorizer a client already meets by sending that statement alone. Test (JniQueryTest, the real JNI path on a host JVM, run by test.sh): two statements, a statement after a comment, a trailing DELETE, a trailing syntax error and EXPLAIN QUERY PLAN with a second statement give the more-than-one message; a lone comment, a lone semicolon and a NUL give theirs; trailing semicolons, whitespace, comments, an open comment and a leading comment still run. With the fix reverted the 8 refusal checks fail, each "null vs 1 the SQL holds ...": the call ran. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Say when a query ran out of time waiting for another tool call A query's 50 s deadline is set before runChecked waits for the tools' lock, so a call queued behind a slow one could fail with "the time limit passed before the query started" or "the query ran past its time limit", and the agent would read that as its own query being too slow. The deadline still starts before the wait (decided in review, so it bounds the wait for an answer once set); only the error changes. runChecked times its wait for the lock, and when the time ran out (SQLITE_INTERRUPT) after that wait took at least half of what the call had left, the message adds "(this call waited N s of its 50 s for another tool call to finish; tool calls run one at a time, so retry it)". Not counted: get_stats sets its deadline before its path check, which also takes the lock, so a wait there is not attributed. A tool call's first wait, in the idle check, comes before any deadline is set. Test (DatabaseToolsTest, fake clock): a second call takes the lock just after the query set its deadline, as a third concurrent call can, and holds it while the fake clock moves. A wait of 50.001 s and of 30 s each get the note; a 10 s wait followed by the query's own timeout does not. Without the fix the first two fail: expected "...started (this call waited 50.001 s of its 50 s ...)" but was "...started", and "the query ran past its time limit" with no note. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Start a tool call's time limit when the call begins The 50 s limit was meant to make the server give up before the client (60 s), so a timed-out call never leaves a query holding the lock after the client has stopped waiting. It did not: every call first waited for the lock in the idle check, and run() set its deadline only after that and the path check, so a call queued behind a slow one could run a full 50 s after the wait. Each tool call now gets a Call when it begins: its deadline (DEADLINE_MS, unchanged) and the time it has spent waiting for the lock. Every lock taken inside the call (idle check, path check, each query, get_stats included) goes through Call.locked, which adds the wait. The note from ff0bd0c6b now uses that total: when the time runs out after waits of at least half the limit, the error says the call waited N s for another tool call and should be retried. Test (DatabaseToolsTest, fake clock): a call starts while another holds the lock and waits for it in the idle check. After a 50.001 s wait a query fails with "the time limit passed before the query started (this call waited 50.001 s ...)"; after 30 s a query that then times out gets the note; get_stats after a 50 s wait fails the same way; a 10 s wait gets no note. Against ff0bd0c6b three fail: the 50.001 s query and get_stats succeed (AssertionError: {"isError":false,...}), and the 30 s case reads "the query ran past its time limit" with no note. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Let the query backstop's ROLLBACK past the server's authorizer After every query bridge_query ran ROLLBACK when the connection was not in autocommit, as a backstop for a transaction left open. On a read-only server connection, the kind every tool uses, the authorizer denies SQLITE_TRANSACTION, and SQLite authorizes ROLLBACK as that action: the ROLLBACK failed with "not authorized", its result was ignored, and the transaction and its lock on the app's database stayed. Nothing a client sends opens one today (BEGIN and SAVEPOINT are refused), so the backstop only mattered for a hole in the authorizer, and there it did nothing. sqlitedbg_end_transaction (sqlitedbg.h) now does the rollback. It sets a thread-local flag around its own sqlite3_exec("ROLLBACK"), and the authorizer lets SQLITE_TRANSACTION through only when that flag is set and the statement is ROLLBACK. A client's BEGIN, COMMIT, END and ROLLBACK are still refused, also while a transaction is open, and SAVEPOINT (with ROLLBACK TO) is untouched. bridge_query checks the result: a rollback that fails becomes the call's error, "a transaction was left open and rolling it back failed: <errmsg>", with ROLLBACK's code. If the query had already failed, that error is kept instead. The connection stays cached either way, so each later query tries the rollback again. Tests: - C (sqlitedbg_test.c, test_server_ends_transaction): a read-only server connection is put into a transaction holding a read lock by clearing the authorizer, running BEGIN and a SELECT, and putting the real authorizer back (a SQLITEDBG_TEST hook exposes it). The app's write gets SQLITE_BUSY. The client's ROLLBACK, COMMIT and BEGIN still get SQLITE_AUTH. sqlitedbg_end_transaction returns SQLITE_OK, the connection is back in autocommit, and the app can write. Afterwards the client's BEGIN and ROLLBACK are still refused. test_server_holds_no_locks also checks that COMMIT, END and ROLLBACK are refused. With the authorizer change reverted it fails with "sqlitedbg_end_transaction(srv) == SQLITE_OK (23 vs 0)", then autocommit stays 0 and the app's write is "database is locked". - JNI (JniQueryTest): a writable server connection holding BEGIN IMMEDIATE, with an authorizer that refuses ROLLBACK, fails the next query with "23 a transaction was left open and rolling it back failed: not authorized" while the app stays locked out. Once that authorizer is cleared, the next query rolls the transaction back and the app can write. With the old unchecked ROLLBACK restored it fails with "the failed rollback is reported: null vs 23 ...": the query returned as if nothing were wrong. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Say when get_schema cut a CREATE statement get_schema reads sqlite_master with a 64 KiB text limit but reported only truncated: result.hasMore, which means more rows exist. A view or trigger whose SQL is longer than 64 KiB came back as a prefix with truncated false, and an agent would read it as the full definition. Each entry now has truncated, true when a value in its row was cut. The result also has truncated_cells, the count of cut values, named as query names it. The top-level truncated is true when anything was cut or rows past the first 1000 were left out. The tool description gives the 64 KiB limit and the three fields. The limit is now a constant, MAX_SCHEMA_SQL_BYTES. The README's Limits paragraph says it too. Other tools checked: query already reports truncated_cells and has_more. explain_query_plan and integrity_check use the 4 KiB text limit and report neither, and were left alone: a plan line or an integrity message near 4 KiB, or more than 1000 of them, is not a realistic case, and integrity_check's ok compares against "ok", which a cut value cannot equal. get_stats reads only numbers and table names. Tests (DatabaseToolsTest with FakeDebugEngine): getSchemaSaysWhichCreateStatementWasCut gives get_schema a result whose view SQL is listed as cut. The top-level truncated is true, truncated_cells is 1, the view entry has truncated true, and the table entry has truncated false. getSchemaIsTruncatedPastMaxRowsEntries checks that 1001 entries still give truncated true with truncated_cells 0. getSchemaGroupsByType checks false and 0 when nothing is cut. With the reporting reverted the first fails with "a cut CREATE statement makes the result truncated",…
davidschachterADFA
added a commit
that referenced
this pull request
Nov 25, 2026
* ADFA-7082: Vendor sqlite-js 1.3.7 with our patches 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Build the sqlite-js AAR for apps in subprojects:sqlite-js 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Release the sqlite-js AAR to sqlite-js-latest 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Build the sqlite-js AAR for arm64-v8a and armeabi-v7a only 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Run no stored code by default; test sqlite-js on pull requests 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Update sqlite-js-latest in place, out of latest-release selection 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Sort the QuickJS copyright lines the same on every machine 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Log stored functions that cannot be listed; guard the tag 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the reviewed sqlite-js patches 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Put back both the assets and the tag if a release update fails 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Find js_functions in any case; sync the cancel test; doc caveats 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a re-run repair a release left without its assets 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor sqlite-js main with our changes merged, one patch left 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Vendor the sqlite-js 1.4.1 release 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a connection open, and its stored functions load, during 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Patch two stack-bound crashes and two garbage cases 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Let a re-run replace a release left as a draft 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * style: spotless reformat, no functional change Spotless wraps the cancelAll() Javadoc paragraph, which the previous commits lengthened. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: End the result sets an interrupted call leaves open 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Make ending result sets safe when it runs JavaScript, and 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Stop what ending result sets runs; count the interrupts db.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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Answer the independent review of patches 0004 to 0007 - 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Test a direct interrupt during db.exec with a result set kept 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7135: Define the interface between the SQLite debugger extension 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: Copy the MCP server from ShareYourApps, renamed 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Add the sqlite-debugger module skeleton 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: MCP server with the eight read-only database tools 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 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Implement the SQLite debugger extension and its host tests 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Add the JNI layer and NativeDebugEngine 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * style: spotless reformat of the SQLite debugger module, no functional change Co-Authored-By: Claude Haiku 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Fix three review findings in the extension - read_events moves the cursor past dropped events when it copies nothing, so a drop is reported once. - An internal failure in sqlitedbg_extension_init is logged and the connection left untracked; the app's own sqlite3_open no longer fails because of it. - A trigger is told apart from app SQL by X differing from sqlite3_sql(P), not by a "--" prefix, so statements that start with a comment are expanded. test.sh builds the extension with SQLITEDBG_TEST for the failure hook. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: Document the SQLite debugger module Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136: List sqlite-debugger among the modules without ABI flavors AndroidModuleConf.kt already excludes it; ARCHITECTURE.md and CLAUDE.md named only plugin-api and sqlite-js. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Never let the debugger crash or miss the host app's early connections - DebuggerStartup catches Throwable after the debuggable check, so a missing requery library (UnsatisfiedLinkError) disables the debugger instead of killing the app. The check itself still throws. - install() runs synchronously in onCreate; only the server start is on the thread, so connections opened in Application.onCreate are tracked. - McpHttp: connection and accept threads catch Throwable; an Error while handling a request is answered with a 500. - McpHttp: a failed accept sleeps 100 ms, doubling to 2 s while failures continue, and resets on success (no spin on EMFILE). Tests: an Error thrown by a tool gives HTTP 500 and the server keeps serving; a ServerSocket whose accept fails is retried with growing gaps, then serves. DebuggerStartup imports android.* and has no JVM test. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7135 Keep read-only server connections from holding locks The read-only authorizer allowed BEGIN, SAVEPOINT and PRAGMA locking_mode, so a client could hold a lock on the app's database: BEGIN; SELECT left the app's INSERT failing with SQLITE_BUSY until ROLLBACK. - sqlitedbg.c: deny SQLITE_TRANSACTION, SQLITE_SAVEPOINT, PRAGMA locking_mode and PRAGMA busy_timeout (any form) on read-only server connections. - sqlitedbg_jni.c: bridge_query rolls back if the connection is not in autocommit when it returns (covers writable connections). - Host C test: each denied statement returns SQLITE_AUTH and the app can still write after a read on that connection. Without the authorizer change the test fails on all 8 statements (BEGIN and SAVEPOINT: "database is locked" for the app's INSERT). The backstop is tested with the JNI test. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Bound query results and report truncation per cell - M4: QueryLimits.maxTotalBytes (DatabaseTools passes 4 MiB). bridge_query counts the TEXT/BLOB bytes kept and 8 per number, and stops with hasMore before the row that would pass the budget; the first row always goes in so a page makes progress. The tool result text is serialised compact: it was sent twice, pretty and as structuredContent. - L11: the engine reports cut cells (QueryResult.truncatedCellIndexes, row * columns + column) instead of DatabaseTools guessing from size >= limit, so a BLOB of exactly maxBlobBytes is no longer flagged. - L12: get_schema and get_stats read sqlite_master (sqlite_schema needs 3.33). - L13: sqlite3_column_text/blob returning NULL (out of memory) is checked. JVM tests: blob at the limit vs one byte over, the budget pages a result of 3 MiB rows, sqlite_master in the SQL sent, compact result text. Each fails with its fix reverted. The native side (budget, cut cells) is tested by the JNI test in a later commit; L13 has no test (needs an allocation failure). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Drop stale server connections and stop expanding SQL when idle - M7: DatabaseTools cached a server connection per path forever, so after the app deleted and recreated its database the server read the old file. Each cached connection remembers the ids of the app connections to its path when it opened. Before each tool call it is closed and dropped when no live app connection has the path, or none of those ids is left. - L14: the first get_events turned on bound-value expansion until the server stopped, so every app statement was expanded twice forever. It now goes off 60 s after the last get_events call, checked on every tool call and by a daemon timer; the tool description says so. - L10 (one lock for all tool calls) is documented in the class KDoc. Tests: recreated database reopens (opened 2, closed 1), a connection survives while a seen app connection remains, a vanished path closes the cached one, and expansion stops after 60 s. Each fails with its fix reverted (expected 2 but was 1; expected 1 but was 0; "60 s after the last get_events"). Limit accepted: a database replaced in place while the same app connections stay open is not detected. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Test the JNI query path test.sh now also builds the JNI layer as it ships (libsqlitedbg.so without SQLITE_CORE, with the version script) against a requery-like libsqlite3x.so (amalgamation, THREADSAFE=2, all symbols exported) and runs src/test/jni/JniQueryTest.java on the host JVM through NativeBridge. It is skipped with a message when no JDK is on PATH. It uses Java stubs of NativeBridge and DebugEngineException (same names and native signatures) rather than compiling the Kotlin, so only a JDK is needed; test.sh fails if the native names in NativeBridge.kt and the stub differ. A change of a Kotlin parameter type alone is not caught. Covers: value types, paging and hasMore, the total-bytes budget (including "first row always goes in" and the budget stopping on a row boundary), per-cell truncation at, over and under the limit with row * columns + column indexes and a budget-dropped row's cells, bound types, the deadline giving SQLITE_INTERRUPT, refused writes giving SQLITE_AUTH, BEGIN/SAVEPOINT/PRAGMA refusals leaving the app able to write, and the rollback backstop. Checked to fail with each native fix reverted: budget (50 rows vs 4), cut cell indexes ([] vs [1, 3]), rollback backstop (app INSERT 5 vs 0, SQLITE_BUSY), authorizer (BEGIN: 0 vs 23), dropped row's cut cells ([0, 1] vs [0]). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7136 Document the JNI test and the requery trace limit README: the JNI test and how it stands in for the Kotlin, and that requery's own sqlite3_trace (log.tag.SQLiteStatements or SQLiteTime VERBOSE) replaces ours on a connection, so its events stop. No code change for that. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba * ADFA-7082: Vendor the sqlite-js 1.4.2 release Upstream released 1.4.2 with our stack, garbage-collection and result-set patches merged (sqliteai/sqlite-js #22, with two maintainer commits, #23 and #24) and with a fix for the use after free we reported (#25). That fix also changes behaviour: a db.exec result set no longer outlives the call into JavaScript that created it, and reading one afterwards throws "The result set was closed when the call into JavaScript that created it returned". So patches 0002 to 0009 go: - 0002 to 0005 and 0008 are upstream, by patch-id identical except for 0002, which has the maintainer's two commits on top. - 0006, 0007 (its second half) and 0009 only told interrupts apart for result sets kept across calls, which 1.4.2 no longer allows. 0001 (sqlitejs_cancel_all, issue 20) is rebased: the same changes, with new context in the struct. A new 0002 keeps what 0006 and the first half of 0007 did for a cancel on SQLite before 3.41: ending a cancelled call's result sets runs the finals of the window and aggregate functions they were computing, each a call that begins after the cancel, which before 3.41 nothing else stops; and those result sets read on as "interrupted". It is narrowed to a cancelled call, since in 1.4.2 result sets are also ended on every normal return. The next commit updates the tests for 1.4.2. vendor.sh --check passes on the 1.4.2 archive (SHA-256 1aa4c566...cf24). The libs/ and license files are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Test sqlite-js 1.4.2's result-set rule and patch 0002 glue_test.c, for 1.4.2: - The progress-handler case kept a result set across calls, which 1.4.2 no longer allows. It now checks, within one call, that a statement a progress handler stopped (as Android's cancelling does) leaves the call's other result set readable, on any SQLite, and that the connection runs SQL afterwards. - A direct sqlite3_interrupt() before SQLite 3.41 shows nowhere, so its kept result set reads as one that outlived its call; on 3.41 and later, as interrupted. - The cleanup that read a kept result set after its call is gone: it now throws. test.sh and the README name patch 0002 for the run as on SQLite 3.40, and the README lists the two patches, states the 1.4.2 rule, and says the 1.4.2 build has not been run on a phone yet. test.sh: upstream's suite 17 of 17 (its 16 and 0001's Cancel all), and glue_test 37 of 37 both normally and as on SQLite 3.40. Without patch 0002, the normal run still passes 37 of 37, and the 3.40 run fails as expected: the kept result set after a cancel reads "The result set was closed ..." rather than "interrupted", and the window function whose final never ends hangs until the 30 s alarm stops the test. Both ABIs build with NDK 29, and libsqlitejs.so exports only JNI_OnLoad and the three entry points. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Keep a call's cancel for the finals its result sets run From the independent review of 3a5cb5356 and 464e6e7ef (no critical, high or medium findings; F01 to F05 low or nits). Patch 0002 told a cancelled call apart only once, in js_leave(), and each final that ending its result sets ran entered JavaScript as a new call with a new cancel epoch. So, before SQLite 3.41: - a cancel that landed while the result sets were ended stopped only the final then running, and the next final that never ended hung the statement (F01); - a cancel that landed just before the call returned let the call succeed with its finals skipped, on any SQLite (F02). Patch 0002 now keeps the call's epoch while its result sets are ended (js_enter), so a cancel during the call or the ending stops every final, and a late cancel fails the statement with an interrupt. The ending_cancelled flag and its interrupt-handler check are gone; the patch is 8 lines. upstream/ is regenerated with vendor.sh. glue_test.c, 44 tests (was 37): - 31: a cancelled call that keeps two result sets whose window finals never end (F03's case); - 33-34: the cancel lands during the first final of a call that returned normally (F01); - 36-37: a cancel that lands as the call returns fails it (F02); - 43: after a progress handler's stop, the kept result set reads as outliving its call, not as interrupted (F04; it passes without the fix too, as a guard against counting such a stop as an interrupt). test.sh: upstream's suite 17 of 17; the glue test 44 of 44 normally and as on SQLite 3.40. With the previous 0002, test 37 fails in the normal run and the 3.40 run hangs at test 34; with 0001 alone, test 37 fails, and the 3.40 run fails test 29 and hangs at test 31. README: what 0002 does now, and what the glue test covers (F05). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Say what a late cancel does to a call's finals From the independent review of 5b9b062eb (no code defects; tests catch what they're named for and are not flaky in 120 runs on 2 cores and 16 on 1; two low findings and a nit): - F01: "those result sets read on as interrupted" holds only when the cancel came before the call returned. js_leave() decides that once, before ending them, so a cancel that lands while they are ended stops their finals but leaves the "closed" message. - F02: a cancel stops each final at QuickJS's next interrupt check. A final that never ends is stopped and the statement fails, but a short final can still run to its end, so "rather than skipping its finals" overstated it. The patch 0002 header and README say so; 5b9b062eb's message overstated both in the same way. Patch 0002's code is unchanged. - F03: test 36's final records that it ran, and a new test 38 checks that the late cancel stopped it before it did; test 37 is renamed to say its final is a long one. test.sh: upstream's suite 17 of 17; the glue test 45 of 45 normally and as on SQLite 3.40. With 0001 alone, tests 37 and 38 fail (the final ran to its end) and the 3.40 run fails 29 and hangs at 31; with the previous 0002, test 37 fails and the 3.40 run hangs at 34. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7135 Set the Kotlin JVM target on the compile tasks The root build sets jvmTarget 17 on every KotlinCompile task, which overrides the module's kotlin { compilerOptions } and made compileDebugKotlin fail against compileOptions' Java 1.8 ("Inconsistent JVM-target compatibility"). Setting it on the tasks keeps 1.8, as sqlite-js uses. First compile of the Android-only files (NativeDebugEngine.kt, DebuggerStartup.kt, sqlitedbg_jni.c, the manifest): with this change :subprojects:sqlite-debugger:assembleDebug builds both ABIs, the C compiles without warnings under -Wall -Wextra, libsqlitedbg.so exports only JNI_OnLoad, and testDebugUnitTest passes 56 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ADFA-7082: Read result sets as interrupted when the cancel lands while they are ended From CodeRabbit's review of 5b5cd201c (4570522172), the same gap the independent review noted as F01: js_leave() decides once, before ending a call's result sets, whether they read on as "interrupted". A cancel that landed while their finals ran stopped the finals but left the "closed when the call ... returned" message. Patch 0002 now has js_end_rowsets() number its passes and mark each result set with the pass that ended it. After the loop, where nothing runs JavaScript and so no final can have freed a listed result set, it marks that pass's result sets interrupted if the cancel epoch has moved. The README and the patch header say the message is "interrupted" whether the cancel came before the call returned or during the ending. glue_test.c: new test 36 reads both result sets after the cancel that lands during the ending, and expects "interrupted". test.sh: upstream's suite 17 of 17; the glue test 46 of 46 normally and as on SQLite 3.40, and the same under AddressSanitizer and UBSan. With the previous 0002, test 36 fails in both runs with the "closed" message. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Address review of the sqlite-js cancel patches Patch 0002 (rebuilt from upstream PR sqliteai/sqlite-js#33) now: - drops the redundant cancelled term from js_leave: the block after the loop in js_end_rowsets marks a cancelled call's result sets interrupted; - says only JavaScript the extension runs while it initialises a connection is exempt from a cancel, not js_init_table's stored functions; - initialises a rowset's end_pass where it is created; - documents sqlitejs_cancel_all in sqlitejs.h. upstream/ is regenerated with vendor.sh. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7136 Bound the request head and refuse before reading the body; say the server is read-only A local app could hold all 8 connection slots without authenticating: the 30 s timeout applied per read and the token was checked after the whole request. The head now has an overall deadline (5 s), and Host, Origin, path and token are checked before the body. The initialize instructions no longer mention a read-write mode that does not exist. Tests: sockets that send nothing or trickle bytes are closed within the deadline and the real client is then served; an unauthenticated request with an unsent body gets 401; the instructions do not mention read-write. All three fail with the fix reverted. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Refuse the process-wide heap limit and temp directory PRAGMAs on server connections SQLite applies hard_heap_limit, soft_heap_limit and temp_store_directory to the whole process, so a client's PRAGMA hard_heap_limit=1 could make the app's own connections fail with SQLITE_NOMEM. Test: each form (set and read) returns SQLITE_AUTH on a server connection; without the change all five return SQLITE_OK. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Give server connections a 3 s busy timeout With the app's database in rollback-journal mode, a server read failed at once with SQLITE_BUSY while the app held a write lock, exactly when the agent wants to look. The timeout is set in C and PRAGMA busy_timeout stays refused, so the client cannot change it. Test: an app connection holds BEGIN EXCLUSIVE; a server read waits about 500 ms and succeeds once it is released, and reports SQLITE_BUSY after about 3 s if it is not. Without the timeout the first read failed after 0 ms with SQLITE_BUSY. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Fail a query whose argument count differs from its parameter count Too few arguments left the missing parameters unbound, which SQLite reads as NULL, so the query ran and returned a plausible empty result. It now throws SQLITE_RANGE with a message naming both counts. Test (JniQueryTest, the real JNI query path on a host JVM, run by test.sh): zero args for one parameter and one for two give SQLITE_RANGE; the first expectation was NULL before, and both fail with the check disabled. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 List an open database once when the databases folder is reached through a link list_databases matched the files of the app's databases folder against connection paths as strings, so on a phone (/data/user/0/<pkg> against /data/data/<pkg>) every open database was listed again as available: false. Both sides are now canonicalised before matching; paths are reported as the connections gave them. Test: a folder listed through a symlink, and the reverse, list the open database once. Without the canonicalisation it was listed twice. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Run the sqlite-debugger host tests in CI test.sh (the extension's C tests under ASan/UBSan and TSan, and the JNI query test) ran in no workflow. The new workflow follows test-sqlite-js.yml and also triggers on the vendored SQLite headers test.sh compares against. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Add debugger_endpoint_table and migration 5 to 6 The SQLite debugger in an app built by Code on the Go reports a token and a port; Code on the Go needs to keep them per app and per project. debugger_endpoint_table (RecentProjectRoomDatabase version 6) is keyed by application_id and holds project_location, token, port and updated_at. project_location is a foreign key to recent_project_table.location with ON DELETE CASCADE, so removing a project removes its endpoints, and ON UPDATE CASCADE, so renaming a project (which rewrites location) does not fail once an endpoint row exists. Room enables PRAGMA foreign_keys itself once the schema declares a foreign key, so no extra code is needed. The pairing upsert is INSERT OR IGNORE plus UPDATE in one transaction: minSdk 28 ships SQLite 3.22, which predates UPSERT (3.24). Tests: migration 5 to 6 on a v5 file opened through Room (projects kept, schema validated, cascade works on the migrated file); delete and rename cascades. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * style: spotless reformat, no functional change LaunchAppAction.kt was indented with spaces; the next commit edits it, which pulls the whole file under the Spotless ratchet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Pair apps with projects and receive their debugger endpoint Code on the Go must know which project an app belongs to before it accepts that app's debugger token and port, otherwise any app could register an endpoint. - A project-started install records (application ID, project) once the install succeeds. An existing pairing moves to the new project and its stale token and port are cleared. LaunchAppAction only adds a pairing when the app has none, and waits for it before launching. The Activity is not captured in the pairing lambda. - DebuggerEndpointReceiver (exported, action com.itsaky.androidide.SQLITE_DEBUGGER_ENDPOINT) stores the endpoint off the main thread. The token must be 1-128 URL-safe base64 characters and the port 1-65535. A broadcast from an unpaired app stores nothing. A database failure is logged, never thrown. - Sender identity: the app attaches an immutable PendingIntent, and the receiver trusts only its creatorPackage, which the framework sets and another app cannot forge, on every API level. A forged broadcast could otherwise point the AI Agent at another app's debugger server. Tests: DAO and repository (pairing rules, failures reported as false, move and clear on re-pairing); the receiver delivered through the framework under Robolectric (stored, unpaired app ignored, no PendingIntent ignored, malformed extras ignored); validation of token and port. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Send the debugger endpoint to Code on the Go once the server listens The library broadcasts its token and port on every process start, after the server listens, so a relaunched app (new port) updates its row. - The broadcast carries an immutable PendingIntent, so Code on the Go can identify the sender from its creatorPackage on every API level. - FLAG_INCLUDE_STOPPED_PACKAGES and FLAG_RECEIVER_FOREGROUND deliver it to Code on the Go when that is not running (cold start). - The library manifest declares <queries> for Code on the Go so the package is visible on API 30+. Code on the Go's receiver is declared in the app manifest, in the previous commit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Docs: describe the debugger endpoint and database version 6 The sqlite-debugger README describes the endpoint broadcast; ARCHITECTURE.md and the Room ADR name Recent Projects database version 6. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7137 Clear pending installs on failure and pin the endpoint broadcast contract A failed or cancelled install left its pendingInstalls entry behind, so a later install of the same applicationId from an APK file was paired with the wrong project. The editor now tells the repository when an install ends without a launch, and entries older than five minutes are ignored as a backstop. Tests: a discarded note is not used, an expired note is not used, a recent note still pairs (the first two fail with the discard and the expiry removed). The broadcast extra names are consts in the library, and EndpointBroadcastTest (Robolectric) checks the sent action, package, extras and creatorPackage. The library is not on :app's classpath, so DebuggerEndpointContractTest in :app pins the same literals; each test names the other. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7139 Add DebuggerEndpointService and the debugger.endpoints permission Plugins such as AI-Agent-MCP need to reach the SQLite debugger of the app the user just built, without the user typing a port or token. DebuggerEndpointService.getEndpoints() returns the open project's endpoints as DebuggerEndpoint values (application ID, port, token, updated at), behind the new permission debugger.endpoints. Contract: SecurityException without the permission; IllegalStateException on a read failure or when called on the main thread; an empty list when no project is open or no app has reported. The API dump and docs/PLUGIN_API_CHANGELOG.md (26.43) are updated, and the plugin docs list the permission. A plugin that declares it needs plugin.min_ide_version 26.43: an older Code on the Go rejects the unknown permission at validation. Tests: the DebuggerEndpoint value class. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7139 Implement DebuggerEndpointService in plugin-manager PluginManager hands each plugin a DebuggerEndpointServiceImpl, which checks the debugger.endpoints permission, refuses the main thread, and maps a read failure to IllegalStateException so a plugin cannot mistake a failure for "no app has reported". Tests: permission refused, no project, endpoints of another project not returned, read failure, main thread refused. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7139 Serve the stored debugger endpoints to plugins The app registers the service when it loads plugins, backed by debugger_endpoint_table (ADFA-7137). The repository looks endpoints up by the canonical project path, so a project opened through a symlink or a non-normalised path still finds the rows stored under its real location. Tests: repository lookup through a non-canonical path. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7139 Docs: describe DebuggerEndpointService in the sqlite-debugger README Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7139 Leave uninstalled apps out of the endpoints and rethrow interrupts reportedEndpoints no longer returns the stored port and token of an app that is no longer installed (injected check, PackageManager in the app). No <queries> is needed: Code on the Go targets SDK 28, below the package visibility filter of SDK 30. The Javadoc says an endpoint can still be stale after the process dies and that updatedAtMillis is when it last reported. DebuggerEndpointServiceImpl rethrows InterruptedException (restoring the flag) and CancellationException unchanged instead of wrapping them. Tests: an uninstalled app is left out, installed ones are returned, the interrupt and the cancellation pass through; all three fail with the fix removed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7139 Docs: DebuggerEndpointService ships in 26.47, not 26.43 26.43 to 26.46 are released without it. The changelog entry moves to a new 26.47 section and the floor plugin.min_ide_version is 26.47. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7082: Vendor the sqlite-js 1.4.3 release, with no patches Upstream merged sqliteai/sqlite-js#33, our patches 0001 (cancel) and 0002 (a cancelled call's finals and result sets) unmodified, and released them in 1.4.3 with one fix of the maintainer's: a cancel no longer stops a stored function's code while js_init_table(1) loads it, as it already spared the JavaScript that loads the extension. Before, a cancel in flight left the connection without that function. Only that call is exempt: JavaScript the code runs through SQL is still cancelled. - upstream/ is plain 1.4.3; patches/ is gone. vendor.sh and test.sh apply any patches/ there may be later (nullglob). - The glue still loads a stored function up to three times, for the case 1.4.3 still cancels. glue_test.c: new test 20 checks that a cancel during a function's own load code does not stop it (fails on 1.4.2 with the two patches); the w and h tests now cancel JavaScript that the load code runs through SQL (they fail with one try). - README, SqliteJs.cancelAll() javadoc: a cancel interrupts the connection, so any other statement in progress on it fails too, and it spares loading stored functions. The README now says the 1.4.2 build passed on the phone and the 1.4.3 build has not run on one yet. test.sh: upstream's suite 17 of 17; glue test 50 of 50 normally and as on SQLite 3.40, and the same under ASan, LeakSanitizer and UBSan. vendor.sh --check passes. NDK 29 builds for both ABIs: no warnings, the same four exports, version string 1.4.3. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * style: spotless rewrap of the cancelAll() javadoc, no functional change Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Answer the independent review of the 1.4.3 move No correctness defects; two nits: - F01: two glue-test comments still credited "patch 0002" for what sqlite-js 1.4.3 now does. - F02: the v test assumed cancel_calls was still 0; it now resets it, as the w and h tests do. Glue test 50 of 50 normally and as on SQLite 3.40. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7082: Record the phone run of the 1.4.3 build On the Note20, with an AAR built from 0c2e603ee: the trial app passes 7 of 7 as a 64-bit and as a 32-bit process, on a new and an existing database, and the template (dev-assets #79) stops its runaway query 11 to 12 ms after Cancel in its 64-bit and 32-bit debug builds and its release build. The README said the 1.4.3 build had not run on a phone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw * ADFA-7135: Correct two README lines the CI and device work made false "No workflow runs either yet" has been false since the test-sqlite-debugger workflow: it runs test.sh, the C and JNI tests. The JVM tests are still in no workflow, which the line now says. "Nothing has run in an app on a device" has been false since the device runs recorded on ADFA-7135. What is left is a device run of the current code, because those results predate the review fixes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Refuse SQL that holds more than one statement bridge_query prepared with no tail pointer, so SQLite compiled only the first statement: query with "SELECT 1; SELECT 2" ran the first, dropped the second and reported success, and explain_query_plan (which prefixes the client's SQL) did the same. A lone comment returned an empty result, and anything after a NUL character was dropped too, since SQLite reads no further. prepare_one now prepares the tail as well. Whitespace, comments and semicolons prepare to no statement and are accepted; anything else, including a tail that fails to prepare (the server's authorizer refuses a trailing write at prepare time), fails the call with SQLITE_ERROR, "the SQL holds more than one statement; run one statement per call". SQL with no statement, or with a NUL, fails with its own message. Every tool reaches SQLite through bridge_query, so this covers query and explain_query_plan; the other tools send fixed SQL, and get_stats builds its COUNT(*) from quoted table names, not client input. Preparing the tail is not running it: the only effects are those a PRAGMA can have at prepare time, under the same authorizer a client already meets by sending that statement alone. Test (JniQueryTest, the real JNI path on a host JVM, run by test.sh): two statements, a statement after a comment, a trailing DELETE, a trailing syntax error and EXPLAIN QUERY PLAN with a second statement give the more-than-one message; a lone comment, a lone semicolon and a NUL give theirs; trailing semicolons, whitespace, comments, an open comment and a leading comment still run. With the fix reverted the 8 refusal checks fail, each "null vs 1 the SQL holds ...": the call ran. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Say when a query ran out of time waiting for another tool call A query's 50 s deadline is set before runChecked waits for the tools' lock, so a call queued behind a slow one could fail with "the time limit passed before the query started" or "the query ran past its time limit", and the agent would read that as its own query being too slow. The deadline still starts before the wait (decided in review, so it bounds the wait for an answer once set); only the error changes. runChecked times its wait for the lock, and when the time ran out (SQLITE_INTERRUPT) after that wait took at least half of what the call had left, the message adds "(this call waited N s of its 50 s for another tool call to finish; tool calls run one at a time, so retry it)". Not counted: get_stats sets its deadline before its path check, which also takes the lock, so a wait there is not attributed. A tool call's first wait, in the idle check, comes before any deadline is set. Test (DatabaseToolsTest, fake clock): a second call takes the lock just after the query set its deadline, as a third concurrent call can, and holds it while the fake clock moves. A wait of 50.001 s and of 30 s each get the note; a 10 s wait followed by the query's own timeout does not. Without the fix the first two fail: expected "...started (this call waited 50.001 s of its 50 s ...)" but was "...started", and "the query ran past its time limit" with no note. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7136 Start a tool call's time limit when the call begins The 50 s limit was meant to make the server give up before the client (60 s), so a timed-out call never leaves a query holding the lock after the client has stopped waiting. It did not: every call first waited for the lock in the idle check, and run() set its deadline only after that and the path check, so a call queued behind a slow one could run a full 50 s after the wait. Each tool call now gets a Call when it begins: its deadline (DEADLINE_MS, unchanged) and the time it has spent waiting for the lock. Every lock taken inside the call (idle check, path check, each query, get_stats included) goes through Call.locked, which adds the wait. The note from ff0bd0c6b now uses that total: when the time runs out after waits of at least half the limit, the error says the call waited N s for another tool call and should be retried. Test (DatabaseToolsTest, fake clock): a call starts while another holds the lock and waits for it in the idle check. After a 50.001 s wait a query fails with "the time limit passed before the query started (this call waited 50.001 s ...)"; after 30 s a query that then times out gets the note; get_stats after a 50 s wait fails the same way; a 10 s wait gets no note. Against ff0bd0c6b three fail: the 50.001 s query and get_stats succeed (AssertionError: {"isError":false,...}), and the 30 s case reads "the query ran past its time limit" with no note. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn * ADFA-7135 Let the query backstop's ROLLBACK past the server's authorizer After every query bridge_query ran ROLLBACK when the connection was not in autocommit, as a backstop for a transaction left open. On a read-only server connection, the kind every tool uses, the authorizer denies SQLITE_TRANSACTION, and SQLite authorizes ROLLBACK as that action: the ROLLBACK failed with "not authorized", its result was ignored, and the transaction and its lock on the app's database stayed. Nothing a client sends opens one today (BEGIN and SAVEPOINT are refused), so the backstop only mattered for a hole in the authorizer, and there it did nothing. sqlitedbg_end_transaction (sqlitedbg.h) now does the rollback. It sets a thread-local flag around its own sqlite3_exec("ROLLBACK"), and the authorizer lets SQLITE_TRANSACTION through only when that flag is set and the statement is ROLLBACK. A client's BEGIN, COMMIT, END and ROLLBACK are still refused, also while a transa…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes Made
Ticket: https://appdevforall.atlassian.net/browse/ADFA-514
Screenshot/Recording
Screen_recording_20250313_123424.webm
Screen_recording_20250313_213116.webm