Table of contents

Processes, native bundles and the broker

PlannedPwshUpdated 2026-10-02

Status: design, 2026-10-02. Each capability below is its own gate with its own receipt; none is proven yet. Policy citations are system/sepolicy 7595d4f4 and frameworks/base 299fe6f5, as in AGENTS.md.

Pwsh is meant to replace a terminal app for real work: run tools, compile code, extend itself, without an old target SDK and without a store. Android allows all of that through two doors, and the line between them decides every design below.

Managed code: anything, on the device

An app may JIT into executable memory in its own process (app.te:199) and read its own files (untrusted_app_all.te:27). So:

Native code: built on the PC, shipped signed

Native code therefore reaches the device only through the package installer: in the APK, or later in a signed split APK added to the installed app (PackageInstaller.MODE_INHERIT_EXISTING, PackageInstaller.java:2227).

User native bundles

Every user builds and signs their own APK; the signing key is generated per user and stays in %LOCALAPPDATA%. Bundling their own libraries and executables is one more input:

Which Linux binaries run

Binary Runs Why
Built with the NDK (bionic) Yes Android's own loader and libc
Statically linked (Go, Rust or C against static musl) Usually No loader or libc needed
Dynamically linked against glibc Only with its loader bundled It asks for /lib/ld-linux-aarch64.so.1, which Android lacks; launch it through a bundled loader with --library-path

Expect occasional failures from the app's seccomp filter (an unusual syscall ends the process) and from tools that assume Linux paths such as /etc/resolv.conf. The broker addresses the second.

The broker

The broker gives bundled binaries what Android lacks, without a proot container and without PowerShell on any per-syscall path.

proot traces every syscall of the child and rewrites it transparently, which is general but stops the process on each call. The broker needs the binary's cooperation (the shim or the protocol) and in return costs nothing on the data path.

Layered loading

Loading is layered the way PATH is: a newer layer shadows an older one, so most updates need no APK.

Layer, checked first to last Holds Updated by
Admitted overlay, in private storage Managed assemblies: lowered code and newer builds of shipped ones, SMA included The device or the paired PC, without the package installer
APK store Everything shipped A signed APK or split

An APK update is then needed only for native changes: the host itself, native bundles, and the shipped public key.

Updating outside a store

The PC builds and signs with the user's key; updates install as a full APK or as a split added to the installed app, and the app can start its own update through PackageInstaller with the install-packages permission, which Android confirms with the user. Whether a sideloaded app that is its own installer of record can update without that confirmation on current Android is not yet traced in the pinned source.

Building APKs on the device

setup.ps1 needs only what the payload already ships (Reflection.Emit, Reflection.Metadata, compression, HTTP, cryptography), so the app can run it. With layered loading, an APK carries only what cannot be overlaid: the native host, the manifest (package name, permissions, activities, icon), the signer identity, native bundles and the store baseline. Rebuilding is for adding a capability, not for changing code.

That makes the phone an APK factory: from a script or a tile, build a new app with its own package name, icon and permissions on the shared runtime baseline (about 15 MB today), with the script as its start point. A new package has no key conflict, since Android requires the same key only to update an existing package; each generated app gets its own key in Android Keystore and installs through PackageInstaller with the user's confirmation.

Emitting the host's ELF on the device needs the rule change proposed below. The work is tested in separable parts:

  1. Build: run setup.ps1 on the device and compare its APK with the PC build of the same inputs, byte for byte wherever the build is deterministic. Pure evidence; no policy change.
  2. New package: build a different package (a script or tile as its own app) on the device, sign it with a Keystore key, install it, and run it.
  3. Install as an update: Android installs an update only when it is signed by the installed app's key, which today never leaves the PC. This needs a decision: a device key in Android Keystore from the first install (the PC can then no longer update that install), or key rotation through APK Signature Scheme v3, which setup.ps1 does not yet emit (it signs with v2). It also needs a rule change: AGENTS.md allows native machine code to be emitted only by the build machine, and setup.ps1 emits ELF. Proposed wording: native code may be emitted on the device only by setup.ps1 itself, into an APK that reaches the device only through the package installer, with the same decode-back and ABI checks as a PC build.

Examples

The pattern: protocols and logic in PowerShell or IL, heavy lifting through Android's own system APIs, native code only when nothing else exists, built on the PC and shipped signed.