← Back to Pull requests

feat(kubernetes): add API discovery and schema inspection #1707

Open
unknown opened this pull request with 219 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 19, 2026 13:25 UTC
Author

Summary

Related to #1706.

This PR extends API discovery so clients can find available types and inspect their schemas without listing CRD objects or resource instances. The motivating case is a kcp consumer workspace, but the tools use standard Kubernetes discovery and OpenAPI endpoints.

  • Extend api_resources_list with unfiltered inventory and optional filters. Results are paginated within a 16 KiB application-JSON budget.

  • Add api_resources_explain for full schemas or selected field paths. Responses exceeding 24 KiB identify omitted branches and provide arguments for narrower reads.

  • Return candidates for ambiguous kinds. When discovery is incomplete, require an explicit apiVersion rather than guessing.
  • Both tools respect denied_resources. The budgets were informed by reviewing client tool-output handling and representative CRD schemas; they are starting points rather than assumed optimal limits.

    Compatibility

    Existing exact-kind api_resources_list calls remain supported. Clients should follow continuation tokens when they need the complete inventory.

    The shared error conversion retains explicitly supplied text and structured content together, so text-only clients receive discovery recovery details.
    Existing Kubernetes Status error output is preserved.

    Tests

  • Added coverage for pagination and byte limits, schema traversal and compaction, incomplete discovery, denied resources, and error output.

  • Passed: go test -count=1 ./pkg/kubernetes ./pkg/toolsets/core ./pkg/mcp

  • Passed: make build, including lint.
  • The implementation was also tested against our kcp-based cluster. The automated tests use fixtures and MCP integration coverage; they do not currently include a real-kcp integration suite.

    Diff: 219 lines (+164 / -55) across 2 files Reviewer: ychampion Review duration: 17189m
    All Vouch review confidence checks passed
    Residual risk 0.32 = Change Risk (0.60) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.60 · 219 lines diff across 2 files
    0.60
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.323
    Sensitive Paths sensitive_paths
    0.060
    Real PR Conversation Timeline
    1 comments
    "Review active on #1707"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed sensitive_module
    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: 59.9% (MEDIUM) · Higher = larger blast radius
    59.9%
    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: 31.9% · Safe to merge
    31.9%