fix(host): APPIMAGE is believed only when this program runs from that image

The AppImage launcher sets APPIMAGE (the image's file) and APPDIR (where
it is mounted) for the program it starts, and every program that one
starts inherits both: a terminal, an editor, an agent's app. The host's
start, the agent's pointer file, the host's check for a replaced program
and `update` each read APPIMAGE and believed it whenever it named a file.

So a wanderbooks run from inside another app's AppImage took that app's
image for its own:

- it started that image as the host, and the books never opened ("the
  books server keeps failing to start");
- `connect` would have written that image into the agent's pointer file;
- `wanderbooks update` replaced that app's file with wanderbooks.

Found by the batch's gate: the_host_outlives_the_app_scope_that_started_it
passes its own environment on (the other tests clear it), and this gate
ran in a session started from an AppImage app. The first and the third
are reproduced by two new tests, which fail without this change (the
update test read an ELF header where the other app's file had been).

The rule now (start.rs INVARIANT 6, from the AppImage documentation's
"Environment variables"): the image is this program's own only when
APPIMAGE is an absolute file, APPDIR an absolute folder, and the running
executable's file is inside APPDIR, compared as resolved paths. One
function decides (`own_appimage`), and all four readers ask it. The host
is handed APPDIR beside APPIMAGE, and neither unless both are its own.

No books and no figure are touched. The tests that pretend to be an
AppImage now set APPDIR as a launcher does; translocation.rs used a bare
APPIMAGE to stand in for a macOS path, the very thing this closes, and
names the program's folder as the mount.

The failing test's message now lists the lines that did arrive, which is
what showed the host was refused rather than slow.

Not checked against a built AppImage (none has been built with this
change): the first trial of one shows `update` and a restart find the
image.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude committed 2026-11-10 02:28:05 -07:00
1 parent 0178809a3d
commit 3bc198594b
12 files changed
+331 -52

No files matched your search

+15
View File
@@ -76,6 +76,21 @@ What the trial found, each of which is built around now:
`a_replaced_appimage_restarts_the_books` (the programs run from one
copy while `APPIMAGE` names another, as a mount does); not run against
a real image mount in this wave.
**That reading trusted the variable alone, and it was wrong**
(found 2026-11-10, when the gate ran in a session started from another
app's AppImage). Every program an AppImage app starts inherits
`APPIMAGE` and `APPDIR`, so a `wanderbooks` run from such an app's
terminal or agent took that app's image for its own: it started that
image as the host ("the books server keeps failing to start"), would
have named it in an agent's pointer file, and `wanderbooks update`
replaced that app's file with wanderbooks. The image is now believed
only when the running executable is inside `APPDIR` (`start.rs`
INVARIANT 6; `an_appimage_is_ours_only_when_the_program_runs_from_its_mount`,
`another_apps_appimage_is_never_run_as_the_host`,
`an_update_never_replaces_another_apps_appimage`). Still not run
against a real image mount: the first trial of a built AppImage checks
that `update` and a restart find the image there.
8. **Onboarding with no terminal does not exist yet.** The unit's Done-when
(1) says an AppImage "opens, onboards and posts an entry with no
terminal". The AppImage opens (a bare launch is the viewer), but the viewer