This repository builds tuned SQLite artifacts for media-server containers: a static CLI, a generic shared library, a Plex shared library, LSIO Docker mod images for Plex and Emby SQLite replacement, and planned-downtime maintenance scripts.
Read docs/architecture.md first.
Project-specific guidance:
- The global kernel still applies; read
~/.claude/CLAUDE.md. - Treat
docs/architecture.mdas the current repository map for build, LSIO mod, smoke-test, and maintenance behavior. docs/architecture.mdis a slim index linking to focused docs underdocs/architecture/for build, rewrite-engine, observability, smoke-tests, lsio-mods, and maintenance.- JF deployment is unsupported until a current binding design and validation plan land.
- Plex uses renamed ICU 69 runtime files. LSIO mod code MUST NOT replace,
rename, move, delete, or overwrite
libicu*plex.so.69; it may only read and verify them. - Plex library replacement targets only
/usr/lib/plexmediaserver/lib/libsqlite3.so. - LSIO mods perform no runtime archive download or extraction. Common runtime
command surface:
awk,chmod,chown,cp,grep,mkdir,mktemp,mv,rm,sed,sha256sum,stat,tr, anduname; Plex patch additionally usesdd,od, andprintf. - Keep
LIBRARY_VARIANT=plexlimited to the Plex ICU build path. - Keep SQLite pins aligned across wrapper, workflow, Dockerfiles, and
build/Build.sh; keep the baked patched source-id literal inscripts/optimize_media_servers.shaligned withpins/versions.envSQLITE_SOURCE_ID, enforced bytests/check_pin_alignment.sh; keep the SORTERREF and PMASZ compile defaults (-DSQLITE_DEFAULT_SORTERREF_SIZE,-DSQLITE_SORTER_PMASZinbuild/Build.sh) aligned with their runtimesqlite3_configvalues insrc/auto_extension.c, enforced bytests/check_pin_alignment.sh; keep ICU pins aligned across.github/workflows/sqlite-build.ymlanddocker-library/Dockerfile; keepBASEIMAGE_UBUNTU,CMAKE_*, andUBUNTU_TOOLCHAIN_R_TEST_KEY_FINGERPRINTaligned acrosspins/versions.env,docker-build-base/Dockerfile,.github/workflows/base.yml,build/base_image_ref.sh, andtests/check_pin_alignment.sh; keepdocker-library/Dockerfile,.github/workflows/sqlite-build.yml, andbuild/build_static_sqlite.shconsumingBASE_IMAGEdynamically with no static generic base digest pin; keepBASEIMAGE_ALPINE=ghcr.io/linuxserver/baseimage-alpine:3.23andGENERIC_GLIBC_MAX=2.27aligned acrosspins/versions.env,docker-cli/Dockerfile,docker-library/Dockerfile, andtests/check_pin_alignment.sh; keep thedocker-library/DockerfileICU and mimalloc dependency layers above all 19 projectCOPYlines; keep the.github/workflows/sqlite-build.ymlGHCRtype=registrycache contract (import the event ref and then the baseline ref; export the event ref only, gated onCACHE_EXPORT_ENABLEDandcontinue-on-error: true; forbidtype=gha) aligned with the hardcoded counts intests/check_pin_alignment.sh(19 projectCOPYlines, 6Load version pinssteps, each of 3 cache scopes appearing twice, 3 baseline refs, and 6 event refs); keep the literal semantics forSQLITE3_DISABLE_REWRITE_APPLIED_SQLandSQLITE3_DISABLE_STMT_TRACE_SAMPLINGaligned across theirsrc/*.cowners,docs/env-vars.md, this file, andtests/check_pin_alignment.sh. - Keep
src/rewrite_modes.has the only rewrite-mode catalogue. Producers pass exact signedOBS_MODE_*ids. Each catalogue row owns target, wire mode, positional logger label, and index-missing eligibility metadata; all mode counter extents useOBS_MODE_COUNT. Applied counters remain per connection; miss and index-missing counters remain process-global. Only Plex taggings, Plex On-Deck, Emby Episodes Latest, Emby movies Latest, and Emby mixed-Latest are index-missing eligible. Invalid ids suppress the requested record and can emit at most one process-wideobs_mode_unregistereddiagnostic while observability is enabled. - Keep runtime optimize opt-in: literal
SQLITE3_DISABLE_RUNTIME_OPTIMIZE=0enables; unset, literal1, and every other value disable. Keep maintenance defaults exact:PLEX_OPTIMIZE_API=0. For configured Plex instances,main()derives internal STAT4 capability state fromGENERIC_SQLITE_BINARYpreflight; the Plex main-DB STAT4 pass runs only when that state is1. - Keep Plex FTS rewrite opt-out (default-on in the Plex/ICU build): literal
SQLITE3_DISABLE_PLEX_FTS_REWRITE=1disables; unset, literal0, and every other value enable -- matching theSQLITE3_DISABLE_OBSERVABILITY,SQLITE3_DISABLE_SLOW_QUERY, andSQLITE3_DISABLE_AUTOPRAGMAkill-switches. Keep Plex GUID-LIKE and On-Deck rewrites opt-in.SQLITE3_DISABLE_PLEX_GUID_LIKE_REWRITE(GUID LIKE NULL guard) enables on literal0; unset, literal1, and every other value disable. It fails open and is independent ofSQLITE3_DISABLE_AUTOPRAGMAandSQLITE3_DISABLE_PLEX_FTS_REWRITE. Keep Plex taggings rewrite opt-out (default-on in the Plex/ICU build): literalSQLITE3_DISABLE_PLEX_TAGGINGS_REWRITE=1disables; unset, literal0, and every other value enable. It fails open and is independent ofSQLITE3_DISABLE_AUTOPRAGMAandSQLITE3_DISABLE_PLEX_FTS_REWRITE. Keep Plex On-Deck rewrite semantics exact:SQLITE3_DISABLE_PLEX_ONDECK_REWRITE(On-Deck) enables on literal0; unset, literal1, and every other value disable. It fails open and is independent ofSQLITE3_DISABLE_AUTOPRAGMAandSQLITE3_DISABLE_PLEX_FTS_REWRITE. The Plex On-Deckviewed_at > <literal>arm runs wheneverSQLITE3_DISABLE_PLEX_ONDECK_REWRITE=0enables the base On-Deck rewrite. Keep rewrite-applied SQL text enabled by default: literalSQLITE3_DISABLE_REWRITE_APPLIED_SQL=1omits source and rewritten SQL text; unset, literal0, and every other value retain the text fields on every emittedsample=first,sample=periodic, andsample=newrecord. Applied rewrites use a per-connection/per-mode first-and-every-1024th sampler plus a bounded per-connection first-seen-corrset; enabled STMT trace uses the same hybrid shape with a per-connection callback count. LiteralSQLITE3_DISABLE_STMT_TRACE_SAMPLING=1logs every enabled STMT callback; unset, literal0, and every other value retain hybrid sampling. A full or unavailable correlation set falls back to the 1024th sampler. If per-connection sampler state cannot be allocated or registered, known-moderewrite_appliedand STMT diagnostics are skipped; sampler failure never increases output. This sampling knob never enables STMT trace by itself. Keep Emby FTS rewrite (SQLITE3_DISABLE_EMBY_FTS_REWRITE) opt-out (default-on in the Emby build): literal1disables; unset, literal0, and every other value enable. Keep Emby fan-out rewrite (SQLITE3_DISABLE_EMBY_FANOUT_REWRITE) opt-out (default-on in the Emby build): literal1disables; unset, literal0, and every other value enable. Keep the Emby dashboard knob opt-in:SQLITE3_DISABLE_EMBY_DASHBOARD_REWRITE(Episodes-Latest, movies-Latest, and mixed-Latest) enables on literal0; unset, literal1, and every other value disable. All three are fail-open and independent ofSQLITE3_DISABLE_AUTOPRAGMA. Knob naming:SQLITE3_DISABLE_<ENGINE>_<PURPOSE>_REWRITE. - Do not create or modify
AGENTS.mdhere unless explicitly asked; the root convention is a symlink to this file.