← Back to Pull requests

feat: subscription streams — subscriptions/listen under ASGI (0.1.4) #32

Closed
unknown closed this pull request without merging on Jul 30, 2026 14:47 UTC
View on GitHub
unknown unknown commented on Jul 30, 2026 14:34 UTC
Author

What

The last deferred protocol feature (SSE/subscriptions): on the 2026-07-28 wire there is no standing GET stream — a client opts into server events by POSTing subscriptions/listen, whose response is itself the stream (SEP-2575). The buffered bridge could never carry it: the suite's three server-stateless failures and the handler returned no HTTP response 500s were all this.

How

  • Routing: the spec's required mcp-method header routes subscriptions/listen to a streaming path — the body is never parsed, and every other request keeps the buffered path byte-identically.

  • ASGI: the dispatch runs as a background task owning the whole session-manager lifecycle (anyio task groups must enter/exit in one task); a StreamingHttpResponse relays its ASGI messages live. Django closing the response on client disconnect cancels the dispatch — the SDK's documented end-of-stream signal.

  • WSGI: an explicit 501 unsupported_deployment — a live stream pins a worker for its lifetime, the exact per-flow tax this package exists to remove. This is the asterisk the build plan predicted, now a documented contract instead of a hang.

  • SDK seams only: ListenHandler acks/tags/filters; MCPServer(subscriptions=…) takes the example's InMemorySubscriptionBus; a real fleet supplies a Redis/NATS-backed SubscriptionBus (documented).
  • Verification

  • Conformance: the script boots uvicorn (streams are ASGI-only); server-stateless went 25/28 → 30/30 with zero warnings and leaves the expected-failures baseline; full suite 78 → 83 passed, baseline check green.

  • Tests: live in-process SSE stream parsed frame-by-frame (ack first, subscription-id tagging, a bus-published event arriving mid-stream, clean close), the WSGI 501, and the trigger tool; full suite + fleet harness + strict docs all green.

  • Example infra: test_trigger_tool_change / test_trigger_prompt_change tools; README gains a curl transcript for watching a live stream (open listen in one terminal, trigger from Inspector in another) including the per-process-bus caveat under the 4-worker demo.
  • mcp_view's return annotation widens to HttpResponseBase (streaming responses aren't HttpResponse subclasses). Version → 0.1.4, CHANGELOG/0.1.4.md, ADR-0020.

    Diff: 287 lines (+215 / -72) across 3 files Reviewer: BenA-SA Review duration: 13m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 287 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.339
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #32"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.8% (MEDIUM) · Higher = larger blast radius
    39.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.7% · Safe to merge
    15.7%