Commit graph

241 commits

Author SHA1 Message Date
6055e0b0a0
fix(runtime): keep helper error messages, and send notification bodies as plain text
Discarding wl-copy's output also lost its error message, such as a
missing Wayland connection. Its standard error is now kept and read
only when it fails, which is always before it leaves its selection
server.

Other fixes:
- An output over the limit is reported as such, instead of as the
  helper dying of the broken pipe.
- The clipboard is read as any text type, since the content is checked
  as UTF-8 anyway.
- Notification bodies are sent with markup escaped, since notification
  servers may render links and images.
- A failed wait for a helper kills and reaps it.
2026-10-09 19:30:47 +00:00
0c9b2c2b0d
fix(runtime): do not wait for the process wl-copy leaves serving the selection
wl-copy forks a process that keeps serving the selection. That process
inherits the helper's output pipes, so reading them to the end would
block a clipboard write until the selection changed. wl-copy's output is
now discarded, and its failure is reported by exit status.
2026-10-09 19:27:39 +00:00
cb4e50b78c
fix(runtime): bound the clipboard and notification helpers, and attribute notifications
The clipboard and notification imports ran wl-paste, wl-copy and
notify-send with no deadline and no size limits, and took the clipboard
text whole. A notification's icon could be any path or URL, and nothing
said which app sent it, so an app could pass one off as the system's.

Each helper now runs with a 5-second deadline, after which it is killed
and the call fails. Clipboard text is at most 1 MiB in either direction.
A notification's title is at most 256 bytes and its body 4096, its icon
must be an icon theme name, and it is sent with the app's ID as the
application name.

Unit tests run real processes for the deadline, the output limit, input
passing and failure reporting, and check the notification bounds.
check_grants.py still passes.
2026-10-09 19:26:47 +00:00
36ae676d83
fix(runtime): close the IPC socket when the connection ends, and do not count refused growth
When the runtime ended an IPC connection, it only marked it closed.
weft-appd therefore kept a session whose messages went nowhere. The
socket is now shut down, so weft-appd ends the session as it does when a
component closes the connection.

A growth past a memory's or table's own maximum is refused without
being counted against the store's limit, since Wasmtime would reject it
anyway.
2026-10-09 18:42:18 +00:00
cbc984eef6
fix(runtime): limit a component's memory in total and end IPC on failed sends
The memory limit applied to each linear memory separately, so a
component made of several core modules could multiply it. A limiter now
accounts all memories together, and bounds table elements, memories,
tables and core instances.

IPC fixes:
- A failed or timed-out send (10 seconds) ends the connection, since
  part of the line may already have been written.
- A line over the limit ends the connection, also when its newline
  arrives in the same read.
- A line that is not UTF-8 is dropped and logged.

TasksMax is raised to 512, since the runtime runs a few threads per CPU.

Counter and Notes still run under the limits (check_counter.py and
check_notes.py), and check_grants.py passes.
2026-10-09 18:39:05 +00:00
044634692f
fix(runtime): bound component memory and app messages
The runtime set no limits of its own:
- A component could grow its linear memory until the host ran out, with
  no ceiling at all where systemd is unavailable.
- An app message could contain line breaks and split into several
  messages.
- An overlong message from weft-appd was buffered without bound.
- A closed connection looked the same as an empty one.

The Wasmtime store now has a limiter: linear memory is capped at 256 MiB
by default (--max-memory-mib changes it), and tables and instances are
bounded too. A memory that would grow past the limit does not grow, and
the component sees an allocation failure.

App messages are single lines of at most 64 KiB, the limit weft-appd
applies. A longer message, or one containing a line break, is refused.
A longer line from weft-appd ends the connection, and sending afterwards
reports that it is closed. The systemd scope also gets TasksMax=64.

