Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d89431e
ADFA-7082: Vendor sqlite-js 1.3.7 with our patches
davidschachterADFA Nov 12, 2026
ae04160
ADFA-7082: Build the sqlite-js AAR for apps in subprojects:sqlite-js
davidschachterADFA Nov 12, 2026
f766299
ADFA-7082: Release the sqlite-js AAR to sqlite-js-latest
davidschachterADFA Nov 12, 2026
3372d3b
ADFA-7082: Build the sqlite-js AAR for arm64-v8a and armeabi-v7a only
davidschachterADFA Nov 12, 2026
1391c4b
ADFA-7082: Run no stored code by default; test sqlite-js on pull requ…
davidschachterADFA Nov 12, 2026
e0f400a
ADFA-7082: Update sqlite-js-latest in place, out of latest-release se…
davidschachterADFA Nov 12, 2026
362ad7f
ADFA-7082: Sort the QuickJS copyright lines the same on every machine
davidschachterADFA Nov 12, 2026
2f3460f
ADFA-7082: Log stored functions that cannot be listed; guard the tag …
davidschachterADFA Nov 12, 2026
401a052
ADFA-7082: Vendor the reviewed sqlite-js patches
davidschachterADFA Nov 12, 2026
44a6e88
ADFA-7082: Put back both the assets and the tag if a release update f…
davidschachterADFA Nov 12, 2026
3c93bda
ADFA-7082: Find js_functions in any case; sync the cancel test; doc c…
davidschachterADFA Nov 12, 2026
0d1f9db
ADFA-7082: Let a re-run repair a release left without its assets
davidschachterADFA Nov 12, 2026
ac748be
ADFA-7082: Vendor sqlite-js main with our changes merged, one patch left
davidschachterADFA Nov 12, 2026
8086fd1
ADFA-7082: Vendor the sqlite-js 1.4.1 release
davidschachterADFA Nov 12, 2026
6957c71
ADFA-7082: Let a connection open, and its stored functions load, duri…
davidschachterADFA Nov 12, 2026
763bb47
ADFA-7082: Patch two stack-bound crashes and two garbage cases
davidschachterADFA Nov 12, 2026
c084450
ADFA-7082: Let a re-run replace a release left as a draft
davidschachterADFA Nov 12, 2026
7f8e40c
style: spotless reformat, no functional change
davidschachterADFA Nov 12, 2026
a113c80
ADFA-7082: End the result sets an interrupted call leaves open
davidschachterADFA Nov 13, 2026
64269ea
ADFA-7082: Make ending result sets safe when it runs JavaScript, and …
davidschachterADFA Nov 13, 2026
851ee17
ADFA-7082: Stop what ending result sets runs; count the interrupts db…
davidschachterADFA Nov 13, 2026
8973b29
ADFA-7082: Answer the independent review of patches 0004 to 0007
davidschachterADFA Nov 13, 2026
db04941
ADFA-7082: Test a direct interrupt during db.exec with a result set kept
davidschachterADFA Nov 13, 2026
e538658
Merge branch 'stage' into feat/ADFA-7082-sqlite-js-aar
davidschachterADFA Nov 13, 2026
3a5cb53
ADFA-7082: Vendor the sqlite-js 1.4.2 release
davidschachterADFA Nov 13, 2026
464e6e7
ADFA-7082: Test sqlite-js 1.4.2's result-set rule and patch 0002
davidschachterADFA Nov 13, 2026
5b9b062
ADFA-7082: Keep a call's cancel for the finals its result sets run
davidschachterADFA Nov 14, 2026
5b5cd20
ADFA-7082: Say what a late cancel does to a call's finals
davidschachterADFA Nov 16, 2026
0ec489a
ADFA-7082: Read result sets as interrupted when the cancel lands whil…
davidschachterADFA Nov 16, 2026
5fc4976
ADFA-7082: Address review of the sqlite-js cancel patches
davidschachterADFA Nov 16, 2026
b15fa5d
ADFA-7082: Vendor the sqlite-js 1.4.3 release, with no patches
davidschachterADFA Nov 16, 2026
d6e0d1a
style: spotless rewrap of the cancelAll() javadoc, no functional change
davidschachterADFA Nov 16, 2026
0c2e603
ADFA-7082: Answer the independent review of the 1.4.3 move
davidschachterADFA Nov 16, 2026
f46e68e
ADFA-7082: Record the phone run of the 1.4.3 build
davidschachterADFA Nov 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/release-sqlite-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Release sqlite-js AAR (manual)

