weft-runtime and weft-app-shell logged to standard output, which carries
their readiness line to weft-appd. weft-appd keeps that stream only at
debug level, so the runtime's warnings and errors, such as a failed
grant or an ended IPC connection, never reached its log, and the lines
carried terminal colour codes.
Both now log to standard error, which weft-appd records at info level,
with colours only on a terminal. In the nested desktop Counter check,
the runtime's own lines appear in weft-appd's log; the grants check
reads the hangup message from standard error.
A runtime outlived the weft-appd that started it. Runtimes run in their
own systemd scopes, outside weft-appd's service, and a component that
waits for messages, as the Counter and Notes demos do, keeps polling a
closed connection forever. Each time weft-appd stopped or restarted and
restored the previous session, the earlier runtimes stayed behind.
The connection is the session: a thread waits for it to hang up, without
reading from it, and the runtime then exits whatever the component is
doing. That covers weft-appd closing the connection, weft-appd ending,
and the runtime ending the connection itself after a failed send or an
overlong message. A runtime given an IPC socket it cannot connect to now
fails instead of running unreachable. weft-appd's relay notes that it
must not shut down half of the connection, which would now end the
session.
tests/runtime/check_grants.py runs the real runtime on the Counter
component over a Unix socket: it answers an increment, and once the test
closes its end the runtime exits with status 0 within 10 seconds; with
the watcher removed it keeps running and the check fails. A unit test
checks that the wait sees a hangup but neither wakes on nor consumes
pending data; CI's runtime-grants job now runs the runtime's unit tests
with its features. The nested desktop Counter and Notes checks pass with
this runtime.
The launcher button, app icons and taskbar entries were custom elements
with click handlers only: none could be focused, named or activated from
the keyboard, and the launcher overlay neither took nor returned focus.
They are now buttons with accessible names and a visible focus ring. The
launcher is a modal dialog that a Super tap or the Apps button opens
with focus on its first app; Tab moves between apps, Enter opens one and
Escape or another Super tap closes it, returning focus to the Apps
button. Each taskbar entry has an activate and a close button reachable
with Tab, and focus moves to a remaining control when an entry closes or
goes away. Notifications, including the offer to force quit, are
announced as status.
Servo does not tell the document when its window loses keyboard focus,
so weft-servo-shell calls window.weftShellBlurred() then and the launcher
closes; the next Super tap opens it again. Servo does not evaluate
prefers-reduced-motion either, so the page has no transitions.
tests/frame/check_system_ui.py drives the real page on the nested
desktop with keys: opening apps from the launcher, reaching the shell
with a Super tap from an application, a Super chord that stays with the
app and leaves no Super modifier held there, activating and closing apps
from the taskbar, the launcher closing when the shell loses focus, and
toggling it. It fails without the compositor's Super handling or the
focus-loss call.
The catalog followed the store's directory listing, so the launcher's
order, and with it its keyboard order, could change between scans. Apps
are listed by name, ignoring case, then by ID.
From an application window there was no keyboard path to the system
shell: only a pointer click on the taskbar strip raised the panel.
The Super keys now belong to the compositor and are never delivered to
an application. A tap, Super pressed and released without another key,
activates the shell's panel, raising it with keyboard focus, and then
delivers the tap to it so the shell can open its launcher; a key or a
pointer button pressed meanwhile makes it no tap. Keys pressed while
Super is held reach the focused window with the Super modifier: a client
is sent the modifiers whenever a key the compositor takes changes them,
so none stays held there. With several panels, the first registered one
is the shell's.
The frame limit constant was inserted between spawn_ipc_relay's doc
comment and its cfg(unix) attribute, so the attribute applied to the
constant instead. A non-Unix build would have had two definitions of
the function.
The size is now checked before the line ending, so a frame one byte
over the limit is refused even when its line break arrives in the same
read. A message that is not UTF-8 ends the relay, as it did before,
rather than reaching the page with replacement characters. The test now
also covers a message at exactly the limit ending in CRLF.
The session's IPC relay read component messages with read_line inside
select!, into a buffer created anew on each pass. When a message from
the page won the select while a component message was half read, the
read part was lost, and the page received the remainder as a message of
its own. The line was also unbounded.
The relay now keeps the frame being read across passes and fills it
with read_until, which keeps partial reads when cancelled. It ends the
relay on a line longer than any message the runtime sends.
A new test writes half a component message, has the relay forward a page
message, then completes it and checks that it arrives whole. On the
previous code the test receives only the second half. It also checks
that an overlong line ends the relay.
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.
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.
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.
Pruning compared a list of the declared capabilities with the set of
approved ones by length. A manifest repeating a capability could
therefore keep an approval it no longer declared. The two are now
compared as sets.
weft-pack approve <id> <capability>... replaced the app's approval
instead of adding to it. It also accepted any app ID and any
capability, which let an approval cover a capability declared later. It
now adds to the approval, requires the app to be installed, and for a
package weft-pack can read, requires each listed capability to be
declared. The docs state the remaining limits for verified images.
weft-pack approve read only the user store, so an app in the system
store, or installed as a verified image, could not be approved. The
remedy the launch refusal named also did not work.
approve now resolves the package in weft-appd's store order. It also
accepts the capabilities by name, which is how an image is approved,
since weft-pack cannot read its manifest.
An install or rollback without --approve now drops approvals for
capabilities the package no longer declares. A capability declared
again later therefore asks again. Both commands report what still needs
approval. weft-appd validates capabilities without side effects first,
then refuses unapproved ones, then derives grants, so an unsupported
capability is reported as such and not as one needing approval. The
docs state that approvals are per user.
Every capability a package declared was granted at launch, so a signed
package received all the permissions it asked for. Blueprint 5.2 rules
that out.
A package now gets only the capabilities the user approved. weft-pack
install --approve approves those the installed package declares, and
weft-pack approve <id> approves those of the installed app later.
Without approval, install lists what still needs it. The approval is
recorded in $XDG_DATA_HOME/weft/approvals/<id>. weft-appd refuses to
launch an app declaring a capability the record does not hold, with
403 and the capabilities named, after refusing unknown or unsupported
ones as before.
An update that declares a new capability needs approval again, and
uninstalling forgets the approval. Private app data is a minimal
execution resource and needs no approval, so Notes and the existing
fixtures are unchanged.
Unit tests cover the approval record, install and approve, an update
adding a capability, uninstall, and appd refusing and then launching.
tests/frame/check_update.py launches a real app declaring notifications:
it is refused until weft-pack approve, then runs.
The relative link in the race test climbed one level too high, so it
pointed at a directory that does not exist and could not catch a read
that left the granted directory.
The race test could finish before its swapping thread first ran, so in
some runs nothing was exercised and the test failed. The link now
exists from the start. The test runs until it has seen both reads that
stay inside and reads refused for leading out, and it also swaps in a
relative link that climbs out.
Other fixes:
- A request line ending in CRLF is measured without the CRLF.
- Responses that the client stops reading time out like requests do.
- Temporary file names include the portal's start time, so a file left
by an earlier instance cannot collide with a new one.
The test binary passed 30 runs in a row.
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.
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.
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.
The documentation range was matched as 3ff0::/12 instead of 3fff::/20,
which also refused unallocated global space. ORCHIDv2 (2001:20::/28)
was missing. IPv4-translated addresses are now judged by the IPv4
address they carry. Tests cover the NAT64 /32 outside the well-known
/96.
The public-address check missed several kinds of IPv6 address:
- IPv4-compatible and 6to4 addresses carrying a private IPv4 address;
- site-local, Teredo, local-use NAT64, discard-only, benchmarking,
ORCHID and documentation ranges.
It also refused all well-known NAT64 addresses, which would break every
named grant on a DNS64 network.
Addresses carrying an IPv4 address are now judged by that address, and
the special-purpose ranges are refused. The HTTP client is told never to
take a proxy from the environment, since it would connect to the proxy
rather than to the checked address.
Path parsing drops '.' components, empty components and a trailing '/'.
A request like dir/. was therefore accepted, and a write renamed over
the directory itself instead of failing. The path text is now checked as
given.
Other fixes:
- A replaced file keeps its permission bits.
- A connection's slot is released even when its handler panics.
- Connections close after 60 seconds without a request.
- Temporary files get unique names and are not listed.
- A request of exactly the line limit is accepted.
A new test swaps a link between a directory inside the granted root and
one outside while reads and writes run, and checks that nothing outside
is read or written.
weft-appd no longer sets WEFT_FILE_PORTAL_SOCKET for the runtime, which
no longer reads it.
A fetch grant for a host name, or for any host, let a component reach
this machine and the local network whenever the name resolved there. A
granted name could therefore be pointed by DNS at loopback, link-local
metadata or private services.
The runtime now resolves each destination itself. It passes only the
allowed addresses to the HTTP client, so the address checked is the one
connected to. Names and the wildcard reach only public unicast
addresses. An IPv4 address named in a grant is still reached as
declared. Credentials in a URL are refused.
tests/runtime/check_grants.py runs the real component and checks these
refusals: the local server through the wildcard, the name localhost,
and credentials in a URL. The server records that none of the refused
requests reached it.
The portal normalised a request path to check it against the granted
directories, but then operated on the raw path. A link inside a granted
directory, followed by '..', therefore reached files outside it. Links
pointing outside were followed too.
Each granted directory is now opened once. Every request is resolved
beneath that descriptor with openat2(RESOLVE_BENEATH | NO_MAGICLINKS),
so the kernel keeps the operation inside the directory even when links
are replaced while it runs. Paths with '.' or '..' components are
refused.
Other changes:
- Writes replace the file atomically and no longer create directories.
- Files are limited to 16 MiB, listings to 10,000 entries, request
lines to the size of a full write, and the portal to 4 concurrent
connections.
- The runtime no longer passes the portal's socket path to components,
which cannot reach it.
The test also covers the refusal reported when no other store has the
app. The new comment states that a package found and then refused is not
replaced by another store's copy. The architecture doc says that a
re-signed copy of the same content is visible at once.
Installing the same content with another signature file gives the same
revision name. The existing revision, possibly the active one, was
removed before the new copy was renamed into place, so a failure in
between left the store link pointing at nothing. The new copy now
replaces it in one exchange.
If an activation fails before its switch, the kept rollback link is
restored, and dropping a stale rollback link is flushed. The staging
claim is released once the copy is placed, so launches are not refused
while the operation finishes. A launch now passes over a store whose
entry for the app is unusable, as the listing does.
An update of a package directory from before revisions removed it
together with the app data an earlier weft-appd kept in its data
directory. That data is now moved out under the uninstall rules first,
or the update stops.
A failure after the store link was switched removed the new revision
while the link pointed to it. The switch is now the commit point;
cleanup after it is left to collection.
Other fixes:
- A revision is reused only when its content and signature file match.
- The revisions directory is flushed before activation.
- A rollback link is not inherited by a new installation, and rollback
refuses a link to the active revision.
- Staging and unpacking directories are held while in use, so another
operation never collects them.
- weft-appd refuses a launch, instead of waiting, while a package
operation holds the revision.
- Listings read only an app's active package.
An installed package could not be updated: install refused it, and
uninstalling and reinstalling it was neither atomic nor safe for running
sessions, which read files from the package directory.
A package is now staged, checked, verified, admitted and flushed. It is
then renamed to an immutable revision named by its content digest,
<store>/.revisions/<id>/<digest>, and activated by one rename of the
link <store>/<id>. A failure or interruption at any point leaves the
previously active revision active, and a failed first installation
leaves nothing installed. The revision active before an update is kept,
and weft-pack rollback makes it active again after checking it against
the owner record. Other revisions are collected by later operations on
the app, unless a session still runs from them. Leftovers of interrupted
operations are collected too.
weft-appd follows the store link only to one of the app's own
revisions. It runs a session from the revision directory and holds a
shared lock on it for the session's lifetime, so an update, rollback or
uninstall never changes or removes the bytes of a running session. A
package directory from before revisions is still read. An update
replaces it in one exchange, and only while no session runs from it.
Repeated close requests could fill the stop queue, so a forced stop sent
after them was dropped while the session was reported as stopping. A
close is now queued only into an empty queue, which leaves room for a
forced stop.
A stop requested while a session was starting could still be queued
when the app shell reported ready. The session was then shown as
running and asked to close, instead of being stopped. The supervisor
now checks for that request before it marks the session running.
Stop requests use a small bounded queue. A repeated request on a
stopping session is neither queued nor broadcast again; only a forced
one is sent. The taskbar's Force quit returns to a normal close when
the entry is activated, or 20 s after it is offered.
An application with the ask close policy could decline every close, and
nothing could end it. TERMINATE_APP now takes force, which terminates
the session without asking. The taskbar offers it as Force quit once an
app has had longer than the close timeout to answer.
The close interaction now comes before Running -> Stopping, as blueprint
6.2 requires. The session stays running while the application answers,
and a declined close no longer moves Stopping back to Running. Stop
requests reach the supervisor on a channel, so a repeated or forced
request during the close wait is seen without registering again. A
declining window is brought to the front, so its prompt is visible. A
clean exit after a close request is recorded as a close on request. A
decline report is recognised after page output that lacks a newline.
Notes keeps a pending Save and close when asked again. It saves text
typed during that save before closing, and reports when it cannot save
because it is not connected.
A package declares its unsaved-change policy in [ui].close. With
"ask", the app shell dispatches a cancelable weftclose event before
the window closes and waits up to 2 s for the page. A page that
cancels the close keeps running, and the app shell reports this to
weft-appd with its readiness token, which returns the session to
running. The page closes itself later with window.close().
Notes declares "ask". With unsaved changes it offers Save and close,
Close without saving, and Cancel. It closes after a save only once the
save is acknowledged. The taskbar shows a declined close as running
again.
TERMINATE_APP broadcasts the Stopping state, so every system UI marks
the entry. A closing taskbar entry is marked once and no longer sends
ACTIVATE_APP. The docs describe which stopped sessions are kept.
A repeated TERMINATE_APP during the close wait no longer removes the
session from the registry. The close wait also watches the runtime and
the IPC relay, and reports a failed app shell exit as a failure rather
than a close. A session being closed is not saved for restore, only the
32 most recent stopped sessions stay registered, and the taskbar shows
an entry as closing until its session stops.
TERMINATE_APP, which the taskbar sends, killed the session's processes
at once, so an application had no chance to finish, for example to
save. A running session is now asked to close through the compositor
(AppCloseRequest, which sends xdg_toplevel close to its windows) and
the app shell is given five seconds to exit by itself before what
remains is terminated. The stop reason records whether the app closed
or was terminated after the timeout. TERMINATE_APP replies stopping and
the session stays registered until it settles; a starting session is
stopped at once, and appd shutting down terminates sessions without a
close.
check_counter.py requires the compositor to ask the session's window
to close and the app shell to exit with status 0 on the close; a unit
test requires an app that ignores the close to be terminated after the
timeout and not before.
The software rendering path (softbuffer) and the EGL path keep their
own Wayland objects on winit's display, so dropping the rendering
context after the event loop could destroy proxies on a disconnected
display just like the shell client did. Both hosts now release the
rendering context and the window in winit's exiting handler as well.
The compositor records the keys whose press a shortcut took and takes
only those releases, so no client sees a release without its press or
keeps a key pressed. check_activation.py watches the panel for six
seconds after Alt+F4 instead of sampling it once.