Skip to content

P13-T2: Implement persistent broker daemon with single upstream Xcode bridge#64

Merged
SoundBlaster merged 9 commits intomainfrom
feature/P13-T2-broker-daemon
Feb 16, 2026
Merged

P13-T2: Implement persistent broker daemon with single upstream Xcode bridge#64
SoundBlaster merged 9 commits intomainfrom
feature/P13-T2-broker-daemon

Conversation

@SoundBlaster
Copy link
Owner

Description

Implements BrokerDaemon in src/mcpbridge_wrapper/broker/daemon.py, replacing the P13-T1 stub with a fully working persistent broker daemon that owns a single xcrun mcpbridge upstream subprocess.

Key capabilities:

  • PID-file locking prevents duplicate instances; stale-lock recovery handles crashed processes
  • Exponential-backoff reconnection (0s, 1s, 2s, … min(2^n, cap)s) when upstream crashes
  • Graceful shutdown: drains read task, closes upstream stdin, waits with timeout, kills if needed, removes PID/socket files
  • status() method returns {state, pid, upstream_pid} for health monitoring
  • run_forever() registers SIGTERM/SIGINT handlers and blocks until stopped

Also updates test_broker_stubs.py to remove now-invalid NotImplementedError assertions from P13-T1.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • CI/CD improvement

Quality Gates

  • make test - All tests pass with ≥90% coverage
    • 485 unit tests pass; broker module coverage 93.2%
    • 26 new tests in tests/unit/test_broker_daemon.py
  • make lint - No linting errors (ruff check src/ clean)
  • make format - N/A (ruff auto-fix applied during development)
  • make typecheck - mypy not configured as hard gate
  • make doccheck - No docs/ changes

Documentation Sync

  • Documentation changes are synced with DocC catalog (or N/A) — no docs/ changes

Testing

  • Added/updated tests for new functionality (tests/unit/test_broker_daemon.py, 26 tests)
  • All tests pass locally (pytest tests/unit/ — 485 passed)
  • Manually tested the changes — integration with live xcrun mcpbridge deferred to P13-T5

Checklist

  • Code follows the project's style guidelines
  • Self-review completed (see SPECS/ARCHIVE/_Historical/REVIEW_P13-T2_broker_daemon.md)
  • Comments added for complex code (lifecycle state transitions, ID remapping hook)
  • Documentation updated (if needed) — user-facing docs deferred to P13-T6
  • No new warnings generated
  • PR title is descriptive

Validation Report

SPECS/ARCHIVE/P13-T2_Implement_persistent_broker_daemon/P13-T2_Validation_Report.md — verdict: PASS

Follow-up Tasks Added

  • FU-P13-T2-1 (P3): Replace run_forever() polling loop with asyncio.Event-based wait
  • FU-P13-T2-2 (P3): Move PID file write to after successful upstream launch

@SoundBlaster SoundBlaster merged commit 69d9c98 into main Feb 16, 2026
9 checks passed
@SoundBlaster SoundBlaster deleted the feature/P13-T2-broker-daemon branch February 16, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant