fix(daemon): refuse a lease-less provider request as unallocated
Summary
On a Limrun connection, shutdown after close --shutdown has no lease. Since #4275 the CLI no longer allocates an instance for it. Lease admission still refused it with an untyped INVALID_ARGS: tenant isolation requires lease id. and an SDK-only hint.
Admission now names the missing instance. A runtime-backed provider (leaseProviderRequiringRuntime, after normalizeLeaseProvider) that sent no lease id gets DEVICE_NOT_FOUND with details.reason: 'provider_instance_unallocated', the same refusal device inventory raises (one factory in @agent-device/contracts/device). The check sits in the missing-lease-id branch, after tenant and run id validation. A malformed lease id, or a logical proxy/cloud lease, keeps INVALID_ARGS. The hint names boot/open. The shutdown help and limrun.md name the code and reason. 10 files. Fixes #4303.
Validation
Head 0e1a742b4f: pnpm check:affected --run --head 0e1a742b4f passed, exactCommit=true. It differs from the live-run commit 789be94623 only by a code comment in lease-registry-scope.ts; 789be94623 also passed check:affected and all 19 CI checks. The admission tests fail on base. Literal rows pin runtime vs logical providers, a malformed id, run id ordering, and a padded ' limrun ' provider with a blank lease id.
Live run on Limrun iOS with the source CLI: connect limrun --platform ios, open com.apple.Preferences, close --shutdown, shutdown --json:
| Build | shutdown --json | Instances created |
|---|---|---|
base 83945b7a9f | INVALID_ARGS "tenant isolation requires lease id.", no details | none |
head 789be94623 | DEVICE_NOT_FOUND, details: { reason: 'provider_instance_unallocated', leaseProvider: 'limrun' } | only the open instance, terminated after close --shutdown (listed by source=agent-device-cli, any state) |
At d03ca2b7e4, a following open allocated a fresh instance (exit 0). The allocation from the report happened on 0.21.36; #4275 already removed it on main. Every instance was released.
š¤ Generated with Claude Code