Skip to content

feat(lbm-agent): the connection to the hook, and a fake hook to develop against - #624

Merged
mgth merged 1 commit into
masterfrom
feat/lbm-agent-hook-client
Sep 11, 2026
Merged

mgth merged 1 commit into
masterfrom
feat/lbm-agent-hook-client

Conversation

@mgth

@mgth mgth commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Phase 3 of the v6 plan, next brick after the reconciler (#623): the agent's connection to the hook, and a fake hook to develop and test it without capturing anyone's mice.

lbm-ipc

  • endpoint: where the hook listens — the Linux socket ($XDG_RUNTIME_DIR/littlebigmouse-v1.sock, else in the data dir), the per-session Windows pipe, LBM_HOOK_ENDPOINTone definition for the daemon and its clients. lbm-hook now takes its default endpoint from it: same names as before, no behaviour change.
  • client::listen is spelled as the C# LocalIpcClient writes it; client::messages batches commands in one <Messages> frame, as C# sends every batch — Load and Run together keep the hook up across a re-apply (frame_rehooks).

lbm-agent

  • hook::HookClient: one connection for both directions — subscribe (Listen), then events in and commands out, in order. (C# opened a fresh connection per command, which is one of the ways commands could reach the daemon out of order — Cursor gets trapped at screen edges after disconnecting and waking from sleep #607/fix: never hook a layout the desktop no longer matches (#607) #609.) Kept up and retried every 100 ms; Lost when it drops (C# synthesizes Dead there), Unreachable on the first failed attempt then about every 5 s (C#'s ConnectionFailed cadence, the cue for launching a hook). Commands given while disconnected are dropped, never replayed stale — a reconnected hook asks for its layout anyway (ConnectedStopped, answered by the reconciler).
  • fake_hook::FakeHook: speaks the protocol and answers as lbm-hook does (state on Listen, Loaded/LoadFailed, Running/Stopped, Load unhooks unless its frame also runs), touching no input device. What --fake-hook will run, and what the tests talk to over a private endpoint.

Tests

Against the fake hook over a real Unix socket (a named pipe on the Windows runner): subscription and state, Load+Run in one frame, the hook's own events, loss and reconnection with nothing replayed, and the unreachable cadence. Repeated 15 times locally without a failure.

Nothing launches or talks to the real hook yet: supervision (D5) and the runtime come next.

🤖 Generated with Claude Code

…thing

- lbm-ipc::endpoint: where the hook listens, one definition for the daemon
  and its clients; lbm-hook now takes its default endpoint from it (same
  names as before). client::listen is written as the C# client writes it,
  and client::messages batches commands in one frame, as C# sends every
  batch (Load and Run together keep the hook up across a re-apply).
- lbm-agent::hook: one connection for both directions — subscribe, then
  events in and commands out in order (C# opened a connection per command).
  Kept up, retried every 100 ms; Lost when it drops, Unreachable on the
  first failed attempt then every ~5 s (the supervisor's cue). Commands
  given while disconnected are dropped, never replayed stale.
- lbm-agent::fake_hook: speaks the protocol and answers as lbm-hook does,
  touching no input device: what --fake-hook will run, and what the tests
  talk to over a private endpoint.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mgth
mgth merged commit b8ad56c into master Sep 11, 2026
3 checks passed
@mgth
mgth deleted the feat/lbm-agent-hook-client branch September 11, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant