memorix icon indicating copy to clipboard operation
memorix copied to clipboard

fix doctor/background control-plane health diagnostics for HTTP mode

Open RaviTharuma opened this issue 7 months ago • 2 comments

Summary

Two CLI diagnostics paths currently misreport healthy HTTP control-plane setups:

  1. memorix doctor probes /health, but the HTTP control plane exposes /api/team and /mcp in real usage.
  2. memorix background status can classify a live memorix serve-http process as an unrelated reused PID when health probing fails transiently, even when the process command is actually Memorix.

Reproduction

Bug 1: doctor false negative

  1. Start the HTTP control plane with memorix background start or memorix serve-http --port 3211.
  2. Confirm the control plane responds on http://127.0.0.1:3211/api/team and completes MCP init/tool listing on http://127.0.0.1:3211/mcp.
  3. Run memorix doctor --json.

Expected

Doctor reports a healthy background control plane.

Actual

Doctor reports Background process is alive but health check failed. Try "memorix background restart". because it probes /health.

Bug 2: background status false reused-PID warning

  1. Start a real memorix serve-http process.
  2. Arrange for a transient health probe failure or stale state path.
  3. Run memorix background status.

Expected

Status distinguishes between a real Memorix process and an unrelated PID.

Actual

Status can print PID reused by unrelated process and clear state even when the PID command is actually memorix serve-http.

Verified locally

I verified the HTTP control plane responds via /api/team and MCP tool listing on /mcp, then reproduced the false CLI diagnostics against v1.0.6.

Proposed fix

  • Reuse a shared control-plane health helper that probes /api/team.
  • Add a narrow process-command check before treating a live PID as an unrelated reused process.
  • Add CLI regression tests for the health path and PID classification helper.

I have a PR ready from a fork with the minimal fix and regression coverage.

RaviTharuma avatar Apr 09 '26 22:04 RaviTharuma

Fixed in v1.0.7 memorix doctor now probes /api/team (the actual health endpoint) instead of /health which did not exist. This eliminates the false negative where doctor reports health check failed even when the control plane is running fine.

AVIDS2 avatar Apr 14 '26 16:04 AVIDS2

memorix background start on a current tsup build can spawn dist/index.js (stdio) instead of dist/cli/index.js serve-http, so the daemon exits immediately (stdin closed). Separate issue: the child may be $HOME/node_modules/memorix rather than the global install.

New write-ups: #219, #220. Fix direction: #214.

RaviTharuma avatar Aug 17 '26 13:08 RaviTharuma