Repository navigation
feat(mcp): bound the invoice walk's offset at the door - #1265
Conversation
MAX_ROWS_PER_SKIP is a local 5,000 with its own reason; ADR 0020 D2 records a door decision measured against MAX_PAGE_ROWS rather than derived from it, and D1 now prices the cursor's door-side cost and its queue-shift benefit.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
🦋 Changeset detectedLatest commit: f7255fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
[Medium impact] The PR appears safe to merge.
|
The MCP door now bounds the invoice walk's skip, so a caller cannot make either backend walk an arbitrarily long prefix.
The bound.
pub const MAX_ROWS_PER_SKIP: u64 = 5_000sits besideMAX_ROWS_PER_PAGE, with the reason in its doc: the skip is linear in the rows it passes (~0.09 µs/key over 20 000 pending rows) and then saturates at the pending set, so an unbounded offset buys a whole index walk for an answer that may be empty — 0.941 ms atoffset: 5_000against 7.936 ms for a served 500-row page, and 1.562 ms atu64::MAXfor an empty one.offset_boundsits besidepage_bound, both run before any repository call, and the refusal isMcpError::Criterionwithoffset: a walk skips at most 5000 rows, {offset} was given.Advertised, not just enforced. The argument's
inputSchemagainsminimum: 0andmaximum: 5000, the property description and the tool description both state the ceiling, and thetools/listsnapshot carries the published document. A caller reading only the schema can choose a legal page.Not a keyset cursor. ADR 0020 D1 records the alternative and its price: a cursor changes a storage trait with six implementors plus the parity fixture and needs a Postgres
ORDER BYtie-break that no test here can run. D2 is the number, decided at this door and measured against the relay's clamp rather than derived from it — the architecture lens caught the first draft aliasingnostream_storage::MAX_PAGE_ROWS, which would have let a relay event-page change move an MCP schema. D3 is the door. Each decision carries its cost.Verified.
store_families19 (base 18), with the existing refusal case extended to 5000 served / 5001 andu64::MAXrefused and a new case seeding 5 001 rows that asserts the page at the ceiling is still served;tools_list5 with a typed pin on the constant;parity_lmdb52;nostream-mcp102 tests; workspace 116 targets green; fmt, both clippy passes and release clean. The approver drove the release binary's stdio door: 5001 andu64::MAXrefused with the exact text before any store call, 5000 passed through, and{limit: 0, offset: 5001}still answers thelimittext.Storage, services and the daemon are untouched; the Postgres
as i64wrap recorded in the issue is now out of MCP's reach and stays a failed call, not a leak. Eight paths, one empty changeset.Rust only: no version bump.
Closes #Nis inert on this repository's integration branch; #1223 is closed by hand with the merge sha.