fix(hub): report pre-limit match count as invocations total - #80
Merged
Conversation
The invocations list handler computed total after applying opts.Limit (total := len(list)), so a request with limit=2 against 19 matching invocations reported total: 2 — and downstream consumers like the MCP list_invocations tool derived truncated: false from it, silently hiding that 17 items were cut. - add Store.ListWithTotal returning items capped by Limit plus the number of matches before the limit is applied - handler now reports the pre-limit match count as total; totalPages is derived from the capped list so page links stay valid Closes #76
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #76
Problem
The hub computed
totalafter applyinglimit(list := s.invocations.List(opts); total := len(list)), so:list_invocations(no limit) →total: 19list_invocationswithlimit=2→total: 2,truncated: falseThe MCP helper
annotateListWithTotalcomputestruncated = total > returned— correct given a truthfultotal. Agents relying ontruncated/totalto decide whether to paginate silently missed data.Changes (hub)
invocations.Store.ListWithTotal(opts)— returns items capped byLimitplus the number of matches before the limit is applied.Listnow delegates to it.listInvocationshandler — reports the pre-limit match count astotal;totalPagesis derived from the capped list so page links remain valid.No MCP change needed:
annotateListWithTotalnow yieldstruncated: truewhenevertotal > len(invocations).Acceptance criteria
list_invocations?limit=Nreturnstotal= number of matching invocations (notmin(N, matches))truncated: truewhenevertotal > len(invocations)Tests
TestStore_ListWithTotalReportsPreLimitCount(with/without limit, filters applied before limit)TestInvocations_ListFilterByLimit(previously asserted the buggytotal=2; now assertstotal=3with 2 returned)go build,go test ./internal/invocations/ ./internal/api/,golangci-lint runall pass.