Store and permissions internals
How the native Store, the shared enzimos-app-permissions worker and Settings review installs, updates and Flatpak policy.
Application installation on enzimOS is split between two repositories:
| Repository | Role |
|---|---|
store | The native Store application (store-app, app ID io.github.enzui.Store). Browses flatpak.enzim.dev and Flathub, runs Flatpak reads and mutations, shows reviews and progress. |
enzimos-app-permissions | A single Rust binary, enzimos-app-permissions, that inspects and edits Flatpak policy and runs reviewed install and update transactions through libflatpak. |
Settings uses the same permissions binary for its Apps → App permissions page, so the Store and Settings share one implementation of policy reading and writing.
Why the Store is a native package
The Store ships as an OS package (enzimos-store) rather than as a Flatpak. It must start
and report errors even when the Flatpak runtime is missing or broken. Its runtime
dependencies are:
- the
flatpakexecutable, for every installed-app read and ordinary mutation (each is an argument array, never a shell string); curl, for Flathub JSON metadata;- libcurl through the framework's transport, for icons and screenshots;
- optionally the XDG Desktop Portal
OpenURIinterface, for publisher links.
If flatpak is absent, the Store still opens and every view reports that it could not read
the system instead of showing an empty list.
Catalogue and metadata
Flathub metadata is fetched from fixed origins with HTTPS only, no private-network targets and no redirects. The catalogue is persisted so the first view paints from disk, followed by a background refresh; an offline refresh keeps the saved catalogue.
Installed names and descriptions come from a bounded local flatpak list query, including
sideloaded apps. Per-app Flathub lookups are only made for IDs already present in the public
catalogue; a remote name, URL or deep link alone cannot trigger one, so a private app ID never
leaks to Flathub.
Icons for locally installed apps are read directly from the active deployment with retained file descriptors. The reader refuses path traversal, followed symlinks and unexpected owners, caps each icon at 1 MiB, decodes to 64×64 RGBA, and attempts at most 128 rows per batch. Scalable icons are rasterised without resolving external images or loading fonts.
Installation scopes
Store installs go to the per-user installation (flatpak --user). The preinstalled apps live
in the system installation; updates to those go through the system installation and Flatpak's
polkit-backed system helper. Removal of system apps is an administrator action. Named
installations are not supported.
The permissions worker protocol
enzimos-app-permissions reads exactly one JSON request on stdin (at most 1 MiB) and writes
one JSON response on stdout. It is a per-user worker, not a privileged policy authority.
Callers supervise it with cancellation, an overall deadline and an output bound. Every request
carries schema_version: 1.
printf '%s' '{"schema_version":1,"method":"inspect","subject":{"app_id":"org.example.App","scope":"user"}}' \
| enzimos-app-permissionsResponses have ok and result, or error. A refusal may include a fixed reason code such
as runtime-unavailable, app-not-found, untrusted-source, out-of-space,
review-stale or installed-source-changed. Reasons are derived from the libflatpak error
domain and code, never from a message, path or URL.
| Method | Input | Result |
|---|---|---|
inspect | subject: {app_id, scope} with scope user or system | Commit, metadata, Flatpak's computed context, four source layers, review token, limitations |
apply | subject, review_token, changes, optional reset | Verified new snapshot, or an explicit "readback unavailable" status |
portal.inspect | app_id | That app's remembered portal grants and per-table status, plus a review token |
portal.change | app_id, review_token, table, resource, values | Modified grant and readback; null values reset only this app's grant |
install.review | app_id, user remote name, optional branch and arch | Resolved app and runtime commits and metadata; aborted before deployment |
install.confirm | as review, plus review_token and changes | Re-resolved exact plan, restrictions saved first, installed commit readback |
update.review / update.confirm | same fields as install | Reviewed update of one existing user application |
Static policy edits
An override edit is {category, value, allow}. Supported categories are shared, sockets,
devices, features, filesystems, session_bus, system_bus, environment and
persistent (additions only). Bus values use well.known.Name=talk or =own; environment
grants use NAME=value and revocation uses NAME. There is no request that passes arbitrary
flatpak options.
The computed context returned by inspect is Flatpak's own info --show-permissions output.
It is not a complete runtime access model: launch arguments and runtime conditionals can
change effective access, and clients must show that caveat. Unknown groups and escaped values
are returned as-is and shown read-only.
User overrides can restrict both user-installed and system-installed apps for the current
user. System-wide policy is never written. Layers that do not apply to a given installation
report status: not-applicable.
Review tokens are optimistic consistency checks, not authentication. Concurrent workers
serialize inspect, token comparison and the user override write on an exclusive lock in
$XDG_RUNTIME_DIR; without that lock, writes are refused. Readback failures are reported
separately, and the worker never blindly undoes an unknown state. Apps must restart to pick up
static policy changes.
Portal grants
Portal reads cover the devices, location, notifications, background,
desktop-used-apps, inhibit, access, screenshot and screencast tables of the
permission store. Only the requesting app's grants are returned; other apps' mappings never
leave the worker. A table with more than 128 resources reports status: too-large and
contributes no grants.
Only existing grants are editable, and yes/no changes are limited to recognised semantics:
devices (camera, microphone, speakers), notifications and background. Location
accuracy, document grants and other formats stay read-only. Resetting uses the permission
store's DeletePermission, never Delete. Portal writes are last-writer-wins at the provider;
the worker validates the reviewed state and reads the result back.
Static and portal policy are independent. Broad static access (host files, all devices, PulseAudio, the session bus) bypasses portal-specific consent, and clients should avoid a misleading microphone switch when direct audio access already exists.
Reviewed install transactions
Installation consent binds the full resolved libflatpak transaction, not a standalone metadata
query. The review runs inside the transaction's ready callback and aborts before deployment.
Each app and runtime commit, the complete metadata, each remote's URL, collection and
signature properties, and the source override layers contribute to the review token.
install.confirm resolves again and refuses a changed plan. Because the token does not cover
the edits made in the dialog, confirmation edits may only add restrictions
(allow: false). Restrictions are written before deployment; if installation then fails,
they remain, and the response says so. Unknown operation types and missing commits fail closed.
Like flatpak install --user, transactions use system installations as dependency sources.
Branch and arch default to the remote's default branch (else stable) and the machine's
architecture.
With stream: true, install.confirm emits newline-delimited progress frames before the
final response:
{"event": "install.progress", "ref": "…", "package": 1, "packages": 2, "operation_percent": 40}At most 101 frames are emitted per operation. Progress is not an ETA, and only the final verified reply means success. A download that produces no transaction signals for 300 s is cancelled; after download completes, only the 6-hour overall bound applies.
Reviewed updates
update.review and update.confirm operate on one unambiguous installed user application,
keeping its installed branch and origin. The plan binds old and new commits, metadata, source
identities and current override layers. Added permissions, removed denials, mode increases and
opaque or conditional changes set requires_consent; unchanged or clearly reduced access does
not. Confirmation always re-resolves and checks the token, including for no-op updates, and
success requires reading back the installed commit. Progress frames use update.progress.
Assistant access
With its center build feature, the Store registers with the
MCP Center under io.github.enzui.Store and exposes three functions:
| Function | Risk | Behaviour |
|---|---|---|
search_apps | read-only | Searches the catalogue; query (1–100 chars), optional limit (1–50, default 20) |
list_installed | sensitive read | Lists installed app IDs, names and versions |
show_app | mutating | Opens an app's detail page in the Store window |
Installation, updates and repository changes are not exposed and require the ordinary UI.
Offline default Flatpaks
The installer image can carry Flatpak apps for offline installation. The selection lives in
the manifests repository at development/default-flatpaks.json; currently it contains Zen
Browser, app.zen_browser.zen on the stable branch. A workspace tool pulls and verifies the
apps and runtimes in a private Flatpak installation and exports a flatpak create-usb
repository, which the image build embeds.
At install time, the installer adds the Flathub remote system-wide, sets its collection ID
(org.flathub.Stable, which sideloading requires), and installs with --sideload-repo
pointing at the medium. Signatures are still checked against Flathub's key, and later updates
come from Flathub normally. Hardware-specific GL extensions are not included and are fetched
online later.
Building and testing
The Store's connector-enabled suite runs with a software renderer:
env -u XDG_DATA_HOME ICED_TEST_BACKEND=software \
cargo test --offline --locked --features center --bin store-app -- --test-threads=1The permissions worker's tests use fakes for the flatpak CLI and the portal store.
qualification/real-flatpak.sh exercises the binary against real libflatpak in a private user
installation with an unsigned, test-only local remote.
See packaging for how both are built into OS packages, and framework integration for the Store's framework pins.