Skip to content

feat: phpmd-warm adapter + portable relative bins + daemon teardown fix#266

Merged
fdaviddpt merged 1 commit into
masterfrom
feat/mcp-phpmd-warm-and-portable-bins
May 30, 2026
Merged

feat: phpmd-warm adapter + portable relative bins + daemon teardown fix#266
fdaviddpt merged 1 commit into
masterfrom
feat/mcp-phpmd-warm-and-portable-bins

Conversation

@fdaviddpt
Copy link
Copy Markdown
Contributor

What

Wires up the PHPMD warm-process validator (4th sibling to rector/phpstan/phpunit) and fixes two issues that affect all four warm servers.

1. New validators/phpmd-mcp/ adapter

Connects to the dpt/mcp-phpmd-warm daemon over UDS, maps PHPMD's JSON report to SCHEMA.md warning entries with source_context. Non-blocking by design (smells surface at edit time, edit is never reverted). Closes the gap where PHPMD only ran at pre-push.

2. Portable relative MCP_*_BIN

The rector/phpstan/phpunit/phpmd adapters now resolve a relative bin path (e.g. Dvsi/dvsi-private/libs/bin/mcp-X-warm) against cwd before falling back to $PATH. Previously a relative path went straight to which(), which rejects path-like strings — so configs had to hardcode /Users/<dev>/… absolute paths. Since .supertool.json is committed/shared, that meant the warm validators only worked on the author's machine. Relative bins fix it for the whole team.

3. daemon.py teardown poll 0.5s → 0.05s

The bridge serves one client at a time and only notices a client disconnect at the top of proc_to_client's loop, after a blocking select(out_fd, …, 0.5). So each new connection waited out the previous connection's ≤0.5s teardown. For a cheap tool (phpmd ~50ms), back-to-back calls were dominated by ~0.5s of dead time (looked like "warm is 4× slower than cold"). Spaced calls were unaffected. Dropping the poll to 50ms brings back-to-back down to ~45ms steady. Benefits all four warm servers.

Testing

  • All adapters py_compile clean.
  • phpmd / rector / phpstan verified spawning + analyzing via relative bins against a real DVSI checkout (zero home-dir paths in config).
  • phpmd end-to-end through supertool paste: smells surface with line numbers, edit kept (non-blocking), ~50ms warm.
  • Companion: dpt/mcp-phpmd-warm v0.1.0 published (github.com/Digital-Process-Tools/mcp-phpmd-warm).

Three related changes for warm-process MCP validators:

1. New validators/phpmd-mcp/ adapter — talks to the dpt/mcp-phpmd-warm
   daemon, maps PHPMD JSON violations to SCHEMA.md warnings (non-blocking).

2. Portable relative MCP_*_BIN — rector/phpstan/phpunit/phpmd adapters now
   resolve a relative bin path (e.g. Dvsi/dvsi-private/libs/bin/mcp-X-warm)
   against cwd before falling back to $PATH. Lets a committed/shared
   .supertool.json drop the hardcoded /Users/<dev>/ home paths so the warm
   validators work on every machine, not just the author's.

3. daemon.py teardown poll 0.5s -> 0.05s — the bridge served one client at a
   time and only noticed a disconnect after a blocking select(out_fd, 0.5).
   Each new connection waited out the previous one's teardown, so rapid
   sequential calls to a cheap tool (phpmd ~50ms) were dominated by ~0.5s of
   dead time. Affects all four warm servers; masked before only because
   rector/phpstan have large per-call cost.

Co-Authored-By: Max <noreply>
@fdaviddpt fdaviddpt merged commit 9082bb2 into master May 30, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant