Skip to content

ADFA-5094: ship the topic tree as a gzipped APK floor asset - #428

Merged
luisguzman-adfa merged 9 commits into
mainfrom
feat/ADFA-5094-apk-tree-floor-update
Aug 18, 2026
Merged

ADFA-5094: ship the topic tree as a gzipped APK floor asset#428
luisguzman-adfa merged 9 commits into
mainfrom
feat/ADFA-5094-apk-tree-floor-update

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

Makes the offline topic tree work from first launch, without a prior R2 pull. The tree is the
offline floor the ticket calls for, but ~16 MB raw is too much to bundle — so ship it gzipped
(~3.3 MB) and decompress on read.

BundledTreeSource now reads kolibri_tree.jsonl.gz — both the APK-bundled floor and the pulled
R2 overlay are gzip — via GZIPInputStream, streaming: the 16 MB is never written out, only the
in-memory index is kept. A truncated or corrupt .gz trips the gzip CRC and falls through to an
empty tree, same as a missing asset, so the live sources still answer.

Adds the committed floor asset src/main/assets/kolibri_tree.jsonl.gz (topics variant, 78,169
folders), and marks *.gz binary in .gitattributes so the repo's default "text=auto eol=lf"
never line-ending-mangles the gzip on checkout.

Pairs with the workflow change that publishes the .gz to R2 (application/gzip), so the periodic
refresh is a ~3 MB download, not ~16 MB. Merge that first so any overlay the app pulls is
already gzip.

Inert-safe: with no asset and no overlay the tree source is empty and the chain behaves as
before (Local → Studio).

luisguzman-adfa and others added 9 commits August 17, 2026 21:15
The committed kolibri_tree.jsonl.gz floor would otherwise fall under the repo's default
"* text=auto eol=lf" and risk line-ending normalization corrupting the gzip on checkout
(Windows especially). Add *.gz to the explicit binary list, next to *.zip / *.tar.gz.
The topic tree is ~16 MB raw; ship and serve it gzipped (~3 MB) instead. BundledTreeSource
now reads kolibri_tree.jsonl.gz — both the APK-bundled floor and the pulled R2 overlay are
gzip — decompressing on read with GZIPInputStream (streaming: the 16 MB is never written out,
only the in-memory index is kept). A truncated or corrupt .gz trips the gzip CRC and falls
through to an empty tree, same as a missing asset, so the live sources still answer.

Pairs with: the workflow gzipping what it publishes to R2, and a committed
src/main/assets/kolibri_tree.jsonl.gz floor asset (~3 MB).
…ore build

.gitignore keeps the raw tree out of git but has no say over packaging:
mergeAssets bundles every file physically present in src/main/assets/, so a
stray kolibri_tree.jsonl left by a local `--tree` generator run would ship in
the APK alongside the .gz. Add a preBuild-hooked task that deletes it, so only
the gzipped bundle (what BundledTreeSource reads) can ship.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ally ships

AGP auto-decompresses any *.gz asset at merge time and drops the extension, so a
source kolibri_tree.jsonl.gz ships inside the APK as an already-decompressed
kolibri_tree.jsonl. BundledTreeSource opened kolibri_tree.jsonl.gz, which is never
present in the APK, so the offline tree loaded nothing and browse was silently empty.

Open the APK asset under APK_ASSET = "kolibri_tree.jsonl" (the name AGP produces),
keeping ASSET = "kolibri_tree.jsonl.gz" for the R2 overlay + refresh worker, and read
both through readGzipAware(): it sniffs the 2-byte gzip signature and decompresses only
the real-gzip overlay, reading the AGP-decompressed asset as-is. The byte signature
decides, so the two paths cannot drift or fail silently again.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The task (and its premise) were based on a wrong diagnosis: the APK never shipped a
stray raw from src/main/assets — AGP itself decompresses the committed
kolibri_tree.jsonl.gz into kolibri_tree.jsonl at asset merge. Guarding the source dir
never touched that. The real fix is in BundledTreeSource (read the AGP-produced name,
gzip-aware). Removing the task also removes its misleading comment. The .gitignore of
kolibri_tree.jsonl stays: it still keeps the generator's transient raw out of git.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@luisguzman-adfa
luisguzman-adfa merged commit dd5e95e into main Aug 18, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the feat/ADFA-5094-apk-tree-floor-update branch August 18, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant