Shrink the APK with Ziran's compact saved IR and single copies

Ziran c8c6c96c writes saved IR format 59: each string once, compact
integers and relative source positions. The root package drops from
34.0 MB to 18.5 MB and the debug APK from 46.3 MB to 29.5 MB.

A host reads only its own program format, so host_api, oldest_host_api
and every package's host_api move to 41 (released hosts are 40). The
Apps controller is rebuilt with Apps ffebcc7 (e41f568f…, 592 KB instead
of 1.94 MB); controllers from before format 59 cannot run here, so their
trust entries go and collections publish again with this one.

The root package no longer carries a second copy of the Apps controller,
which the host reads from its own apps.zx asset, and the profile picker
draws Entity's flowers picture instead of an identical 1.85 MB copy.
This commit is contained in:
waozi committed 2026-10-29 13:05:36 -03:00
1 parent c9a0eae23c
commit 6ae3f5853d
28 files changed
+100 -83

No files matched your search

+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- The download is about 16 MB smaller: apps are stored more compactly, and shared pictures are included only once.
## [2.1.61] - 2026-10-29
- Chinese, Japanese and Korean text displays correctly.
-1
View File
@@ -384,7 +384,6 @@ STYLE_FILES := $(wildcard $(KSS_DIR)/styles/*.kss) \
$(wildcard themes/catalog_*.kss)
IMAGE_FILES += assets/app/icon-sky-cradle.png assets/app/icon-ink-and-air.png
IMAGE_FILES += $(wildcard assets/social/*.png)
IMAGE_FILES += $(wildcard assets/profile-pictures/*.png)
IMAGE_FILES += $(KRYON_DIR)/icons/ui.png $(KRYON_DIR)/icons/pfp.png
APP_BUNDLES := $(addprefix $(BUILD_DIR)/apps/,lists.zx habits.zx practices.zx diary.zx lumi.zx leaderboard.zx)
INBE_BUNDLE := $(BUILD_DIR)/inbe.zx
+15 -15
View File
@@ -1,6 +1,6 @@
{
"host_api": 40,
"oldest_host_api": 12,
"host_api": 41,
"oldest_host_api": 41,
"package_format": "zx",
"module_api": 2,
"apps": {
@@ -9,7 +9,7 @@
"version": "2.1.62",
"sequence": 59,
"bundled": true,
"host_api": 40,
"host_api": 41,
"release": "2.1.61"
},
"habits": {
@@ -17,8 +17,8 @@
"version": "1.3.15",
"sequence": 38,
"bundled": true,
"host_api": 38,
"oldest_host_api": 30,
"host_api": 41,
"oldest_host_api": 41,
"release": "2.1.61"
},
"practices": {
@@ -26,8 +26,8 @@
"version": "1.6.9",
"sequence": 38,
"bundled": true,
"host_api": 37,
"oldest_host_api": 31,
"host_api": 41,
"oldest_host_api": 41,
"release": "2.1.61"
},
"lists": {
@@ -35,7 +35,7 @@
"version": "1.1.28",
"sequence": 36,
"bundled": true,
"host_api": 27,
"host_api": 41,
"release": "2.1.61"
},
"diary": {
@@ -43,7 +43,7 @@
"version": "1.3.25",
"sequence": 42,
"bundled": true,
"host_api": 21,
"host_api": 41,
"release": "2.1.61"
},
"lumi": {
@@ -51,7 +51,7 @@
"version": "1.5.27",
"sequence": 45,
"bundled": true,
"host_api": 20,
"host_api": 41,
"release": "2.1.61"
},
"leaderboard": {
@@ -59,9 +59,9 @@
"version": "1.0.29",
"sequence": 30,
"bundled": true,
"host_api": 40,
"host_api": 41,
"release": "2.1.61",
"oldest_host_api": 40
"oldest_host_api": 41
}
},
"node_apps": {
@@ -70,21 +70,21 @@
"title": "Photos",
"version": "1.0.4",
"sequence": 5,
"host_api": 15
"host_api": 41
},
"library": {
"id": "inbe.library",
"title": "Library",
"version": "1.0.4",
"sequence": 5,
"host_api": 29
"host_api": 41
},
"radio": {
"id": "inbe.radio",
"title": "Radio",
"version": "1.0.3",
"sequence": 4,
"host_api": 18
"host_api": 41
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

+2 -2
View File
@@ -509,8 +509,8 @@ declares the oldest host interface it needs (`host_api` in its ledger entry),
and the host runs packages from `oldest_host_api` to its own `host_api`.
A host loads only programs in its own Ziran program format, so a toolchain whose
format changed is a new interface too: `oldest_host_api` and every package's
`host_api` rise above the last released host. Host 12 is the first with
format 58; released apps up to 2.1.34 (host 11) cannot load packages built
`host_api` rise above the last released host. Host 41 is the first with
format 59; released apps up to 2.1.61 (host 40) cannot load packages built
since, and are not offered them.
Records between them match fields by name, so a field one side lacks keeps its
zero value and an unknown field is ignored. Update checks send the host's
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- Stažení je asi o 16 MB menší: aplikace jsou uložené úsporněji a sdílené obrázky jsou přibalené jen jednou.
## [2.1.61] - 2026-10-29
- Čínský, japonský a korejský text se zobrazuje správně.
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- Der Download ist etwa 16 MB kleiner: Apps werden kompakter gespeichert und gemeinsame Bilder nur einmal mitgeliefert.
## [2.1.61] - 2026-10-29
- Chinesischer, japanischer und koreanischer Text wird richtig angezeigt.
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- La descarga ocupa unos 16 MB menos: las apps se guardan de forma más compacta y las imágenes compartidas se incluyen una sola vez.
## [2.1.61] - 2026-10-29
- El texto en chino, japonés y coreano se muestra correctamente.
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- Le téléchargement est plus léger d'environ 16 Mo : les apps sont stockées de façon plus compacte et les images partagées ne sont incluses qu'une fois.
## [2.1.61] - 2026-10-29
- Le texte chinois, japonais et coréen s’affiche correctement.
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- Unduhan sekitar 16 MB lebih kecil: aplikasi disimpan lebih ringkas, dan gambar bersama hanya disertakan sekali.
## [2.1.61] - 2026-10-29
- Teks Tionghoa, Jepang, dan Korea kini tampil dengan benar.
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- Il download è più leggero di circa 16 MB: le app sono salvate in modo più compatto e le immagini condivise sono incluse una sola volta.
## [2.1.61] - 2026-10-29
- Il testo in cinese, giapponese e coreano si vede correttamente.
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- ダウンロードサイズが約16MB小さくなりました。アプリをよりコンパクトに保存し、共通の画像は一度だけ含めるようにしました。
## [2.1.61] - 2026-10-29
- 中国語・日本語・韓国語の文字が正しく表示されるようになりました。
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- 다운로드 크기가 약 16MB 줄었습니다. 앱을 더 작게 저장하고, 공유 이미지는 한 번만 포함합니다.
## [2.1.61] - 2026-10-29
- 중국어, 일본어, 한국어 글자가 올바르게 표시됩니다.
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- O download ficou cerca de 16 MB menor: os apps são guardados de forma mais compacta e as imagens compartilhadas vêm só uma vez.
## [2.1.61] - 2026-10-29
- Textos em chinês, japonês e coreano aparecem corretamente.
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- Загрузка стала примерно на 16 МБ меньше: приложения хранятся компактнее, а общие изображения включены только один раз.
## [2.1.61] - 2026-10-29
- Китайский, японский и корейский текст отображается правильно.
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [Unreleased]
- 下载大小减少约 16 MB:应用的存储方式更精简,共用的图片只包含一次。
## [2.1.61] - 2026-10-29
- 中文、日文和韩文文字现在可以正常显示。
+1 -1
View File
@@ -20,7 +20,7 @@ python3 tests/lumi_guide_narration_test.py "$ziran"
python3 scripts/generate-package-versions.py
python3 scripts/animation_inventory.py --check
python3 scripts/prepare-package-assets.py --apps-controller "$controller"
if [ ! -s build/package-assets/inbe/assets/apps/apps.zx ]; then
if [ ! -s "$controller" ]; then
echo 'Root Apps requires the reviewed Apps controller bundle; run make apps' >&2
exit 1
fi
+4 -6
View File
@@ -37,7 +37,7 @@ patterns = (
'assets/mcp/*.json', 'assets/app/icon.png', 'assets/app/icon-sky-cradle.png',
'assets/app/icon-ink-and-air.png', 'assets/easteregg/*.png', 'assets/pet/*.png',
'assets/apps/icons/*.png',
'assets/social/*.png', 'assets/profile-pictures/*.png',
'assets/social/*.png',
'assets/sounds/*.ogg',
'assets/habits/**/*', 'assets/lists/**/*', 'assets/diary/**/*', 'assets/lumi/**/*',
'assets/fonts/subset/*-App-Regular.*', 'assets/styles/*.kss',
@@ -108,8 +108,9 @@ for name in NODE_APPS:
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source, destination)
# Root launcher cards share the reviewed Apps controller. A node-only build
# can omit it; the root bundle build below requires this asset explicitly.
# Root launcher cards share the reviewed Apps controller. The host reads it
# from its own apps.zx asset beside the root package, so the root package
# does not carry a second copy. A node-only build can omit it.
apps_bundle = options.apps_controller.resolve()
if apps_bundle.is_file():
controller = apps_bundle.read_bytes()
@@ -117,9 +118,6 @@ if apps_bundle.is_file():
expected = re.search(r'AppsControllerSha256\s*::\s*"([0-9a-f]{64})"', source)
if not expected or hashlib.sha256(controller).hexdigest() != expected[1]:
raise SystemExit('Apps controller differs from the reviewed native digest')
destination = OUTPUT / 'inbe/assets/apps/apps.zx'
destination.parent.mkdir(parents=True, exist_ok=True)
destination.write_bytes(controller)
# Each app owns its bounded achievement catalog and translations, including
# optional node apps. Source presence never determines device visibility.
+2 -1
View File
@@ -43,7 +43,8 @@ ProfilePictureImage :: (icon_type: s32, label: string) -> ImageProps {
image.alt_text = label
if icon_type == 50 {
// The profile card needs more detail than the 64-pixel icon atlas.
image.asset_path = "assets/profile-pictures/flowers.png"
// Entity's copy in the root package is the same picture.
image.asset_path = "assets/entity/flowers.png"
image.fit = cast(ImageFit)ImageFitContain
return image
}
+3 -29
View File
@@ -1,31 +1,5 @@
// Trusted shared Apps UI reviewed for this host. Containers may carry these
// bytes, but cannot select or replace the host's controller trust anchor.
// Collections built before the ZX format carried ZIB controllers, which this
// runtime cannot run; earlier ZX controllers stay trusted for collections.
AppsControllerSha256 :: "a4c32798cb17c56ffe052cd5a35ba800df82674fdf851ab79b00720455d13398"
// Existing collections keep the controller from before the reorder gutter.
AppsControllerBeforeReorderGutter :: "a1b56259e0b8581188459cc366736feacda3969b2db3055e8425a81065b065e1"
// Existing collections keep the controller from before shared saved records.
AppsControllerBeforeSharedRecords :: "a99851fc40d67a8ca820841722ce2ddde5ca51844e0778c4762681570c488289"
// Previously reviewed collections keep opening while add-on downloads arrive.
AppsControllerBeforeAddons :: "f58bc6319a177d79ff6ce7668f5834473b070f0eb66a8fa11a5c175855198f80"
// The ZX controller before the download dialog and the fading carousel
// titles. Collections published with it, such as Arcade 0.7.49, keep opening.
AppsControllerBeforeDownload :: "b8733db7256c4e96f8f8bd198072dcc2c3fc4e66b266a9e396c40e88949d8011"
// Existing collections keep the controller from before separate downloads.
AppsControllerBeforeSeparateDownloads :: "20ad36d054088484f069e3e7aa72135762fe25354fb8249ca0a2fcc019834a48"
// Existing collections keep their controller when the cover library updates.
AppsControllerBeforeCoverGrid :: "0b350b5a5ae9813e9e0521ad6089bda78ee125483cefa09cf9062f42c3d70227"
// Collections that pack the controller from before small phone covers,
// such as Arcade 0.7.77, keep opening.
AppsControllerBeforeSmallCovers :: "5490a8e61f5fa218e813b6e3d78bece6198d2ed935c42fc77b7d5e4aeed9bfe3"
// Collections published before installation completion was retained.
AppsControllerBeforeInstalledDownloads :: "a81eb5b14d2066925d19c3fd922865af40c90673cf54fb11bd7f9bf89a29cb98"
// Controllers built before Ziran's saved IR format 59 cannot run here, so
// collections publish again with this controller.
AppsControllerSha256 :: "e41f568fade6b2fc1d622d42d57340ad4743c0cea281f410764b79fcefdf4ec0"
+2 -2
View File
@@ -1,5 +1,5 @@
// Generated from apps/versions.json. This host runs packages built for host
// interfaces from the oldest to the current one; module interfaces must match.
PackageHostAPI :: 40
PackageHostAPIOldest :: 12
PackageHostAPI :: 41
PackageHostAPIOldest :: 41
PackageModuleAPI :: 2
-8
View File
@@ -490,14 +490,6 @@ NodeTreeStart :: (runner: *NodeAppRunner, bytes: string, verified: string,
payload := cast(*TextDescriptor)(*bytes)
Sha256Hex(payload.data, bytes.count, *digest[0])
}
unused AppHostTrustHarness(host, AppsControllerBeforeSharedRecords)
unused AppHostTrustHarness(host, AppsControllerBeforeAddons)
unused AppHostTrustHarness(host, AppsControllerBeforeCoverGrid)
unused AppHostTrustHarness(host, AppsControllerBeforeSmallCovers)
unused AppHostTrustHarness(host, AppsControllerBeforeDownload)
unused AppHostTrustHarness(host, AppsControllerBeforeSeparateDownloads)
unused AppHostTrustHarness(host, AppsControllerBeforeInstalledDownloads)
unused AppHostTrustHarness(host, AppsControllerBeforeReorderGutter)
platform := AppPlatform.{.context = cast(*void)runner, .allows = NodeTreeAllows, .call = NodeTreeCall,
.widgets = NodeTreeWidgets, .save = NodeTreeSave, .state = NodeTreeState,
.effect = NodeTreeEffect, .bundle = NodeChildBundle,
+2 -2
View File
@@ -20,8 +20,8 @@ PackageBundledSequence :: (index: s32) -> s32 {
// them; an older one gives way to the bundled copy.
PackageHostAPIOldestFor :: (index: s32) -> s32 {
if index < 0 || index >= 7 {
return 12
return 41
}
oldest: [7]s32 = .[12, 12, 30, 31, 12, 12, 40]
oldest: [7]s32 = .[41, 41, 41, 41, 41, 41, 41]
return oldest[index]
}
+1 -1
View File
@@ -50,7 +50,7 @@ catalog_assets = bundle_assets(CATALOG.read_bytes())
catalog = json.loads(catalog_assets['assets/apps/catalog.json'])
assert catalog['id'] == 'inbe.arcade'
assert all(entry['bundle'] not in catalog_assets for entry in catalog['children'])
host_controller = bundle_assets(BUNDLE.read_bytes())['assets/apps/apps.zx']
host_controller = (ROOT / 'build/apps-ui/apps.zx').read_bytes()
controller_digest = hashlib.sha256(host_controller).hexdigest()
if catalog['harness'] in catalog_assets:
assert controller_digest == hashlib.sha256(catalog_assets[catalog['harness']]).hexdigest(), 'Catalog uses another controller'
+2
View File
@@ -76,6 +76,8 @@ class PackageVersionsTest(unittest.TestCase):
def test_root_package_needs_the_newest_bundled_host(self):
value = copy.deepcopy(self.ledger)
# The host range spans two interfaces, so only the root's pin is wrong.
value["host_api"] = value["oldest_host_api"] + 1
value["apps"]["inbe"]["host_api"] = value["oldest_host_api"]
value["apps"]["lumi"]["host_api"] = value["oldest_host_api"] + 1
self.write(value)
+5 -2
View File
@@ -181,8 +181,11 @@ class VersionTest(unittest.TestCase):
def test_unreleased_changes_keep_the_released_version(self):
code = re.search(r"versionCode (\d+)", self.read("droid/app/build.gradle"))[1]
name = "CHANGELOG.md"
self.write(name, self.read(name).replace(
"# Changelog\n", "# Changelog\n\n## [Unreleased]\n\n- A change waiting for the next release.\n", 1))
changelog = self.read(name)
if "## [Unreleased]" not in changelog:
changelog = changelog.replace(
"# Changelog\n", "# Changelog\n\n## [Unreleased]\n\n- A change waiting for the next release.\n", 1)
self.write(name, changelog)
self.assertEqual(self.check("--print-version").stdout, f"{self.version}\n")
subprocess.run(["bash", str(self.root / "update_version.sh")], capture_output=True, text=True, check=True)
self.assertEqual(self.check("--print-version").stdout, f"{self.version}\n")
+11 -11
View File
@@ -60,6 +60,14 @@
"source": true,
"url": "https://github.com/raysan5/raylib.git"
},
{
"commit": "ffebcc79b67496641587473e38e0cbea3cf49890",
"dependencies": {"crypto": "pc23fbf455e97614d", "kryon": "p31868b412b407f25"},
"id": "p5d084698913942da",
"name": "Apps",
"ref": "ffebcc79b67496641587473e38e0cbea3cf49890",
"url": "https://github.com/waozixyz/apps.git"
},
{
"commit": "22d2ddbdc236796953c905a05a2cebf5ab1b4ff3",
"dependencies": {"liboqs": "p563eec337af1337e"},
@@ -86,14 +94,6 @@
"source": true,
"url": "https://github.com/waozixyz/practices.git"
},
{
"commit": "becce9220e092d33b26a2ec106b93e43714f3946",
"dependencies": {"crypto": "pc23fbf455e97614d", "kryon": "p31868b412b407f25"},
"id": "p9c41020c62c76410",
"name": "Apps",
"ref": "becce9220e092d33b26a2ec106b93e43714f3946",
"url": "https://github.com/waozixyz/apps.git"
},
{
"commit": "3f888653b6b97010163d824c4cc72476be3214f3",
"dependencies": {"kryon": "p31868b412b407f25"},
@@ -154,12 +154,12 @@
}
],
"root": {
"dependencies": {"apps": "p9c41020c62c76410", "crypto": "pc23fbf455e97614d", "curl": "pd4bcd11b7d623073", "daochi_client": "pf7b24c15869d6839", "entity": "pdc16ac5fc40634fd", "game2d": "p20eb23d3e6db3711", "kryon": "p31868b412b407f25", "kss": "p1b13dda539ed2a39", "liboqs": "p563eec337af1337e", "mingcute": "pe1027b9d16704793", "monocypher": "p809b4d31a48625a3", "oqs": "p7098ac9cd92f7e5f", "plot": "pab5377a2950368a2", "practices": "p9079dde0fcc11248", "qrcode": "p0dfa70137405b096", "rini": "p09fa77e94b0dfc6c", "sqlite": "peaa43c4b7ef72edf"},
"dependencies": {"apps": "p5d084698913942da", "crypto": "pc23fbf455e97614d", "curl": "pd4bcd11b7d623073", "daochi_client": "pf7b24c15869d6839", "entity": "pdc16ac5fc40634fd", "game2d": "p20eb23d3e6db3711", "kryon": "p31868b412b407f25", "kss": "p1b13dda539ed2a39", "liboqs": "p563eec337af1337e", "mingcute": "pe1027b9d16704793", "monocypher": "p809b4d31a48625a3", "oqs": "p7098ac9cd92f7e5f", "plot": "pab5377a2950368a2", "practices": "p9079dde0fcc11248", "qrcode": "p0dfa70137405b096", "rini": "p09fa77e94b0dfc6c", "sqlite": "peaa43c4b7ef72edf"},
"name": "Inbe"
},
"toolchain": {
"commit": "5a1ce92f921be670c9777b7d46fa86ead3062519",
"ref": "5a1ce92f921be670c9777b7d46fa86ead3062519",
"commit": "c8c6c96c396f816a899ea8674e586d3396c27c40",
"ref": "c8c6c96c396f816a899ea8674e586d3396c27c40",
"url": "https://github.com/ziranlang/ziran.git"
}
}
+2 -2
View File
@@ -5,7 +5,7 @@ module_roots = ["src", "src/apps", "src/app", "src/core", "src/habits", "src/pra
[toolchain]
git = "https://github.com/ziranlang/ziran.git"
ref = "5a1ce92f921be670c9777b7d46fa86ead3062519"
ref = "c8c6c96c396f816a899ea8674e586d3396c27c40"
[dependencies.kryon]
git = "https://github.com/kryonlabs/kryon.git"
@@ -74,7 +74,7 @@ ref = "master"
[dependencies.apps]
git = "https://github.com/waozixyz/apps.git"
ref = "becce9220e092d33b26a2ec106b93e43714f3946"
ref = "ffebcc79b67496641587473e38e0cbea3cf49890"
# The practices' pictures, course data and recordings (scripts/practice_media.py).
[dependencies.practices]