TDD: LSP Transport Process Resource Leak on Exception in StdioTransport.start() #7047

Open
opened 2026-04-10 07:24:36 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Branch: tdd/m3.6.0-lsp-transport-resource-leak
  • Commit Message: test(lsp): add tdd issue-capture test for StdioTransport.start() resource leak
  • Milestone: v3.6.0
  • Parent Epic: #824
  • Bug Issue: #7044

Background and Context

This is the TDD issue-capture companion to bug #7044 (LSP Transport Process Resource Leak on Exception in StdioTransport.start()). Per the project's mandatory Bug Fix Workflow, every Type/Bug issue requires a corresponding Type/Testing issue whose sole deliverable is a Behave scenario that proves the bug exists before the fix is implemented.

The test must be tagged @tdd_issue @tdd_issue_7044 @tdd_expected_fail so that CI passes while the bug is unfixed (the framework inverts the result). The @tdd_expected_fail tag is removed by the bug-fix developer when they implement the fix in #7044.

Deliverable

A single Behave scenario (or minimal set of scenarios) in features/ that:

  1. Spawns a StdioTransport and forces an exception to occur after subprocess.Popen succeeds but before start() returns (e.g., by monkeypatching structlog.get_logger or the post-spawn logger call to raise)
  2. Asserts that after the exception propagates, the subprocess has been terminated (i.e., process.poll() is not None) and transport.is_alive is False
  3. Is tagged with all three required tags: @tdd_issue, @tdd_issue_7044, @tdd_expected_fail

Example skeleton (Gherkin):

@tdd_issue @tdd_issue_7044 @tdd_expected_fail
Scenario: StdioTransport cleans up subprocess when post-spawn initialization raises
  Given a StdioTransport configured with a valid command
  And the post-spawn logger is patched to raise RuntimeError
  When start() is called and the exception propagates
  Then the spawned subprocess is terminated
  And transport.is_alive is False
  And transport._process is None

The mock/patch code must live under features/mocks/ per project file organization rules.

Acceptance Criteria

  • Behave scenario exists that reproduces the resource leak condition
  • Scenario is tagged @tdd_issue @tdd_issue_7044 @tdd_expected_fail
  • Test passes CI (because @tdd_expected_fail inverts the result while the bug is unfixed)
  • Test is placed in the correct features/ subdirectory (alongside other LSP transport tests, or in a new features/lsp/ file if none exists)
  • Mock/patch code lives under features/mocks/
  • All nox stages pass

Subtasks

  • Locate or create the appropriate Behave feature file for LSP transport tests under features/
  • Write the Gherkin scenario with all three required tags
  • Implement step definitions (extend existing LSP step file if one exists, otherwise create features/steps/lsp_transport_steps.py)
  • Place any mock/patch helpers under features/mocks/
  • Verify the scenario passes CI with @tdd_expected_fail present (bug still exists → test passes)
  • Run nox (all default sessions), fix any errors
  • Verify coverage ≥ 97% via nox -s coverage_report

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details.
  • The commit is pushed to the remote on the branch tdd/m3.6.0-lsp-transport-resource-leak.
  • The commit is submitted as a pull request to master, reviewed, and merged.
  • The TDD issue is closed when the PR is merged.
  • Bug issue #7044 remains open and depends on this TDD issue until the fix is implemented.

Automated by CleverAgents Bot
Supervisor: Acting on behalf of: UAT Testing | Agent: new-issue-creator

## Metadata - **Branch**: `tdd/m3.6.0-lsp-transport-resource-leak` - **Commit Message**: `test(lsp): add tdd issue-capture test for StdioTransport.start() resource leak` - **Milestone**: v3.6.0 - **Parent Epic**: #824 - **Bug Issue**: #7044 ## Background and Context This is the TDD issue-capture companion to bug #7044 (LSP Transport Process Resource Leak on Exception in `StdioTransport.start()`). Per the project's mandatory [Bug Fix Workflow](../CONTRIBUTING.md#bug-fix-workflow), every `Type/Bug` issue requires a corresponding `Type/Testing` issue whose sole deliverable is a Behave scenario that **proves the bug exists** before the fix is implemented. The test must be tagged `@tdd_issue @tdd_issue_7044 @tdd_expected_fail` so that CI passes while the bug is unfixed (the framework inverts the result). The `@tdd_expected_fail` tag is removed by the bug-fix developer when they implement the fix in #7044. ## Deliverable A single Behave scenario (or minimal set of scenarios) in `features/` that: 1. Spawns a `StdioTransport` and forces an exception to occur **after** `subprocess.Popen` succeeds but **before** `start()` returns (e.g., by monkeypatching `structlog.get_logger` or the post-spawn logger call to raise) 2. Asserts that after the exception propagates, the subprocess has been terminated (i.e., `process.poll()` is not `None`) and `transport.is_alive` is `False` 3. Is tagged with all three required tags: `@tdd_issue`, `@tdd_issue_7044`, `@tdd_expected_fail` **Example skeleton (Gherkin):** ```gherkin @tdd_issue @tdd_issue_7044 @tdd_expected_fail Scenario: StdioTransport cleans up subprocess when post-spawn initialization raises Given a StdioTransport configured with a valid command And the post-spawn logger is patched to raise RuntimeError When start() is called and the exception propagates Then the spawned subprocess is terminated And transport.is_alive is False And transport._process is None ``` The mock/patch code must live under `features/mocks/` per project file organization rules. ## Acceptance Criteria - [ ] Behave scenario exists that reproduces the resource leak condition - [ ] Scenario is tagged `@tdd_issue @tdd_issue_7044 @tdd_expected_fail` - [ ] Test **passes** CI (because `@tdd_expected_fail` inverts the result while the bug is unfixed) - [ ] Test is placed in the correct `features/` subdirectory (alongside other LSP transport tests, or in a new `features/lsp/` file if none exists) - [ ] Mock/patch code lives under `features/mocks/` - [ ] All `nox` stages pass ## Subtasks - [ ] Locate or create the appropriate Behave feature file for LSP transport tests under `features/` - [ ] Write the Gherkin scenario with all three required tags - [ ] Implement step definitions (extend existing LSP step file if one exists, otherwise create `features/steps/lsp_transport_steps.py`) - [ ] Place any mock/patch helpers under `features/mocks/` - [ ] Verify the scenario passes CI with `@tdd_expected_fail` present (bug still exists → test passes) - [ ] Run `nox` (all default sessions), fix any errors - [ ] Verify coverage ≥ 97% via `nox -s coverage_report` ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details. - The commit is pushed to the remote on the branch `tdd/m3.6.0-lsp-transport-resource-leak`. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged**. - The TDD issue is closed when the PR is merged. - Bug issue #7044 remains open and **depends on** this TDD issue until the fix is implemented. --- **Automated by CleverAgents Bot** Supervisor: Acting on behalf of: UAT Testing | Agent: new-issue-creator
HAL9000 added this to the v3.6.0 milestone 2026-04-10 07:24:52 +00:00
Author
Owner

Verified — TDD test for critical resource leak: LSP Transport process resource leak. MoSCoW: Must-have. Priority: Critical.


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

✅ **Verified** — TDD test for critical resource leak: LSP Transport process resource leak. MoSCoW: Must-have. Priority: Critical. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

Reference
cleveragents/cleveragents-core#7047
No description provided.