# Fenestra Implementation Boundaries

_Peios / Developing for Peios / GXWI Architecture_

> Locate compositor responsibilities and security boundaries in the source.

Fenestra separates session state from browser layout. The Rust process
owns application connections and surfaces. Each desktop page receives that
state and applies its window manager locally.

## Source layout

The implementation assigns these responsibilities:

| Source | Responsibility |
|---|---|
| `src/main.rs` | Inherited listener, session startup, and compositor routes |
| `src/apps.rs` and `src/apps/shell_child.rs` | Application transport, shell supervision, and peer checks |
| `src/surface.rs` | Surface ownership, workspace assignments, and changes |
| `src/desktop.rs` | Browser snapshots, requests, and session termination |
| `src/forward.rs` | Forward application HTTP and WebSocket traffic |
| `src/live.rs` | Serve the shared live-page runtime and icons |
| `src/settings.rs` | Read and validate the shell selection |
| `page/fenestra.js` and `page/wm/tiling.js` | Browser composition and local window layout |
| `page/sdk.js` and `page/keys.js` | Live application interaction and raw-page keyboard forwarding |
| `src/bin/` | Companion taskbar and launcher |

The [source repository](https://github.com/peios/fenestra) contains the
implementation and its tests. Contributor instructions belong in
`docs/building.md`; installed references belong in `docs/man` and
`docs/fenestra.regman`.

## Session and application boundaries

GXWI passes a listening descriptor to Fenestra and controls access to it.
Fenestra restamps the listener to the session identity. The compositor
assumes that incoming session traffic has passed GXWI's authentication and
routing boundary; it is not a standalone public web server.

Application connections use a Unix sequenced-packet socket in the session
runtime directory. Fenestra compares the connecting account's security
identifier with its own and obtains the process identity from the kernel.
Shell authority is assigned only to a tracked configured child connection.
Requesting a panel, background, or dialog role does not itself confer shell
authority. Reaping a shell child and revoking its tracked process ID share
the same admission lock, so a recycled ID cannot retain that authority.

The application supplies an HTTP/2 connection for its content. Fenestra
associates it with that application connection and a generated origin
label. GXWI's origin routing keeps pages separated. Fenestra strips
cookies from forwarded requests and `Set-Cookie` from application responses.
Application-origin requests cannot fall through to compositor routes.

These rules rely on the kernel, GXWI, and browser protections as well as
Fenestra. Host unit tests do not establish that those boundaries work in an
installed Peios session.

## Live and raw pages

A live surface uses Fenestra's page runtime to display content from the
application process and return user actions. Its content security policy
permits the runtime script through a response-specific nonce. The
application's own scripts are not part of that live-page execution model.

A raw surface serves the application's page and scripts. Its state can be
local to one browser page. The shared keyboard-forwarding helper allows
that page to participate in desktop shortcuts. Fenestra treats messages
from a frame according to the surface and its shell authority.

## Resource bounds and failure handling

An application connection can create at most 64 simultaneous surfaces.
Application messages are limited to 64 KiB, and titles are retained up to
128 characters. A truncated application message closes the connection and
removes its surfaces.

Surface resource paths start with a single `/`, exclude the reserved
`/.fx/` prefix, and fit a total limit of 1024 UTF-8 bytes. Fenestra rejects
ASCII control characters anywhere in the supplied path. In the pathname
before the first `?` or `#`, it also rejects literal backslashes and
segments that browsers interpret as `.` or `..`. This includes
case-insensitive `%2e` dots and combinations of literal and encoded dots.

Unicode names, ordinary spaces, query strings, and fragments are retained.
Dots or backslashes in a query or fragment do not count as pathname
traversal. The check does not recursively decode percent escapes or reject
dots within longer names. A rejected resource path prevents the surface
from being created and is reported without closing the app connection.

Workspace selection, renumbering, moves, and initial surface placement
share one session-state lock. Concurrent browser pages cannot split those
updates across inconsistent workspace states.

The desktop has up to 16 workspaces. Its change channel retains 256
messages; a lagging browser reconnects for a snapshot. A shell is sent a
complete surface list on each change, so a later successful update repairs
a missed list. A failed send is reported rather than treated as delivery.

Closing a surface requests cooperation from the application. Fenestra does
not claim that a close request has saved work or forced a process to exit.
Disconnecting the application removes its surfaces and releases their
compositor state.

## Animation lifetime

The arrival animation releases its resize listener when it finishes. A
canceled departure animation stops its frame loop, cancels pending timers,
aborts its availability request, and releases its resize listener. Each
attempt has a generation marker, so callbacks from an earlier attempt
cannot update a later attempt's state or redirect its page.

A shell announcement can arrive while the compositor page is checking an
address after its socket closes. The page rechecks departure ownership
when that probe completes, so the active departure receives the closure
instead of starting a competing reconnect path.
