Skip to content

Owner-only snapshot and selected-refresh worker sources keep a private copy in the mirror - #2165

Merged
zlareb1 merged 23 commits into
mainfrom
feat/mcp-worker-stored-copy
Dec 5, 2026
Merged

zlareb1 merged 23 commits into
mainfrom
feat/mcp-worker-stored-copy

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Related: #1190
Related: #2144

Changelog category (leave one):

  • New Feature

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):

With knowledge_source_worker_copies_enabled on, a collection writer can register an owner-only snapshot or selected_refresh worker source. The sync worker keeps a private copy of its selected resources in the collection's mirror, which only the owner can search.

Why

A worker source served only live reads: each search read the resource through the worker and kept nothing. snapshot (copy once) and selected_refresh (copy again on an interval) were in the setup contract but answered unavailable. They need a stored copy, a refresh, a read check and erasure, all of which the native mirrored sources already have.

This change gives worker copies those same pieces: the source sync engine, the collection's mirror, the mirror read gate and the knowledge_source_retire queue. It adds no table. The one worker protocol change is an optional reason on the worker's 403 body.

Scope and risk

  • Setting. knowledge_source_worker_copies_enabled, off by default. While it is off, setup answers unavailable for both modes, as before, and nothing in this PR writes or serves a copy.
  • Setup.
    • With the setting on, preview and register accept owner-only snapshot and selected_refresh. Team access still answers unavailable.
    • selected_refresh takes a new interval_seconds field, 300 to 86400: the least time between a resource's copies, since a copy is read again at most once a sync pass and only with room in the mirror document bound. It is required for that mode and refused for the others.
  • Source worker. An upstream HTTP 403 to a POST carrying a resources/read or mapped tools/call request becomes a new client error, forbidden, which the HTTP service answers with the upstream_access reason. A 403 to initialize, tools/list, any other POST, the GET stream or the closing DELETE stays a plain denied, because those are often the worker's own network or setup (an allowlist, an Origin check, a firewall). Grant, binding and protocol refusals keep the plain {"status":"denied"} body.
  • CLI. loom knowledge source worker-preview and worker-register gain --interval-seconds, and their --mode help says snapshot and selected_refresh answer unavailable unless the server keeps worker copies. The CLI snapshots and reference are regenerated.
  • Channel. The worker channel gets a copy share of 1 slot, since a process sends at most one copy at a time, so a copy never takes one of Loom's live-read channel slots. On the worker, a copy and a live read share the same read_limits.concurrent and concurrent_per_org slots, so on a small worker a copy in flight can make a live read answer overloaded; the boundary page says so. A copy uses the worker's existing live route, and an access check uses check_access, which returns a digest and no content.
  • Sync turn (server/knowledge/app/source_sync_worker.py), for each selected resource:
    • A resource is copied when it has no copy, or for selected_refresh when its interval has passed. The copy is read as the owner through CurrentRead(purpose="stored") and written with an access list naming only the owner. An unchanged digest writes nothing.
    • Other copies have their access checked once their last confirmation is half of knowledge_source_acl_stale_seconds old. A check confirms the owner's access only; the digest is not compared, so a changed resource keeps its copy until the copy is due again.
    • Of the worker's answers, only its named upstream denial retires a copy at once: a 403 with body {"status":"denied","reason":"upstream_access"}, which the worker sends only when the upstream MCP server answered 403 to the resource read itself. The registration, the owner's standing and the owner's authority must also still hold when re-read just before. Every other denied ends the turn and retires nothing. That covers the worker refusing Loom's grant (a rotated key, a skewed clock, a mismatched binding) and Loom's own changed authority, as well as a reply Loom cannot trust.
    • timeout and unsupported leave that copy unconfirmed and the turn moves on. A timeout may come from the upstream or the worker, so it never retires a copy. A copy answering unsupported (for example a resource deleted upstream) is retired once its confirmation would lapse before the next pass, that is, once it is older than knowledge_source_acl_stale_seconds less knowledge_source_sync_interval_seconds. Two conditions must also hold: another copy was confirmed after this copy's own check fell due, which shows the failure is the resource's, and the owner's authority, read again, still holds, in a turn no other refusal ended. The copy then waits before it is tried again, so one resource cannot keep the source's other copies from being served. reconnect, overloaded, unavailable or lost owner standing end the turn.
    • A turn reads the stored copies of exactly the selected addresses, so a selection of up to 240 resources is never cut by a page of documents. Every stored copy belongs to a selected resource: a copy's address is fixed by the source ID and the resource ID, and a registration's selection cannot change.
    • Removal, namespace retirement, owner erasure and the end of a registration also retire every copy of the source.
    • Copies spend the pass's mirrored document bound. Access checks spend only the pass's time, so a worker source's turn still starts once other mirrored sources have used up the bound, and only its due copies wait.
    • A resource without a copy waits half the stale window after a timeout, a plain denial or another turn-ending refusal, and its refresh interval (half the stale window for a snapshot) after the upstream's denial or an unsupported answer, so the next turn reaches the others. A stored copy whose request keeps ending turns keeps every copy of the source unserved until it answers or the source is removed, which fails closed.
  • Fail-closed freshness. The turn records the mirror listing at the oldest confirmation among the stored copies. The read gate serves copies only while that listing is fresher than knowledge_source_acl_stale_seconds. So once any copy's access has gone unconfirmed for that long, none of the source's copies is served.
  • Read gate (source_access._worker_copy_eligible): it admits a worker source's copies only when all of these hold:
    • the setting is on;
    • the latest row has the same source ID and the same pinned registration;
    • the mode is not live and the policy is owner-only;
    • the reader is the owner and has viewer access;
    • the collection's approval and the owner's worker account are still current.
  • Owner standing in the turn. One helper, connected_accounts.owner_writes, now reads the owner's writer grant for both connected sources and worker copies. The owner keeps their directory standing, with no revocation since the registration, and a writer grant on the namespace. Every worker request reads that whole standing again, and CurrentRead re-checks the approval and the owner's worker account at the registered generation before the request and after its reply, so a SCIM deactivation or revocation mid-turn stops the next read and write.
  • Permanent loss of authority. When the approval is missing or at another generation, or the owner's worker account is missing, inactive or at another generation, the turn re-reads them under the sources lease. If they are still gone, it marks the source inactive, queues its copies for retirement and records owner_inactive, as the owner check does for connected sources. A failing read, a lost writer grant or a profile this replica's routes file does not provision ends nothing.
  • Processes. The workers child process and loom knowledge sync open the source worker runtime, so copies sync in the default workers_process=child deployment.
  • Capacity. A process sends copies and checks one at a time within the mirrored phase of each sync pass, which native mirrored sources share, and every stored copy needs a check every half stale window. So the copies one deployment keeps served are bounded by that phase's time over one check's time. Past the bound, the oldest listings lapse and those copies stop being served, which fails closed, and a turn the bound cuts (a visit, a refresh held back by the document bound, which is checked only when its check is due, a retirement or the listing) reads pass bound reached in the source's sync state (a source the phase does not reach keeps its last state). The boundary page states this. The bound is not measured in this PR; raising it (concurrent checks, or a worker-side refresh) belongs to the hosted scale qualification. The feature is experimental and off by default.
  • A routes file that does not provision the registration's profile in this process ends the turn unavailable, not owner_unavailable.
  • Read path cost. With the setting on, the read gate's store query returns only worker rows whose stored registration names a copy mode and owner-only access, so a live worker row adds no cost to reads. While a namespace holds any copy-mode worker row, every reader of it pays one standing read of their own subject by prepare and one by each check batch; a copy row the reader does not own is then skipped before any registry read.
  • Retirement and erasure.
    • knowledge.source.remove, namespace retirement and owner erasure queue a worker source's copies for the knowledge_source_retire worker. Owner erasure queues them before it deletes the rows.
    • The retirement worker no longer skips an inactive worker row; it still leaves an active row with the same source ID alone.
    • Copies carry the sync worker's actor and the source-id: tag, so the existing retirement path finds them.

Compatibility, rollout and rollback

  • Wire: a new optional interval_seconds on the worker setup preview and register inputs, required for selected_refresh and refused for the other modes. A selected_refresh preview or register without it, which used to answer unavailable, now gets an invalid-input error, whatever the setting. The remove and setup descriptions are updated, and the SDKs and the docs reference are regenerated.
  • Settings: one new setting (above).
  • Rolling upgrade: rule 77 in docs/architecture/rolling-upgrades.md.
    • N-1 registers no copy source.
    • N-1's sync worker and mirror reads skip every worker row.
    • N-1's live read refuses a non-live registration.
    • N-1's removal paths queue no worker copy.
    • So the setting is turned on only once every replica runs this build.
    • Source worker versions: an older worker never names the upstream reason, so Loom N never retires a copy on its denial; a copy answering unsupported follows the lapsing rule with either worker build. That source's copies stop being served after the stale window instead. An N-1 Loom ignores the reason a new worker adds.
    • With the setting off, N still queues retirement and sets pending_delete when a worker source is removed, because a copy written while the setting was on outlives turning it off. With no copy the entry finds nothing; N clears it and N-1 leaves it pending.
  • Operator steps:
    • Turn the setting on only after every replica runs this build.
    • Before rolling back to N-1, remove every snapshot and selected_refresh worker source with N and let the knowledge_source_retire worker drain. N-1 neither serves nor retires their copies.
  • Storage: no migration. The copies are ordinary mirror documents, and their per-resource state is in the mirror's sync state.
  • Rollback: reverting removes the modes. Follow the operator step above first, so no copy is left behind.

