wire the broker to the compositor, containers and pointer
The four slices existed and nothing called them. Now the broker builds a
spatial container per session, reads back what the compositor actually did,
and aims the cursor into one container under a broker-wide lease.
Record schema 3 (registry.py): `container` {output, workspace, mode,
created_by, state}, `pointer` {bookmark, last_released_at, released_by} and
the compositor's `signature`. A v2 record is migrated on load, not refused —
its application is still running. Every field that could not be verified is
null; `container: null` means "no container", never "probably something".
Containers (new container_host.py, manager.py, launcher.py): `start`
allocates a slot from `WorkspaceAllocator`, runs `container_plan()`'s argv,
launches the app with the container stamp in its environment, then reads the
workspace, output and window back out of `clients -j`. Teardown removes the
output, releases the slot and reports survivors rather than claiming success
— and runs for an unprompted exit and for `gc` too, so no container is ever
left unattended. Broker start-up reconciles: adopt `hh-*` outputs a live
session claims, remove the rest, `contains_output()` being the only filter.
No IPC means `container: degraded` and lifecycle verbs unchanged.
The plans' argv are dispatched over the compositor's request socket rather
than by executing `hyprctl`, which is what hyprctl does with the same words;
the reply is checked, so a refused command is not recorded as a container.
Pointer (new driver.py, manager.py): a client for the driver's private
socket, and `pointer.acquire|move|button|click|release|state` on top of
`PointerLease`. The broker owns the lease, the driver executes. The bookmark
is marked on every move and before release and stored in the record, so it
survives a restart. On expiry `pressed()` is read before `expire()` and
`release_all` goes to the driver, because the lease cannot lift a button
itself; a sweep runs unprompted so the TTL is a promise.
containers.py to v2: `quarantine_plan()` -> `quarantine_argv()`, with the
before-any-per-session-rule ordering stated where the caller could get it
wrong. protocol.py: 9 NO_LEASE, 10 COMPOSITOR, the verb table, and the
`request_id` cache moved out of the server so the CLI agrees with it.
Tests: real AF_UNIX everywhere — a stateful fake compositor and the shipped
pointer driver behind a recording sink. No mocked sockets, no compositor, no
VM. 551 -> 693.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mUq7QvQ9EZb2Wi35xj4cs
This commit is contained in:
1 parent
20b2aee109
commit
129430bffd
20 files changed
+4805
-89
No files matched your search
@@ -16,7 +16,7 @@ from hhstreamd.containers import (
|
||||
contains_output,
|
||||
container_plan,
|
||||
output_name,
|
||||
quarantine_plan,
|
||||
quarantine_argv,
|
||||
)
|
||||
|
||||
|
||||
@@ -193,11 +193,12 @@ def test_an_app_id_that_could_forge_a_rule_field_is_refused(bad: str) -> None:
|
||||
assert "[A-Za-z0-9._+-]" in str(exc.value)
|
||||
|
||||
|
||||
def test_quarantine_plan_is_the_catch_all_keyword() -> None:
|
||||
plan = quarantine_plan("special:quarantine")
|
||||
def test_quarantine_argv_is_the_catch_all_keyword() -> None:
|
||||
argv = quarantine_argv("special:quarantine")
|
||||
|
||||
assert plan is not None
|
||||
assert plan.create == [
|
||||
# Bare argv lists, not a ContainerPlan: a quarantine rule has no output,
|
||||
# no numbered workspace and no mode to put in one (CONTRACT v2 §3.2).
|
||||
assert argv == [
|
||||
[
|
||||
"hyprctl",
|
||||
"keyword",
|
||||
@@ -205,19 +206,33 @@ def test_quarantine_plan_is_the_catch_all_keyword() -> None:
|
||||
"match:initial_class .*, workspace special:quarantine",
|
||||
]
|
||||
]
|
||||
# A rule, not a container: nothing to remove, no output, no mode.
|
||||
assert plan.teardown == []
|
||||
assert (plan.output, plan.workspace, plan.mode) == ("", 0, (0, 0))
|
||||
|
||||
|
||||
def test_the_quarantine_rule_matches_what_a_container_rule_does_not() -> None:
|
||||
"""The backstop and a container rule must not be able to collide.
|
||||
|
||||
The catch-all is what every unplaced window hits, so it has to be the same
|
||||
shape as a per-session rule with a wider match — otherwise the two are
|
||||
evaluated differently and the ordering the caller gets right stops
|
||||
mattering.
|
||||
"""
|
||||
|
||||
(backstop,) = quarantine_argv("special:quarantine")
|
||||
container = container_plan("x1", 1000, 1280, 720, "hh-x1").create[2]
|
||||
|
||||
assert backstop[:3] == container[:3] == ["hyprctl", "keyword", "windowrule"]
|
||||
assert backstop[3].startswith("match:initial_class .*,")
|
||||
assert container[3].startswith("match:initial_class ^hh-x1$,")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("disabled", ["", " ", "\n"])
|
||||
def test_quarantine_plan_is_none_when_disabled(disabled: str) -> None:
|
||||
assert quarantine_plan(disabled) is None
|
||||
def test_quarantine_argv_is_none_when_disabled(disabled: str) -> None:
|
||||
assert quarantine_argv(disabled) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad", ["special:quarantine, monitor eDP-1", "a b", "q\n1", "q'"])
|
||||
def test_a_quarantine_workspace_that_could_forge_a_field_is_refused(bad: str) -> None:
|
||||
with pytest.raises(ValueError) as exc:
|
||||
quarantine_plan(bad)
|
||||
quarantine_argv(bad)
|
||||
assert "quarantine_workspace" in str(exc.value)
|
||||
assert repr(bad.strip()) in str(exc.value)
|
||||
Reference in new issue
Block a user