fix(cli): never resolve a proxy connection through the machine-wide session pointer
Merged
TH
5h ago+777+777+012345678901234567890123456789-121-121-012345678901234567890123456789
Summary
Without --session, a command used .active-session.json, so agent A's snapshot ran on agent B's proxy lease. Amended rule for #3931:
- On a leased connection (any
leaseProvider, including a remote config that sets one), every command needs an explicit session from--session,AGENT_DEVICE_SESSION, or config. That coversconnect,open,open --remote-config,batch,close,disconnect, andconnection status. - Otherwise the command fails with
INVALID_ARGS, reasonREMOTE_SESSION_REQUIRED, using the parser's lease provider. No second profile read and no lease work happen first. - Nothing mints a session. Each session on a shared leased profile gets a client and run derived from its name, so two sessions never share a lease. A host-issued lease keeps its scope.
- A named session never reads the pointer. Unnamed non-leased flows are unchanged.
Behavior change: unnamed CI flows on lease providers now fail. Migration: set AGENT_DEVICE_SESSION=<name> per job before connect. Migrated here: the BrowserStack smoke test (asserting the refusal), help remote, the provider docs, and the Revyl, TestMu and proxy READMEs.
Direct daemon RPC callers are not covered here; tracked in #4171.
Fixes #3931
Validation
- Gate
355a90b9bb: passed,exactCommit=true. - New
cli-leased-session.test.ts(8 tests) covers:- two agents on one proxy, and on one shared profile, replayed against a real daemon;
- a single profile read;
- unnamed leased commands refused with no RPC;
- a Limrun collision;
- named sources;
- a
macos-apphost lease.
- No device run (CLI-only).
š¤ Generated with Claude Code