The grants probe component now also tries a 300 MiB allocation and the
two refused messages. tests/runtime/check_grants.py checks that the
allocation fails at the default limit and succeeds with a 512 MiB
limit.
2026-10-09 18:23:07 +00:00
5c82b540e6
Merge fix/resolve-verified-package: resolve each launch to one package and fail closed on images (#16)
weft-appd resolves each launch once: a verified image in any store wins over a directory install and must mount or the launch is refused, with no fallback to a mutable directory. The manifest must declare the requested ID and its entries must be contained regular files without links. weft-runtime receives --module and weft-app-shell --ui; neither searches the stores. Grants come from the same manifest and the mount belongs to the session. The manifest parser and image file names are shared through weft-ipc-types with weft-pack.
2026-10-09 14:53:49 +02:00
cad8c016d6
Merge remote-tracking branch 'origin/main' into fix/resolve-verified-package 2026-10-09 12:50:31 +00:00
c0fdca18b6
Merge fix/confine-app-renderer: confine application pages to their UI files and bridge (#15)
weft-app-shell checks every resource load: files inside the UI directory, also after resolving links, inline data: and blob: resources, about:blank and the session bridge are allowed; other files and network destinations, redirects and loads not tied to the webview fail before a request leaves the renderer. The Servo pin moves to e5d9a51, which keeps pending classic scripts traced until they run and withholds navigator.servo from about:blank and about:srcdoc documents.
2026-10-09 14:50:24 +02:00
ba82535ae2
Merge remote-tracking branch 'origin/main' into fix/confine-app-renderer 2026-10-09 12:33:46 +00:00
8214c12d7e
Merge fix/session-owned-ipc-relay: make the IPC relay part of the session it serves (#14)
The session supervisor opens and owns each session's IPC relay; every exit path stops the relay task, removes its socket and unregisters its sender. A session ends when its IPC connection closes. IPC_FORWARD never waits on a component and reports an error for a missing relay or a full queue. appd's runtime directory is created mode 0700 and the relay socket 0600.
2026-10-09 14:33:28 +02:00
969f719d2d
Merge remote-tracking branch 'origin/main' into fix/session-owned-ipc-relay 2026-10-09 12:18:43 +00:00
84930b13d8
Merge fix/separate-app-data: keep app data apart from installed packages (#13)
App data lives in $XDG_DATA_HOME/weft/app-data/<id>, private to the user, and is moved from the earlier layout in one no-replace rename; conflicting or cross-filesystem data is never moved or deleted. weft-pack never removes a data directory with a package. Notes stores text exactly, refuses saves edited from a stale revision and writes through a locked, synced staging file.
2026-10-09 14:18:28 +02:00
1f58a7be11
Merge remote-tracking branch 'origin/main' into fix/separate-app-data 2026-10-09 11:57:17 +00:00
744acc8164
Merge fix/enforce-session-grants: enforce effective capability grants per session (#12)
weft-appd derives each session's grants once, before the session exists, from one shared capability vocabulary and refuses packages it cannot satisfy. weft-runtime receives them as --grant and --preopen arguments, preopens read-only directories read-only and checks every notifications, clipboard and fetch call. Fetch is limited to http and https to granted hosts, standard methods, no Host or hop-by-hop headers, unfollowed redirects and bounded time and size.
2026-10-09 13:56:57 +02:00
6f2f566fe4
Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package
# Conflicts:
#	crates/weft-runtime/src/main.rs
2026-10-09 11:43:01 +00:00
b45fe27e9b
Merge remote-tracking branch 'origin/fix/session-owned-ipc-relay' into fix/confine-app-renderer 2026-10-09 11:37:44 +00:00
cda9c14426
Merge remote-tracking branch 'origin/fix/separate-app-data' into fix/session-owned-ipc-relay 2026-10-09 11:37:17 +00:00
b17b74f310
Merge remote-tracking branch 'origin/fix/enforce-session-grants' into fix/separate-app-data 2026-10-09 11:36:27 +00:00
12e4c1d91a
Merge remote-tracking branch 'origin/main' into fix/enforce-session-grants
# Conflicts:
#	.gitignore
#	README.md
#	docs/building.md
2026-10-09 11:30:01 +00:00
0ab429b2ea
Merge fix/authorize-session-messages: authorize WebSocket clients by role and session (#11)
weft-appd's WebSocket requires HELLO within 5 seconds. A system role authenticated with appd.systoken manages sessions; an app role authenticated with a per-session bridge token exchanges APP_MESSAGE envelopes with its own session only. The Servo hosts hand credentials only to their own top-level documents and deny navigation outside them.
2026-10-09 13:28:43 +02:00
8eed654be7
fix(appd): let no directory shadow an image, and refuse linked roots
- A verified image in any store now takes precedence over a directory
  install in any store, so a user's directory cannot shadow a system
  image of the same app.
- The package root must be a directory and wapp.toml a regular file,
  not links to content outside the root the entries are checked in.
- Incomplete or malformed image metadata is refused with 403; a
  missing helper, a failed mount or an unreadable manifest with 500.
- A supervisor test records the arguments of both children and
  requires the resolved component and UI document.

The documentation states that the root hash is read from the store
and not yet authenticated.
2026-10-09 11:08:41 +00:00
04cde8901c
Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package 2026-10-09 10:29:32 +00:00
fecf4c5b55
fix(app-shell): report a UI path that is not absolute 2026-10-09 10:29:32 +00:00
1641bf31a8
build(servo): trace pending classic scripts instead of rooting them
Servo e5d9a51 replaces the root that kept a pending classic script
alive with tracing through the document that holds it. A root also
kept the script's global alive, so a document dropped while a script
was pending would leak. The crash the root fixed stays fixed.
2026-10-09 10:29:24 +00:00
e2f9746fb5
Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package
# Conflicts:
#	docs/architecture.md
2026-10-09 10:18:47 +00:00
d056045ad8
test(appd): launch complete packages in the supervisor tests
Launch tests wrote manifests without names, versions or entries, which
the shared parser rejects. They now write complete packages.
2026-10-09 10:18:36 +00:00
687439a2a3
test(frame): make the worker and srcdoc confinement probes observable
Servo refuses worker scripts for file: pages, blob: ones included, so
the worker probe now requires only that no worker fetch succeeds, and
the worker is built from the page itself. The srcdoc frame reports to a
listener installed before the frame exists. Band failures and requests
that reached the servers are reported together, so a run without the
policy shows every leak.
2026-10-09 10:16:22 +00:00
2148ffc8ae
fix(appd): resolve each launch to one package and fail closed on images
The runtime, the app shell and grant derivation each searched the
package stores and parsed wapp.toml on their own, so they could use
different roots; the runtime ignored [runtime].module, the image loader
looked for companion files the builder never wrote, and a failed image
mount fell back to the mutable directory install.

weft-appd now resolves a launch once: a verified image wins over a
directory in the same store, and when any image file exists the image
must mount or the launch is refused. The manifest must declare the
requested ID, and both entries must be plain relative paths to regular
files without links. The runtime receives --module and the app shell
--ui; neither looks for the package. Grants come from the same
manifest, and the mount belongs to the session.

The manifest parser and the image file names move to weft-ipc-types,
shared with weft-pack, whose check now applies the same entry rules.
Mapper devices are named after their per-launch mountpoint, so
concurrent sessions no longer collide.
2026-10-09 10:03:40 +00:00
16a184ad9e
fix(app-shell): close the remaining paths out of the application page
Review of the renderer policy found loads it did not see or judged
wrongly:

- Loads Servo does not attribute to the webview, such as
  navigator.sendBeacon(), reached the network. They are all refused.
- On a redirect Servo reports the first URL again, so every redirect
  is refused.
- A symbolic link inside the UI directory led anywhere on disk; file
  loads are checked again after resolving links.
- Only about:blank is allowed among about: URLs.

The Servo pin moves to 5d90f51, which keeps compiled classic scripts
rooted until they run (a parser-blocking script waiting for a failed
stylesheet import crashed the content process) and withholds
navigator.servo from about:blank and about:srcdoc documents.

The confinement check gains probes for links, workers, beacons,
imports, fonts and srcdoc frames, and its WebSocket server completes
the handshake. The slow stylesheet's delay now starts when the host
first tries to open it.
2026-10-09 10:03:30 +00:00
d60152f443
fix(app-shell): confine application pages to their UI files and bridge
An application page could load any local file through file: URLs and
reach any network destination with images, fetch, XHR or WebSockets,
bypassing the component's fetch grants. The shell now checks every
resource load: files inside the UI directory, inline data:, blob: and
about: resources and the session bridge are allowed; anything else
fails with a network error before a request leaves the renderer.

tests/frame/check_confinement.py probes each path on the nested desktop
and requires that no HTTP request or TCP connection reaches the host.
The frame check's slow stylesheet becomes a file next to the page held
back with a file lease, so it stays inside the confined scope.
2026-10-09 09:39:37 +00:00
010573eb16
fix(appd): create the runtime directory private wherever it is made
appd created $XDG_RUNTIME_DIR/weft with the umask mode when it opened
its own socket, wrote its port or system token, or opened a portal
socket, so the 0700 mode requested for session sockets never applied.
All of them now use one helper that creates the directory 0700 and
tightens an existing one.
2026-10-09 09:27:28 +00:00
ec00531c75
test(appd): give each test process its own runtime directory
Session sockets are named by session ID and every test registry starts
at 1, so test processes running at the same time shared one socket path
in the common test runtime directory and broke each other's sessions.
Each test process now uses its own directory under the system temporary
directory, and directories of ended test processes are removed. The
test of a closed IPC connection connects to the socket itself instead
of relying on python3 in a child script.

A session whose component closes its IPC connection during startup now
stops before it is reported ready. The weft runtime directory is
created with mode 0700, and the socket is removed if its permissions
cannot be restricted.
2026-10-09 09:24:49 +00:00
67bce2fb22
Merge branch 'main' into fix/authorize-session-messages 2026-10-09 09:19:26 +00:00
5174a58d47
Merge pull request #9: report sessions running only after the UI host is ready
Sessions become Running only after token-authenticated READY from the runtime and the app shell, and every exit path shares one teardown.
2026-10-09 11:19:16 +02:00
818a831895
Merge pull request #6: stop reporting readiness without an engine
A runtime built without wasmtime-runtime now exits with an error instead of printing READY; its env-dependent tests are serialised.
2026-10-09 11:19:13 +02:00
26bd5b5079
fix(appd): end sessions whose IPC connection closes and never block on it
IPC_FORWARD held the registry lock while awaiting a send to the
component; with a full queue it stalled appd, and once the relay was
closed it locked the registry again and deadlocked. It now sends without
waiting and reports an error when the session has no relay or its queue
is full.

A relay whose component disconnected left the session running with no
way to exchange messages. The session now stops when its IPC connection
closes. The relay releases its task and socket when dropped, so a
cancelled supervisor leaks neither, and the socket is created with mode
0600.

New tests fail against the previous code: IPC_FORWARD against a missing
relay and a full queue must answer at once, and a runtime that closes
its IPC connection while still running must end its session. The test
runtime directory lives under target/ instead of one directory per run.
2026-10-09 09:18:39 +00:00
ac6559a814
Merge pull request #10: add the stability blueprint, engineering contract and contributor toolkit
BLUEPRINT.md defines the 0.1.0 target; AGENTS.md and .agents/ give the contribution procedures and checks.
2026-10-09 11:14:20 +02:00
d9d9d24205
fix(appd): make the IPC relay part of the session it serves
dispatch opened each session's IPC socket and registered its sender
before the supervisor existed, and nothing released them: a relay whose
runtime never connected waited forever with its socket file in place,
and every stopped session left its sender registered, so app messages
for it were still accepted and queued.

The supervisor now opens the relay after its early checks, and the
session owns it: every exit path stops the relay task, removes the
socket and unregisters the sender. A session whose socket cannot be
opened does not start. The relay accepts a single connection.

A dispatch-level test launches a package whose runtime reports ready
and exits without connecting; it requires the stopped session to leave
no sender and no socket, and fails against the previous code. The
Counter and Notes checks pass end to end.
2026-10-09 09:11:35 +00:00
481495d929
fix(notes): show loading status and check the editor after a failed load
The first load showed an empty status while the editor was read-only;
it now says loading. check_notes.py also types and saves after a failed
load and requires the stored file to stay unchanged.
2026-10-09 09:07:27 +00:00
c1ea57fbef
fix(notes): keep Discard usable after a failed load
Discard waited for a stored revision, so after a load failed (stored
notes not valid UTF-8, a read error, a lost reply) the editor stayed
read-only with no way to reload. The page now tracks the outstanding
load itself: Discard is refused only while a load or save is in flight,
a load error or a ten-second timeout ends the load, and Discard retries.

A save acknowledgement arriving after its timeout and after Discard had
started a reload replaced the saved state while the editor still showed
older text, so the next save would silently revert it. Acknowledgements
are ignored while a load is outstanding, and a reload forgets the last
save.

The component removes a lock whose token could not be written and
cleans up renamed stale locks with the abandoned staging files.
check_notes.py adds a failed load followed by a repaired file and
Discard; the previous package stays read-only there and fails.
2026-10-09 09:05:25 +00:00
87436d0e08
fix(notes): apply only the outstanding load and own the save lock
A second load reply, from Discard clicked twice or during the first
load, replaced the editor again after it had become editable. Only the
reply to the outstanding load is applied now, and Discard does nothing
while a load is outstanding.

The save lock holds an owner token and is released only by its owner; a
stale lock is renamed away before removal, so two saves cannot both take
it over. A save removes only a staging file it created and, holding the
lock, removes staging files left by saves that ended before their
rename. A save acknowledgement arriving after the page's timeout is
still accepted, and text that cannot be encoded is refused before it is
sent. app.wasm is rebuilt and the package re-signed with the demo key.
2026-10-09 09:01:28 +00:00
1928ffb661
fix(pack): never delete a data directory that was not moved
weft-pack uninstall moved earlier app data only when the package
manifest could be read and declared an app-data capability, and only
when the store path was spelled exactly as the user store; otherwise it
removed the package directory with the data in it. A directory left
holding only data by an earlier weft-appd, which has no manifest, was
deleted that way.

A data directory is now never removed with a package. In the user
store, recognised by its real location rather than its spelling, it is
moved when the package declares app data or its manifest cannot be
read; in every other case uninstall stops and changes nothing. Tests
cover a directory holding only data, a store reached through '..', a
symbolically linked home, an app without the capability and another
store.

weft-appd reports both locations when a move fails with an I/O error and
creates the data directory with mode 0700 instead of tightening it
afterwards.
2026-10-09 09:01:28 +00:00
d2bc176344
Merge branch 'main' into fix/appd-session-readiness
# Conflicts:
#	crates/weft-appd/src/runtime.rs
2026-10-09 08:57:41 +00:00
e3c2e80142
Merge branch 'main' into fix/runtime-stub-readiness 2026-10-09 10:57:06 +02:00
8ae7b8517c
docs: describe the portable profile without implying other hosts
The portable checks run on Linux only; they cover the crates that need
no Linux system libraries.
2026-10-09 08:57:00 +00:00
1e344d684d
docs: name the portable CI job in the verification runner
The portable profile mirrors the CI job that now runs on Ubuntu only
under the name portable.
2026-10-09 08:56:50 +00:00
4d39ec3a8b
Merge branch 'main' into docs/add-engineering-contract 2026-10-09 08:56:42 +00:00
87222599f1
Merge pull request #8: verify native pointer and keyboard input through weft-compositor
tests/frame/check_input.py drives a page through weft-compositor with real X input and checks the presented pixels.
2026-10-09 10:56:29 +02:00
ce40916a98
Merge pull request #4: build and test on Linux only
The Windows CI job tested no supported configuration; the portable checks now run on Ubuntu only.
2026-10-09 10:56:22 +02:00