Tests

  • tests/unit/test_worker_source_copies.py (53 test functions, 76 cases with parametrization) covers:
    • the predicate and the setup gate;
    • each turn path: copy, unchanged digest, access check, denied retires, transient failures keep the copy and record no listing, the document bound, a copy answering unsupported retired before its confirmation lapses only when a peer was confirmed since its check fell due, kept on any timeout, on refusals that end the turn and when the owner's authority is gone; a deactivation mid-turn stopping the next read; worker turns past the document bound;
    • the read gate: owner admitted, other reader refused, setting off, changed registration, approval or worker account;
    • retirement queueing on remove and owner erasure.
  • Existing retirement, connected-account cleanup, setup register, source access and assistant mirror tests are updated. tests/unit/test_mcp_worker_read.py covers the copy share.
  • tests/unit/test_cli_knowledge_source_worker.py adds a selected_refresh preview sending its interval, and no interval sent unless given.
  • tests/unit/test_worker_copy_store_sql.py runs the new store queries on clickhouse-local against schema.sql. It checks that 241 copies are all found past a page of documents, along with another writer's row and a superseded row, and that the read gate's query returns only owner-only copy-mode worker rows.
  • The source worker tests cover the upstream_access answer for an upstream 403 to the read, and a plain denied for a 403 to initialize, discovery, the GET stream or closing the session, and for grant, binding and resource mismatches. source_worker/qualification/test_real_tls.py adds a read-time 403 over real TLS.
  • A turn where every request gets a plain 403 with Loom's authority intact retires nothing.
  • Each of these guards was mutated once, and a test failed:
    • the read gate's owner check, its account check, and its worker branch admitting every row;
    • the owner-only check;
    • the setup gate ignoring the setting;
    • the copy share swapped for the live share;
    • the retirement exemption put back;
    • remove and erasure without queueing;
    • retire on denied;
    • the listing status guard;
    • the registration check;
    • the unchanged-digest skip;
    • the document bound;
    • the owner check at the start of the turn.

Local runs:

  • ruff format and ruff check, the function-length gate, the no-secrets check, all 16 generator --checks, and Prettier and the prose checker on the changed docs.
  • mypy on the changed modules. It reports errors only for imports missing locally (numpy, tree_sitter).
  • Through the focused gate, the new and changed test files and the settings, SDK, docs, transport, knowledge source and worker test files all passed.
  • The source worker suite (398 tests), source_worker/qualification/test_real_tls.py (7 tests) and mypy on loom_source_worker.
  • The integration tests, the TypeScript vitest suite and the Rust crate build run in CI.

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 turn, the read gate, the retirement changes and the tests. I set the design (reuse the sync engine, mirror, read gate and retirement queue instead of a new queue; fail closed through listing freshness; a setting turned on after the rollout) and checked the turn and the rolling-upgrade rule.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, the settings reference, schema and example, and the docs/reference/ tables.
  • No migration.
  • No plugin-shipped file changed.
  • No frontend change.
  • Docs under docs/ describe the system as it now is.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off.

🤖 Generated with Claude Code


Note

Medium Risk
Touches sync, mirror access control, retirement/erasure, and cross-version rollout when enabling the flag; default-off limits exposure, but mixed replicas or rollback without draining sources can leave orphaned unserved copies.

Overview
Adds experimental, off-by-default owner-only snapshot and selected_refresh worker sources that Loom mirrors into the collection (gated by LOOM_KNOWLEDGE_SOURCE_WORKER_COPIES_ENABLED). Preview/register gain interval_seconds for selected_refresh; setup serves those modes only when the flag is on.

A new source_sync_worker turn copies or refreshes selected resources through the source worker (dedicated copy channel slot), runs periodic access checks, and records listing freshness fail-closed like native mirrored sources. The mirror read gate admits those copies only to the owner with current approval and worker account.

Removal, namespace retirement, and owner erasure now queue worker copies for knowledge_source_retire (same path as other mirrored sources), including erasure ordering before row delete. Connected-source owner inactive retirement is factored to shared retire_owner_inactive.

The source worker distinguishes upstream resource 403 (reason: upstream_access) from other denials so Loom can retire a copy immediately on true upstream access loss; other failures keep copies until stale/lapsing rules apply.

Workers child and loom knowledge sync load the source worker runtime so copies can sync in the default deployment. Docs, settings schema, and SDKs are regenerated for the flag and wire fields.

Reviewed by Cursor Bugbot for commit cd1cf33. Bugbot is set up for automated code reviews on this repo. Configure here.

…e copy in the mirror

With knowledge_source_worker_copies_enabled on, a collection writer can register an
owner-only snapshot or selected_refresh worker source (the latter with a new
interval_seconds field). The sync worker keeps its copy in the collection's mirror:
each turn copies a resource that has no copy or whose refresh interval passed through
a new copy share of the worker channel, checks the rest with check-access once their
confirmation is half the ACL stale window old, retires a copy the worker denies, and
records the listing at the oldest confirmation of the stored copies, so an unconfirmed
copy stops being served within the stale window. The mirror read gate admits a worker
source's copies to its owner alone while the registration, the approval and the
owner's worker account are current.

knowledge.source.remove, namespace retirement and owner erasure now queue a worker
source's copies for the retirement worker, which no longer skips an inactive worker
row. The setting is off by default and is turned on only once every replica runs this
build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 5, 2026 12:45am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 12:45am UTC

Request Review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

zlareb1 and others added 2 commits December 4, 2026 18:47
…d-copy

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…er's own denial

The workers child and `loom knowledge sync` open the source worker directory, so their
sync turns reach the provisioned workers. A turn reads exactly the selected copies'
addresses instead of the newest page of documents, and a page of unselected leftovers
apart. A copy is retired only on the worker's own 403, once the registration and the
owner's authority are read again and hold; a denial Loom's own checks answer ends the
turn with every copy kept. A resource left without a copy waits its refresh interval or
half the stale window before it is read again. An approval or worker account that no
longer matches the registration ends it under the sources lease: the row goes
inactive, its copies are queued for retirement and its state reads owner_inactive.

A copy request resolves its authority before it is sent and after the reply, no longer
three times. The mirror read gate's registration read returns only worker rows whose
stored registration names an owner-only copy mode. The setup `mode` description fits
the generated references whole, and the docs say what removal does with the setting
off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

