|
| 1 | +# PRD: FU-P13-T17 — Enable broker-hosted Web UI with shared multi-client telemetry |
| 2 | + |
| 3 | +## 1. Objective |
| 4 | + |
| 5 | +Deliver a single-host broker topology where one long-lived broker process can also host the Web UI dashboard and expose telemetry aggregated across all broker-connected agents. This closes the current behavior gap where broker paths are transport-only and do not start dashboard services. |
| 6 | + |
| 7 | +The implementation must support: |
| 8 | +- `--broker-daemon --web-ui [--web-ui-config|--web-ui-port]` in one process |
| 9 | +- `--broker-spawn --web-ui ...` propagating Web UI args to the spawned daemon host |
| 10 | +- broker-side telemetry recording for `initialize` and `tools/call` lifecycles so all broker clients appear in one metrics/audit stream |
| 11 | + |
| 12 | +## 2. Success Criteria and Acceptance Tests |
| 13 | + |
| 14 | +### Success Criteria |
| 15 | +- Broker daemon can start Web UI server when requested without entering direct-mode bridge loop. |
| 16 | +- Auto-spawn proxy can bootstrap a broker host with Web UI enabled from the same client config. |
| 17 | +- Shared dashboard reflects tool requests/responses from multiple broker clients. |
| 18 | +- Existing direct-mode and broker-only behavior remains backward compatible. |
| 19 | + |
| 20 | +### Acceptance Tests |
| 21 | +- Unit test: `main()` broker-daemon + `--web-ui` starts server thread and wires telemetry store into broker transport. |
| 22 | +- Unit test: `main()` broker-spawn + `--web-ui` passes spawn args to `BrokerProxy` and includes Web UI flags. |
| 23 | +- Unit test: `UnixSocketServer` records request/response telemetry and client identity on broker-routed traffic. |
| 24 | +- Regression: existing broker tests and Web UI tests remain green. |
| 25 | + |
| 26 | +## 3. Test-First Plan |
| 27 | + |
| 28 | +1. Add failing unit tests first for new broker-daemon Web UI branch behavior in `tests/unit/test_main.py`. |
| 29 | +2. Add failing tests for `BrokerProxy` spawn-arg propagation in `tests/unit/test_broker_proxy.py`. |
| 30 | +3. Add failing transport telemetry tests in `tests/unit/test_broker_transport.py`. |
| 31 | +4. Implement runtime changes after tests exist. |
| 32 | +5. Run required gates: |
| 33 | + - `PYTHONPATH=src pytest` |
| 34 | + - `ruff check src/` |
| 35 | + - `mypy src/` |
| 36 | + - `PYTHONPATH=src pytest --cov=src/mcpbridge_wrapper --cov-report=term-missing` |
| 37 | + |
| 38 | +## 4. Execution Plan (Hierarchical TODO) |
| 39 | + |
| 40 | +### Phase A — Broker+WebUI runtime orchestration |
| 41 | +- Inputs: `__main__.py` argument parsing and broker mode branches. |
| 42 | +- Outputs: broker-daemon mode can initialize Web UI components and start dashboard thread. |
| 43 | +- Verification: broker path exits through `asyncio.run(daemon.run_forever())` with Web UI active when requested. |
| 44 | + |
| 45 | +### Phase B — Broker telemetry integration |
| 46 | +- Inputs: `broker/transport.py` request/response routing logic. |
| 47 | +- Outputs: optional metrics/audit hooks recorded for `initialize` and `tools/call` traffic. |
| 48 | +- Verification: request latency/error stats emitted into shared store and audit stream. |
| 49 | + |
| 50 | +### Phase C — Auto-spawn configuration consistency |
| 51 | +- Inputs: `broker/proxy.py` spawn command construction. |
| 52 | +- Outputs: optional spawn args support so `--broker-spawn --web-ui` uses one shared config story. |
| 53 | +- Verification: spawned daemon command contains requested Web UI args. |
| 54 | + |
| 55 | +### Phase D — Validation/reporting |
| 56 | +- Inputs: updated code + tests. |
| 57 | +- Outputs: `SPECS/INPROGRESS/FU-P13-T17_Validation_Report.md` with PASS/FAIL and gate outputs. |
| 58 | +- Verification: acceptance criteria checklist fully resolved. |
| 59 | + |
| 60 | +## 5. Decision Points and Constraints |
| 61 | + |
| 62 | +- Keep Web UI hosting on broker daemon only; do not start dashboard in short-lived `--broker-connect` proxy processes. |
| 63 | +- Preserve current stdout protocol behavior: JSON-RPC only, no dashboard logs on stdout. |
| 64 | +- Keep feature additive and backward-compatible for existing configs. |
| 65 | +- Review subject name: `fu_p13_t17_broker_hosted_webui`. |
| 66 | + |
| 67 | +## 6. Notes (Files likely touched) |
| 68 | + |
| 69 | +- `src/mcpbridge_wrapper/__main__.py` |
| 70 | +- `src/mcpbridge_wrapper/broker/transport.py` |
| 71 | +- `src/mcpbridge_wrapper/broker/proxy.py` |
| 72 | +- `tests/unit/test_main.py` |
| 73 | +- `tests/unit/test_broker_proxy.py` |
| 74 | +- `tests/unit/test_broker_transport.py` |
| 75 | + |
| 76 | +--- |
| 77 | +**Archived:** 2026-02-28 |
| 78 | +**Verdict:** PASS |
0 commit comments