Repository navigation
Conversation
This was referenced Nov 26, 2026
…c, DB handlers, and manifests Hardens security boundaries across app, common, feature, and autoquran: - Zip Slip / path traversal guards in archive extraction, imports, and DatabaseHandler - Safer TLS/network client config, DNS fallback, download validation, and URI handling - Tightened deep-link validation, backup/extraction rules, and exported manifest components - Parameterized SQLite queries across SuraTimingDatabaseHandler and DatabaseHandler.getVersesInternal with CAST(? AS INTEGER) for FTS3/FTS4 column affinity safety - Reduced sensitive logging in release paths and added unit test coverage across affected modules
…ze 2011 legacy code Combines performance, animation/RTL/a11y audit fixes, ultra-light optimizations, and legacy code modernization: - Cold-start, RAM/bitmap (API 28+ ImageDecoder HARDWARE + WindowMetricsCalculator), SQLite WAL, networking, audio, presenter, and Compose optimizations - Migrate SearchActivity off LoaderManager/ListView to RecyclerView + Coroutines - Replace deprecated LocalBroadcastManager with SharedFlow-backed DownloadProgressBus - Convert 17 legacy Java classes to Kotlin and remove all ActionBarSherlock relics - Fix RTL, animation, styling, and accessibility audit items
…bi-v7a) Adds zero-crate native Rust Arabic search engine with bitmask and 2-step ExactPair skipping, catch_unwind FFI safety, and automatic SQLite fallback: - Supports modern 64-bit (arm64-v8a, 16 KB ELF aligned) and 32-bit (armeabi-v7a) devices - ~1.01 ms warm search latency for 'الله' (1,842 hits, 100% parity across all 6,236 verses) - Includes 11 Rust unit tests and JVM fallback + adversarial unit tests
taljeri
force-pushed
the
pr/3-rust-arabic-search
branch
from
November 26, 2026 21:47
6a3adcf to
4a88438
Compare
… and Kotlin search engine
- Add Arabic morphological & proclitic query support in Rust engine (engine.rs, lib.rs) and Kotlin search helpers (ArabicMorphologicalQuery, ArabicCharacterHelper, ArabicCompiledQuery, ArabicSearcher)
- Rebuild 16 KB ELF-aligned arm64-v8a and armeabi-v7a libquran_search.so binaries
- Match proclitic/prefix/definite-article inflections cleanly ('الله' 1,913 verses / 2,816 occurrences; 'الجنة' 154 Ayah verses; 0% false positives)
- Expand Rust adversarial and ArabicCompiledQuery unit test coverage
…ty and JNI cache - Add bidirectional masculine/feminine singular/dual/plural morphology, weak-ي stems, and curated broken-plural/lemma lexicon across all Quran words with 100% Rust <-> Kotlin/Tafsir parity (e.g. مسلم 2->42v, مؤمن 19->200v, قلب 19->124v, نبي 55->76v, 0% FP) - Add JNI compiled-query cache and rebuild 16 KB page-aligned arm64-v8a and armeabi-v7a native libraries - Expand ArabicCompiledQueryTest coverage for universal morphological forms
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.
Summary
[Batch 3 of 5 — Stacked PR Series (
pr/3-rust-arabic-search←#4063pr/2-performance-and-modernization)]Adds a zero-crate native Rust Arabic Quran search engine (
common/search/src/main/rust/) with 100% 16 KB ELF alignment acrossarm64-v8aandarmeabi-v7a, a compiled-query JNI cache, and 100% algorithmic parity in Kotlin (ArabicMorphologicalQuery.kt) across 24 files (+6,961 / -46):Architecture & 16 KB Native Alignment
PT_LOAD p_align = 0x4000):common/search/src/main/jniLibs/arm64-v8a/libquran_search.so(489,680 B) andcommon/search/src/main/jniLibs/armeabi-v7a/libquran_search.so(327,728 B), both verified withzip_offset % 16384 == 0andPT_LOAD p_align == 0x4000across all segments—upgrading the earlier Stage 2.debugarmeabi-v7a/libquran_search.so(222,764 B,0x10004 KB alignment) to full Android 15+ 16 KB page-size compliance, with automatic SQLite/Kotlin fallback on ABIs without prebuilt.sofiles.src/engine.rs,+2,831):VerseIndex&CompiledArabicQuery: 64-bitletter_mask/query_maskbitmask prefiltering plus 2-stepAnchor::ExactPairskip scanning across all 6,236 verses.ALLAH_PROCLITICS,DEF_PROCLITICS,L_PROCLITICS(لِـ+الelision such asلله/للجنة),INDEF_PROCLITICS, andVERB_PROCLITICS; Uthmani open-Ta (ة/ت) equivalences; bidirectional masculine/feminine singular/dual/plural forms and weak-يstems (e.g.متقي↔المتقين,يد↔أيدي); plus curated broken-plural &LEMMA_FAMILIES_RAWlexicon sets with zero false positives (eliminating substring leaks such asيومmatchingيومئذ/اليومincorrectly).src/jni_bridge.rs,+412;src/jni_sys.rs,+135;src/lib.rs,+855):INDEXandQUERY_CACHE: RwLock<Option<(Vec<u16>, Option<Arc<CompiledArabicQuery>>)>>(compile_cached_query) so repeated searches reuse the compiled morphological automaton without recompilation.QUERY_STACK_CAP = 128UTF-16 stack buffering, wraps every exported symbol instd::panic::catch_unwind, and checksExceptionCheckafter every fallible JNI call so panics never unwind across FFI.ArabicMorphologicalQuery.kt,+1,752):engine.rsrule-for-rule with 4-tier matching (TIER_EXACT..TIER_FALLBACK_SUBSTR) in Kotlin, powering SQLite/fallback searches and enabling exact morphological parity for Tafsir search (DatabaseHandler.searchArabicNormalizedin PR#4066) and match highlighting (SearchResultFormatter.kt).RustArabicSearchEngine.kt,RustSearchResultsCursor.kt,ArabicSearcher.kt,ArabicCompiledQuery.kt,app/proguard.cfg):RustArabicSearchEngineAdversarialTest.kt,RustArabicSearchEngineFallbackTest.kt,ArabicCompiledQueryTest.kt, andSearchResultsCursorAndArabicHighlightTest.kt.Freshly Measured 6,236-Verse Corpus & Moto g05 Benchmarks
1. Rust Release Corpus Benchmark (
quran.ar.db, 6,236 Verses,n = 200Runs/Query)cargo test --release -- --nocapture(QURAN_AR_TSVexported fromquran.ar.db,810,133 B):12 passed; 0 failed; 0 ignoredin0.16s(includingreal_quran_db_export_parity_if_present, verifying ~80 queries, exact span offsets, 0% false positives, and< 5.0 mscap).VerseIndex::from_utf8_rows, 6,236 verses,n = 20):min = 18.952 ms,median = 23.438 ms,p95 = 38.148 ms,max = 38.646 ms.:common:search:testReleaseUnitTest --rerun-tasks:79/79PASS (ArabicSearcherTest12,DefaultSearcherTest15,RustArabicSearchEngineAdversarialTest3,RustArabicSearchEngineFallbackTest2,SearchTextUtilTest19,ArabicCharacterHelperTest21,ArabicCompiledQueryTest7).الله0.03380.05940.03700.0645لله0.00430.00590.01160.0181الجنة0.02360.04350.13460.2149بالجنة0.03280.03530.22790.2486مسلم0.06400.08460.40210.4944مسلمين0.06240.08120.38290.4622مؤمن0.04230.05790.24300.2870المؤمنون0.04410.05580.25640.2923كافر0.05460.07310.33340.3749كافرين0.05490.07120.36030.3978متقي0.02980.03730.19040.2062المتقين0.00420.00540.01900.0260صالح0.04230.07920.24850.4438الصالحات0.03430.06180.20370.3708نبي0.03400.03900.20400.2272أنبياء0.03440.04180.19910.2303رسول0.06220.08200.33540.4215رسل0.02690.03680.10650.1295كتاب0.04130.05610.22560.2760كتب0.01680.02310.06940.0893قلب0.01550.02410.07210.0867قلوب0.03970.07190.22890.3978نفس0.02220.03800.09980.1604أنفس0.05120.08860.29910.4919رجل0.02110.02930.11390.1386رجال0.03890.04950.23950.2801يوم0.02220.03050.09100.1122أيام0.04870.08840.25300.4491اليد0.02170.02820.11630.1481أيدي0.01380.01660.06660.08612. Live Moto g05 Comparison: Stage 2 (
.debugv1 Rust) vs. Stage 3 (.hybridv5 Universal Morphology)(Compared against Stage 1
audit/combinedSQLite"الله"=442.1 ms; cold index load on.hybrid=75.28 ms, cold first query =4.95 ms; KotlinArabicMorphologicalQueryalso powers live Tafsir parity onquran.ar.muyassar.dbin PR#4066.).debug(v1 Rust) Hits / Warm (ms).hybrid(v5 Rust) Hits / Warm (ms)الميسر)الله1,842/1.68 ms1,913/0.50 ms3,286+71verses (لله, proclitics)الجنة57/1.57 ms154/2.30 ms306+97verses (جنة,جنات,جنتين)مسلم42/1.46 ms42/0.84 ms103100%parityمؤمن200/2.18 ms200/1.30 ms503100%parityكافر132/2.14 ms157/1.27 ms485+25versesمتقي43/1.10 ms49/1.42 ms44+6versesصالح132/1.28 ms132/1.52 ms252100%parityنبي76/1.54 ms76/1.77 ms383100%parityرسول215/1.71 ms291/2.10 ms1,429+76verses (رسل)كتاب232/1.33 ms255/1.67 ms280+23verses (كتب)قلب53/2.17 ms124/2.18 ms236+71verses (قلوب)نفس268/1.67 ms268/0.92 ms515100%parityرجل41/1.38 ms66/1.00 ms116+25verses (رجال)يوم530/2.95 ms377/0.91 ms646-153false positives eliminatedاليد2/0.93 ms108/0.81 ms133+106verses (يد,أيدي)Stack Overview
pr/1-security-hardeningSEC-01–SEC-22) & FTS3CAST(? AS INTEGER)mainpr/2-performance-and-modernizationpr/3-rust-arabic-search(this PR)pr/4-calm-themes#000000)pr/5-proposal5-hybrid-uiComplete File-by-File Breakdown (24 Files,
+6,961 / -46)All 24 files in
pr/2-performance-and-modernization..pr/3-rust-arabic-search(6d487bed6..b2c8b77e1)app/proguard.cfgapp/src/main/java/com/quran/labs/androidquran/QuranApplication.ktapp/src/main/java/com/quran/labs/androidquran/SearchActivity.ktapp/src/main/java/com/quran/labs/androidquran/database/DatabaseHandler.ktapp/src/main/java/com/quran/labs/androidquran/util/SearchResultFormatter.ktapp/src/test/java/com/quran/labs/androidquran/util/SearchResultsCursorAndArabicHighlightTest.ktcommon/search/build.gradlecommon/search/src/main/java/com/quran/common/search/ArabicSearcher.ktcommon/search/src/main/java/com/quran/common/search/RustArabicSearchEngine.ktcommon/search/src/main/java/com/quran/common/search/RustSearchResultsCursor.ktcommon/search/src/main/java/com/quran/common/search/arabic/ArabicCharacterHelper.ktcommon/search/src/main/java/com/quran/common/search/arabic/ArabicCompiledQuery.ktcommon/search/src/main/java/com/quran/common/search/arabic/ArabicMorphologicalQuery.ktcommon/search/src/main/jniLibs/arm64-v8a/libquran_search.socommon/search/src/main/jniLibs/armeabi-v7a/libquran_search.socommon/search/src/main/rust/Cargo.lockcommon/search/src/main/rust/Cargo.tomlcommon/search/src/main/rust/src/engine.rscommon/search/src/main/rust/src/jni_bridge.rscommon/search/src/main/rust/src/jni_sys.rscommon/search/src/main/rust/src/lib.rscommon/search/src/test/java/com/quran/labs/androidquran/common/search/RustArabicSearchEngineAdversarialTest.ktcommon/search/src/test/java/com/quran/labs/androidquran/common/search/RustArabicSearchEngineFallbackTest.ktcommon/search/src/test/java/com/quran/labs/androidquran/common/search/arabic/ArabicCompiledQueryTest.kt