Agent API over unix socket (labctl LAB_URL unix://) #201
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/coding-lab#201
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
Move the agent surface off loopback TCP: the server additionally listens for /agent/v1 on a unix domain socket at
<state-dir>/agent.sock, and labctl learns a unix scheme for LAB_URL (e.g.unix:///run/lab/agent.sock). Spawned runs get the unix LAB_URL by default. This is the transport the container runner will bind-mount into instances; it must also work for today's host-spawned runs, end to end (labctl issue/pr/secret commands + pre-push scan).The web UI / human HTTP surface stays on its existing TCP listener; only the agent API is dual-listened. Socket file mode must restrict access to the lab user; recreate stale sockets on boot.
Acceptance criteria
<state-dir>/agent.sockin addition to the existing TCP listener; socket is 0700-owned by the service user and safely recreated on restartLAB_URL=unix:///abs/path(all subcommands, including secret exec and secret scan) with unchanged behavior for http URLsBlocked by
None - can start immediately
Agent Brief
Category: enhancement
Summary: Serve /agent/v1 on a unix domain socket and teach labctl a
unix://LAB_URL scheme; spawned runs default to the socket.The issue body's "What to build" and acceptance-criteria checklist are the authoritative spec (grilled 2026-07-22). This brief adds the interface map and scope fences.
Current behavior:
The /agent/v1 tree is one handler (built by the agent-API package's
New(...)/Handler(), guarded by run-tokenAuthMiddleware) mounted on the same TCP listener as the human/web surface. ThelabURLhelper resolves the URL handed to runs with precedence AgentURL → BaseURL →http://127.0.0.1:<port>loopback, andspawnEnvemits it asLAB_URL. labctl only speaks http/https.Desired behavior:
The same agent handler is additionally served on a unix socket at
<state-dir>/agent.sock(mode restricted to the service user; stale socket unlinked and recreated on boot). labctl acceptsLAB_URL=unix:///abs/pathin every subcommand — includingsecret execandsecret scan, which the pre-push guard hook shells out to — with http(s) behavior unchanged.spawnEnvhands new runs the unix URL by default; the web/human TCP surface is untouched.Key interfaces:
Handler()— reuse the one mux on a second listener; do not duplicate routes. Run-token auth must apply identically over the socket.labURLresolution precedence — extend so the socket becomes the default agent URL for spawned runs while explicit AgentURL config still wins.unixscheme should route through a transport whose dialer connects to the socket path; one shared client seam so all subcommands inherit it.Acceptance criteria: the checklist in the issue body.
Out of scope: