Repository navigation
Conversation
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
This reverts commit 43642ce. Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
|
The earlier changes corrected the reported type errors, documented the metadata tables, classified live reads, and regenerated the SDK and settings snapshots. The focused checks passed. Fresh source review and required hosted checks are pending; setup, stored copy writes and native retirement remain disabled. |
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
|
The full CI run for
The base commit's CI run already failed seven of the same unit and isolation job categories. That comparison does not clear any required check. The changes above still need a new exact-head run and an independent whole-diff review. This draft remains limited to the protected live read path; it does not enable a deployment, stored copies, or the refresh worker. |
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
|
Independent review of
The exact head passed hosted lint and type checks. Both PostgreSQL storage jobs are still running, so the local revision is not published yet. A new independent review and exact-head hosted run are required after the next push. No activation is proposed by this draft. |
|
Hosted workflow New head |
|
Independent review of The exact-head HTTP schema job failed in |
|
Exact head
The overall required workflow failed; separate unit and isolation jobs are red, and the separate HTTP contract workflow still records the input generation health check failure noted above. The independent review requests verification. This head cannot merge. The storage result covers the live-read control and its fence; it does not qualify scheduled refresh, stored document copies, or a real upstream provider. |
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Resolve the current enrollment, account realm, and worker approval before checking selection for a team reader. Keep unselected owner requests out of the approval lookup. Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
|
The formatter failed on PR job: https://github.com/ClickHouse/loom/actions/runs/45862140452/job/140055809389 |
End the worker read timeout before retaining the protected result. The retention path still validates session and source authority under its bounded delivery deadline. Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A valid UTF-8 document over the 4 MB live budget is unsupported, not denied; a digest mismatch stays denied. A publication window or delivery fence that runs out of time reports timeout instead of looking like revoked access. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…usal The worker document model no longer caps text by characters, so the UTF-8 byte check decides and a long ASCII document answers unsupported rather than denied. A delivery fence runs while the response is already being sent, so a timeout there cannot become a status; it is reverted to one refusal. The live output fields carry descriptions, and the boundary page names both size limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The status description leads with what each status means and which are worth retrying, so generated references keep it. The boundary page names the worker source kind, what an older build does with it, and that a large body can be cut off when a client cannot receive it before the publication deadline. The delivery fence uses the caller's deadline directly, payload privacy imports sit at module top, and the fenced chunk size says why it is not a setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The live read input names the source with name, as every other knowledge.source op does; the operation is experimental and unreleased. A worker fetch time up to a second before the grant counts as current, since the two hosts' whole-second clocks may differ. The boundary page names every cause of a truncated large response and drops a stored-copy fallback no op has. The ledger drops live payloads inline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
| try: | ||
| reading = WorkerReading.model_validate_json(payload) | ||
| if reading.request_id != issued.request_id or not ( | ||
| issued.issued_at - _CLOCK_SKEW_S <= reading.fetched_at < issued.expires_at |
There was a problem hiding this comment.
Clock skew breaks stored-read proofs
Medium Severity
Relaxing _validate_reading to accept a worker fetched_at one second before the grant lets live reads succeed when clocks differ, but confirm_stored_read still passes that timestamp to can_read_stored_copy, which requires issued_at <= confirmed_at. A worker one second behind Loom now fails stored-copy confirmation after a successful worker reply.
Reviewed by Cursor Bugbot for commit 6552505. Configure here.
A live frame held the namespace's exclusive source lease while it sent to the client, so a slow reader kept every source write and erasure retirement waiting, and concurrent live reads of one collection ran one at a time. Source writes now also hold a Postgres advisory lock exclusively for the length of the lease, and each frame takes it shared in its fence transaction, before the knowledge lock as writers do, and rereads the source there. Postgres queues a new frame behind a waiting write, so a write waits only for frames already running. A frame uses one pooled connection. A build without the lock writes under the lease alone, so in a rolling upgrade such a retirement can let through the one frame already past its reread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The fenced reread ran outside sequential reads, so a retirement committed through another ClickHouse replica could be missed, and it compared only a few fields. It now reads under sequential reads and withholds the frame when the row differs at all from the one the frame's check read. The source lock's wait sets a statement timeout above its lock timeout, so a busy lock answers OVERLOADED instead of a cancelled statement, and the Postgres wait gets only the time left after the lease. The boundary page states the pooled-connection bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A unit test drives sources_lease with Postgres authority and checks that the exclusive source lock is held for the block and gets only the wait the lease left. The lock statement's client timeout outlasts its lock timeout, so a long erasure wait answers OVERLOADED rather than a client timeout, and the comments state the pool acquire's own wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The approval, reader account and reader link lookups used a bare pooled connection, so a lost connection or failover answered 500; they now run in a read transaction, which maps an outage to 503, and the source lock maps one the same way. The lock's session sets TCP keepalives so Postgres drops the lock of a holder whose host disappears within about a minute rather than hours. The lease-wait test uses the module's clock seam. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The approval, reader account and reader link reads use pg.fetchrow, which maps an outage to 503 in one statement, instead of a read transaction that cost three round trips per lookup on every fenced chunk. The source lock's first statement now maps an outage as the lock statement does. The boundary page states what a vanished lock holder and an outage look like. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A parametrized test makes the pooled connection lose itself under each of the approval, reader account and reader link reads and expects 503. The boundary page says an outage during a frame's handoff withholds the response, and that live reads wait out their frame deadline while a vanished holder still has the lock. The row converters are typed and the keepalive assertions name the full calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The ledger dropped a live read's error before the status class read it, so a fail-closed refusal during an authority outage counted as the client's; the error now stays for classification and is still never written. The signed worker grant lives as long as the live read timeout allows, the worker response cap is a named bound, and the boundary page and lock docstring are rewrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A grant derived as the live timeout rounded up could expire before a lowered timeout ran out, since grants are stamped in whole seconds and the worker's clock may run a second ahead; the lifetime adds both. The ledger test asserts no error class or message reaches a live read's row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The SDKs and references are regenerated from the merged registry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ 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 e7a709e. Configure here.
| now=now(), | ||
| max_evidence_age_seconds=max_age_seconds, | ||
| ): | ||
| raise WorkerReadRefused("denied") |
There was a problem hiding this comment.
Stored proof rejects allowed clock skew
Medium Severity
confirm_stored_read stamps issued_at from Loom's clock before the worker call, then can_read_stored_copy requires issued_at <= confirmed_at. The worker read already accepts fetched_at one second behind the grant (_CLOCK_SKEW_S). A worker whose clock is slightly behind therefore passes _validate_reading and then fails the stored-copy proof, so a successful check_access cannot mint evidence.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit e7a709e. Configure here.
Generated SDK comments keep the first line of a field description, which cut the status description mid-word; the summary now stands alone on its first line, with each status's meaning after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The status description's first sentence carries the retry hint so the reference keeps it, its source lines stay within the lint limit, and the worker boundary page opens with what Loom does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The worker channel's last step rechecks authority, so the read path now checks only that the route is unchanged before building the document; the full check stays in the fence. The three worker timeout settings say their maximum is the default, so a value can only shorten them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The route directory is built once and never changes, so a live read's channel cannot differ from the route that served it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The route directory never changes, so the live read no longer checks for a swapped route; the test keeps its selection change check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>


Related: #1189
Related: #1190
Related: #1298
Changelog category
Changelog entry
Add an experimental operation for reading a selected document through a provisioned source worker. The read keeps no body and does not change stored document search. This build has no operation that registers a worker source, approval or account, so the operation answers
deniedorunavailableuntil source setup ships.Why
Live reads need the exact caller's upstream connection, but Loom does not need the credential. The worker resolves an opaque connection under a signed request. Loom checks the caller's collection grant, approved worker, selected resource and current account before it contacts the worker and again before it delivers the result.
Scope and risk
knowledge.source.liveis an experimental read operation on the existing HTTP and MCP transports. It requires the protected publication barrier and Postgres knowledge authority. Each response frame holds the namespace's Postgres source lock shared, rereads the source row with sequential consistency and refuses the frame if the row changed at all since the frame's authority check, and locks the exact approval, account and team link rows. Every source write holds that lock exclusively for the length of its source lease, so a retirement, update or erasure that commits first withholds the frame; live reads of one collection share it, and a write waits only for frames already running. A build without the lock writes under the lease alone, so during a rolling upgrade a retirement from such a replica can let through the one frame already past its reread. A frame holds one pooled Postgres connection, and a source write holds one for its lease. The worker read ends before the separate deadline for retention, accounting and delivery. A team reader needs a separate enrolled connection for the same verified resource realm. Loom checks current team enrollment, both connections and approval before testing whether the requested identifier is selected. Selected and unselected identifiers get the same response when a team reader lacks current authority. The live read limits document text to 4,000,000 UTF-8 bytes and the encoded document with its escaped MCP text copy to 16 MiB before it retains the publication fence. A document over either limit returnsunsupportedwithout a document; a digest mismatch staysdenied, and a publication window that runs out of time returnstimeout. Both transports reject unknown argument names that are too large or cannot be encoded as UTF-8. They return valid ignored names to the caller without logging or caching them. MCP applies a separate bound and the same encoding check to the JSON-RPC request ID. This operation admits no answer tokens and does not fall back to a stored copy. The transports recognise this one experimental op by name for its argument-name and request-ID bounds, throughserver/core/operation_privacy.py; HTTP marks its responsesno-store, and every MCP response carriesno-storebecause MCP cannot tell which tool a response answers when it sets headers; anOperationflag would add a registry field for a single op, so it waits until a second op needs the same handling. The ledger keeps request accounting without arguments, result bodies or exception text. The operation disables body capture regardless of namespace consent.This is the live read prerequisite. Account setup, selected imports, refresh and stored access remain separate work. The setup layer those ops will call ships here and has no caller in
server/yet: the enrollment, approval, selection and proof modules,encode_worker_source,current_routes,WorkerRoutes.enrollment_route,WorkerReadChannel.request_enrollmentand its access check, the Postgres store writers (replace_on,set_on,revoke_on,issue_challenge,consume_challenge,revoke_account,prune_expired_challenges,owner_transaction), andplan_worker_setup/confirm_worker_setup.LOOM_KNOWLEDGE_SOURCE_WORKER_SELECTION_PARALLELISMhas no effect until then. They land here because they are the write side of the approval, enrollment and reader tables this PR adds and the live fence reads; shipping those tables with tested readers and no tested writers would leave their contract unchecked. A Postgres outage in the live read's lookups before the response, or in a source write's lock, answers 503, and one during a frame's handoff withholds the response; and the lock's session uses short TCP keepalives so a vanished holder's lock is released within about a minute. A large body near the 16 MiB ceiling can be cut off after the status line when the client cannot receive it within the publication deadline; the boundary page states this. The audience-scoped retrieval SDK example now waits for its fixture grants to become visible before the first search, which the integration run for this branch needs. The dashboard has no protected live view. No provider or native source is removed. See Document source worker boundary.Compatibility, rollout and rollback
knowledge.source.liveand explicit read status, body, source link and fetch time. Existing operations and defaults are unchanged.LOOM_KNOWLEDGE_SOURCE_WORKER_ROUTES_FILEdefaults to empty. A configured route requires explicit trust, a client certificate and a separate request signing key. Worker settings can shorten the read, publication and frame deadlines and reduce concurrent setup checks. The defaults keep the existing bounds. Keep registrations and copy writes disabled until the worker, account setup, erasure and mixed versions qualify together.Tests
Focused tests cover worker authority, enrollment, approvals, route configuration, privacy, and the SDK and settings contracts. Configuration tests cover valid overrides and refusal of out-of-range worker limits. A selection test proves the lowest parallelism setting still checks every selected resource. Regression tests cover concurrent delivery, retirement during delivery, equal responses for selected and unselected identifiers during approval outages, retention and delivery after the read deadline, and the exact worker metadata erasure statements. Ruff, function length and strict mypy for the changed authority modules pass. The Python, TypeScript, Ruby and Rust contracts describe the protected live read. Large fenced response bodies use bounded chunks. Each chunk checks current source and worker authority under the publication locks without repeating those lookups outside the fence. The response keeps its byte length, stream terminator, and existing deadlines. Focused request-tail and worker tests cover a 16 MiB transport body under simulated datastore latency and revocation between chunks. Worker protocol fixtures also exercise the real HTTP and MCP encoders: escape-heavy content within the budget arrives intact, while oversized content returns a complete refusal without retaining the publication fence. Transport tests cover refusal of escaped lone surrogates, valid Unicode, and ignored names appearing only in the caller’s response. Hosted
tests/integration/test_mcp_worker_pg_fence.pycovers the real Postgres lock order; mixed-build qualification of this op is not yet run.AI assistance in the code
AI-generated with Codex. The tests and diff were checked against the current authority and publication code.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
Note
High Risk
Touches authentication/authorization, Postgres locking, and transient delivery of large document bodies over HTTP/MCP, with incomplete operator rollout until worker setup ops ship.
Overview
Adds experimental
knowledge.source.live, which reads one selected document from an operator-provisioned MCP source worker (upstream credentials stay on the worker). Loom validates collection grant, worker approval, enrolled connection, and resource selection, issues a signed worker grant, and re-checks authority before each response chunk using a new Postgres source registry shared lock plus updated request-tail publication fencing.This PR also lands the Postgres schema and app layer for worker enrollment challenges, accounts, approvals, and team reader links; erasure/census coverage for those tables;
LOOM_KNOWLEDGE_SOURCE_WORKER_*settings and routes-file runtime inmain; operator/docs/SDK contract updates; and CI coverage viatest_mcp_worker_pg_fence.py. Live-read bodies are excluded from diagnostic capture and the op refuses narrowed read-scope tokens. Worker source registration and other setup write APIs are not exposed yet, so live calls typically returndeniedorunavailableuntil follow-on setup ships.Reviewed by Cursor Bugbot for commit 639bf16. Bugbot is set up for automated code reviews on this repo. Configure here.