Repository navigation
Description
Problem
The MCP surface is exactly two tools — lease_simulator and
release_simulator (src/mcp/server.ts). An agent holding a device for hours
therefore has:
- no cheap way to ask "do I still hold a device?" After a context
compaction, or any suspicion that something changed, its only option is to
poke the device and infer from the failure. - no way to learn that its lease ended. When a lease expires or is
force-released (pitlane release --all,nuke, doctor expiry), the daemon
emitslease.expired/lease.releasedon the event bus, but nothing is
pushed to the holding connection.McpSession.#ownedLeaseIdkeeps claiming
ownership of a lease that no longer exists.
Both matter much more once leases are long-lived.
Proposed change
lease_status tool (read-only): returns this session's current lease —
lease_id, device, os, platform, device_id, address,
expires_at_ms, state — or an explicit "no lease held" result. Small output,
cheap to call, safe to call repeatedly.
Lease-lost notification: the daemon pushes a lease-ended fact to the
connection holding that lease (the push-frame channel already exists and is
used for progress). McpSession clears #ownedLeaseId and relays it to the
client as an MCP logging notification, so a well-behaved agent finds out its
device is gone instead of silently operating on a device that was erased and
possibly handed to someone else.
Notes
- Events stay observer-only: the daemon subscribes to the existing
post-commitlease.expired/lease.releasedfacts and pushes to the
affected connection. No transaction waits on an event (events rule). - Keep the MCP surface focused — this adds one read-only tool and one
notification, not the operator surface. Status, config, events, cleanup and
destructive commands stay CLI-only as documented in the README.
Depends on #12 (the notification and the status tool are what make a
long-lived lease observable).
Acceptance criteria
-
lease_statusreturns the held lease's details, and a well-formed
"none" result when the session holds nothing. - Expiring or force-releasing a lease pushes a notification to the holding
connection and clearsMcpSession.#ownedLeaseId. - After a lease-lost notification,
release_simulatorfor that lease id
returnsLEASE_NOT_OWNEDrather than a transport error. - A push to a closed connection cannot break the daemon (handler failures
stay isolated from emitters). - README MCP section documents the third tool and the notification.
-
pnpm checkgreen.
Activity