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
@@ -21,6 +21,8 @@ def test_the_frozen_numbers():
|
||||
assert ExitCode.POLICY == 6
|
||||
assert ExitCode.TIMEOUT == 7
|
||||
assert ExitCode.BUSY == 8
|
||||
assert ExitCode.NO_LEASE == 9
|
||||
assert ExitCode.COMPOSITOR == 10
|
||||
# 1 is deliberately absent: it is the shell's "something went wrong", and
|
||||
# reusing it would make an unhandled crash indistinguishable from a
|
||||
# documented outcome.
|
||||
@@ -61,6 +63,17 @@ def test_the_frozen_numbers():
|
||||
# 8 — busy
|
||||
("busy", 8),
|
||||
("already_managed", 8),
|
||||
("pointer_busy", 8),
|
||||
# 9 — the verb needs the lease and this session does not hold it
|
||||
("no_lease", 9),
|
||||
# 10 — the compositor side failed; the session itself survives
|
||||
("compositor", 10),
|
||||
("compositor_unavailable", 10),
|
||||
("no_container", 10),
|
||||
("driver_unavailable", 10),
|
||||
("driver_refused", 10),
|
||||
# 6 — the container band is full: a budget, not a compositor failure
|
||||
("container_budget", 6),
|
||||
],
|
||||
)
|
||||
def test_every_error_name_maps_to_its_documented_code(error, code):
|
||||
@@ -77,7 +90,9 @@ def test_the_table_has_no_entries_this_test_does_not_know_about():
|
||||
"bad_state", "pid_reuse_detected", "identity_unknown",
|
||||
"daemon_unreachable", "not_allowlisted",
|
||||
"argument_refused", "session_cap_reached", "refused", "timeout",
|
||||
"readiness_timeout", "busy", "already_managed",
|
||||
"readiness_timeout", "busy", "already_managed", "pointer_busy",
|
||||
"container_budget", "no_lease", "compositor", "compositor_unavailable",
|
||||
"no_container", "driver_unavailable", "driver_refused",
|
||||
}
|
||||
assert set(EXIT_CODE_FOR_ERROR) == documented
|
||||
|
||||
@@ -87,6 +102,26 @@ def test_success_is_zero():
|
||||
assert exit_code_for("") == 0
|
||||
|
||||
|
||||
def test_losing_the_compositor_is_not_the_same_as_losing_the_session():
|
||||
"""Code 10 exists precisely so these two cannot be confused (PLAN §8.2).
|
||||
|
||||
A session whose container could not be built is still running; one that
|
||||
exited is not. An agent that saw the same code for both would kill a
|
||||
healthy application to recover from a compositor hiccup.
|
||||
"""
|
||||
|
||||
assert exit_code_for("compositor") == ExitCode.COMPOSITOR
|
||||
assert exit_code_for("session_exited") == ExitCode.BAD_STATE
|
||||
assert ExitCode.COMPOSITOR != ExitCode.BAD_STATE
|
||||
|
||||
|
||||
def test_a_missing_lease_and_a_held_one_are_different_codes():
|
||||
"""8 means "wait", 9 means "acquire". One code could not say both."""
|
||||
|
||||
assert exit_code_for("pointer_busy") == ExitCode.BUSY
|
||||
assert exit_code_for("no_lease") == ExitCode.NO_LEASE
|
||||
|
||||
|
||||
def test_an_unknown_error_degrades_to_not_usable_rather_than_to_success():
|
||||
"""A caller that does not recognise the failure must still not see a 0."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user