copy.entry["retry_at"] = (asked + self._wait()).isoformat()
if copy.stored:
copy.entry["verified_at"] = asked.isoformat()
return True

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refused copy still resets refresh clock

Medium Severity

When a stored copy's new body is refused, _write returns without updating sha, but visit still sets copied_at and verified_at. For selected_refresh, that restarts interval_seconds and lets _vouch treat the old body as freshly confirmed, so the upstream text is not read again until the full interval elapses.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bb02ac0. Configure here.

zlareb1 and others added 4 commits December 4, 2026 19:51
The source worker answers the upstream's own HTTP 403 to a read with
{"status": "denied", "reason": "upstream_access"}; every refusal it makes itself (a grant
that fails to verify, a binding or record that no longer matches, a document naming
another resource, a redirect, a refused closing DELETE) stays a plain denied. Loom reads
that body bounded and strictly, and its sync retires a copy only on it, after the
registration and the owner's authority are read again; a plain 403 ends the turn with
every copy kept. A worker build without the reason never causes a retirement.

The mirror read gate skips a worker row its reader does not own before any registry
read, using the row's owner and the reader's own subject read once per plan. A
registration whose authority is gone ends through the same helper a connected source
uses, and the leftover-copy retirement stops at the pass budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…enial

The source worker answers `upstream_access` only for an upstream 403 to the
resources/read, or the mapped read's tools/call, inside an opened session. A 403 to
initialize, tool discovery, the GET stream or the closing DELETE may come from a network
policy in front of the upstream, so it stays a plain denied.

A plain denial of a resource with no copy now sets its wait before the turn ends, so
the next turn reaches the other resources. A process sends at most one copy at a time,
so the channel's copy share holds one slot. The boundary page says a copy and a live
read share the worker's own read slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The boundary page said a stored-copy confirmation compares digests; it confirms
the owner's access only, and a test now pins that. The upstream-403 check drops
a method test the read flag already implies, and a one-key comprehension becomes
a plain lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A stored copy whose access check keeps answering timeout or unsupported no longer pins
the listing of every other copy: once its last confirmation is older than
knowledge_source_acl_stale_seconds it is served no more, so it is retired, waits, and is
copied again once readable. The state notes copy_unconfirmable.

The unselected-copy sweep goes: a copy's address is fixed by its source ID and resource,
and a registration's selection never changes. The owner's writer-grant check is one
helper, connected_accounts.owner_writes, for the worker turn and both connected checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

A copy that kept answering timeout or unsupported was retired only after the
listing it held back had expired, leaving the source's other copies unserved
until the next pass. It now goes once its confirmation would lapse before the
next pass, and only while the owner's authority, read again, still holds. The
listing write drops a publication guard that does nothing for a worker source,
and the docs say which retirements there are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…firmed peer

A stalled upstream answers every request with a timeout, and retiring the copies
that lapsed then cost a full re-copy and a wait of up to the refresh interval for
nothing. A timeout now keeps the copy. A copy answering unsupported as its
confirmation is about to lapse goes only when another copy was confirmed after
its own check fell due, which shows the failure is the resource's. A resource
without a copy that times out waits half the stale window, so it no longer comes
first on every pass. The lapsing age drops a floor no check could reach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

zlareb1 and others added 4 commits December 4, 2026 21:41
Retiring a lapsing copy in a turn that a later refusal ended gained nothing, since
that turn records no listing, and broke the documented rule that such a refusal
keeps every copy. The lapsing age's docstring and the boundary page now give the
real reason no copy goes before half the stale window, and two paragraphs are
reflowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…d-copy

The worker copies rolling-upgrade rule becomes rule 76 after main's read receipts
took 75, and it, the boundary page and the source worker README now say an older
worker never causes a retirement on a denial, while a copy answering unsupported
follows the lapsing rule with either build. The boundary page lists the turn's
authority checks in the order the code runs them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…the turn's checks

The boundary page and the source worker README said an older worker never causes
a retirement; a copy answering unsupported still follows the lapsing rule with
either build. The boundary page lists the turn's authority checks in the order
the code runs them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…s pass the bound

