|
| 1 | +# Validation Report: P2-T8 — Gate broker tools/list on warmed tool catalog |
| 2 | + |
| 3 | +**Date:** 2026-03-10 |
| 4 | +**Verdict:** PASS |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Acceptance Criteria |
| 9 | + |
| 10 | +| # | Criterion | Status | |
| 11 | +|---|-----------|--------| |
| 12 | +| 1 | Broker does not forward external `tools/list` while the internal tools cache is still cold | ✅ PASS | |
| 13 | +| 2 | Empty or invalid internal `tools/list` probe results do not open the client-facing readiness gate | ✅ PASS | |
| 14 | +| 3 | Client `tools/list` returns either a warmed catalog or a clear TTL error, never a premature empty success | ✅ PASS | |
| 15 | +| 4 | Existing non-`tools/list` broker traffic still flows after `upstream_initialized` | ✅ PASS | |
| 16 | +| 5 | `pytest` passes | ✅ PASS | |
| 17 | +| 6 | `ruff check src/` passes | ✅ PASS | |
| 18 | +| 7 | `mypy src/` passes | ✅ PASS | |
| 19 | +| 8 | `pytest --cov` remains at or above 90% | ✅ PASS | |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Evidence |
| 24 | + |
| 25 | +### Functional behavior |
| 26 | + |
| 27 | +- Added a dedicated `tools_catalog_ready` event in the broker daemon so tool discovery |
| 28 | + is gated separately from the upstream `initialize` round-trip. |
| 29 | +- The broker now treats only non-empty, structurally valid internal `tools/list` |
| 30 | + probe results as a ready catalog; empty or invalid results keep the gate closed, |
| 31 | + clear the cache, and schedule another broker-internal warm-up probe instead of |
| 32 | + requiring a reconnect or manual restart. |
| 33 | +- External client `tools/list` now waits on the warmed catalog gate and returns a |
| 34 | + deterministic `-32001` TTL error if the broker never reaches a safe ready state. |
| 35 | +- Non-`tools/list` methods still wait only on `upstream_initialized`, preserving the |
| 36 | + existing broker contract for normal request forwarding. |
| 37 | + |
| 38 | +### Regression coverage |
| 39 | + |
| 40 | +- `tests/unit/test_broker_daemon.py` |
| 41 | + - verifies catalog readiness opens only for a valid non-empty probe result |
| 42 | + - verifies empty probe results keep the catalog gate closed |
| 43 | + - verifies an empty first probe retries until a valid tool catalog becomes available |
| 44 | + - verifies reconnect clears both cache and readiness state |
| 45 | +- `tests/unit/test_broker_transport.py` |
| 46 | + - verifies `tools/list` times out with a catalog-specific readiness error |
| 47 | + - verifies non-`tools/list` requests still wait on upstream initialization only |
| 48 | + - verifies `tools/list` resumes from the warmed cache instead of racing upstream |
| 49 | +- `tests/integration/test_broker_multi_client.py` |
| 50 | + - keeps concurrent multi-client coverage aligned with the stronger broker warm-up |
| 51 | + contract by exercising a normal forwarded tool call path instead of the special |
| 52 | + cached `tools/list` path |
| 53 | + |
| 54 | +### Validation environment hardening |
| 55 | + |
| 56 | +- Added `pythonpath = ["src"]` to `pyproject.toml` so pytest in a clean worktree |
| 57 | + imports the local checkout instead of an unrelated editable install from another |
| 58 | + repository path. This makes FLOW validation deterministic and fixes `pytest --cov` |
| 59 | + reporting in multi-worktree setups. |
| 60 | + |
| 61 | +### Command results |
| 62 | + |
| 63 | +- `pytest` → **901 passed, 5 skipped, 2 warnings** |
| 64 | +- `ruff check src/` → **All checks passed** |
| 65 | +- `mypy src/` → **Success: no issues found in 20 source files** |
| 66 | +- `pytest --cov` → **901 passed, 5 skipped, 2 warnings; coverage 91.58%** |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## Changed Files |
| 71 | + |
| 72 | +- `pyproject.toml` |
| 73 | +- `src/mcpbridge_wrapper/broker/daemon.py` |
| 74 | +- `src/mcpbridge_wrapper/broker/transport.py` |
| 75 | +- `tests/integration/test_broker_multi_client.py` |
| 76 | +- `tests/unit/test_broker_daemon.py` |
| 77 | +- `tests/unit/test_broker_transport.py` |
0 commit comments