Repository navigation
A mapped listing ends when the member that holds its cursor is absent, proved on results recorded from an open-source wiki's protocol server - #2383
Conversation
…, proved on results recorded from an open-source wiki's protocol server A server may leave out the whole member that holds its cursor on a listing's last page and on an empty listing. The mapped reader took only the last key of next_cursor_path as optional, so it read the first page of such a listing and refused the last one with protocol. For next_cursor_path alone, a member that is absent or null at any depth means that no page follows. A member that is present and is not an object where the path goes on, and a cursor that is not a string, still refuse with protocol. The optional paths of an item keep their rule: only the last key may be absent. The mapping format is unchanged. source_worker/mappings/wiki.json is the reference mapping for an open-source wiki's protocol server. source_worker/tests/fixtures/mapped/wiki holds what that server answered for a wiki of made-up pages. It was recorded through source_worker/qualification/stand_in_channel.py, which stands in for an account host's tool channel: it lists the server's tools as advertised and raises the reader's code for a result over its cap, a sign-in that is needed, a server that is not enabled and a tool that is not allowed. The proof test reads the recording with the reference mapping and puts the channel in each refusing state. The recorder replaces an id as a link spells it as well: percent-encoded, or with _ for a space. A wiki's link holds the page's name in that spelling, which the recorder left in the written files. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main changed no file of this branch. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3448a90. Configure here.
| for known in sorted(self._values, key=len, reverse=True): | ||
| value = value.replace(known, self._values[known]) | ||
| for spelling in spellings(known): | ||
| value = value.replace(spelling, self._values[known]) |
There was a problem hiding this comment.
Scrub splits percent-encoded values
Medium Severity
scrub applies spellings with the raw value first. quote encodes % as %25, so that raw value is a prefix of its percent-encoded spelling. The first replace tears the encoded form apart, the later spelling no longer matches, and the hold check looks only for the original spellings, so the recording keeps a broken link.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 3448a90. Configure here.
| for known in sorted(self._values, key=len, reverse=True): | ||
| value = value.replace(known, self._values[known]) | ||
| for spelling in spellings(known): | ||
| value = value.replace(spelling, self._values[known]) |
There was a problem hiding this comment.
Underscore spellings alias other ids
Medium Severity
scrub still orders values by raw length, then replaces every spellings form, including space turned into _. A link spelling that is exactly some other upstream value is replaced with the first value's neutral id, so two different ids become one token in the recording.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3448a90. Configure here.


Related: #1189
Related: #1190
Related: #1232
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
The source worker's mapped reader ends a listing when a member on the path to its cursor is absent or
nullat any depth, so a read mapping can list a server that leaves out the whole member that holds its cursor on the last page.source_worker/mappings/wiki.jsonis a reference mapping for an open-source wiki's protocol server, and a test reads it on results recorded from that server.Why
The mapped reader was proved on results built by hand for a made-up server. Recorded from a protocol server Loom did not write, one shape did not fit. The server holds its next cursor three keys down (
truncation.continueWith.value) and leaves out the wholetruncationmember on a listing's last page and on an empty listing. The reader took only the last key ofnext_cursor_pathas optional, so it read the first page and refused the last page and the empty scope withprotocol.A listing's cursor was already optional. Servers commonly leave out the member that holds it, so this is the same rule read along the whole path, and no new mechanism. The mapping format does not change.
Scope and risk
source_worker/loom_source_worker/readers/mcp_mapped.py)._cursorreadsnext_cursor_path: a member that is absent ornullat any depth means that no page follows. A member that is present and is not an object where the path goes on, and a cursor that is not a string, refuse withprotocolas before. The optional paths of an item (title, link, revision, modified time) still go through_optional, where only the last key may be absent.source_worker/mappings/wiki.json, idwiki). It pins the server's listing tool and its fetch tool by the digests the server advertised. The scope is a user, the listing is by change and by time, an id is a page's name, and a removal is the fetch's not-found answer. The listing names changes, not pages, so the mapping declares it notcompleteand nothing is retired by absence. It names nodeniedmatcher: the wiki had no page its reader may not read, so no denial was recorded.source_worker/tests/fixtures/mapped/wiki/). A wiki made for the run, in a container, held 53 short made-up pages and one long one by one made-up user, and a second user with no change. The recorder wrote the two tool definitions, a listing of two pages (50 and 4 changes), the listing of what changed since (4), the empty scope, a document, a missing one, one the server cut at its size cap, andexpected.json. The wiki ran under a made-uphttpsorigin on a reserved example name, so every link in the files is on that origin and no file holds an address of the machine. The directory'sREADME.mdnames the server, its version and the image once, with the commands that repeat the recording.source_worker/qualification/stand_in_channel.py).Stdiostarts a server as a local process.Channelstands between the reader and it as an account host's channel does: it lists the server's tools as advertised (29 here, of which the mapping pins 2) and raisestoo_largefor a result over its cap,reconnect_requiredwhen the account needs a sign-in,server_offwhen the server is not enabled andtool_not_allowedfor a tool the host's policy refuses. It holds no error text of any host, and the package does not import it.source_worker/qualification/record_mapped.py). The first recording still held every page's name: the server's link spells it with_for a space, and the recorder replaced an id only as written.spellingsadds the two ways a link spells a value (percent-encoded, or_for a space) to the replacement and to the check that stops the recorder when a call still holds a value.test_the_recorder_replaces_an_id_as_a_link_spells_itfailed first on a written file that held both spellings.Channelover the recorded results in each state. The same four states were also run against the live server, with the same codes.max_result_bytesof 400,000 is set from that measurement, with room for a page whose text doubles when it is written as JSON.tools.jsonholds the two definitions as advertised, parameter descriptions included, because the digest covers the input schema. One description names a public site as an example of an argument. Removing it would change the digest the mapping pins.Stdiowaits on the server's pipe without a deadline. It is used by a person who records, never by the package or a test.examplerecording is unchanged.next_cursor_pathhas more than one key ends its listing where a member above the cursor is absent ornull; before, it refused withprotocol. A server that left such a member out in the middle of a listing would end it early, as a server that leaves out the cursor itself already does. No read mapping in the repository had such a path before this change.Compatibility, rollout and rollback
protocol, as before: the turn ends with that error and is retried.Tests
source_worker/tests/test_mapping_proof.py, over the hand-built recording with the cursor moved two members down:test_a_listing_ends_when_the_cursor_member_is_absent(7 cases). On the unchanged reader 4 failed withprotocol: the member absent,nullor empty, and the member under itnull.test_a_cursor_member_of_the_wrong_type_still_refuses(7 cases): a string, a list or a number where an object is expected, at both depths, and a number as the cursor. Every value is falsy on purpose.test_an_item_field_keeps_the_last_key_rule: an absent last key of a title path reads as no title; an absent ornullmember above it refuses.test_the_reference_mapping_pins_the_recorded_definitions.test_the_reference_mapping_reads_what_the_recording_expects: the reader producesexpected.json, every field of every listed change and of the fetched document.test_the_recorded_listing_ends_where_the_server_leaves_its_cursor_member_out: two pages of 50 and 4, the second asked for by the first page's cursor, notruncationmember on the last page, the changed listing and the empty scope.test_the_recorded_missing_page_is_gone_and_the_cut_page_is_too_large.test_no_fixture_holds_an_upstream_id_or_name, now run over both recordings. It also fails when a file holds a link on another origin than the mapping approves, and for the wiki when a change names a page or a user that is not a neutral value.test_a_refusal_of_the_channel_reaches_the_engine_by_its_code(one case per refusal): the reader raises the channel's code,removedanswersunknown, and only a result's size is judged after the call._optional, 9 tests of the file fail withprotocol: the 4 cases above and 5 tests of the recorded directory.python -m pytest -q source_worker/tests, serially as the package's workflow runs it: 618 passed, 28 subtests passed. The run before it had one failure in an unchanged file,test_enrollment_http.py::test_a_grant_outside_its_scope_is_denied_before_lookup[issued-ahead]. Its parameter is a time ten seconds ahead that is computed at collection, so it fails when the test starts later than that. It passes alone and in its file.ruff format --check source_worker,ruff check source_worker,mypy --strict source_worker/loom_source_worker(no issues in 20 source files),make typecheck(0 errors).tests/unit/test_package_contracts.py,test_op_transport_contract.py,test_tunable_constants.py,test_store_names_refused.py,test_degraded_unnoted.py,test_public_copy.py,test_doc_links.py,test_agent_instructions.pyandtests/analyzer, on the tree merged withmain: 616 passed, 12 skipped, 1 failed. The failure istest_degraded_unnoted.py::test_every_broad_handler_notes_its_fallback_or_says_why_it_need_not, which namesserver/code/app/review_brief.py::_rebuild. That handler ismain's, and this change touches no server file, so it is not changed here.npx --yes prettier@3.9.9 --checkon the two docs pages and the directory's note, and Biome's format check onsource_worker: no change.tests/integration/test_assigned_source_turn.pyreads the hand-built recording, whose cursor path has one key, through the reader. No generator applies to this change.mainatff9e20291, merged without a conflict.mainchanged no file undersource_worker/and neither of the two docs pages since the branch started, so the worker suite was not run again after the merge.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked by installing the server at its pinned version and calling its tools against a wiki made for the run, by reading the server's code for where its cursor, its link origin and its size cap come from, by writing each test before the code and watching it fail, by loosening the new rule and watching the two guard tests fail, and by repeating the recording with the final code.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code
Note
Medium Risk
Listing pagination behavior changes for multi-key
next_cursor_pathmappings: absent/null intermediates end the list instead of raisingprotocol, which could truncate listings if a server omits members mid-sequence. Scope is confined to the source worker reader and test/qualification tooling, not auth or stored data.Overview
The mapped reader now treats a listing as finished when any segment along
next_cursor_pathis missing ornull, not only the final cursor key. That supports servers (e.g. MediaWiki MCP) that nest the continue token undertruncation.continueWith.valueand omit the wholetruncationobject on the last page or empty listings. Pagination uses a new_cursorhelper inmcp_mapped.pyinstead of the old last-key-only optional read.This PR adds
source_worker/mappings/wiki.jsonas a reference mapping for@professional-wiki/mediawiki-mcp-server, plus a recorded fixture tree undertests/fixtures/mapped/wiki/and docs on how to re-record it. Qualification tooling growsstand_in_channel.py(Stdio+Channel) so recordings can run through a local stdio server with host-like refusals (reconnect_required,server_off,tool_not_allowed,too_large).The recorder
spellings()now neutralizes IDs in plain text and common link forms (percent-encoding and_for spaces), and skips numeric IDs.test_mapping_proof.pycovers nested-cursor edge cases, replays bothexampleandwikifixtures, and asserts channel error codes propagate unchanged.Reviewed by Cursor Bugbot for commit 3448a90. Bugbot is set up for automated code reviews on this repo. Configure here.