Skip to content

Commit 78ff23e

Browse files
authored
Merge pull request #115 from SoundBlaster/codex/feature/FU-P13-T17-broker-hosted-webui
FU-P13-T17: Enable broker-hosted Web UI with shared multi-client telemetry
2 parents 7242d57 + c08ec9d commit 78ff23e

12 files changed

Lines changed: 1095 additions & 58 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Validation Report: FU-P13-T17 — Enable broker-hosted Web UI with shared multi-client telemetry
2+
3+
**Date:** 2026-02-28
4+
**Task ID:** FU-P13-T17
5+
**Verdict:** PASS
6+
7+
## Scope Implemented
8+
9+
- Updated `src/mcpbridge_wrapper/__main__.py` to support broker-hosted dashboard runtime:
10+
- `--broker-daemon --web-ui` now starts broker transport and Web UI in one process.
11+
- `--web-ui-only` is now rejected when combined with broker flags.
12+
- Added shared helpers for Web UI runtime preparation and broker spawn arg construction.
13+
- Updated `src/mcpbridge_wrapper/broker/proxy.py`:
14+
- Added configurable `spawn_args` support for `--broker-spawn` flows.
15+
- Ensured daemon spawn command includes `--broker-daemon` plus propagated Web UI args.
16+
- Updated `src/mcpbridge_wrapper/broker/transport.py`:
17+
- Added optional metrics/audit dependencies to broker transport.
18+
- Added broker-side client identity capture (`initialize`) and tool telemetry tracking (`tools/call` request/response latency + error state).
19+
- Added/updated tests:
20+
- `tests/unit/test_main.py`
21+
- `tests/unit/test_broker_proxy.py`
22+
- `tests/unit/test_broker_transport.py`
23+
24+
## Quality Gates
25+
26+
- `PYTHONPATH=src pytest` → PASS (`689 passed, 5 skipped, 2 warnings`)
27+
- `ruff check src/` → PASS
28+
- `mypy src/` → PASS
29+
- `PYTHONPATH=src pytest --cov=src/mcpbridge_wrapper --cov-report=term-missing` → PASS
30+
- Total coverage: **91.81%** (required: >= 90%)
31+
32+
## Acceptance Criteria Check
33+
34+
- [x] `mcpbridge-wrapper --broker-daemon --web-ui --web-ui-config <path>` starts broker socket and dashboard without launching direct-mode bridge loop.
35+
- [x] `mcpbridge-wrapper --broker-spawn --web-ui --web-ui-config <path>` can auto-start a broker host with Web UI enabled.
36+
- [x] Tool calls from multiple broker-connected clients appear in one dashboard metrics/audit stream.
37+
- [x] Existing direct mode and broker-only behavior remain backward compatible.
38+
39+
## Notes
40+
41+
- In this environment, direct `pytest` (without `PYTHONPATH=src`) is not used for gating because imports resolve via `PYTHONPATH=src`.

SPECS/ARCHIVE/INDEX.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# mcpbridge-wrapper Tasks Archive
22

3-
**Last Updated:** 2026-02-28 (FU-P13-T16_Document_multi_agent_MCP_usage_and_single_Web_UI_host)
3+
**Last Updated:** 2026-02-28 (FU-P13-T17_Enable_broker-hosted_Web_UI_with_shared_multi-client_telemetry)
44

55
## Archived Tasks
66

77
| Task ID | Folder | Archived | Verdict |
88
|---------|--------|----------|---------|
9+
| FU-P13-T17 | [FU-P13-T17_Enable_broker-hosted_Web_UI_with_shared_multi-client_telemetry/](FU-P13-T17_Enable_broker-hosted_Web_UI_with_shared_multi-client_telemetry/) | 2026-02-28 | PASS |
910
| FU-P13-T16 | [FU-P13-T16_Document_multi_agent_MCP_usage_and_single_Web_UI_host/](FU-P13-T16_Document_multi_agent_MCP_usage_and_single_Web_UI_host/) | 2026-02-28 | PASS |
1011
| FU-P11-T2-4 | [FU-P11-T2-4_Add_one-command_Web_UI_restart_workflow/](FU-P11-T2-4_Add_one-command_Web_UI_restart_workflow/) | 2026-02-28 | PASS |
1112
| FU-P11-T2-3 | [FU-P11-T2-3_Reorder_sessions_from_the_last_to_the_first/](FU-P11-T2-3_Reorder_sessions_from_the_last_to_the_first/) | 2026-02-28 | PASS |
@@ -163,6 +164,7 @@
163164

