← Back to Pull requests

feat(mcp): explicit discovery modes and semantic inventory (CW-20261001-0542) #102

Open
unknown opened this pull request with 572 lines diff across 7 files
View on GitHub
unknown unknown commented on Oct 01, 2026 23:22 UTC
Author

Flat MCP clients currently receive discovery/dispatch hatches that can reach upstreams outside --servers. This change makes flat the default honest surface and adds explicit search mode under the final ADR 0047 names. CW-20261001-0542.

  • Flat lists native targets and permitted upstream tools directly, plus tether_gateway_status; no search/list/call wrappers. Search lists exactly tether_tool_search, tether_tool_list, tether_tool_call, tether_gateway_status. The semantic inventory includes native targets as origin tether.

  • The shared gateway service resolves argument > client env > typed profile hook > gateway config > persisted Tether setting > flat. Every supplied value validates, including overridden values and explicit empty strings; same-tier explicit selectors must agree. Selection/source is immutable for this endpoint. CLI supports --discovery-mode and TETHER_MCP_DISCOVERY_MODE; catalog config uses mcp.discovery_mode.

  • Existing settings persistence supplies a global mcp.discovery_mode fallback via GET/PUT /settings/mcp ({"discovery_mode":"search"}, {} clears). The daemon mount and client are wired; daemon-only proxies read it over HTTP without opening state DB. Known setting keys validate even through the generic persistence seam.

  • tether_tool_list now enumerates real schemas or hydrates exact names; tether_tool_search uses a nonempty query with summary/schema detail, server/tag filters and numeric limits. Both report total/returned/truncation, incomplete discovery and unavailable origins. Cursors bind selection, filters and inventory/schema/availability snapshot; changed requests or inventory fail with restart guidance. Unknown/excluded/unavailable hydration names get per-name errors without schema leakage. No guessed safety or pseudo schema/example refs remain.

  • tether_tool_call(name, arguments) dispatches only eligible exact targets, preserving upstream content, tool errors and structured results; transport errors retain their protocol semantics. Native targets use a private in-memory SDK connection, preserving their existing schema validation, auth/scopes, result conversion and metadata without copying the provider/server library. The wrapper advertises possible writes, and docs explain that client permissions/hooks see the dispatcher rather than the downstream name.

  • --servers is a strict loading/secret/discovery/hydration/dispatch/refresh restriction in both modes, regardless of --confine. Unknown/disabled IDs fail; explicit empty lists select none. --broker is removed. --only continues to omit native targets, while the selected mode's gateway infrastructure remains visible.
  • The minimal status reports mode/source, origin connection status/counts/errors and per-name visibility reasons (mode, restriction, availability). Profile selection/filtering is 0008: only Profile.DiscoveryMode / mcp.profiles.<id>.discovery_mode and the resolver tier are added here. Naming/collision/lint policy is 0009, metadata/status extras 0010, conformance 0011, HTTP MCP transport/selectors 0539, shared ranker adoption 0012 after go-toolselect is tagged. The existing scorer stays behind the service seam. No second tool rename, deployment, daemon restart or live configuration edits.

    Validation: preliminary isolated make check passed (lint, full race suite, vulnerability check, 72.1% coverage). The final merged candidate 64be31f passed lint and all race packages except the existing TestDaemonToolCallPublisher_AHugeErrorStillRecordsTheCall timing flake, tracked as CW-20261001-0427 and fixed separately in #101. Per lead direction, that test is unchanged here; main will be merged after #101 lands and the final gate rerun. Post-cleanup focused race suites and separate Sysop frontend build / Go tests passed. All gates use isolated HOME, clear CODEX_* and use TMPDIR under /var/tmp. Focused integration/package checks pass, including real proxy subprocess surfaces/restrictions, native hydration/dispatch, unknown/disabled startup refusal, every mode tier and overridden invalid values, stale pagination cursors, settings persistence/clear/validation, extraction/provenance and upstream refresh/recovery. Existing daemon route-table guard includes the new settings mount. Separate Sysop check builds its ignored frontend artifacts first; its pre-existing local library link is resolved by installing the declared @hollis-labs/sysop-ui@0.9.0 with --no-save --package-lock=false, leaving tracked frontend dependencies unchanged.

    Diff: 572 lines (+429 / -143) across 7 files Reviewer: copilot-pull-request-reviewer[bot] Review duration: 0m
    All Vouch review confidence checks passed
    Residual risk 0.44 = Change Risk (0.50) × (1 − Review Confidence (0.11)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 572 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 6% · Reviewer familiarity: 35%
    10%
    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.380
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #102"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 10.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: 49.8% (MEDIUM) · Higher = larger blast radius
    49.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: 10.8% · Lower = rushed or shallow review
    10.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: 44.4% · Moderate risk
    44.4%