← Back to Pull requests

fix: one canonical browser-selection resolution for serve, gateway, and doctor #151

Closed
unknown closed this pull request without merging on Aug 04, 2026 01:50 UTC
View on GitHub
unknown unknown commented on Aug 04, 2026 01:29 UTC
Author

Problem

After #136 the stdio gateway composes its worker factory eagerly at startup. On any install without AUTOMATION_RUNTIME_BROWSER_SELECTION exported, the fail-closed default (exact Firefox, no enrolled profile) makes the gateway exit before answering initialize — agent hosts report a dead server, while pre-#136 the same install ran managed Chromium. Root cause: each entry point resolved browser selection differently (env-only, or not at all).

Changes

  • firefox_companion::selection::resolve_browser_selection: single resolution order shared by bobby serve, the MCP gateway, and bobby doctor — env var override → persisted <config-dir>/bobby-browser/browser-selection.json → built-in default. Present-but-malformed sources fail closed.

  • bobby enroll-firefox-profile persists the selection atomically (0600) at enrollment instead of instructing an env export. Enroll once; all entry points resolve it with no shell wiring.

  • bobby doctor reports which source resolved (env / persisted path / default), closing the class of bug where doctor validates a path the gateway never uses.

  • run_doctor refactor into a structured DoctorReport with render/exit split and extracted pure checks — it was the one genuinely untested high-degree hotspot from the graph audit (the other six flagged hotspots already had direct or by-design coverage, verified by reading the test tree).

  • Docs: resolution order and enrollment persistence in the configuration, firefox-companion, cli, and troubleshooting guides.
  • Verification

  • New tests: resolver precedence (env > persisted > default), fail-closed on malformed env and malformed persisted file, persist roundtrip with 0600 permissions, doctor report counts, expiry fail/warn/ok thresholds, handshake error classification, and three end-to-end run_doctor tests (malformed config, malformed selection, satisfiable config).

  • cargo test green on firefox-companion (25), bobby-browser (39), mcp-gateway (52); clippy, fmt, and cargo check --workspace --all-targets clean.

  • Live on the real default path: with a satisfiable persisted selection, doctor reports all checks ok including mcp-handshake (43 tools), and the gateway binary answers initialize + tools/list. With nothing configured, serve/gateway/doctor fail closed with the identical actionable error.
  • Diff: 295 lines (+221 / -74) across 3 files Reviewer: sasan1200 Review duration: 20m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.45) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 295 lines diff across 3 files
    0.45
    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%
    56%
    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.340
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #151"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 45.0% (MEDIUM) · Higher = larger blast radius
    45.0%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 19.4% · Safe to merge
    19.4%