Espacio de trabajo: tu correo dentro de la app (workspace)
Espacio de trabajo: tu correo dentro de la app en una caja Self Host Wizard: la pieza workspace, solo interna, ingreso none, límite de memoria 133 MB.
De un vistazo
| Dato | Valor |
|---|---|
| Dirección | no está en la web (solo la usan las piezas que la necesitan) |
| Ingreso | none: sin ingreso de la oficina adelante |
| Límite de memoria | 133 MB (ram_mb: pico medido × 1,3) |
| Servicio del sistema | thx-workspace.service |
| Necesita | stalwart |
| La necesitan | nada |
| Licencia (según el README) | MIT |
Cómo activarla
thx enable agrega workspace y todo lo que necesita al estado de la caja; después thx apply la instala. Las apps se aplican recién cuando site_domain está definido.
sudo thx enable workspace
sudo thx apply
Notas técnicas (pieces/workspace/README.md)
Las notas técnicas de cada pieza están en inglés, tal como están en el repositorio.
Each person's own mail inside Self Host Wizard's workspace pages: the service behind
https://app.<apps_domain>/ws/* (API: .lead/WS-API.md). Code in internal/workspace, binary
cmd/thx-workspace. W1 is mail; the other places come later.
How it reaches a person's mail
Caddy routes /ws/* of home's host (app.<apps_domain>) through Authelia's forward auth, with the
same copy_headers as every forward-auth host, to 127.0.0.1:18098. The service believes those
Remote-* headers only on that host, and only because nobody else can connect (Firewall, below).
Writes also need X-Thx-Request: 1, a JSON body (an upload's body is the file) and, when the
browser sends one, a same-host Origin, as thx-app's API does.
It opens the person's mailbox on Stalwart as <their address>%thx-workspace@<apps_domain>:
Stalwart's master-user login (pieces/stalwart README, "Master users"). thx-workspace is an LLDAP
service user that core keeps (password: this piece's ldap_password secret); Stalwart's post_up
grants it impersonate while this piece is enabled (IMPERSONATORS in stalwart.py) and takes
it back when the piece is disabled. A person without a mailbox is refused by Stalwart, and the API
answers off. Account ids are per mailbox and collide across people on purpose: an id from
someone else's mail, put in a URL, reaches only the signer's own mail.
What it keeps
Only the feed read cursors, one time per person, in /var/lib/thx-workspace/seen.json (0600).
No tokens, no bodies, no lists: every answer is fetched from Stalwart for that request. In memory:
the JMAP account id per person (10 minutes) and a refused login (2 minutes, so a person without
a mailbox does not count toward Stalwart's failed-login ban on every page view).
Live updates
/ws/events holds one JMAP EventSource on Stalwart per person with the page open, however many
tabs, closed when the last tab leaves; nobody else's mail is watched or polled. Every Stalwart
state event becomes an event: mail; so does a reconnect after the stream was lost, since
changes in between were not pushed. A comment goes out every 25 s to keep proxies from closing
the stream.
Mail HTML
A message's HTML is a stranger's. /ws/mail/body/<id> serves it as its own document behind
Content-Security-Policy: sandbox allow-popups allow-popups-to-escape-sandbox; default-src 'none';
img-src data:; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'; frame-ancestors 'self'
(only the app's own pages frame it; no X-Frame-Options, which would blank that frame), after an
allow-list sanitiser (sanitize.go): no scripts, handlers, forms, frames, embeds, SVG or MathML;
no remote image (the mail's own cid: images are inlined as data, up to 1 MB each and 4 MB a
body as served; past that they stay out like remote ones, and are not fetched); CSS loses
url(), @import, image-set(), expression() and every escape that could spell them; every
link opens a new tab with rel="noopener noreferrer", and only http, https and mailto links
keep their target. Attachments download as application/octet-stream, never rendered here.
Firewall
The service runs as the fixed system user thx-workspace (apply creates it before the guards;
it stays if the piece is disabled, owning nothing and let through nowhere). The loopback guards
(internal/firewall) let only root and Caddy reach pieces' ports; a host unit whose unit has a
User= line also gets that uid through the guards of the ports of the pieces in its depends,
and nowhere else: here Stalwart's 18080, never Caddy's admin API (2019), thx-app (18096), other
pieces or the Docker bridges. The list of ports is depends, so it changes with this file, not
with code. Root and Caddy are the only users that reach 18098.
Unit
ProtectSystem=strict, ProtectHome, PrivateTmp, PrivateDevices, NoNewPrivileges, no
capabilities, InaccessiblePaths=/etc/thx/secrets: the password arrives on stdin
(StandardInput=file:; systemd opens the root-only file before it drops to the service's user).
Not LoadCredential=: on the test box (systemd 255 in Docker) no credential ever appears in
$CREDENTIALS_DIRECTORY, even one from SetCredential=, so that way could not be proven. It reads
/etc/thx/state.json (0644) for the apps domain, the companies and whether webmail is on.
Measured
The docker stage (internal/containertest/docker.sh, "workspace"), 2026-11-26, amd64.
Typical traffic: 4 pages x 25 rounds of mailboxes + list + feed + a sanitised body, with 4 event streams open: peak RSS (VmHWM) 14 MB.
Worst case, which the limit is sized from: 4 requests at once for the heaviest body there is,
3 rounds, with 4 event streams open. That body is 4 MB of HTML whose quotes and control characters
Stalwart escapes to 11.8 MB of JSON (just under maxResponse, 12 MiB), plus 3 inline pictures of
980000 bytes (3.9 MB as served, the inline budget). The highest of two runs sets the limit:
- Run 1, no
GOMEMLIMIT, a 512M limit: peak RSS (VmHWM) 96 MB. - Run 2,
GOMEMLIMIT=110MiB: 102 MB (cgroup memory.peak 100 MiB).
ram_mb = 133 and MemoryMax=133M are 102 x 1.3. MemorySwapMax=0 makes the limit the
ceiling: without it the box swapped the service out, and even the old 19M passed.
GOMEMLIMIT=118MiB makes the collector work harder just below the limit.
What bounds it:
- At most
heavySlots(2) requests hold a whole mail at once (bodies, threads); the rest wait. - A JMAP response past
maxResponse(12 MiB) is refused (504), not decoded. Decoding costs about 2.5x the response. - A thread's text is shared out between its messages: 4 MB in all.
- Inline pictures stop at 4 MB a body as served, and are not fetched past that.
- The sanitiser streams token by token. The parse tree it replaced held 35x the HTML and was quadratic on stray table cells.
- Attachment downloads and uploads stream.
The stage proves it both ways. All 12 worst-case bodies answer under 133M. With
MemoryMax=19M (on a fresh process), the OOM killer ends the service and requests fail. A body past maxResponse
gets a 504 and the service keeps running. Past MemoryMax, systemd kills the service and
Restart=always brings it back in 2 s.
Known gaps
- Stalwart indexes new mail for search a second or two after delivery; a search right after arrival may miss it.
whoin the feed is the sender's display name, or the address; there is no contact lookup.