UAT: LspRegistry.remove() does not terminate running LSP server processes — spec requires process termination on removal #2496

Open
opened 2026-04-03 18:39:25 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/lsp-registry-remove-terminate-process
  • Commit Message: fix(lsp): terminate running LSP server processes when removing from registry
  • Milestone: v3.6.0
  • Parent Epic: #824

Summary

LspRegistry.remove() in src/cleveragents/lsp/registry.py only removes the server configuration from the in-memory registry dict. It does not terminate any running LSP server processes associated with the removed entry. The spec requires that running processes be terminated when a server is removed. This leaves orphaned language server processes running after agents lsp remove is called.

What Was Tested

  • Code analysis of src/cleveragents/lsp/registry.py
  • Code analysis of src/cleveragents/cli/commands/lsp.py
  • Code analysis of src/cleveragents/lsp/lifecycle.py
  • Specification review of LSP server removal requirements

Expected Behavior (from spec)

Per docs/specification.md (line 8800):

"Remove a registered LSP server from the LSP Registry. Running LSP server processes bound to the removed entry are terminated. Actor configurations referencing this server by name will fail at activation until resolved."

When agents lsp remove <name> is called:

  1. The server config is removed from the LSP Registry
  2. Any running LSP server process for that server is terminated (via LspLifecycleManager.stop_server())
  3. A warning is shown if actors reference the removed server

Actual Behavior

In src/cleveragents/lsp/registry.py (lines 137-157), LspRegistry.remove() only does:

def remove(self, name: str) -> bool:
    if not name:
        raise ValueError("name must be a non-empty string")
    with self._lock:
        if name in self._servers:
            del self._servers[name]  # ← only removes config dict entry
            logger.info("Removed LSP server: %s", name)
            return True
        return False

No call to LspLifecycleManager.stop_server() or any process termination.

In src/cleveragents/cli/commands/lsp.py (lines 228-237), the remove command calls registry.remove(name) and that's it — no lifecycle manager interaction.

Code Locations

  • src/cleveragents/lsp/registry.py lines 137-157: remove() method — no process termination
  • src/cleveragents/cli/commands/lsp.py lines 228-237: remove command — no lifecycle manager call

Impact

When a user runs agents lsp remove local/pyright:

  1. The registry entry is removed (config no longer accessible)
  2. But the pyright-langserver process continues running in the background
  3. Resources (memory, CPU, file handles) are leaked
  4. The orphaned process may interfere with future LSP server starts for the same workspace

Subtasks

  • LspRegistry should accept an optional LspLifecycleManager dependency (or the CLI command should coordinate between registry and lifecycle manager)
  • When remove() is called, check if the server is running via LspLifecycleManager.health_check(name) and call stop_server(name) if so
  • Handle the case where the server is not running gracefully (no error)
  • Update the CLI remove command to coordinate registry removal with lifecycle manager
  • Add BDD test verifying that process termination occurs on removal
  • Verify all CI checks pass

Definition of Done

  • agents lsp remove <name> terminates any running LSP server process for that server
  • No orphaned processes remain after removal
  • BDD test covers the process termination behavior
  • All CI checks pass
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/lsp-registry-remove-terminate-process` - **Commit Message**: `fix(lsp): terminate running LSP server processes when removing from registry` - **Milestone**: v3.6.0 - **Parent Epic**: #824 ## Summary `LspRegistry.remove()` in `src/cleveragents/lsp/registry.py` only removes the server configuration from the in-memory registry dict. It does not terminate any running LSP server processes associated with the removed entry. The spec requires that running processes be terminated when a server is removed. This leaves orphaned language server processes running after `agents lsp remove` is called. ## What Was Tested - Code analysis of `src/cleveragents/lsp/registry.py` - Code analysis of `src/cleveragents/cli/commands/lsp.py` - Code analysis of `src/cleveragents/lsp/lifecycle.py` - Specification review of LSP server removal requirements ## Expected Behavior (from spec) Per `docs/specification.md` (line 8800): > "Remove a registered LSP server from the LSP Registry. **Running LSP server processes bound to the removed entry are terminated.** Actor configurations referencing this server by name will fail at activation until resolved." When `agents lsp remove <name>` is called: 1. The server config is removed from the LSP Registry 2. Any running LSP server process for that server is terminated (via `LspLifecycleManager.stop_server()`) 3. A warning is shown if actors reference the removed server ## Actual Behavior In `src/cleveragents/lsp/registry.py` (lines 137-157), `LspRegistry.remove()` only does: ```python def remove(self, name: str) -> bool: if not name: raise ValueError("name must be a non-empty string") with self._lock: if name in self._servers: del self._servers[name] # ← only removes config dict entry logger.info("Removed LSP server: %s", name) return True return False ``` No call to `LspLifecycleManager.stop_server()` or any process termination. In `src/cleveragents/cli/commands/lsp.py` (lines 228-237), the `remove` command calls `registry.remove(name)` and that's it — no lifecycle manager interaction. ## Code Locations - `src/cleveragents/lsp/registry.py` lines 137-157: `remove()` method — no process termination - `src/cleveragents/cli/commands/lsp.py` lines 228-237: `remove` command — no lifecycle manager call ## Impact When a user runs `agents lsp remove local/pyright`: 1. The registry entry is removed (config no longer accessible) 2. But the `pyright-langserver` process continues running in the background 3. Resources (memory, CPU, file handles) are leaked 4. The orphaned process may interfere with future LSP server starts for the same workspace ## Subtasks - [ ] `LspRegistry` should accept an optional `LspLifecycleManager` dependency (or the CLI command should coordinate between registry and lifecycle manager) - [ ] When `remove()` is called, check if the server is running via `LspLifecycleManager.health_check(name)` and call `stop_server(name)` if so - [ ] Handle the case where the server is not running gracefully (no error) - [ ] Update the CLI `remove` command to coordinate registry removal with lifecycle manager - [ ] Add BDD test verifying that process termination occurs on removal - [ ] Verify all CI checks pass ## Definition of Done - `agents lsp remove <name>` terminates any running LSP server process for that server - No orphaned processes remain after removal - BDD test covers the process termination behavior - All CI checks pass - All nox stages pass - Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.6.0 milestone 2026-04-03 18:39:30 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: Should Have — Spec compliance or quality improvement that should be included in the milestone.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: Should Have — Spec compliance or quality improvement that should be included in the milestone. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Confirmed
  • MoSCoW: Should Have (already set)

Valid finding verified during batch triage.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: Confirmed - **MoSCoW**: Should Have (already set) Valid finding verified during batch triage. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo removed this from the v3.6.0 milestone 2026-04-07 00:49:04 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#824 Epic: LSP Functional Runtime
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2496
No description provided.