Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# PRD: FU-P13-T4-2 — Implement or remove reconnect parameter in BrokerProxy

**Created:** 2026-02-18
**Priority:** P2
**Branch:** `codex/feature/FU-P13-T4-2-reconnect-parameter`
**Status:** PLAN

---

## 1. Problem Statement

`BrokerProxy` accepts a `reconnect` parameter, stores it, and documents reconnect behavior, but `_run_bridge` never reads this setting. This leaves dead configuration in the API and ambiguous expectations for callers.

---

## 2. Scope

### In Scope
- Remove the unused `reconnect` parameter from `BrokerProxy.__init__` and internal state.
- Remove reconnect claims from proxy module docs/docstrings that no longer match behavior.
- Update call sites and tests that pass `reconnect=`.
- Add/adjust tests to ensure no dead reconnect API remains.

### Out of Scope
- Adding reconnect loop behavior to proxy I/O lifecycle.
- Broker daemon reconnect logic (`broker/daemon.py`).
- New CLI flags for reconnect tuning.

---

## 3. Deliverables

1. `src/mcpbridge_wrapper/broker/proxy.py`
- Remove `reconnect` constructor argument and `_reconnect` field.
- Update docstrings to reflect current behavior (no proxy-level reconnect retry).

2. `src/mcpbridge_wrapper/__main__.py`
- Remove obsolete `reconnect=False` argument at proxy construction.

3. `tests/unit/test_broker_proxy.py`
- Keep coverage around proxy forwarding/connect/exit behavior and ensure API remains clean.

4. `SPECS/INPROGRESS/FU-P13-T4-2_Validation_Report.md`
- Record quality-gate results and acceptance evidence.

---

## 4. Acceptance Criteria

- [ ] `BrokerProxy.__init__` no longer exposes an unused `reconnect` parameter.
- [ ] No dead reconnect state remains in proxy implementation.
- [ ] Relevant unit tests pass with updated API.
- [ ] Full quality gates pass:
- `pytest`
- `ruff check src/`
- `mypy src/`
- `pytest --cov` (coverage >= 90%)

---

## 5. Dependencies

- P13-T4 ✅

---

## 6. Risks and Mitigations

- **Risk:** Existing callers may still pass `reconnect=` and break at runtime.
- **Mitigation:** Update known call site (`__main__.py`) and run full test suite to catch hidden usage.

---

## 7. Validation Plan

1. Search repository for `reconnect=` uses in proxy construction and remove obsolete usage.
2. Run `pytest tests/unit/test_broker_proxy.py`.
3. Run required quality gates and record outputs in validation report.


---
**Archived:** 2026-02-18
**Verdict:** PASS
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Validation Report: FU-P13-T4-2

**Task:** FU-P13-T4-2 — Implement or remove reconnect parameter in BrokerProxy
**Date:** 2026-02-18
**Branch:** `codex/feature/FU-P13-T4-2-reconnect-parameter`

## Scope validated

- Removed the unused `reconnect` parameter from `BrokerProxy.__init__` and deleted dead `_reconnect` state.
- Updated proxy construction in `src/mcpbridge_wrapper/__main__.py` to remove obsolete argument.
- Updated proxy tests and added constructor-signature assertion to prevent reconnect API regression.

## Quality gates

### 1) Targeted task test

Command:

```bash
pytest tests/unit/test_broker_proxy.py
```

Result: **PASS** (`16 passed`)

### 2) Full test suite

Command:

```bash
pytest
```

Result: **PASS** (`578 passed, 5 skipped`)

### 3) Lint

Command:

```bash
ruff check src/
```

Result: **PASS** (`All checks passed!`)

### 4) Type checks

Command:

```bash
mypy src/
```

Result: **PASS** (`Success: no issues found in 18 source files`)

### 5) Coverage

Command:

```bash
pytest --cov
```

Result: **PASS** (`Total coverage: 92.31%`, threshold: `>= 90%`)

## Acceptance criteria evidence

- [x] `BrokerProxy.__init__` no longer exposes an unused `reconnect` parameter.
- Evidence: `tests/unit/test_broker_proxy.py::TestBrokerProxyConnectTimeout::test_constructor_has_no_reconnect_parameter` passed.
- [x] No dead reconnect state remains in proxy implementation.
- Evidence: `rg -n "reconnect|_reconnect" src/mcpbridge_wrapper/broker/proxy.py src/mcpbridge_wrapper/__main__.py` returned no reconnect parameter/state references.
- [x] Relevant unit tests pass with updated API.
- Evidence: `pytest tests/unit/test_broker_proxy.py` -> `16 passed`.
- [x] Full quality gates pass.
- Evidence: `pytest`, `ruff check src/`, `mypy src/`, and `pytest --cov` all passed; coverage `92.31%`.

