`checks.vm-mcp-http` -- the sibling of `vm-mcp`, on the same session machine. That one proves the *surface* over a pipe; this one proves the two things stdio does not have: a unit systemd supervises, and a credential on the way in. So there is one tool call and one resource read here, just enough to show a request reached the broker through an authenticated session, and the weight is on the refusals, the state directory's permissions, and the unit's lifecycle. **The first subtest is the one that justifies the file.** The server exits 2 while the authorization table is empty, which leaves a freshly provisioned machine in a failed state on purpose -- and that trade is only sound because the unit retries, so the first `token mint` brings it up with no `systemctl start`. That self-heal lives in `StartLimitIntervalSec = 0` and nothing in Python can test it. If it regresses, every machine that enables the option comes up dead and stays dead, and this is the only thing that would notice. Also asserted, and each for a reason rather than for coverage: the state directory is 0700 and owned by the account that mints tokens (which is also the proof an operator *can* mint one on a machine configured this way); the table is 0600 and does not contain the token; the port is on loopback and **not** in the firewall, because neither default may become implied; the refusals are 401 with an empty body and no echo; two tokens served by one process see different tool budgets, which is the whole argument for putting toolsets on a token; a revocation takes effect on the next request with no restart, because an operator who must restart a service to lock someone out does not have revocation; and revoking *every* token does not stop the process, since the startup refusal exists to catch a forgotten mint rather than to police a deliberate one. `lib/mcp_http_client.py` is raw JSON-RPC over `urllib` and deliberately not the SDK's client, for the reason `lib/mcp_client.py` is not either -- the SDK on both ends would agree with itself about a framing and a header neither side had to get right, and the header is half of what this file is about. It earned that choice immediately: it is what caught the 307 on the exact path that the SDK-shaped test client had been following silently. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KchcvnbfhhZhUHy83YL3Ya
100 lines
4.4 KiB
Nix
100 lines
4.4 KiB
Nix
# The flake's `checks` output. One file per check; this is only the wiring.
|
|
#
|
|
# unit -- pytest over tests/, against the nix/package.nix build
|
|
# vm-mcp -- the MCP server over stdio, against a live broker
|
|
# vm-mcp-http -- the MCP server's HTTP transport, its token, and its unit
|
|
# vm-stream -- the per-session live stream, with a real HTTP viewer
|
|
# vm-basic -- nixosTest with a fake capture backend: module + wire contract
|
|
# vm-hyprland -- nixosTest with the real compositor and grim
|
|
# vm-sessions -- nixosTest with the real compositor and the session broker
|
|
# vm-ipc -- the compositor's IPC sockets, and an event that arrives
|
|
# vm-containers -- one output and one workspace per session
|
|
# vm-pointer -- the lease, the driver, and a click the application saw
|
|
# vm-keyboard -- the uploaded keymap, keyboard focus, and a decoded symbol
|
|
# vm-keyboard-de -- the same check with sessions.keyboard.layout = "de"
|
|
# vm-stream-firewall -- the stream's port in the guest's own running firewall
|
|
#
|
|
# What the guests need lives in checks/lib: `test-tools.nix` for the fake
|
|
# capture and the contract asserter, `session-tools.nix` for the event
|
|
# subscriber and the two input targets, `session-machine.nix` for the guest the
|
|
# session checks share, and `session-prelude.nix` for their test-script
|
|
# helpers.
|
|
#
|
|
# `vm-keyboard` and `vm-keyboard-de` are one file twice over, and that is the
|
|
# point: `sessions.keyboard.layout` reaches the uploaded keymap only through
|
|
# the driver unit's argv, and a single-layout check cannot tell that path from
|
|
# a hardcoded `us`. See the header of vm-keyboard.nix.
|
|
#
|
|
# Run them ONE AT A TIME. Each boots a VM with a software-rendered compositor;
|
|
# two at once on a two-core machine make the timing-sensitive assertions flake,
|
|
# and a flaky green is worth less than a slow one.
|
|
{
|
|
pkgs,
|
|
self,
|
|
system,
|
|
}:
|
|
let
|
|
hhstream = self.packages.${system}.hhstream;
|
|
hhstream-mcp = self.packages.${system}.hhstream-mcp;
|
|
hhsModule = self.nixosModules.default;
|
|
testTools = pkgs.callPackage ./lib/test-tools.nix { };
|
|
# The session checks take the same arguments; naming them once keeps a new
|
|
# check from being wired up with a different compositor or a different
|
|
# package than its neighbours.
|
|
sessionArgs = {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
in
|
|
{
|
|
unit = pkgs.callPackage ./unit.nix { inherit hhstream hhstream-mcp; };
|
|
|
|
vm-basic = pkgs.callPackage ./vm-basic.nix {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
|
|
vm-hyprland = pkgs.callPackage ./vm-hyprland.nix {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
|
|
vm-sessions = pkgs.callPackage ./vm-sessions.nix {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
|
|
vm-ipc = pkgs.callPackage ./vm-ipc.nix sessionArgs;
|
|
|
|
vm-containers = pkgs.callPackage ./vm-containers.nix sessionArgs;
|
|
|
|
vm-pointer = pkgs.callPackage ./vm-pointer.nix sessionArgs;
|
|
|
|
vm-keyboard = pkgs.callPackage ./vm-keyboard.nix sessionArgs;
|
|
|
|
vm-keyboard-de = pkgs.callPackage ./vm-keyboard.nix (
|
|
sessionArgs // { keyboardLayout = "de"; }
|
|
);
|
|
|
|
# Not a `sessionArgs` consumer: this one is about the module's own options,
|
|
# not about the broker or the compositor (see the file's header).
|
|
vm-stream-firewall = pkgs.callPackage ./vm-stream-firewall.nix {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
|
|
# The session machine again, plus `mcp.enable`, driven over stdio by a
|
|
# JSON-RPC client the check writes itself. `sessionArgs` plus the one package
|
|
# the others have no reason to carry.
|
|
vm-mcp = pkgs.callPackage ./vm-mcp.nix (sessionArgs // { inherit hhstream-mcp; });
|
|
|
|
# The same machine again with `mcp.http.enable`. A separate check and not a
|
|
# subtest of `vm-mcp`, because it proves a different thing: that one is about
|
|
# the surface over a pipe, this one is about a unit systemd supervises and a
|
|
# credential on the way in. Sharing a guest would also mean one failure
|
|
# hiding the other, and the first subtest here deliberately waits for a unit
|
|
# to FAIL -- which is not something to do in the middle of a check whose
|
|
# other assertions need it up.
|
|
vm-mcp-http = pkgs.callPackage ./vm-mcp-http.nix (sessionArgs // { inherit hhstream-mcp; });
|
|
|
|
# The live stream: `stream enable`, a real HTTP viewer inside the guest, and
|
|
# the one thing no in-process test can say -- that a connected viewer moves
|
|
# the idle clock. Spends real time on purpose; see the file's header.
|
|
vm-stream = pkgs.callPackage ./vm-stream.nix sessionArgs;
|
|
}
|