Skip to content

Commit e271bc2

Browse files
authored
Merge pull request #84 from SoundBlaster/codex/fu-p13-review-followup-backlog
P13: Add follow-up backlog from implementation gap audit
2 parents 56d8b2a + d530249 commit e271bc2

4 files changed

Lines changed: 166 additions & 2 deletions

File tree

SPECS/ARCHIVE/INDEX.md

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

3-
**Last Updated:** 2026-02-19 (REVIEW_fu_p12_t3_1_error_message_docstring_archived)
3+
**Last Updated:** 2026-02-19 (REVIEW_Phase13_Implementation_Gap_Audit_archived)
44

55
## Archived Tasks
66

@@ -196,6 +196,7 @@
196196
| [REVIEW_P13-T4_stdio_proxy_mode.md](_Historical/REVIEW_P13-T4_stdio_proxy_mode.md) | Review report for P13-T4 |
197197
| [REVIEW_P13-T5_prompt_reduction_multi_client_stability.md](_Historical/REVIEW_P13-T5_prompt_reduction_multi_client_stability.md) | Review report for P13-T5 |
198198
| [REVIEW_P13-T6_broker_mode_configuration_migration.md](_Historical/REVIEW_P13-T6_broker_mode_configuration_migration.md) | Review report for P13-T6 |
199+
| [REVIEW_Phase13_Implementation_Gap_Audit.md](_Historical/REVIEW_Phase13_Implementation_Gap_Audit.md) | Consolidated Phase 13 implementation gap audit report |
199200
| [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 |
200201
| [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 |
201202
| [REVIEW_FU-P13-T2-1_event_wait_shutdown.md](_Historical/REVIEW_FU-P13-T2-1_event_wait_shutdown.md) | Review report for FU-P13-T2-1 |
@@ -368,6 +369,7 @@
368369
| 2026-02-19 | FU-P12-T1-5 | Archived REVIEW_FU-P12-T1-5_client_identity_retention report |
369370
| 2026-02-19 | FU-P12-T1-6 | Archived Uniform_HTML_escaping_in_renderClientWidgets (PASS) |
370371
| 2026-02-19 | FU-P12-T1-6 | Archived REVIEW_FU-P12-T1-6_uniform_client_widget_escaping report |
372+
| 2026-02-19 | P13 | Archived REVIEW_Phase13_Implementation_Gap_Audit report |
371373
| 2026-02-19 | FU-P12-T3-1 | Archived Document_unused_error_message_parameter_in_MetricsCollector_record_response (PASS) |
372374
| 2026-02-19 | FU-P12-T3-1 | Archived REVIEW_FU-P12-T3-1_error_message_docstring report |
373375
| 2026-02-19 | FU-P12-T3-2 | Archived Add_error_code_column_to_audit_CSV_export (PASS) |
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
## REVIEW REPORT — Phase 13 Implementation Gap Audit
2+
3+
**Scope:** Final implementation phase review (`Phase 13: Persistent Broker & Shared Xcode Session`, including P13-T1..P13-T6 and linked follow-ups)
4+
**Primary Sources:** `SPECS/Workplan.md`, `SPECS/ARCHIVE/P13-T*_*/`, `src/mcpbridge_wrapper/broker/*`, `src/mcpbridge_wrapper/__main__.py`, `docs/broker-mode.md`
5+
6+
### Summary Verdict
7+
- [ ] Approve
8+
- [ ] Approve with comments
9+
- [x] Request changes
10+
- [ ] Block
11+
12+
### Critical / High Findings
13+
14+
1. **[High] `--broker-spawn` auto-start path is not functionally complete (`--broker-daemon` entrypoint missing).**
15+
- `BrokerProxy` spawns `python -m mcpbridge_wrapper --broker-daemon`: `src/mcpbridge_wrapper/broker/proxy.py:135`.
16+
- `main()` only parses `--broker-connect` / `--broker-spawn`; no daemon-mode branch exists: `src/mcpbridge_wrapper/__main__.py:192`, `src/mcpbridge_wrapper/__main__.py:271`, `src/mcpbridge_wrapper/__main__.py:273`.
17+
- Unknown flags are forwarded to upstream bridge command in direct path: `src/mcpbridge_wrapper/bridge.py:38`.
18+
- Result: spawned process does not become a broker daemon and auto-spawn can timeout instead of creating the socket.
19+
- Gap type: missed/lost feature versus expected runtime behavior in P13-T4/P13-T6 broker adoption flow.
20+
21+
2. **[High] JSON-RPC numeric request IDs are lossy/collision-prone due 20-bit masking.**
22+
- Integer IDs are truncated: `int_id = original_id & _ID_MASK`: `src/mcpbridge_wrapper/broker/transport.py:306`.
23+
- Response restoration returns lower 20 bits unless mapped as string: `src/mcpbridge_wrapper/broker/transport.py:397`.
24+
- Impacts:
25+
- IDs larger than `0xFFFFF` are mutated in responses.
26+
- Negative integer IDs are transformed.
27+
- Distinct large IDs can collide within one session.
28+
- Gap type: functional protocol correctness risk under valid JSON-RPC ID patterns.
29+
30+
### Secondary Findings
31+
32+
3. **[Medium] Planned local security boundary is documented but not enforced in transport.**
33+
- Architecture/ADR specifies same-UID verification via `getpeereid` and owner-only socket permissions:
34+
`SPECS/ARCHIVE/P13-T1_Design_persistent_broker_architecture_and_protocol_contract/P13-T1_Design_persistent_broker_architecture_and_protocol_contract.md:55`,
35+
`SPECS/ARCHIVE/P13-T1_Design_persistent_broker_architecture_and_protocol_contract/P13-T1_Design_persistent_broker_architecture_and_protocol_contract.md:201`.
36+
- Runtime currently accepts clients without UID validation; `peer_uid` is derived from `peername` and not enforced: `src/mcpbridge_wrapper/broker/transport.py:189`, `src/mcpbridge_wrapper/broker/transport.py:201`.
37+
- Socket mode is not explicitly set to `0600` after bind: `src/mcpbridge_wrapper/broker/transport.py:77`.
38+
- Gap type: security hardening feature not closed.
39+
40+
4. **[Medium] Broker startup is not atomic if transport startup fails after upstream launch.**
41+
- In `start()`, upstream launch + PID file write occur before transport bind/start: `src/mcpbridge_wrapper/broker/daemon.py:109`, `src/mcpbridge_wrapper/broker/daemon.py:112`, `src/mcpbridge_wrapper/broker/daemon.py:127`.
42+
- If `transport.start()` raises, `start()` exits without cleanup of upstream process or PID/socket state.
43+
- Gap type: reliability/lifecycle issue under bind/permission/race failures.
44+
45+
5. **[Medium] Core Phase 13 objective remains partially unverified (prompt reduction acceptance not closed).**
46+
- Workplan still marks P13-T5 as partial and leaves manual prompt criterion unchecked: `SPECS/Workplan.md:2102`, `SPECS/Workplan.md:2114`.
47+
- Validation report confirms unresolved interactive verification: `SPECS/ARCHIVE/P13-T5_Validate_prompt_reduction_and_multi_client_stability/P13-T5_Validation_Report.md:26`.
48+
- Gap type: incomplete closure of the main UX outcome this phase targets (reduced repeated Xcode permission prompts).
49+
50+
6. **[Low] Operational “broker status/start/stop” is documented as shell/python one-liners, not first-class CLI mode.**
51+
- Workplan output expected health/status command: `SPECS/Workplan.md:2001`.
52+
- Current guide relies on long inline commands including private attribute mutation (`d._transport=t`): `docs/broker-mode.md:28`, `docs/broker-mode.md:42`, `docs/broker-mode.md:54`.
53+
- Gap type: maintainability/operability mismatch vs intended productized flow.
54+
55+
### Tests and Coverage Gaps
56+
57+
- Missing end-to-end runtime test that `--broker-spawn` actually creates a live broker socket (not only mocked spawn paths).
58+
- Missing transport tests for large/negative integer request IDs to ensure identity preservation.
59+
- Missing tests for UID rejection behavior (if security boundary is intended to be enforced).
60+
- Missing failure-path test for `BrokerDaemon.start()` where `transport.start()` fails after upstream launch.
61+
62+
### Recommended Follow-Up Tasks
63+
64+
1. Implement explicit daemon CLI mode (`--broker-daemon` or `broker host`) in `main()` and add E2E spawn validation.
65+
2. Replace lossy int-bitmask remap with reversible per-session int-ID mapping (parallel to string ID map), then add regression tests.
66+
3. Enforce local auth boundary (`getpeereid` same-UID check) and explicit socket permission hardening (`chmod 0600`) with tests.
67+
4. Make `BrokerDaemon.start()` transactional (cleanup on partial startup failure).
68+
5. Complete P13-T5 interactive desktop validation and update verdict from PARTIAL to PASS/FAIL with evidence.
69+

SPECS/INPROGRESS/next.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@
1111

1212
## Suggested Next Tasks
1313

14-
- No pending tasks remain (`126/126` complete).
14+
- FU-P13-T10: Implement explicit broker daemon entrypoint and operational CLI flows (P0)
15+
- FU-P13-T11: Preserve JSON-RPC numeric request ID fidelity in broker transport (P1)
16+
- FU-P13-T12: Enforce local Unix-socket security boundary for broker clients (P1)
17+
- FU-P13-T13: Make broker startup transactional when transport bind/start fails (P1)
18+
- FU-P13-T14: Complete interactive Xcode prompt verification and close P13-T5 (P1)
19+
20+
Pending follow-up backlog from review: `5` open tasks.

SPECS/Workplan.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,6 +2187,93 @@ Phase 9 Follow-up Backlog
21872187

21882188
---
21892189

2190+
#### ⬜️ FU-P13-T10: Implement explicit broker daemon entrypoint and operational CLI flows
2191+
- **Description:** Make broker host mode first-class by implementing a real daemon entrypoint (`--broker-daemon` or equivalent broker subcommand) in `__main__.py`, ensuring `--broker-spawn` can reliably auto-start and connect. Replace doc-only one-liner operational flows with supported CLI commands for start/status/stop.
2192+
- **Priority:** P0
2193+
- **Dependencies:** P13-T2, P13-T4
2194+
- **Parallelizable:** no
2195+
- **Outputs/Artifacts:**
2196+
- Updated `src/mcpbridge_wrapper/__main__.py` broker daemon branch and command parsing
2197+
- Updated `src/mcpbridge_wrapper/broker/proxy.py` spawn target (if needed)
2198+
- Integration test covering `--broker-spawn` end-to-end readiness
2199+
- Updated `docs/broker-mode.md` and setup docs with first-class broker host commands
2200+
- **Acceptance Criteria:**
2201+
- [ ] Running `mcpbridge-wrapper --broker-daemon` starts broker host mode and creates live PID/socket state
2202+
- [ ] `--broker-spawn` successfully auto-starts broker and connects without manual bootstrap
2203+
- [ ] No broker-only flags are accidentally forwarded to `xcrun mcpbridge`
2204+
- [ ] Start/status/stop commands are documented as supported CLI flows (not private inline Python snippets)
2205+
2206+
---
2207+
2208+
#### ⬜️ FU-P13-T11: Preserve JSON-RPC numeric request ID fidelity in broker transport
2209+
- **Description:** Remove lossy 20-bit integer ID masking in broker request remapping and implement a reversible per-session ID mapping for numeric IDs so all valid JSON-RPC IDs round-trip exactly.
2210+
- **Priority:** P1
2211+
- **Dependencies:** P13-T3
2212+
- **Parallelizable:** yes
2213+
- **Outputs/Artifacts:**
2214+
- Updated `src/mcpbridge_wrapper/broker/transport.py` ID remap/restore strategy
2215+
- Updated `src/mcpbridge_wrapper/broker/types.py` session mapping fields (if required)
2216+
- New/updated unit tests for large, negative, and concurrent numeric IDs
2217+
- **Acceptance Criteria:**
2218+
- [ ] Integer IDs (including negative and > 20-bit) are returned unchanged to clients
2219+
- [ ] Distinct concurrent numeric IDs cannot collide within a session
2220+
- [ ] Existing string-ID routing behavior remains backward compatible
2221+
- [ ] Broker transport tests cover ID round-trip fidelity for int and string IDs
2222+
2223+
---
2224+
2225+
#### ⬜️ FU-P13-T12: Enforce local Unix-socket security boundary for broker clients
2226+
- **Description:** Implement same-UID peer credential verification for broker socket clients and enforce owner-only socket permissions, aligning runtime behavior with P13-T1 ADR security decisions.
2227+
- **Priority:** P1
2228+
- **Dependencies:** P13-T1, P13-T3
2229+
- **Parallelizable:** yes
2230+
- **Outputs/Artifacts:**
2231+
- Updated `src/mcpbridge_wrapper/broker/transport.py` peer credential checks and rejection path
2232+
- Updated broker socket creation flow to enforce `0600` permissions
2233+
- Unit tests for accepted/rejected client credential cases
2234+
- Documentation update in `docs/broker-mode.md` and/or `docs/troubleshooting.md`
2235+
- **Acceptance Criteria:**
2236+
- [ ] Broker accepts only same-UID local clients
2237+
- [ ] Connections failing UID verification are rejected without affecting active sessions
2238+
- [ ] Broker socket file is owner-readable/writable only (`0600`)
2239+
- [ ] Security-boundary behavior is documented and test-covered
2240+
2241+
---
2242+
2243+
#### ⬜️ FU-P13-T13: Make broker startup transactional when transport bind/start fails
2244+
- **Description:** Harden `BrokerDaemon.start()` so partial startup failures (for example socket bind errors after upstream launch) perform full rollback, leaving no orphaned upstream process or stale PID/socket files.
2245+
- **Priority:** P1
2246+
- **Dependencies:** P13-T2, P13-T3
2247+
- **Parallelizable:** yes
2248+
- **Outputs/Artifacts:**
2249+
- Updated `src/mcpbridge_wrapper/broker/daemon.py` startup failure rollback path
2250+
- Regression tests for transport-start failure after upstream launch
2251+
- Troubleshooting note for deterministic failure behavior
2252+
- **Acceptance Criteria:**
2253+
- [ ] If transport startup fails, upstream subprocess is terminated and waited
2254+
- [ ] PID/socket files are cleaned up on startup failure
2255+
- [ ] Broker state returns to a safe non-ready state after rollback
2256+
- [ ] Unit tests cover rollback behavior and prevent regression
2257+
2258+
---
2259+
2260+
#### ⬜️ FU-P13-T14: Complete interactive Xcode prompt verification and close P13-T5
2261+
- **Description:** Execute and document the remaining human-run interactive validation for Xcode permission prompts in direct mode vs broker mode, then update P13-T5 verdict and linked acceptance states.
2262+
- **Priority:** P1
2263+
- **Dependencies:** P13-T5, P13-T6
2264+
- **Parallelizable:** no
2265+
- **Outputs/Artifacts:**
2266+
- Updated `SPECS/ARCHIVE/P13-T5_Validate_prompt_reduction_and_multi_client_stability/P13-T5_manual_prompt_validation.md`
2267+
- Updated `SPECS/ARCHIVE/P13-T5_Validate_prompt_reduction_and_multi_client_stability/P13-T5_Validation_Report.md`
2268+
- Workplan status update for P13-T5 acceptance line items
2269+
- **Acceptance Criteria:**
2270+
- [ ] Interactive desktop run confirms observed prompt behavior for repeated short-lived sessions
2271+
- [ ] P13-T5 manual prompt criterion is resolved to PASS or FAIL with concrete evidence
2272+
- [ ] Any discovered deviations are captured in troubleshooting and/or follow-up bug tasks
2273+
- [ ] BUG-T4 related resolution path is reconciled with the final validation outcome
2274+
2275+
---
2276+
21902277

21912278
#### ✅ FU-BUG-T7-1: Cap `pending_methods` map to guard against unbounded growth
21922279
- **Status:** ✅ Completed (2026-02-18)

0 commit comments

Comments
 (0)