## Notes

- Existing `websockets` deprecation warnings in Web UI tests remain unchanged and unrelated to this task.
6 changes: 5 additions & 1 deletion SPECS/ARCHIVE/INDEX.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mcpbridge-wrapper Tasks Archive

**Last Updated:** 2026-02-18 (FU-P13-T4-1)
**Last Updated:** 2026-02-18 (FU-P13-T4-2)

## Archived Tasks

Expand Down Expand Up @@ -111,6 +111,7 @@
| P13-T5 | [P13-T5_Validate_prompt_reduction_and_multi_client_stability/](P13-T5_Validate_prompt_reduction_and_multi_client_stability/) | 2026-02-18 | PARTIAL |
| P13-T6 | [P13-T6_Document_broker_mode_configuration_migration_and_rollback/](P13-T6_Document_broker_mode_configuration_migration_and_rollback/) | 2026-02-18 | PASS |
| FU-P13-T4-1 | [FU-P13-T4-1_Fix_asyncio_get_event_loop_deprecation_in_BrokerProxy/](FU-P13-T4-1_Fix_asyncio_get_event_loop_deprecation_in_BrokerProxy/) | 2026-02-18 | PASS |
| FU-P13-T4-2 | [FU-P13-T4-2_Implement_or_remove_reconnect_parameter_in_BrokerProxy/](FU-P13-T4-2_Implement_or_remove_reconnect_parameter_in_BrokerProxy/) | 2026-02-18 | PASS |

## Historical Artifacts

Expand Down Expand Up @@ -185,6 +186,7 @@
| [REVIEW_P13-T5_prompt_reduction_multi_client_stability.md](_Historical/REVIEW_P13-T5_prompt_reduction_multi_client_stability.md) | Review report for P13-T5 |
| [REVIEW_P13-T6_broker_mode_configuration_migration.md](_Historical/REVIEW_P13-T6_broker_mode_configuration_migration.md) | Review report for P13-T6 |
| [REVIEW_FU-P13-T4-1_broker_proxy_loop.md](_Historical/REVIEW_FU-P13-T4-1_broker_proxy_loop.md) | Review report for FU-P13-T4-1 |
| [REVIEW_FU-P13-T4-2_broker_proxy_reconnect.md](_Historical/REVIEW_FU-P13-T4-2_broker_proxy_reconnect.md) | Review report for FU-P13-T4-2 |

## Archive Log

Expand Down Expand Up @@ -324,3 +326,5 @@
| 2026-02-18 | P13-T6 | Archived REVIEW_P13-T6_broker_mode_configuration_migration report |
| 2026-02-18 | FU-P13-T4-1 | Archived Fix_asyncio_get_event_loop_deprecation_in_BrokerProxy (PASS) |
| 2026-02-18 | FU-P13-T4-1 | Archived REVIEW_FU-P13-T4-1_broker_proxy_loop report |
| 2026-02-18 | FU-P13-T4-2 | Archived Implement_or_remove_reconnect_parameter_in_BrokerProxy (PASS) |
| 2026-02-18 | FU-P13-T4-2 | Archived REVIEW_FU-P13-T4-2_broker_proxy_reconnect report |
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## REVIEW REPORT — FU-P13-T4-2 broker proxy reconnect

**Scope:** origin/main..HEAD
**Files:** 8

### Summary Verdict
- [x] Approve
- [ ] Approve with comments
- [ ] Request changes
- [ ] Block

### Critical Issues
- None.

### Secondary Issues
- None.

### Architectural Notes
- Removing the unused `reconnect` constructor argument reduces API surface area and aligns implementation, docs, and call sites.
- The constructor-signature test in `tests/unit/test_broker_proxy.py` guards against accidental reintroduction of dead parameters.

### Tests
- Required quality gates were run during EXECUTE and all passed:
- `pytest`
- `ruff check src/`
- `mypy src/`
- `pytest --cov` (92.31%, threshold 90%)

### Next Steps
- No actionable review findings.
- FOLLOW-UP step is skipped per FLOW rules.
4 changes: 2 additions & 2 deletions SPECS/INPROGRESS/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Recently Archived