# Publishes the sqlite-js AAR (subprojects/sqlite-js) to the moving sqlite-js-latest release, from
# which dev-assets fetches it into the template that uses it (ADFA-7082).

on:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: release-sqlite-js
cancel-in-progress: false

jobs:

release-sqlite-js:
runs-on: self-hosted
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
persist-credentials: false

- name: Check the vendored sqlite-js
run: subprojects/sqlite-js/vendor.sh --check

- name: Build the sqlite-js AAR
run: |
flox activate -d flox/base -- \
./gradlew --console=plain --no-daemon :subprojects:sqlite-js:createSqliteJsAar

- name: Stage sqlite-js release assets
run: |
mkdir -p .release
cp subprojects/sqlite-js/build/libs/sqlite-js.aar .release/sqlite-js.aar
( cd .release && sha256sum sqlite-js.aar > checksums.txt )
ls -la .release

# Once published, the release is updated in place, never deleted, so dev-assets can always
# fetch an AAR. If any step of the update fails, the previous assets (downloaded first) and
# tag are put back.
- name: Update sqlite-js-latest release
env:
GH_TOKEN: ${{ github.token }}
shell: flox activate -d flox/base -- bash -eo pipefail {0}
run: |
TARGET_SHA="$(git rev-parse HEAD)"
NOTES="built from ${TARGET_SHA} on $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
# gh release create makes a draft and publishes it once its assets are uploaded, so a first
# run that stopped during the upload leaves a draft. It has no tag yet and dev-assets cannot
# fetch from it: delete it, and create the release again.
if [ "$(gh release view sqlite-js-latest --json isDraft --jq .isDraft 2>/dev/null)" = true ]; then
gh release delete sqlite-js-latest --yes
fi
if ! gh release view sqlite-js-latest >/dev/null 2>&1; then
gh release create sqlite-js-latest \
--target "$TARGET_SHA" \
--latest=false \
--title "sqlite-js AAR (latest)" \
--notes "$NOTES" \
.release/sqlite-js.aar \
.release/checksums.txt
exit 0
fi
TAG_REF="repos/${GITHUB_REPOSITORY}/git/refs/tags/sqlite-js-latest"
PREVIOUS_SHA="$(gh api "$TAG_REF" --jq .object.sha)"
mkdir -p .previous
# A run that stopped during an upload can leave an asset missing. Back up only the assets
# that exist: the upload below then replaces the missing ones, so running again repairs it.
Comment thread
davidschachterADFA marked this conversation as resolved.
Resolved
PREVIOUS_ASSETS="$(gh release view sqlite-js-latest --json assets --jq '.assets[].name')"
for asset in sqlite-js.aar checksums.txt; do
if grep -qx "$asset" <<<"$PREVIOUS_ASSETS"; then
gh release download sqlite-js-latest --dir .previous --pattern "$asset"
fi
done
if ! { gh release upload sqlite-js-latest .release/sqlite-js.aar .release/checksums.txt --clobber &&
gh api -X PATCH "$TAG_REF" -f sha="$TARGET_SHA" -F force=true >/dev/null &&
gh release edit sqlite-js-latest --latest=false --notes "$NOTES"; }; then
echo "::error::updating sqlite-js-latest failed; putting back the previous assets and tag"
# each is attempted even if the other fails, since bash -e would stop at the first
if [ -f .previous/sqlite-js.aar ] && [ -f .previous/checksums.txt ]; then
gh release upload sqlite-js-latest .previous/sqlite-js.aar .previous/checksums.txt --clobber ||
echo "::error::could not put back the previous assets"
else
echo "::error::the release lacked an asset before this run, so none are put back; run the workflow again"
fi
gh api -X PATCH "$TAG_REF" -f sha="$PREVIOUS_SHA" -F force=true >/dev/null ||
echo "::error::could not put back the tag at $PREVIOUS_SHA"
exit 1
fi
34 changes: 34 additions & 0 deletions .github/workflows/test-sqlite-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test sqlite-js

