Part of #722 (Milestone 2 — high leverage). Blocked by: #723, #724 (safety-net tests) and #726 (contracts extraction — overlapping import graphs, do not parallelize).
src/daemon-client.ts (1,801 LOC) mixes daemon discovery/spawn/lock-recovery, socket/HTTP transport selection and retries, progress-stream parsing, artifact upload/download, and lease RPC marshaling. Four functions are grandfathered complexity-critical in fallow-baselines/health.json. Maintainer-approved on the condition it improves maintainability and readability.
Approach — one seam per PR, in dependency order
- Artifacts (
sendHttpRequest, downloadRemoteArtifact, materialization helpers) → daemon-artifacts.ts — most self-contained
- Progress streaming → merge with existing
daemon-client-progress.ts
- Lifecycle (
ensureDaemon, startLocalDaemon, lock/info handling, isReusableDaemonInfo) → daemon-lifecycle.ts
- Transport selection/retry →
daemon-transport.ts
Keep daemon-client.ts as a façade re-exporting the current public surface so cli.ts, MCP, and the fallow entry graph see no change.
Gotchas
- Module-level state (cached settings, shared in-flight spawn promise) must move intact — spawn dedup relies on a shared promise
- rslib bundles
.d.ts; verify declaration output unchanged
- Update
fallow-baselines/health.json keys (file-keyed) in each PR
Acceptance criteria (after the final PR)
Effort: XL (4 PRs). Risk: medium.
Part of #722 (Milestone 2 — high leverage). Blocked by: #723, #724 (safety-net tests) and #726 (contracts extraction — overlapping import graphs, do not parallelize).
src/daemon-client.ts(1,801 LOC) mixes daemon discovery/spawn/lock-recovery, socket/HTTP transport selection and retries, progress-stream parsing, artifact upload/download, and lease RPC marshaling. Four functions are grandfathered complexity-critical infallow-baselines/health.json. Maintainer-approved on the condition it improves maintainability and readability.Approach — one seam per PR, in dependency order
sendHttpRequest,downloadRemoteArtifact, materialization helpers) →daemon-artifacts.ts— most self-containeddaemon-client-progress.tsensureDaemon,startLocalDaemon, lock/info handling,isReusableDaemonInfo) →daemon-lifecycle.tsdaemon-transport.tsKeep
daemon-client.tsas a façade re-exporting the current public surface socli.ts, MCP, and the fallow entry graph see no change.Gotchas
.d.ts; verify declaration output unchangedfallow-baselines/health.jsonkeys (file-keyed) in each PRAcceptance criteria (after the final PR)
daemon-client.ts< 600 LOC; fallow complexity-critical count for the client path: 4 → 0src/index.tsexports untouched); smoke tests greenEffort: XL (4 PRs). Risk: medium.