← Back to Pull requests

OCPEDGE-2650: Add pagination, filtering, response trimming, and field projection #13

Closed
unknown closed this pull request without merging on May 26, 2026 16:39 UTC
View on GitHub
unknown unknown commented on May 20, 2026 21:38 UTC
Author

Summary

  • Typed Go response structs for all 17 API endpoints with ReshapeJSON for field control

  • Pagination params (limit/page) on every domain tool; client-side PaginateArray with 5-minute ResponseCache for endpoints that ignore server-side pagination

  • fields param on every domain tool for LLM-driven response projection, with get_tool_fields discovery tool

  • include_metrics toggle on test report tools (default off)

  • Configurable sort, variant filters, section filtering, and test name filters across tools

  • SearchCI type param fix, timeout bump to 60s, --cache-ttl flag

  • Split mcpchecker eval into domain-only and proxy-only configs to prevent accidental proxy tool usage during evals
  • Closes #4

    🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    This PR extends the existing PR description with concrete implementation and test details, plus tooling/eval config updates already present in the change set.

    What's new / concrete implementation details (additive)

  • Response shaping & types

  • - Implemented JSON shaping helpers and many typed response structs in pkg/client/types.go:
    - FilterFields(), PaginateArray(), generic ReshapeJSON[T](), ReshapeTestReport(), and ToolFieldRegistry().
    - Added many endpoint-specific types (JobRunRow, JobRunsResponse, JobReportRow, TestReportRow with custom UnmarshalJSON, Regression, RegressionMatch, PRTestResult, PayloadTestFailure, ReleaseHealth/HealthResponse, ComponentReadinessResponse, SearchResponse, etc.)
    - ReshapeTestReport supports include_metrics toggling and nested metrics extraction.

  • Client-side caching

  • - New ResponseCache in pkg/client/cache.go with NewResponseCache(ttl) and GetOrFetch(key, fetch) for optional, concurrency-safe caching (nil receiver handled).
    - Unit tests added in pkg/client/cache_test.go to validate caching, expiry, and error propagation.

  • Field discovery tool

  • - New domain tool get_tool_fields (pkg/tools/domain/fields.go) returning tool name and allowed fields via ToolFieldRegistry; registered into core tools and covered by pkg/tools/domain/fields_test.go tests.
    - README and smoke tests updated to reflect get_tool_fields presence.

  • Per-tool behavior (high-level, implemented changes)

  • - Tests/CIs:
    - get_ci_test_report, get_recent_test_failures, get_test_details: include_metrics and fields support; variant filtering added for test details.
    - Jobs:
    - get_job_report: configurable sort_field/sort_order (mapped to upstream sortField/sort) and fields trimming.
    - get_job_runs: page support (forwarding/handling) and fields trimming; tests validate page conversion and trimming.
    - Payloads:
    - get_payload_status: limit param truncates tags via truncatePayloadTags.
    - get_payload_diff and get_payload_test_failures: support limit/page and test_name filtering; use ResponseCache for client-side pagination when upstream lacks perPage; tests added.
    - Pull requests:
    - get_pull_request_impact: pagination (limit/page → perPage/page) and fields.
    - get_release_prs (GetPullRequestsHandler): fetch full list into cache and apply client-side PaginateArray + fields.
    - Components:
    - get_regressions: limit/page/fields, uses cache.GetOrFetch and client-side pagination; GetRegressionDetailHandler reshapes and combines regression + matches.
    - get_component_readiness: reshape to ComponentReadinessResponse and supports fields; README notes passing a view to avoid extra /views call.
    - Releases:
    - get_releases: fields param and ReshapeJSON usage.
    - get_release_health: sections param (health, release_health) to request only needed endpoints and combine responses; fields supported.
    - Search:
    - search_ci_logs: added limit (mapped to maxResults) and fields; Search client updated to respect explicit type param (only default type=all when missing).

  • CLI / server config

  • - CLI adds --cache-ttl flag (default 5m) and increases default upstream timeout from 30s → 60s (cmd/openshift-ci-mcp/main.go).
    - Server Config gains CacheTTL (pkg/server/server.go) default 5m and constructs/propagates a ResponseCache into payload/PR tool registrations; core tools include get_tool_fields.

  • Tests & test helpers

  • - Added extensive unit tests: pkg/client/types_test.go (reshape/pagination/filtering/ToolFieldRegistry), pkg/client/cache_test.go, pkg/client/searchci_test.go, many domain tool tests under pkg/tools/domain/_test.go covering pagination, filters, trimming, and parameter forwarding.
    - New capturingSearchCI test double and updated guidance for test helpers (CONTRIBUTING.md, .agents SKILL.md).
    - Smoke test adjustments to expect get_tool_fields and handle wrapped/paginated payloads.

  • Eval & QA tooling

  • - Split mcpchecker evals into domain-only and proxy-only evaluations:
    - mcpchecker/domain-eval.yaml updated to use domain-mcp-config.yaml and removed proxy suite; increased maxToolCalls for tests/payload suites.
    - New mcpchecker/proxy-eval.yaml and proxy-mcp-config.yaml created for proxy-specific evals (sippy_api required).
    - Makefile: check target reorganized into check-domain and check-proxies; added check-all target; check-% rules adjusted to run domain-eval; check-proxies runs proxy-eval.

  • Fixes and safeguards

  • - SearchCI client now only defaults type=all when not provided; tests added to validate explicit type preserved.
    - Guards added to PaginateArray and truncatePayloadTags to prevent panics/truncation errors on negative limits/pages.
    - Increased default upstream timeout and exposed cache TTL flag.
    - Split mcpchecker eval checks to avoid accidental proxy tool usage during domain evals.

    Tests added/updated summary

  • 13+ new/updated test functions across domain tools (jobs, payloads, components, releases, search, tests) validating paging, filters, field projection, trimming, and param forwarding.

  • Unit tests for JSON shaping, pagination, and Field registry (pkg/client/types_test.go).

  • Cache unit tests (pkg/client/cache_test.go) and SearchCI type tests (pkg/client/searchci_test.go).

  • Fields handler tests (pkg/tools/domain/fields_test.go).
  • Closing/issue

  • Addresses and closes issue #4 (Pagination and Filtering Improvements for Reduced Context Bloat).
  • Notes for reviewers (concise)

  • Many domain tool handlers now accept and propagate a client.ResponseCache; review for correct nil handling and cache key composition.

  • A large amount of new typed structs and tests were added—focus review on the JSON (un)marshalling logic (TestReportRow custom UnmarshalJSON), ReshapeJSON/FilterFields semantics, and Param forwarding (perPage/page, sort mappings).

  • <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: jeff-roche Review duration: 8341m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #13"
    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: 57% (MEDIUM) · Higher = larger blast radius
    57%
    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: 22.5% · Safe to merge
    22.5%