# The tests the Android build cannot run (ADFA-7082): that upstream/ is the sqlite-js release with
# any patches/ applied, upstream's test suite on it, and the test of sqlitejs_android.c's entry
# points. See subprojects/sqlite-js/test.sh.

on:
pull_request:
paths:
- 'subprojects/sqlite-js/**'
- '.github/workflows/test-sqlite-js.yml'

permissions:
contents: read

jobs:

test-sqlite-js:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Download sqlite-js
run: |
eval "$(grep -E '^(VERSION|URL)=' subprojects/sqlite-js/vendor.sh)"
curl -fsSL -o "$RUNNER_TEMP/sqlite-js.tar.gz" "$URL"

- name: Check the vendored sqlite-js
run: subprojects/sqlite-js/vendor.sh --check "$RUNNER_TEMP/sqlite-js.tar.gz"

- name: Run the sqlite-js tests
run: subprojects/sqlite-js/test.sh "$RUNNER_TEMP/sqlite-js.tar.gz"
5 changes: 3 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Strategy: **layer-and-subsystem based**, not feature-by-feature. The Gradle buil

- **`app` depends inward; libraries never depend on `app`.** Subsystems are consumed by `app`, not vice versa.
- **Vendored forks are substituted, not imported ad hoc.** `composite-builds/build-deps` and `build-deps-common` provide forked `javac`/`jdt`/`layoutlib`/etc.; `settings.gradle.kts` substitutes them in for `com.itsaky.androidide.build:*`. Don't add a Maven coordinate for something already substituted. Pebble is likewise built from source, as `subprojects:pebble`, for a lexer fix Android needs (its `NOTICE` says what changed); depend on `projects.subprojects.pebble`, not `io.pebbletemplates:pebble`.
- **All module config flows through `composite-builds/build-logic`.** Every Android module gets the `v7`/`v8` ABI flavors centrally (`AndroidModuleConf.kt`) — there is no flavorless `assembleDebug`. `:plugin-api` is intentionally excluded from flavors.
- **All module config flows through `composite-builds/build-logic`.** Every Android module gets the `v7`/`v8` ABI flavors centrally (`AndroidModuleConf.kt`) — there is no flavorless `assembleDebug`. `:plugin-api` and `:subprojects:sqlite-js`, libraries for other projects that need one artifact, are intentionally excluded from flavors.
- **`RepositoriesMode.FAIL_ON_PROJECT_REPOS`** — repositories are declared once in `settings.gradle.kts`; modules must not declare their own.
- **Avoid new dependencies.** Check `gradle/libs.versions.toml` first; the build almost certainly already has it.

Expand All @@ -104,9 +104,10 @@ Strategy: **layer-and-subsystem based**, not feature-by-feature. The Gradle buil
These structural facts shape every module. Day-to-day build *commands* live in `CLAUDE.md`; the rules that produce them live here.

