Skip to content

Add pagination support rubydex mcp#638

Open
st0012 wants to merge 2 commits intomainfrom
add-pagination-support-rubydex-mcp
Open

Add pagination support rubydex mcp#638
st0012 wants to merge 2 commits intomainfrom
add-pagination-support-rubydex-mcp

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Mar 4, 2026

Summary

  • Add offset and total pagination to search_declarations, get_descendants, and find_constant_references
  • limit=0 treated as "use default" to prevent empty pages
  • Add 26 unit tests calling tool handlers directly via graph injection
  • Document pagination and ordering in docs/architecture.md

Design decisions

Result ordering

Ordering is stable within a server session (graph is immutable after indexing) but may change across restarts due to parallel indexing affecting insertion order.

No caching

Each call re-walks the full filtered collection. This is O(N) per call and acceptable for expected cardinalities (hundreds to low thousands). Pagination is introduced now to support large codebases so we can start testing.

Caching will be introduced when we finished the incremental invalidation/resolution infrastructure.

@st0012 st0012 force-pushed the add-pagination-support-rubydex-mcp branch from aae8e62 to b208aa6 Compare March 4, 2026 22:26
@st0012 st0012 marked this pull request as ready for review March 4, 2026 22:36
@st0012 st0012 requested a review from a team as a code owner March 4, 2026 22:36
@st0012 st0012 self-assigned this Mar 4, 2026
@st0012 st0012 force-pushed the add-pagination-support-rubydex-mcp branch from b208aa6 to 3dcb8a2 Compare March 4, 2026 22:38
@st0012 st0012 force-pushed the add-pagination-support-rubydex-mcp branch 2 times, most recently from 756e622 to 7a175d1 Compare March 6, 2026 10:12
}

/// Assert a JSON field equals the expected u64 value.
macro_rules! assert_json_int {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MCP's architecture still makes these tests a bit weird. It would be nice to have a separation of logic and presentation, so that we could verify logic with proper Rust structures and not have to worry about JSON.

@st0012 st0012 force-pushed the add-pagination-support-rubydex-mcp branch from 7a175d1 to ab1dff0 Compare March 6, 2026 21:17
st0012 added 2 commits March 6, 2026 21:19
Add offset/total pagination to search_declarations, get_descendants,
and find_constant_references. Uses a two-pass paginate! macro: filter
pass counts total, map pass builds JSON only for the requested page.

- search_declarations: response wrapped in {results, total} envelope
- get_descendants: gains limit (default 100, max 500) and offset
- find_constant_references: gains offset; total always present
- limit=0 treated as default to guard against accidental empty pages
- Tool descriptions and server instructions mention pagination
- Add GraphTest::into_graph() for test graph injection
- Add 26 unit tests calling tool handlers directly (no process spawn)
- Windows-compatible test URIs via test_root()/test_uri() helpers
Add MCP Server section covering the two-pass pagination approach,
result ordering guarantees (stable within a session, may vary across
restarts due to parallel indexing), and key file references.
@st0012 st0012 force-pushed the add-pagination-support-rubydex-mcp branch from ab1dff0 to ecd1dc0 Compare March 6, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants