Repository navigation
Conversation
…ncurrency A process sent the copies and access checks of a worker source's turn one at a time, so the copies one process keeps served were bounded by the mirrored phase time in half the stale window divided by one request's time in Loom (authority reads and the worker's reply). A turn now keeps up to knowledge_source_worker_copy_concurrency requests in flight, which raises that bound by the same factor. The concurrency is a setting, not a constant: each worker's read_limits.concurrent_per_org must hold it beside the org's live reads, and only the operator knows both. The default is 2, the floor a worker that serves setup already meets (a selection proof runs two checks), so an existing deployment keeps working; 1 restores one request at a time. It is read at boot for the channel shares and at each turn, and is not live. What holds under concurrency: - Requests start in the visit order (resources without a copy, then the oldest confirmation) and the pass's time and stop checks run before each start. - A copy reserves its place in the document bound before it is sent and gives it back when no document arrives, so the copies in flight never spend more than the bound has left. - A request that ends the turn stops new ones; those in flight finish and their answers apply. An upstream denial answered beside such a refusal keeps its copy, so a turn that ended on a refusal retires nothing. Lapsing retirement and the listing still run only after every request finished, gated as before. - An error raised by one request is raised once the others finish; a cancelled turn cancels its requests in flight. - Every request still resolves the owner's authority before and after. The channel's stored-check and copy shares each hold the setting's number of slots, counted in the connection pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.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 c8b9e6a. Configure here.
| finally: | ||
| await visits.finish() | ||
| if visits.error is not None: | ||
| raise visits.error |
There was a problem hiding this comment.
Finished peer copies discarded on error
Medium Severity
If one request raises, the others are drained and can still write a copy or confirm access. The stored error is then raised out of the turn before _keep, and the sync caller records a fresh failed result. Those finished updates never reach sync state, so a written copy can disagree with the recorded digest and confirmation.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c8b9e6a. Configure here.
…share A default of 2 would raise every process's sync load on each worker at upgrade, and a worker at the setup minimum (concurrent_per_org 2) would lose its room for live reads: live reads and turns would answer overloaded, turns would end and listings would lapse. The setting now defaults to 1, today's behaviour; raising it is the operator's step, with each worker's concurrent_per_org at least the setting plus room for the org's live reads and setup. The channel kept a stored-check share and a copy share of copy_slots each, reserving twice what a turn can use. Copies and checks now take one sync share of copy_slots, counted once in the connection pool. The capacity workflow takes a copy_concurrency input (default 2, inside the worker's default concurrent_per_org of 4), passed only through the environment. The driver records the setting in environment.loom and refuses a value above the worker's concurrent_per_org, which would read as a figure rather than a misconfigured run. The docs say that an upstream denial answered after a refusal ended the turn retires nothing, while one answered before it retires, as one request at a time; a test covers the denial-first order. Only the turn's own request answering overloaded ends it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…pass A manual loom knowledge sync, or a lease handover, can run a second copy turn for an org against the same worker, so the sizing advice now allows for twice the setting there. The copy turn drains its requests in one place, and a test that read the HTTP client's private pool is dropped; the share tests cover it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
With requests in flight, a refusal answered after another had ended the turn replaced its status, so the source showed whichever came last. A request answered after the turn ended now keeps its copy and leaves the status alone. A request that raised just before a cancel has its error read, and the routes test says it checks only the wiring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A copy's upstream denial whose authority read outlasted a peer's turn-ending refusal replaced that refusal with its own. It now fails the turn only while the turn is still ok. An uncopied resource whose own answer arrives after the turn ended waits its refresh interval, as the module says, and the boundary page says copies and confirmations share one set of slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…'s read The guard keeping a stored copy whose upstream denial was read again while a peer ended the turn had no test. One now covers it, the own-answer wait covers an upstream denial as well as unsupported, and the provisioning paragraph says copies and their checks share the copy concurrency slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>