- 2026-02-18 — FU-P13-T4-2: Implement or remove reconnect parameter in BrokerProxy (PASS)
- 2026-02-18 — FU-P13-T4-1: Fix asyncio.get_event_loop() deprecation in BrokerProxy (PASS)
- 2026-02-18 — P13-T6: Document broker mode configuration, migration, and rollback (PASS)
- 2026-02-18 — P13-T5: Validate prompt reduction and multi-client stability (PARTIAL)
- 2026-02-18 — P13-T4: Add stdio proxy mode for compatibility with existing MCP clients (PASS)
- 2026-02-18 — P13-T3: Implement multi-client transport and JSON-RPC multiplexing (PASS)
- 2026-02-17 — P13-T2: Implement persistent broker daemon with single upstream Xcode bridge (PASS)

## Suggested Next Tasks

- FU-P13-T4-2 — Implement or remove `reconnect` parameter in `BrokerProxy` (P2)
- P13-T5 follow-up — Complete interactive prompt verification in a desktop session (P1)
- FU-P13-T2-1 — Replace run_forever() polling loop with asyncio.Event-based wait (P3)
- FU-BUG-T7-1 — Cap `pending_methods` map to guard against unbounded growth (P3)
9 changes: 5 additions & 4 deletions SPECS/Workplan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,8 @@ Phase 9 Follow-up Backlog

---

#### FU-P13-T4-2: Implement or remove reconnect parameter in BrokerProxy
#### ✅ FU-P13-T4-2: Implement or remove reconnect parameter in BrokerProxy
- **Status:** ✅ Completed (2026-02-18)
- **Description:** The `reconnect: bool` parameter is stored but never used in `_run_bridge`. Either implement the reconnect loop (retry once on broken socket before stdin EOF) or remove the parameter entirely and add a comment referencing P13-T5.
- **Priority:** P2
- **Dependencies:** P13-T4
Expand All @@ -2089,9 +2090,9 @@ Phase 9 Follow-up Backlog
- Updated `src/mcpbridge_wrapper/broker/proxy.py`
- Updated `tests/unit/test_broker_proxy.py`
- **Acceptance Criteria:**
- [ ] `reconnect=True` either reconnects on broken socket or the parameter is removed
- [ ] No dead/unused code remains
- [ ] Tests pass
- [x] `reconnect=True` either reconnects on broken socket or the parameter is removed
- [x] No dead/unused code remains
- [x] Tests pass

---

Expand Down
1 change: 0 additions & 1 deletion src/mcpbridge_wrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ def main() -> int:
broker_config,
auto_spawn=broker_spawn,
connect_timeout=10.0,
reconnect=False,
)
try:
asyncio.run(proxy.run())
Expand Down
5 changes: 0 additions & 5 deletions src/mcpbridge_wrapper/broker/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ class BrokerProxy:
flag.
connect_timeout:
Maximum seconds to wait for the broker socket to become available.
reconnect:
When ``True``, attempt to reconnect once if the socket connection is
broken before stdin EOF (covers broker RECONNECTING window).
stdin:
Asyncio stream to read from (defaults to ``sys.stdin.buffer``).
stdout:
Expand All @@ -53,15 +50,13 @@ def __init__(
*,
auto_spawn: bool = False,
connect_timeout: float = 10.0,
reconnect: bool = False,
stdin: asyncio.StreamReader | None = None,
stdout: asyncio.StreamWriter | None = None,
) -> None:
"""Initialise the proxy with the given broker configuration."""
self._config = config
self._auto_spawn = auto_spawn
self._connect_timeout = connect_timeout
self._reconnect = reconnect
self._stdin = stdin
self._stdout = stdout

Expand Down
6 changes: 5 additions & 1 deletion tests/unit/test_broker_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
- EOF on socket causes clean exit
- auto_spawn: spawns broker subprocess when socket absent
- auto_spawn: no-op when broker already running (PID file present)
- reconnect=False: broken connection is not retried
- _parse_broker_args: --broker-connect flag
- _parse_broker_args: --broker-spawn implies --broker-connect
- _parse_broker_args: unknown flags pass through
Expand All @@ -16,6 +15,7 @@
from __future__ import annotations

import asyncio
import inspect
import os
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock, patch
Expand Down Expand Up @@ -72,6 +72,10 @@ def _make_writer() -> MagicMock:


class TestBrokerProxyConnectTimeout:
def test_constructor_has_no_reconnect_parameter(self) -> None:
params = inspect.signature(BrokerProxy.__init__).parameters
assert "reconnect" not in params

@pytest.mark.asyncio
async def test_raises_timeout_when_no_socket(self, tmp_path: Path) -> None:
cfg = _make_config(tmp_path)
Expand Down