164165
| File | Description |
165166
|------|-------------|
167+
| [REVIEW_fu_p13_t17_broker_hosted_webui.md](_Historical/REVIEW_fu_p13_t17_broker_hosted_webui.md) | Review report for FU-P13-T17 |
166168
| [REVIEW_fu_p13_t16_multi_agent_mcp_docs.md](_Historical/REVIEW_fu_p13_t16_multi_agent_mcp_docs.md) | Review report for FU-P13-T16 |
167169
| [REVIEW_P1-T1_project_structure.md](_Historical/REVIEW_P1-T1_project_structure.md) | Review report for P1-T1 |
168170
| [REVIEW_P1-T2_pyproject.toml.md](_Historical/REVIEW_P1-T2_pyproject.toml.md) | Review report for P1-T2 |
@@ -275,6 +277,8 @@
275277

276278
| Date | Task ID | Action |
277279
|------|---------|--------|
280+
| 2026-02-28 | FU-P13-T17 | Archived REVIEW_fu_p13_t17_broker_hosted_webui report |
281+
| 2026-02-28 | FU-P13-T17 | Archived Enable_broker-hosted_Web_UI_with_shared_multi-client_telemetry (PASS) |
278282
| 2026-02-28 | FU-P13-T16 | Archived REVIEW_fu_p13_t16_multi_agent_mcp_docs report |
279283
| 2026-02-28 | FU-P13-T16 | Archived Document_multi_agent_MCP_usage_and_single_Web_UI_host (PASS) |
280284
| 2026-02-28 | FU-P11-T2-3 | Archived REVIEW_fu_p11_t2_3_session_ordering report |
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## REVIEW REPORT — FU-P13-T17 broker-hosted Web UI
2+
3+
**Scope:** `origin/main..HEAD`
4+
**Files:** 11
5+
6+
### Summary Verdict
7+
- [x] Approve
8+
- [ ] Approve with comments
9+
- [ ] Request changes
10+
- [ ] Block
11+
12+
### Critical Issues
13+
- None.
14+
15+
### Secondary Issues
16+
- None.
17+
18+
### Architectural Notes
19+
- Broker-daemon runtime now owns optional Web UI startup, while proxy mode remains stdio-only except for daemon spawn argument propagation. This keeps short-lived clients lightweight and centralizes dashboard ownership.
20+
- Broker transport telemetry hooks are additive and optional (`metrics`/`audit` injected), preserving backward compatibility for broker-only deployments.
21+
22+
### Tests
23+
- `PYTHONPATH=src pytest` → PASS (`689 passed, 5 skipped`)
24+
- `ruff check src/` → PASS
25+
- `mypy src/` → PASS
26+
- `PYTHONPATH=src pytest --cov=src/mcpbridge_wrapper --cov-report=term-missing` → PASS
27+
- Coverage: **91.81%** (>= 90%)
28+
29+
### Next Steps
30+
- FOLLOW-UP is not required; no actionable findings were identified.

SPECS/INPROGRESS/next.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
## Recently Archived
44

5+
- **FU-P13-T17** — Enable broker-hosted Web UI with shared multi-client telemetry (2026-02-28, PASS)
56
- **FU-P13-T16** — Document multi-agent MCP usage and single Web UI host (2026-02-28, PASS)
67
- **FU-P11-T2-4** — Add one-command Web UI restart workflow (2026-02-28, PASS)
7-
- **FU-P11-T2-3** — Reorder sessions from the last to the first (2026-02-28, PASS)
88

99
## Suggested Next Tasks
1010

11-
- None (all workplan tasks are complete)
11+
- **FU-P13-T18** — Document unified single-config setup for broker + Web UI multi-agent workflows
12+
- **FU-P13-T19** — Add integration coverage for broker-hosted Web UI observability