A copy whose request ended a turn (unavailable, overloaded, reconnect, a plain
denial) came first again on every pass, so one failing resource kept every other
copy of its source unconfirmed. It now sorts after the others for half the stale
window, and a resource without a copy waits that long. A worker source's turn
also starts once other mirrored sources have used up the document bound, since
its checks spend only time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

zlareb1 and others added 5 commits December 4, 2026 22:20
A stored copy refused with a plain denied (a reply naming another resource) ended
every turn first, as the other turn-ending refusals did before. It now gets the
same mark and sorts after the rest. The module docstring states the order and
each wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…he ended mark

A turn read the owner's directory standing once at its start, then only the
writer grant for each request, so a SCIM deactivation or revocation mid-turn
still let the turn read and write copies. Every request now reads the whole
standing. The mark that sent a copy last after a turn-ending refusal changed
nothing a reader sees, since that copy ends each turn it is checked in, so it is
removed; the docs say such a copy keeps the source's copies unserved until it
answers, which fails closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…a docstring

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…n wait

Copies and checks run one at a time within the mirrored phase, so the copies one
deployment keeps served are bounded by that phase's time over one check's; the
boundary page says so, and that past the bound copies stop being served. A plain
denial of a resource without a copy waits half the stale window, as other
turn-ending refusals do, and a routes file that does not provision the profile
reads unavailable rather than the owner's. interval_seconds is described as the
least time between copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…d-copy

Brings the worker setup CLI from main. With this branch's copy modes, the
worker-preview and worker-register commands gain --interval-seconds, and --mode's
help says snapshot and selected_refresh answer unavailable unless the server
keeps worker copies. Also: the interval_seconds description leads with its rule so
the generated reference keeps it, the capacity paragraph says only a turn the
bound cuts reads pass bound reached, and a check that could not fail is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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 001a636. Configure here.

]
oldest = _oldest_confirmation(copies)
if not due and oldest is not None and oldest.isoformat() == listed:
return # every copy was confirmed lately, and the listing says so

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idle sync skips registration retirement

Medium Severity

When nothing is due and the stored listing timestamp already matches, _sync_copies returns before authority. A revoked approval or a dead worker account then never reaches _end_registration until a check is due, up to half of knowledge_source_acl_stale_seconds. The registration stays active and its copies are not queued for retirement.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 001a636. Configure here.

zlareb1 and others added 4 commits December 4, 2026 23:47
The turn marked the bound only when it cut a visit, so a turn whose time ran out
after its last visit recorded no listing with no mark. The listing and lapsing
steps now mark it too. The interval_seconds description fits the generated SDK
comment, and the capacity paragraph is rewrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A stored selected_refresh copy due for its refresh at an exhausted document bound
was only checked, with no mark, so the turn read ok while refreshes waited; it
now marks pass bound reached. The retry waits come from one helper, the lapsing
step's pass-bound branch has a test, and rule 76 says N-1's retirement worker
leaves an entry pending while an inactive worker row of that source ID remains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…k is due

The previous change sent an access check every pass for a stored copy due for
refresh at an exhausted document bound, however fresh its access, which spent
the mirrored phase's time the capacity bound counts on. It now marks the bound
and checks only when the copy's check is due. Rule 76 states N-1's pending
retirement once, and the worker drops an authority refusal the close never meets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…d-copy

The generated Go wire models conflicted; they are taken from main and generated
again for this branch's fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…d-copy

The worker copies rolling-upgrade rule becomes rule 77 after main's session-run
rule took 76.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 merged commit 33f3a1f into main Dec 5, 2026
90 of 94 checks passed
zlareb1 added a commit that referenced this pull request Dec 5, 2026
main's #2165 made an owner's worker copy a mirrored turn (`_mirrored`): the
two turn-tally lines this branch adds in `_sync_turn` use `_mirrored` too,
so a worker copy's failure counts under `SYNC_FAILED`. The generated SDK
models are regenerated over both sides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant