b2bc84602aec214978d05ac006da8171b9870c2c
22
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b2bc84602a |
build: point TURBOJPEG_PATH at lib.getLib, not the package's default output
The default output of libjpeg-turbo in this nixpkgs is the tools (-bin), which has no lib/ at all, so the check failed with 'cannot load libjpeg-turbo from .../-bin/lib/libturbojpeg.so'. lib.getLib selects the output that actually holds the shared library. |
||
|
|
a417a6919d |
tests: find libjpeg-turbo by TURBOJPEG_PATH, not LD_LIBRARY_PATH
The unit check failed with the library present: in nativeBuildInputs is a nix wrapper that sets LD_LIBRARY_PATH itself, so an export from the builder script is overwritten before the tests run. TURBOJPEG_PATH is read first by jpeg._load_library, no wrapper touches it, and the package's console scripts now set it too. |
||
|
|
7190960120 |
capture: encode JPEG in-process too, so the live stream keeps working
PNG-only was a real defect, not a nice-to-have: `hhstream_live.server` serves
`multipart/x-mixed-replace` with `image/jpeg` parts and its own capture default is
`grim -c -t jpeg -q 80 -`, so switching this backend on would have broken video
streaming while looking faster in a benchmark.
JPEG now goes through libjpeg-turbo by ctypes, using its `TJPF_BGRX` input format
-- which is exactly the compositor's B, G, R, X memory order, so the frame goes
into the encoder with no copy and no colour conversion. Measured on this VM
against the real compositor, the deployment's own settings (Virtual-1, 1280x720,
jpeg q80, 200 frames each, two runs):
p50 ms fps our CPU compositor CPU
in-process 76.2 13.1 2.1 ms 51.5 ms
grim -c -t jpeg 137.0 7.3 0.5 ms 80.2 ms
(second run: 84/144,
55.1/79.8 -> 1.71x)
So ~1.7-1.8x the frame rate and ~1.5x less of the compositor's CPU, with frames
of the same order (188 KB against grim's 222 KB). PNG stays available through the
stdlib for a deployment that would rather not carry the library.
Both segfault-class traps from the spike are handled and documented: every
argtype is declared (an undeclared pitch is a crash, not a wrong number), and
`*jpegBuf` is reset to NULL after `tjFree` (turbojpeg reads a non-NULL pointer as
a caller buffer, so the next frame would write into freed memory). The decoder is
here because a lossy codec can only be tested by round-tripping pixels -- the new
suite encodes solid blocks whose channels differ enough that a swap is
unmistakable, and includes a padded stride.
Packaging: libjpeg-turbo is reached through ctypes, so nothing links it and the
path must reach the loader -- the console scripts get a wrapper with it on
LD_LIBRARY_PATH, and the unit check exports it too. A missing library is reported
at startup rather than once per frame: a server that is up but can never produce
a frame is worse than one that refuses to start.
Verified end to end: server with `--capture wayland:Virtual-1 --format jpeg`,
client Hello `image/jpeg`, three frames read, each magic `ffd8`.
|
||
|
|
a7d9357b43 |
capture: an in-process Wayland backend, and the measurements that justify it
The frame server could only capture by running a program once per frame
(grim). That works, but ~95% of a grim frame is waiting -- fork, connect,
handshake, round trip -- not encoding, and grim makes the compositor import
a *new* shared-memory buffer for every single frame.
This adds `--capture wayland[:OUTPUT]`: one long-lived zwlr-screencopy-v1
client per server, with one shm buffer reused for the whole run, capturing
inside the process. Measured here at 1280x720 (spike capture-speed, 200
frames; live re-check on Virtual-1, 60 frames):
grim (subprocess) 117.3 ms/frame 8.1 fps compositor 116.4 ms
grim-rs (Rust crate) 124.6 ms/frame 7.5 fps compositor 123.1 ms
this backend 78.0 ms/frame 13.9 fps compositor 67.5 ms
live, PNG both sides: this 128.5 ms/frame against grim's 389.3 ms (3.0x)
Three findings, each of which shaped the code:
* The win is buffer reuse, not language. grim and grim-rs both hand the
compositor a fresh buffer per frame, which is why their compositor CPU is
nearly double ours. The per-frame allocate-copy-swizzle that grim-rs pays
was measured in isolation at 2.4 ms of *client* time; the rest of its
deficit lands inside the compositor.
* ext-image-copy-capture-v1 is no faster (78.0 vs 77.7 ms) and its
create_frame path appears in a Hyprland segfault stack, so this keeps the
deprecated protocol grim uses. The switch is one constant when that crash
is fixed.
* PNG only, deliberately: PNG is the one encoding this package produces
without a dependency, so --format jpeg is refused rather than publishing a
Hello whose MIME type the frames do not have. A PNG frame is ~2.1 MB
against ~120 KB for JPEG q80, which is why the command backend stays the
default and why a libjpeg-turbo encoder (1.7 ms/frame, measured) is the
obvious follow-up.
The timeout is the load-bearing part of the client: pywayland only reads
events from read()/dispatch(block=True), neither of which takes a timeout,
and the server captures in a worker thread where SIGALRM is unavailable. It
therefore polls the display fd itself, so a compositor that stops answering
produces a CaptureError instead of a capture thread that never returns.
The protocol bindings are vendored under src/hhstream/_protocol/ exactly the
way hhstream_pointer already vendors its two, with regenerate.py recording
where each XML came from. No new dependency: pywayland was already required
by the input driver.
Contract: the new server flag and the two new module options are documented
in docs/CONTRACT.md, and docs/ARCHITECTURE.md's prediction that a native
screencopy client would be "a swap rather than a rewrite" is now the record
of what the swap cost.
Unit suite: 977 passed, 2 skipped, 0 failed (nix build -L .#checks.unit).
The live numbers were taken on this VM against the real compositor.
|
||
|
|
5f94833a76 |
Merge origin/main into feat/keyboard-input: keep both the stream and the
keyboard sides
origin/main brought the session live-stream feature (stage 1): the
`hhstream_live` router, its phrase generator and wordlist, the
`sessions.stream.*` module options with their loopback-vs-openFirewall
assertion and the one firewall port, the `vm-stream-firewall` check, and
`tests/live/`. This branch adds keyboard input: the `key`/`type` ops, the
uploaded XKB keymap, `sessions.keyboard.{layout,model,variant,options}`
and the four `--xkb-*` flags on the driver unit, `vm-keyboard` and
`vm-keyboard-de`, and their docs.
The two features are independent, so every conflict wanted both sides.
Four files, resolved as follows.
checks/default.nix -- both the header list and the attribute set take all
three new checks: `vm-keyboard`, `vm-keyboard-de` (the same file with
`keyboardLayout = "de"`, because the layout reaches the keymap only
through the driver unit's argv) and `vm-stream-firewall`, which stays a
non-`sessionArgs` consumer with main's comment saying why. Neither side's
check list is reduced; the flake now exposes ten.
nix/package.nix -- one `pythonImportsCheck` list with both sides' entries:
`hhstream_pointer.keymap` and the vendored
`virtual_keyboard_unstable_v1` from here, `hhstream_live.server` from
main. The surrounding hunks were not in conflict, so the branch's
xkbcommon dependency and main's wordlist `postFixup` both survive, and
both ran in this merge's `checks.unit` build (`wordlist ok: 7772 words`).
nix/module.nix -- the sole conflict was textual: both sides open a new
sub-option block immediately after `sessions.pointer`. Both blocks are
kept, `keyboard` then `stream`, each with its own closing. Everything
else in the file merged cleanly, so `loopbackBinds`, the
openFirewall-on-loopback assertion and
`networking.firewall.allowedTCPPorts` are present alongside the driver
unit's `--xkb-layout`/`--xkb-model`/`--xkb-variant`/`--xkb-options`.
README.dev.md -- the `checks/` layout listing keeps both entries in the
file's existing order, `vm-keyboard.nix` then `vm-stream-firewall.nix`.
Verified: `nix flake check --no-build` evaluates every output green, and
`nix build .#checks.x86_64-linux.unit` passes -- 977 passed, 2 skipped,
0 failed, over both sides' suites. The VM checks were not run (they boot
a software-rendered compositor and must run one at a time).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjpHyir6hxyjdw2o1RwQmn
|
||
|
|
7141900070 |
module: declare the stream's port, and the one hole it needs
`sessions.stream { port, bind, openFirewall }` -- the piece of stage 3 that
does not need the broker. It exists because a machine had to be able to *reach*
a stream before the rest of the app is settled: the operator asked for the port
to be open on the deployment machine, where the app still runs by hand, and a
bare `networking.firewall.allowedTCPPorts` line in one machine's config is the
wrong place for a fact about this flake.
- `openFirewall` defaults false and is deliberately not implied by
`sessions.enable`: a live view of the desktop is readable by anyone who can
reach the port, the phrase in the URL is its only credential, and there is no
TLS. It opens exactly one port -- the one the option names.
- `bind` defaults to loopback and is *checked*: `openFirewall = true` beside a
loopback bind is refused, because that is a hole with no service behind it.
- `checks/vm-stream-firewall.nix` boots the module with a configured port that
is not the module's default, puts listeners on that port and on a neighbour,
and asserts from a second machine on the same VLAN that the peer reaches the
configured port and is refused on the other -- while both answer on loopback
inside the guest, so the refusal is the firewall's doing and not an empty
socket. The peer is a second machine because a probe from the test driver
proves nothing: the driver is not on the test VLAN.
Nothing here turns a stream on -- no unit, no phrases, no `session stream`
verbs, which stay stage 2+3 -- and docs/plans/2026-10-04-session-stream-webapp.md
now records which part of its stage 3 landed and why out of order.
|
||
|
|
db7aaf8276 |
build(nix): prove the wordlist is actually installed
`pythonImportsCheck` only imports, and `hhstream_live.phrase` reads its wordlist lazily, so a wheel that dropped `wordlist.txt` sailed past the check and would have failed at the first `enable` instead. The package now reads the list from the installed tree and mints a phrase through `validate`, which is the only place the packaged data is exercised -- `doCheck = false`, the suite runs in the flake's `checks`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01URhyHGQnmKH9zBXxoznfQY |
||
|
|
9744d35945 |
feat(live): one port, a router, and a phrase per session (stage 1)
The session-stream web app: a single HTTP listener (9988) that serves a page
per enabled session, keyed by a spoken phrase. Off by default, so a stream
exists only for the sessions it was enabled on.
src/hhstream_live/phrase.py four EFF-large words + a 5-char base-36 tail
(~77.5 bits); the phrase is the password
src/hhstream_live/publisher.py one capture thread + one frame slot per
output; one slot/no queue; capture paused at
zero viewers
src/hhstream_live/server.py the router: /, /<phrase>/, /stream.mjpg,
/frame.jpg, /status.json; unknown phrase is
an empty 404, rate-limited
src/hhstream_live/pages.py the built-in dark pages (no CDN, no build)
src/hhstream_live/__main__.py hhstream-live serve|phrase, standalone
The root page is a form, never a list: the phrase is known only by whoever
enabled the stream. Transport is MJPEG (multipart/x-mixed-replace), reusing
the JPEG grim already produces. Not yet wired to the broker -- that is
stage 2. Tests: tests/live (51).
|
||
|
|
e6f4c3bb3f |
Stage 1 review fixes, and Stage 2: the broker, the CLI and the module
The Stage 1 review (docs/reviews/2026-10-04-stage1-review.md, verdict
yes-with-fixes) found a real bug, and it was the kind Stage 2 would have
cemented. All five findings:
(1) HIGH, and reproduced before fixing: `key` resolved the action and
then used only its `code`. So `keyboard key A` sent a bare code 30
and the window received `a`; on `de`, `at` lost its level-three mask
and typed `q`. `type` was the only path that used the mask, which is
why every `type` test stayed green. `key` now sends
modifiers(baseline | mask) before the down and restores the baseline
on the up -- the one-character `type` sequence -- and `Shift_L`
keeps its key-then-mask order, which is the other path on purpose.
The same hole aliased two names onto one keycode: `down A` then
`down a` recorded both and pressed 30 twice, Hyprland dropped the
second, and the held set lied until the lease ended. A second name
for a code already down is now refused.
(2) HIGH: the shutdown comment claimed hyprland-conf.nix sets
input:virtualkeyboard:release_pressed_on_close. It did not. The line
is there now, with the note that it releases keys and still never
clears a mask -- which is why release_all zeroes the mask on every
path we control rather than relying on it.
(3) MEDIUM: nothing would have noticed the keymap upload stopping. A
`main` that connected and listened without uploading passed every
test in the tree. Now asserted on the real sink: uploaded once,
before `listen` (one shared ordering log across both stand-ins), the
payload NUL-terminated with `size == len(utf8) + 1` read back
through the fd, format 1, one terminator not two, and modifiers(0)
straight after.
(4) LOW: `key` up now forgets the name only after a successful send,
like `button` -- otherwise a raise between the two leaves us
believing a key is up that the compositor still has down, and
release_all will not try again.
(5) LOW: `\r` no longer aliases to Return (CRLF would have become two
newlines silently), and an empty layout is refused -- xkbcommon
compiles "" as the same keymap as `us`, so `--xkb-layout ''` looked
configured and typed `us`.
Several of the review's named false passes are closed too: Control's
mask is compared against mod_get_index("Control") rather than merely
"not Shift's"; the keymap text assertion names pc_us_inet/pc_de_inet
instead of substring-matching "us"; the capital-under-Control case
asserts the whole sequence; the exit-code mirror is compared against
hhstreamd.protocol; and the module's defaults are read out of
nix/module.nix rather than asserted against themselves.
Stage 2 proper:
* broker verbs keyboard.key / keyboard.type, both in the mutation set,
both through _refresh (so they refresh the lease and, like every
pointer verb, do NOT count as activity)
* the driver's `kind` token mapped: a bad keysym or character is
invalid_argument (exit 2), a missing keyboard global stays
driver_refused (exit 10). The 4096-scalar cap and the shape checks
are broker-side, because only a broker-side invalid_argument is 2
* keys[] on pointer.state, keys_lifted[] on pointer.release and on
pointer_lease_timeout, one release_all for both halves
* CLI `session keyboard type|key|down|up`, reusing the pointer lease
and its cache; `type` takes one raw argument and interprets nothing;
the audit records a character count and never the text
* sessions.keyboard.{layout,model,variant,options} on the unit's argv,
layout defaulting to "us" with a type that refuses a comma. NO
[keyboard] TOML table: hhstreamd reads that file and the driver is a
different unit, so it would be a setting with no effect
* CONTRACT-sessions.md bumped to v3; README.dev.md item 3 and
vm-pointer.nix's header corrected (both still said the conf ships
follow_mouse = 0 and that the keyboard work would choose)
And the operator decision that acquire grabs both devices: it now sends
two warps a real pixel apart, because one warp onto an idle cursor moves
the cursor and not keyboard focus. follow_mouse_threshold = 0 is set
explicitly in hyprland-conf.nix since the second warp depends on it,
`dispatch focuswindow` is the fallback when the nudge cannot be sent,
and the reply and audit carry which mechanism ran. The acquire test
asserts the pair and that they floor to different pixels -- a test that
only saw wl_pointer.enter would pass while the first keystroke went to
the wrong window.
nix develop -c python -m pytest tests/pointer tests/sessions/unit -q
605 passed in 27.11s
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GhNPM6rGcuzxocM1nATnuM
|
||
|
|
f931858f30 |
Stage 1: the driver learns to type
`zwp_virtual_keyboard_v1`, spoken by the process that already speaks
`zwlr_virtual_pointer_v1`. One device for the seat, one keymap uploaded
once, keysym names on our socket and evdev codes only on the Wayland
request -- the division buttons.py already draws.
keymap.py is the new seam, and it holds the three decisions that have a
wrong version which looks right:
* A capital is the MASK, not a synthetic Shift keycode. Hyprland's
virtual keyboard never runs updateXkbStateWithKey, so a virtual
KEY_LEFTSHIFT changes no modifier state at all -- and sending both
is how a toolkit applies Shift twice.
* A modifier is whatever the keymap says is one, measured by pressing
each key in a throwaway xkb state. Not a name list: `@` on `de` is a
level-three symbol, and a Shift-only special case types the wrong
character. (The measured set is also smaller than the canonical one,
because no keycode on us/pc105 carries Meta or Hyper.)
* A lock is not a modifier. Caps_Lock reports a *locked* mask, so
`type` refuses while it is held rather than guessing the case.
The whole string resolves before anything is emitted, and every refusal
names the scalar INDEX, never the character: these messages reach the
driver's log and the string is a password as often as not.
Folding in the review's changes 1, 2, 3 and 6:
1 a Rejected now carries a `kind`. A bad keysym or an unmappable
character is `invalid_argument`; a missing keyboard global is
`refused`. Without the token the broker would have to tell exit 2
from exit 10 by reading English, and _drive maps every `ok: false`
to driver_refused today.
2 the keymap `size` on the wire includes the trailing NUL, and the fd
outlives a roundtrip rather than a flush. Hyprland mmaps exactly
that many bytes and hands the pointer to xkb_keymap_new_from_string.
3 release_all lifts buttons, then keys in press order, then zeroes the
mask -- and the mask only if something set it, so a compositor with
no keyboard global still gets its buttons lifted. One release_all is
the whole of expiry; an exception in the key half would abandon it.
6 `key` and `type` never call _aimed(). A keyboard has no output, and
one test deliberately never warps so that stays true.
Also: `--xkb-layout/-model/-variant/-options`, compiled BEFORE any
Wayland call so a bad layout is exit 2 rather than exit 10; a comma in
the layout refused outright, because v1 always sends group 0 and
xkbcommon would hand back a second group nothing could reach; the
keymap uploaded after connect and before listen, with one
modifiers(0,0,0,0) after it; and xkbcommon as a hard, non-optional
dependency -- an optional one would let test_keymap.py skip, and the
unmappable-character path is the one that must not rot.
nix develop -c python -m pytest tests/pointer tests/sessions/unit -q
549 passed in 25.70s
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GhNPM6rGcuzxocM1nATnuM
|
||
|
|
c1dc60af00 |
hyprland-conf: follow the pointer, because one now exists
vm-pointer measured what this setting actually does: with follow_mouse=0 Hyprland delivers pointer events only to the keyboard-focused window, so a click aimed at 0.25,0.75 of a session's container put the cursor at x=299 y=519 -- inside that window -- and both clients reported nothing. The click was aimed correctly and delivered nowhere. The comment here said 'no pointer will ever exist; do not let focus depend on one', which was true when written and is false now that the broker injects a virtual pointer. The cursor lease already serialises input, so focus following the pointer cannot make two sessions fight over the keyboard. |
||
|
|
de408e4b7f |
the surface: CLI verbs, the module's options, and three checks the compositor votes in
Everything below the CLI was merged and green against fakes; none of it was
reachable and none of it had ever met a compositor. This wires it up and then
puts the compositor in a position to disagree.
CLI (src/hhstream/cli.py, src/hhstream_session/**)
session container [ID], session reconcile [ID], and the seven pointer verbs
from PLAN §9. `start` still prints the bare session id and nothing else.
`list` gains WS / OUTPUT / POINTER, with the gap marker where a value is
genuinely unknown rather than a blank that reads as zero -- the POINTER
column needs a second, read-only `pointer.state` call because the `list`
reply carries no lease state.
The lease id is cached in `hhstream_session.lease` (under
$XDG_RUNTIME_DIR), because PLAN §9's gesture verbs take no --lease and the
wire requires a lease_id on every one of them; --lease and $HHSTREAM_LEASE
override it, and a `no_lease` refusal drops the stale entry.
Exit codes are the contract's: a gesture with no lease is 9 and never
reaches the broker, and a compositor failure is 10 with a message that says
the session is still running. `kill` now warns about
`session.container_survivors` -- windows the compositor still shows -- and
distinguishes `null` ("could not ask") from `[]`.
`shot`/`record --output NAME` capture one container through `grim -o`; the
frame socket publishes the main output only, so it cannot do it.
Module (nix/module.nix)
sessions.containers.{enable,max,mode,workspaceBase},
sessions.pointer.{enable,leaseTtl,leaseMax}, rendered into the generated
TOML with §10's key names. hhstream-pointer.service: the operator's account,
supplementary group hhstream, After=/BindsTo= the compositor,
Restart=on-failure, KillMode=process, and the command line §3.4 freezes.
tmpfiles for /run/hhstream plus RuntimeDirectoryPreserve on the broker,
without which restarting the broker deletes the driver's socket out from
under it. The runtime-directory length assertion is untouched.
And ExecStartPost on the compositor, opening its IPC directory to its own
group: Hyprland creates <runtime>/hypr with S_IRWXU, so the broker -- a
different account by design -- could not reach the request or event socket
at all, and degraded silently exactly as it is built to.
Checks (checks/**)
vm-ipc: both sockets at their frozen names, measured against sun_path's 108
bytes, and a socket2 subscriber that receives an openwindow for a window the
test creates. The subscriber is the shipped HyprlandIPC, not a second
implementation: this check exists to prove that this client hears this
compositor.
vm-containers: one hh-* output per session at the container mode, the window
on it, a second window of the same application beside it, an unmatched
window quarantined, grim -o isolating one container, teardown removing the
output and freeing the slot. PLAN experiment 3 is answered: `hyprctl output
create headless` works.
vm-pointer: a version-2 virtual pointer, a warp and a click whose
coordinates the *application* reports, BUSY naming the holder, an expired
lease swept with its held button lifted, and a broker restart that leaves
the lock free, the bookmark intact and the driver reachable.
checks/lib gains the guest the three share, their test-script helpers (no
assertions live there), an event-socket subscriber and a Wayland client that
says where it was clicked -- nothing in nixpkgs both honours
$HHSTREAM_APP_ID and reports pointer events.
Reported, not worked around: the broker reads none of the container or
pointer config (policy.py takes [defaults] and [apps] only), `start` has no
no_container field so --no-container is refused rather than silently ignored,
and nix/hyprland-conf.nix sets input:follow_mouse = 0, which sends pointer
events to the focused window only -- measured, with the cursor at the aimed
pixel and no client told. README.dev.md has the evidence for each.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQy29x9AfHWyzNd1f7XPGK
|
||
|
|
8c180ec938 |
merge slice/pointer into main
Built in an independent worktree against docs/CONTRACT-sessions.md. Reports its own slice's verification in its final message; the parent re-runs the union. |
||
|
|
0d414d76bc |
pointer: the lease, and a driver process that only executes
There is one cursor on this compositor build and every virtual pointer writes to it, so aiming at a session is a matter of serialising input, not of binding harder. Two pieces, and the split between them is the point. `hhstreamd/pointer.py` is the lease: one holder, an idle TTL and a hard cap on an injected clock, tracked buttons, and the window-local-to-normalised arithmetic that makes "click 40px into this window" mean something on an output that is not at the layout origin. Pure, so the expiry tests move time instead of sleeping. `hhstream_pointer/` is the driver: its own process because a Wayland client needs its own connection and a blocked one must not stall the broker. It holds no lease state -- it is told what to do and does it. The manager is bound at version 2 and pointers are created with `create_virtual_pointer_with_output`; a version-1-only manager is reported and refused rather than quietly aiming at the global layout. The wlr protocol module is vendored scanner output under `_protocol/`, so a checkout builds without a code generator; `_protocol/regenerate.py` says how to refresh it and why pywayland's own scanner entry point cannot be used. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011txKimbdkqPFpq6m8KDELu |
||
|
|
06041030b0 |
rename the compositor runtime directory to /run/hypr-stream
`/run/hyprland-headless-stream` is 29 characters, and the compositor's IPC sockets live under it at `hypr/<instance signature>/.socket2.sock`. With a ~30-character signature the *event* socket does not fit in `sun_path` and the compositor refuses to bind it: ERR ]: Socket2 path is too long. (2) IPC will not work. The *request* socket kept answering `hyprctl` (both ends agree on a residual truncated path), which is why this looked healthy while every observation feature that needs events had nothing to read. `/run/hypr-stream` is 16 characters. The rename reaches both units' `RuntimeDirectory`, `WorkingDirectory`, `XDG_RUNTIME_DIR` and `HOME`, the broker's `--compositor-runtime-dir`, the `socketPath` option default, the `hhstream` CLI's frame-socket default and the `agent-eyes` helper. An assertion now holds the name at <= 25 characters, the ceiling frozen in docs/CONTRACT-sessions.md §5, so this cannot regress silently -- the failure mode is a working request socket and a dead event stream, which looks like nothing is wrong. Its message says what breaks and why the limit exists. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018YqpJb5aZvZQKb49QDnV7P |
||
|
|
f51197afca |
module: one tmpfiles definition, merged
Adding the broker's state directory as a second assignment to systemd.tmpfiles.settings does not evaluate at all (the option takes one definition), which broke every check that enables sessions. Both reasons to write a tmpfiles entry now live in one lib.mkMerge. |
||
|
|
fc5112aa6a |
module: let the broker's state be pointed off the system disk
The unit used systemd's StateDirectory=, which can only ever mean /var/lib/<name> — on this kind of machine that is the disposable root. The records the broker adopts and events.jsonl, the audit trail of every accepted command, are precisely the things that should outlive a reinstall, so they are now an option (`sessions.stateDir`) and the directory is declared with tmpfiles so its owner and mode are still declarative. |
||
|
|
30f456c07e |
integrate the session broker: one CLI, a module unit, and a VM check
M0 of the sessions design, wired into the flake and gated by a real check. What is here now: - `src/hhstreamd/` — the broker: session registry, lifecycle verbs, process-group teardown, app allowlist, audit log, idle reaper on CLOCK_BOOTTIME. - `src/hhstream_session/` — the CLI handlers, registered into the one front door. - `src/hhstream/cli.py` — `hhstream status|shot|run|record|session …`, so the frame verbs and the session namespace are one binary. - `nix/module.nix` — `sessions.*` options and the `hhstream-sessions.service` unit: the operator's own account (never a service account, because launched applications should see that account's home), the compositor's group as a supplementary group (without it a launched GUI client cannot open the Wayland socket), the generated app allowlist, and `--compositor-runtime-dir` so applications are handed the compositor's session rather than the broker's. - `checks/vm-sessions.nix` — 18 subtests on a real compositor in a VM. Two bugs found by driving it, both fixed: - BUG-01: launched applications could not reach the compositor at all — the broker spawned them with its own inherited environment, which names the login session. `hhstreamd/compositor.py` discovers the socket and builds the child environment; a directory with no usable socket is a startup refusal, not a warning. - BUG-02: `kill` refused to signal a live application and said nothing was wrong. The identity gate hashed `/proc/<pid>/cmdline`, which every `execve` replaces — and on NixOS applications are reached through wrapper scripts that do exactly that. The gate now rests on `starttime` (+ boot id, + session id where it is immutable) and records command-line drift as evidence of nothing. KillMode=process is set on the unit on purpose: the default control-group kill would take the applications down with the broker, which would make adoption and a broker restart pointless. |
||
|
|
6510e315d4 |
module: make outputs monitor rules for real connectors, and own the seat flag
A machine running this module has a GPU. aquamarine's headless backend has no allocator of its own -- `CHeadlessBackend::drmFD()` returns -1 and `CBackend::start()` takes the allocator from the first backend with a drm fd -- so the session always rides on the DRM backend and always has the host's own connectors. `HEADLESS-1` is a name no connector will ever have, which made the shipped default a monitor rule Hyprland silently ignored, and made `vm-hyprland`'s assertion on that name unsatisfiable. `outputs` now means "monitor rules applied to whatever outputs the machine has". `name` is a regex against the real connector names and defaults to the empty string -- Hyprland's own wildcard form, as in its shipped `monitor=,preferred,auto,1` -- so `enable = true` alone gives a session at a known size on any host. Nothing else about the option changed. SEATD_VTBOUND=0 moves from checks/lib/gpu-session.nix into the compositor unit, where it belongs: libseat finds no seatd socket and no logind session for a system service, falls back to its embedded seatd, and that seat is VT-bound by default -- so it opens /dev/tty0, which the service user cannot, and every device open is refused. That is true on any host, not just in the test. gpu-session.nix keeps only the two things that really are the test machine's business: a render node and Mesa. vm-hyprland now asserts over `hyprctl -j monitors` that at least one monitor exists at the configured mode, with no monitor name anywhere in the check. It also gains a wallpaper, because `--reject-blank` could not otherwise mean anything: the session the module configures by default is a flat black field, which grim captures as an all-zero 1280x720 RGBA PNG of exactly 3653 bytes -- `blank_png_size()` to the byte. Runs that passed that assertion were reading Hyprland's startup notification overlay, which expires after about fifteen seconds. With `misc:force_default_wallpaper` on, the frame is 85267 bytes with all 921600 pixels non-zero and is byte-identical at +15s, +30s and +60s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M5GEju6XhoRXDWvEiaAX2r |
||
|
|
231fa317cb | module: discover the Wayland socket instead of assuming wayland-0 | ||
|
|
464c93e8f4 |
module: wire up the headless session and the frame server
Implements the `config` side of the module surface in docs/CONTRACT.md: - `hhstream` user/group, and one private runtime directory shared by both units (RuntimeDirectory= with Preserve=yes, so the Wayland socket survives a restart of either side). - A rendered hyprland.conf (nix/hyprland-conf.nix): one `monitor =` line per `outputs` entry plus `extraConfig` verbatim, with the logo/splash, config autoreload, DPMS, cursor, animations, shadows and the update/donation and guiutils/XDG checks switched off -- none of them mean anything in a session with no seat, no input device and no user. Validated with `Hyprland --verify-config`. - `hyprland-headless.service`: Hyprland as the service user, Type=notify (it sends READY=1), Restart=always, and deliberately no WAYLAND_DISPLAY or DISPLAY in the environment so the compositor cannot pick a nested backend and falls back to headless. - `hyprland-headless-stream.service`: hhstream-server as the same user, After=/BindsTo= the compositor, Restart=always, with --socket/--fps/ --format/--capture-command on the command line. `outputs.*.scale` used `lib.types.positive`, which does not exist in nixpkgs and made the whole `outputs` option unreadable; it is now `lib.types.numbers.positive`. `package` gets its documented default (the flake's own build) via mkDefault on the config side, so the declared option surface is otherwise untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015pS3JxTJZBufyBKwimwBxy |
||
|
|
8993f026d3 | buzz: initial mirror |