- **Centralized convention logic.** All Android module setup flows through `composite-builds/build-logic` (`conf/AndroidModuleConf.kt`). Modules stay thin and share configuration, so understanding any module's setup starts here.
- **ABI product flavors.** Every Android module *except* `:plugin-api` gets two flavors on the `abi` dimension — `v7` (`armeabi-v7a`) and `v8` (`arm64-v8a`) — defined centrally. There is no flavorless variant; tasks are `assembleV8Debug`, `assembleV7Release`, etc.
- **ABI product flavors.** Every Android module *except* `:plugin-api` and `:subprojects:sqlite-js` gets two flavors on the `abi` dimension — `v7` (`armeabi-v7a`) and `v8` (`arm64-v8a`) — defined centrally. There is no flavorless variant; tasks are `assembleV8Debug`, `assembleV7Release`, etc.
- **SDK levels** (`build-logic/.../build/config/BuildConfig.kt`): `COMPILE_SDK=36`, `MIN_SDK=28`, `TARGET_SDK=28`. **`TARGET_SDK` is deliberately pinned at 28:** higher targets enforce W^X (write-xor-execute), which blocks executing code from app-writable files. That is fatal for an on-device IDE that compiles and runs code (Gradle, `javac`, Termux binaries), so it is a hard requirement, not tech debt. `MIN_SDK_FOR_APPS_BUILT_WITH_COGO=16` is the floor for the apps a *user* builds with CoGo — distinct from CoGo's own `MIN_SDK`.
- **Native asset bundling.** The on-device LLM (`llama-impl`) ships as a per-flavor native AAR, wired through the root `build.gradle.kts` (`bundleLlamaV8Assets` / `assembleV8Assets`, …); prebuilt per-flavor assets live under `assets/release/v7/` and `assets/release/v8/`.
- **sqlite-js for apps built with CoGo** (ADFA-7082). `subprojects:sqlite-js` builds the AAR that the JavaScript-in-SQLite project template depends on: the sqlite-js release vendored (see its README), for arm64-v8a and armeabi-v7a, minSdk 26, without core-library desugaring. Nothing in CoGo depends on it. Its default entry point runs no code stored in a database; loading stored functions is a separate entry point, only for databases the app made, since loading runs their code. `test-sqlite-js.yml` runs its host tests on pull requests. The manual `release-sqlite-js.yml` publishes it to the moving `sqlite-js-latest` release, from which dev-assets fetches it into the template, as it fetches `plugin-api-latest` for the plugin template.
- **Native lib compression** (ADFA-2306, ADFA-4729). The app manifest hard-codes `android:extractNativeLibs="true"` (required: the installer must materialize libs in `nativeLibraryDir`, e.g. `libshizuku.so` is an executable the adb shell runs from there). That attribute overrides the `jniLibs.useLegacyPackaging` DSL, so AGP packages `lib/<abi>/*.so` deflate-compressed in **every** APK — ~5.9 MB smaller (`libtree-sitter-kotlin.so` alone is 4.18 MB → 339 kB). The trap is the `recompressApk` post-step (release always, debug in CI only): its no-compress lists in `app/build.gradle.kts` must NOT contain `"so"`, or it silently re-stores the libs and undoes the saving — which is what ADFA-2306 fixed for release and ADFA-4729 for CI debug. Locally built debug APKs (including the e2e farm's) never run that step and were always fine.
- **Quick Build shares the Gradle distribution's toolchain** (ADFA-4931). `:app`'s `quickBuildDaemonZip` leaves the Kotlin compiler and eight other jars out of the daemon zip, because the on-device Gradle distribution already carries them; `QuickBuildArtifactStager` links them in at provision time. That makes the daemon's Kotlin version the distribution's, so `:quickbuild:daemon` takes its Kotlin artifacts at `org.adfa.constants.GRADLE_DISTRIBUTION_KOTLIN_VERSION`, and `:app:quickBuildDistJarCheck` fails the build when the distribution it packages lacks a linked jar. See [ADR 0016](docs/adr/0016-quick-build-compiles-outside-gradle.md).
- **`app` package layout is by concern, not feature:** `activities`, `fragments`, `services`, `di`, `agent`, `viewmodel(s)`, `repositories`, `roomData`, `localWebServer`, `preferences`, `ui` (Compose screens live under `ui/compose`), `templates/manager` (the Manager screen's `.cgt`-parsing data layer, with direct filesystem access to `Environment.TEMPLATES_DIR` — distinct from the plugin-facing `IdeTemplateService` in `plugin-api`/`plugin-manager`), `utils`, ….
Expand Down
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ flox activate -d flox/local -- ./gradlew <task>
```

- **Debug APK (arm64, the usual target):** `flox activate -d flox/local -- ./gradlew :app:assembleV8Debug --parallel --max-workers=6`
- **Module unit tests:** `flox activate -d flox/local -- ./gradlew :editor:testV7DebugUnitTest` - unit tests are per-flavor, there is no plain `test` task. `:plugin-api` is the one module without flavors: `:plugin-api:testDebugUnitTest`.
- **Module unit tests:** `flox activate -d flox/local -- ./gradlew :editor:testV7DebugUnitTest` - unit tests are per-flavor, there is no plain `test` task. `:plugin-api` and `:subprojects:sqlite-js` are the modules without flavors: `:plugin-api:testDebugUnitTest`.
Comment thread
davidschachterADFA marked this conversation as resolved.
Resolved
- **Single unit test:** append `--tests "com.itsaky.androidide.SomeTest"` to the flavored task above.
- **Fast iteration:** during multi-file/multi-module changes, verify with targeted `:module:compileV8DebugKotlin`/`compileV8DebugJavaWithJavac` invocations (batch several modules into one Gradle call) rather than a full assemble. Reserve `:app:assembleV8Debug` for final end-to-end verification — it's slow (multi-minute) in this multi-module project, and running it after every small change adds up.
- **Long-running commands: narrate them, and background only the read-only ones.** Anything that can exceed ~60s — `assembleV8Debug`, a full test sweep, a cold Gradle invocation of any kind (daemon start plus configuring this many modules is ~20s before any task runs, and far worse under memory pressure), and `git push`, which runs Spotless through the hook — gets a line before it starts saying what is running and roughly how long it takes, and a status line every couple of minutes while it runs: elapsed time, the last output line, whether it is still progressing. A silent terminal is indistinguishable from a hang, and saying which it is is your job, not the user's to ask.
Expand All @@ -26,7 +26,7 @@ When the user names a CI/CD job ("the sonar job", "the analyze workflow"), read

### ABI product flavors (v7 / v8)

Every module carries `v7` (`armeabi-v7a`) and `v8` (`arm64-v8a`) flavors, so build tasks are `assembleV8Debug`, `assembleV7Release`, etc. — there is **no** flavorless `assembleDebug`. See [ARCHITECTURE.md](ARCHITECTURE.md) (Build & Module Configuration) for flavors, native asset bundling, and SDK levels.
Every module except `:plugin-api` and `:subprojects:sqlite-js` carries `v7` (`armeabi-v7a`) and `v8` (`arm64-v8a`) flavors, so build tasks are `assembleV8Debug`, `assembleV7Release`, etc. — there is **no** flavorless `assembleDebug`. Those two build one artifact for other projects. See [ARCHITECTURE.md](ARCHITECTURE.md) (Build & Module Configuration) for flavors, native asset bundling, and SDK levels.

### Emulator / device

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ private val disableCoreLibDesugaringForModules =
// Like :logsender, the AAR is injected into apps built with CoGo and must
// not force desugaring onto user projects (ADFA-4128).
":quickbuild:runtime",
// The AAR is a dependency of apps built with CoGo (ADFA-7082).
":subprojects:sqlite-js",
)

/**
* Modules without the v7/v8 flavors: libraries for other projects, which need one artifact.
* :subprojects:sqlite-js is an AAR for apps built with CoGo, with all the ABIs they run on.
*/
private val modulesWithoutAbiFlavors = setOf(":plugin-api", ":subprojects:sqlite-js")

/**
* The name of the build type used for automated testing.
*/
Expand Down Expand Up @@ -238,7 +246,7 @@ fun Project.configureAndroidModule(coreLibDesugDep: Provider<MinimalExternalModu
}
}
}
if (project.path != ":plugin-api") {
if (project.path !in modulesWithoutAbiFlavors) {
flavorDimensions("abi")
productFlavors {
create("v7") {
Expand Down
2 changes: 1 addition & 1 deletion docs/adr/0005-per-abi-product-flavors.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The app bundles large native components per ABI — llama.cpp, plus the on-devic

## Decision

Define two **product flavors** on an `abi` dimension — `v7` (`armeabi-v7a`) and `v8` (`arm64-v8a`) — **centrally** in `composite-builds/build-logic` (`conf/AndroidModuleConf.kt`), applied to every Android module except `:plugin-api`.
Define two **product flavors** on an `abi` dimension — `v7` (`armeabi-v7a`) and `v8` (`arm64-v8a`) — **centrally** in `composite-builds/build-logic` (`conf/AndroidModuleConf.kt`), applied to every Android module except `:plugin-api` and `:subprojects:sqlite-js` (an AAR for apps built with CoGo, with both ABIs in one artifact; ADFA-7082).

Consequences for the build:
- Build tasks are flavor-qualified: `assembleV8Debug`, `assembleV7Release`, etc. **There is no flavorless `assembleDebug`.**
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ include(
":subprojects:shizuku-server-shared",
":subprojects:shizuku-shared",
":subprojects:shizuku-starter",
":subprojects:sqlite-js",
":subprojects:tooling-api",
":subprojects:tooling-api-events",
":subprojects:tooling-api-impl",
Expand Down
Loading
Loading