feat(host): request devices by shape

Draft
VK
2mo ago
+2691-149

Stacked on #3272. Please review only the top three commits.

Summary

On Host, a worker requests a device by type (ADR 0021 §5):

agent-device open com.example.app --platform ios --device "iPhone 16"

If authenticated health reports device-shape, the client allocates by type instead of reading inventory, then addresses the leased device by UDID or serial. Anything else on a Host is refused, typed, before any lease request:

  • no --device, or a UDID or serial;
  • a missing token;
  • a Host without the feature;
  • another type on a session that holds one.

Plain proxy behaves as before.

The daemon validates a Host-principal lease_allocate, calls the new HostShapeAllocator seam, and publishes the lease bound to the returned device. It gives the allocation back if publishing fails or the requester left. /health advertises device-shape exactly when an allocator is set. No protocol bump.

The seam is proposed for #3269; nothing configures it yet, so tests use the scripted fake.

Closes #3267. 19 files, 924 gross lines vs #3272. Proxy lease device selection moves out of connection-runtime.ts (now under 1,000 lines).

Validation

Tested commit d3b9856c2:

  • pnpm check:affected --run: all pass except a flaky affected-selector test (ENOTEMPTY on temp cleanup; unchanged from main). The 17 checks after it pass when run separately.
  • pnpm check:daemon-wire-compat passed.
  • Tests: pre-lease refusals make no allocate call or inventory read; the leased UDID is pinned; the allocator gets the type and principal; cancellation and failed publication release the allocation.