Repository navigation
Conversation
`mcp__flare__docs(action="list")` serialized every live document with its
`content`, and `limit` was optional with no default. Per-item rustdoc/npm
indexing means one crate contributes hundreds of documents, so a routine
cache reached 10,889 documents / 7.75 MB -- a single MCP response no
context window can receive. Even `limit: 15` returned 71 KB, because the
cap bounded the number of bodies, not the bytes.
`list` now returns a metadata projection and a capped page:
{"total": 10889, "offset": 0, "returned": 100, "docs": [...]}
`total` travels with the page because a truncated listing that cannot say
what it withheld reads exactly like a complete one -- that is how a caller
concludes a cache is smaller than it is. `offset` is new for the same
reason the cap is defensible at all: bounding a response must not put a
document out of reach.
The projection is pushed into SQL rather than applied to a fetched Vec.
Truncating in Rust still makes SQLite read and allocate every row's
`content` first, which is the cost being removed. `content_bytes` casts to
BLOB before measuring, since SQLite's LENGTH() counts characters on TEXT
and a caller sizing a response needs bytes.
`doc_list`/`DocsStore::list` are untouched: the CLI writes to a terminal a
human can pipe through jq, and changing its output would break scripts for
a problem it does not have.
The existing test asserted the old behaviour as the contract, so it is
replaced rather than extended -- by four covering the default cap and
reported total, oversized-limit clamping, offset paging, and the size
property itself (a 100 KB body must not make the listing 100 KB bigger).
Verified: cargo test --workspace, 834 bin tests + all crate suites, 0
failures; cargo fmt --all clean; clippy clean on every touched crate.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe PR adds lightweight document summaries and count APIs, threads bounded pagination through ChangesDocument listing pagination
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant MCPClient
participant flare_docs_impl
participant DocsStore
participant Store
MCPClient->>flare_docs_impl: submit list request
flare_docs_impl->>DocsStore: count()
DocsStore->>Store: count live documents
Store-->>DocsStore: total
flare_docs_impl->>DocsStore: list_summaries(limit, offset)
DocsStore->>Store: fetch bounded summary page
Store-->>DocsStore: DocumentSummary rows
DocsStore-->>flare_docs_impl: summaries
flare_docs_impl-->>MCPClient: paginated JSON response
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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 agentflare item #381 (NOT GitHub PR #381).
Found dogfooding
mcp__flare__docsafter the rename landed in #342/#344.The problem
action="list"serialized every live document with itscontent, andlimitwas optional with no default. Per-item rustdoc/npm indexing (#337/#343) means one crate contributes hundreds of documents, so a routine cache is five figures. Measured against my own store:261x. Both numbers come from running each code path's exact SQL against the live 10,857-document cache, not a fixture.
The bounded call was broken too:
limit: 15returned 71,073 characters and tripped the harness's max-tokens guard, because the cap bounded the number of bodies, not the bytes.The change
Three decisions worth flagging for review:
totaltravels with the page. A truncated listing that cannot say what it withheld reads exactly like a complete one — that is precisely how a caller concludes a cache is smaller than it is.offsetis new, and was not in the filed item. I added it because a cap is only defensible if bounding a response does not put a document out of reach. Without it the fix would trade one silent wrongness for another.The projection is pushed into SQL, not applied to a fetched
Vec. Truncating in Rust still makes SQLite read and allocate every row'scontentfirst, which is the cost being removed.content_bytescasts to BLOB before measuring because SQLite'sLENGTH()counts characters on TEXT, and a caller sizing a response needs bytes — there is a test pinning that (日本is 6, not 2).doc_list/DocsStore::listare deliberately untouched. The CLI writes to a terminal a human can pipe throughjq/head; changing its output shape would break scripts to solve a problem it does not have.doc_list_summaries/doc_countare additive on the shared store, so existing consumers are unaffected.Tests
The existing
list_returns_everything_by_default_but_honours_a_capped_limitencoded the bug as the contract, so it is replaced rather than extended. Four tests take its place:totalreports the full setlimitclamps rather than errorsoffsetreaches documents past the first page (paths zero-padded soORDER BY pathmatches numeric order — otherwise the assertion would not say what it appears to say)raw.len() < 1_000rather than a brittle byte countPlus three at the store layer: paging without bodies, deleted/other-project exclusion, and the bytes-not-characters case.
Verification
cargo test --workspace— 834 bin tests + every crate suite, 0 failurescargo fmt --all— cleancargo clippy— 0 warnings onagentflare-store,flare-docs, and theagentflarebinSummary by CodeRabbit
New Features
Documentation