Files
ruflo/v3/@claude-flow/cli/__tests__/services
Ofer Shaal a553da3439 fix(daemon): self-terminating TTL + idle shutdown, global status --all, honest HNSW/init footguns (#2361)
Carry-forward of the still-open, fixable-in-ruflo findings from
pacphi/ruflo-machine-ref (token-leak + honesty investigations). Most of
that kit's findings already landed upstream (#2219 SQLite, #2222 route
persistence, #2239 encoder collapse in 3.10.11); this addresses what
remained.

Daemon token-leak (root cause of multi-day background token burn):
- worker-daemon: self-terminating lifecycle. New ttlMs (default 24h) +
  idleShutdownMs (opt-in) config, sourced constructor > config.json
  (daemon.ttlSecs/idleSecs) > env (RUFLO_DAEMON_TTL_SECS/IDLE_SECS) >
  default. A monitor (unref'd, 60s) grace-shuts-down via stop()+exit(0),
  mirroring the signal path so the foreground ref'd keep-alive can't leave
  a zombie. An explicit 0 disables (preserves run-until-stopped).
- daemon command: --ttl flag (forwarded through the background fork) and
  TTL shown in the status/start boxes.
- daemon status --all: global view across every workspace via the same
  ps/tasklist scan used by kill-stale, reading each workspace's
  daemon-state.json for age + TTL and flagging daemons past their TTL/12h.
  Leaked daemons in other workspaces were previously invisible.

Honest status / init footguns:
- neural status: getHNSWStatus() now reports real capability
  (@ruvector/core resolvable) vs in-process load, ending the false
  "HNSW Not loaded" when the package is installed.
- init: keep auth-gated cloud MCP servers (ruv-swarm, flow-nexus) opt-in
  even under --full via a new --cloud-mcp flag (committed .mcp.json +
  per-session token cost).
- claudemd-generator: emit `ruflo@latest mcp start` (matches the actual
  generated .mcp.json) instead of legacy `@claude-flow/cli@latest`, and
  note the daemon's token cost + TTL.

Tests: TTL/idle precedence + 0-disable + monitor arming; the
extractWorkspaceFromDaemonLine helper behind --all; HNSW status contract
updated to assert initialized-vs-available separation.

Credit: investigation, reproductions, and statistical eval by
@pacphi (https://github.com/pacphi/ruflo-machine-ref).
2026-06-12 08:55:12 -04:00
..