← Back to Pull requests

node: rank remote tools by intent word overlap #832

Open
unknown opened this pull request with 352 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 29, 2026 06:00 UTC
Author

find_remote_tools currently accepts intent without using it. This adds a Go-standard-library lexical baseline: distinct query-word coverage in service/tool names and descriptions, then name matches, with deterministic tool-name/peer-ID ties. No dependencies, flags, or protocol changes.

Ranking runs after authorized discovery and peer/service filtering. Exact tool_name lookups take precedence. Nonmatching tools, labels, and diagnostic rows are retained. Empty/function-word-only queries preserve the unranked order; zero-overlap queries return the authorized catalogue in deterministic order. Raw intent text is no longer logged.

Related to #313. This is keyword ranking without synonym inference or embeddings; no broader semantic-retrieval quality claim is made. The API reference shows the three-word versus one-word ordering and documents the no-match behavior.

Review follow-up:

  • TestHandleFindRemoteTools_Intent now lives in internal/node/mcp_handlers_test.go and checks complete tool order for snake_case natural-language matching, exact-name precedence, multi-word coverage, and zero overlap. Peer/service filters and authorization hiding remain covered.

  • The snake_case case requires a match from the name and a change from the original catalogue order; its description cannot supply the match.

  • The benchmark labels its catalogue row counts and documents that it includes the slice copy and local ranking, excludes network discovery, and does not measure relevance.
  • Validation on Linux/arm64 with Go 1.27.3 after merging upstream main 1fae868e:

  • The updated handler regression fails four ranking assertions on unchanged main. Exact-name, zero-overlap, and denied-service controls pass there.

  • Focused discovery/ranking tests and all seven final handler cases pass with -race; unit cases cover Unicode/punctuation, duplicate terms, deterministic ties, and retained metadata/errors.

  • make: pass.

  • make test: 874 top-level tests passed, 10 SDK tests skipped because their JavaScript/Python SDK environments are not installed.

  • make lint: pass, including formatting, both Helm charts, golangci-lint v2.14.0 (zero issues), and deadcode.

  • make e2e-test: all 32 Bats scenarios pass, including the remote tool discovery/call/describe scenarios.

  • Local ranking benchmark (100 / 1,000 / 10,000 rows): about 86.8 µs / 826 µs / 7.83 ms per operation on this four-vCPU VM. At 1,000 rows it reports 1,196,146 B/op and 9,005 allocs/op. These are synthetic local-cost measurements, not mesh latency or retrieval-quality results.
  • Google CLA passed before this follow-up; the new commit uses the same CLA-associated author and DCO identity. Upstream checks will validate the new head after push.

    AI assistance: implemented with Codex, with independent read-only code/documentation review.

    Diff: 352 lines (+264 / -88) across 4 files Reviewer: aojea Review duration: 12702m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.42) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 352 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.351
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #832"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 42.5% (MEDIUM) · Higher = larger blast radius
    42.5%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 22.6% · Safe to merge
    22.6%