Related: #2165
Related: #2196
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):
A worker source's copy turn can keep up to
knowledge_source_worker_copy_concurrencyworker requests in flight (default 1, as before); raising it lets a turn wait on several worker requests at once instead of one, once each worker has the slots for it. Its effect on how many copies one process serves is not measured yet.Why
A hosted run of the copy capacity workflow (24 sources × 10 resources) measured, in Loom, about 234 ms per copy and 302 ms per access check at the median, while the worker answered in about 93 ms. A process sent those requests one at a time within the mirrored phase of each sync pass. At the default settings that keeps roughly a thousand copies served per process. Most of each request's time is Loom's own authority reads before and after it, which stay as they are. So the request count in flight is the lever.
Scope and risk
knowledge_source_worker_copy_concurrency, default 1 (one request at a time, as before), range 1 to 16, read at boot and at each turn, not live. Raising it is the operator's step: each worker'sread_limits.concurrent_per_orgneeds at least the setting plus room for the org's live reads and setup, and twice the setting where a manualloom knowledge syncruns beside the background pass (or a lease handover overlaps two passes); otherwise live reads and the turn's own requests answeroverloaded. Only the turn's own request answeringoverloadedends the turn.server/knowledge/app/source_sync_worker.py):pass_context.check_stop()and the document count are checked before each start.run.leftbefore it is sent and gives it back if it brings no document, sorun.leftnever goes below 0. A turn may leave a place unused that a later pass picks up.unsupported) arrives after the turn ended waits its refresh interval; any other refusal waits half the stale window. An upstream denial answered after a refusal ended the turn retires nothing; one answered before it retires, as it does one request at a time.server/knowledge/app/mcp_worker_read.py,mcp_worker_routes.py): copies and access checks share onesyncshare sized from the setting through acopy_slotsargument, replacing the fixed stored and copy shares, and the connection pool counts it once.copy_concurrencyinput (default 2) reaches Loom only through the job's environment. The driver records the setting and refuses, as a harness error, a value past the worker'sconcurrent_per_org.docs/architecture/mcp-source-worker-boundary.md, and the source worker README'sread_limitsnote (concurrent_per_orgneeds at least the setting plus room for live reads).Compatibility, rollout and rollback
read_limits.concurrent_per_orgat least that many slots plus room for live reads.Tests
tests/unit/test_worker_source_copies.py(91 passed): the existing tests run one request at a time. Fourteen new ones, thirteen at 2 or 3 in flight and one at 1, cover:unsupportedor an upstream denial) after the turn ended waiting its refresh interval;tests/unit/test_mcp_worker_read.py(28) andtests/unit/test_mcp_worker_routes.py(6) cover the shared sync share and the setting reaching the channel;tests/unit/test_bench_source_worker_copies.py(59) covers the workflow input and the driver's room check.test_tunable_constants.py,test_doc_links.py,test_public_copy.py,test_settings_reference.py,test_settings_every_field_read.py,test_live_settings.py. ruff, the function-length gate, the settings and docs generator--checks, the prose checker and Prettier pass; mypy shows no errors in the changed modules.copy_concurrencyof 2.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 wrote the concurrent turn, the setting and the tests. I set the scope from the measured run (concurrency as the lever, authority reads unchanged) and checked the bound and refusal handling.
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/describe the system as it now is.🤖 Generated with Claude Code
Note
Medium Risk
Changes mirrored sync turn scheduling, refusal/retirement timing with overlapping requests, and worker channel capacity; default 1 preserves prior behavior but mis-tuned concurrency can cause
overloadedon workers or alter copy-serving bounds.Overview
Adds
knowledge_source_worker_copy_concurrency(default 1, range 1–16) so each process’s worker copy turn can keep multiple copy and access-check requests in flight instead of strictly serializing them.The sync turn schedules due resources in the same order as before but starts up to the limit in parallel via
_Visits(asynciotasks). A turn-ending refusal stops new starts while in-flight work still settles; document-bound slots are reserved before a copy is sent and returned when no document is written. On the worker channel, separate stored/copy slot pools are replaced by onesyncshare sized from the setting.The source-worker copy capacity workflow gains a
copy_concurrencyinput (default 2); the bench driver records the value and fails fast if it exceeds the worker’sconcurrent_per_org.Reviewed by Cursor Bugbot for commit c71a5c6. Bugbot is set up for automated code reviews on this repo. Configure here.