perf(daemon-client): read the registration lock without a process-table run

Merged
TH
6h ago
+88-55

Summary

Every CLI and MCP request reads the daemon registration. That read judged the lock owner's liveness with a blocking ps run, but both callers (readRegisteredDaemon, startup birth recovery) only compare the recorded owner with daemon.json, so the judgment was thrown away. readProcessLock returns the recorded owner alone. inspectProcessLock keeps the liveness judgment for the startup paths that use it.

The explicit-lifecycle test seam that replayed lock inspections existed only to avoid this ps; it is deleted, and the file runs at the same speed.

Value

iPhone 17 Simulator, snapshot -i through agent-device mcp, 100 reads per arm, alternating arms:

  • MCP process CPU per call: 8.5 ms → 2.4 ms (sync spawnSync('ps') gone).
  • Client attach (daemon_startup diag): 6 ms → 1–2 ms on an installed tree.

Validation

  • Part of a read-latency series (#5193–#5197). Combined, on the external sign-in harness (iPhone 17 Simulator, iOS 27.0, checkout, warm runner): snapshot -i median 61–73 ms → 38–42 ms; press, fill, flow and batch unchanged or faster (all ops succeeded, flow reply tokens identical).

  • daemon-client-metadata.test.ts: new case pins that reading the registration spawns no process tool; it fails on origin/main.

  • Focused: process-lock, explicit lifecycle, registration owner, startup state root tests pass.

  • CI owns the full gates.

🤖 Generated with Claude Code