SPECS/Workplan.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,6 +2607,55 @@ Phase 9 Follow-up Backlog
26072607

26082608
---
26092609

2610+
#### ✅ FU-P13-T17: Enable broker-hosted Web UI with shared multi-client telemetry — Completed (2026-02-28, PASS)
2611+
- **Status:** ✅ Completed (2026-02-28, PASS)
2612+
- **Description:** Implement a broker-mode runtime path where `--broker-daemon --web-ui` starts both the persistent broker and dashboard in one host process, and broker-side request/response telemetry feeds one shared Web UI view for all connected agents.
2613+
- **Priority:** P0
2614+
- **Dependencies:** P13-T10, FU-P13-T8
2615+
- **Parallelizable:** no
2616+
- **Outputs/Artifacts:**
2617+
- Updated `src/mcpbridge_wrapper/__main__.py` to support broker-daemon + Web UI startup orchestration
2618+
- Updated `src/mcpbridge_wrapper/broker/transport.py` to record tool telemetry for broker-routed clients
2619+
- Updated `src/mcpbridge_wrapper/broker/proxy.py` to propagate Web UI spawn args in `--broker-spawn` flows
2620+
- Updated unit tests in `tests/unit/test_main.py`, `tests/unit/test_broker_proxy.py`, and `tests/unit/test_broker_transport.py`
2621+
- **Acceptance Criteria:**
2622+
- [x] `mcpbridge-wrapper --broker-daemon --web-ui --web-ui-config <path>` starts broker socket and dashboard without launching direct-mode bridge loop
2623+
- [x] `mcpbridge-wrapper --broker-spawn --web-ui --web-ui-config <path>` can auto-start a broker host with Web UI enabled
2624+
- [x] Tool calls from multiple broker-connected clients appear in one dashboard metrics/audit stream
2625+
- [x] Existing direct mode and broker-only behavior remain backward compatible
2626+
2627+
---
2628+
2629+
#### ⬜️ FU-P13-T18: Document unified single-config setup for broker + Web UI multi-agent workflows
2630+
- **Description:** Update setup and troubleshooting docs so users can apply one MCP config across agents while reusing a shared broker host and one dashboard endpoint.
2631+
- **Priority:** P1
2632+
- **Dependencies:** FU-P13-T17
2633+
- **Parallelizable:** yes
2634+
- **Outputs/Artifacts:**
2635+
- Updated `README.md`, `docs/broker-mode.md`, `docs/webui-setup.md`, and `docs/troubleshooting.md`
2636+
- Updated mapped DocC files in `Sources/XcodeMCPWrapper/Documentation.docc/`
2637+
- **Acceptance Criteria:**
2638+
- [ ] Docs include one-config examples for Zed/Cursor/Claude/Codex with broker + dashboard expectations
2639+
- [ ] Docs clearly define dashboard ownership and fallback behavior
2640+
- [ ] Troubleshooting includes broker-hosted Web UI diagnostics
2641+
2642+
---
2643+
2644+
#### ⬜️ FU-P13-T19: Add integration coverage for broker-hosted Web UI observability
2645+
- **Description:** Add automated test coverage that validates broker-mode telemetry visibility in Web UI APIs under multi-client request load.
2646+
- **Priority:** P1
2647+
- **Dependencies:** FU-P13-T17
2648+
- **Parallelizable:** yes
2649+
- **Outputs/Artifacts:**
2650+
- New or updated integration tests under `tests/integration/webui/`
2651+
- Validation notes for deterministic multi-client telemetry assertions
2652+
- **Acceptance Criteria:**
2653+
- [ ] Tests demonstrate aggregated metrics visibility for broker-connected clients
2654+
- [ ] Tests cover at least one error-path request and verify error reporting in metrics/audit output
2655+
- [ ] CI remains stable without flaky timing assumptions
2656+
2657+
---
2658+
26102659
### Phase 14: Release 0.4.0 Readiness
26112660

26122661
#### ✅ P14-T5: Stabilize broker Unix-socket permission test against path-length limits — Completed (2026-02-20, PASS)

0 commit comments

Comments
 (0)