Repository navigation
A knowledge source's failure marks Loom degraded only when most orgs' sources fail; ops.incidents lists the caller org's failing sources - #2134
Merged
Conversation
…g; ops.incidents lists the caller org's failing sources
knowledge_source_sync noted a pass failure for every source whose turn
failed, so one org's revoked credential built the worker's streak and,
after three passes, made ops.incidents answer degraded to every org. A
source's failure is already in its own sync state. The pass now tallies
the turns that ran and noted failures, mirrored ones included, and notes
one SourcesFailed ("7 of 9 sources failed") only when most of them
failed: an outage, or a deployment's only source. The store and model
legs still note as before.
ops.incidents gains `sources`: the caller org's failing sources that
every reader of their namespace sees (a count and up to 5, latest
failure first), read under the same org-whole gate as `requests`, from
one bounded statement in the knowledge store, cached per org. It never
changes `status`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The pass counted failed sources across orgs, so one org that holds most
of a deployment's sources still built the worker's streak with its own
revoked credential. The mining and retirement legs still noted each
source's failure, so one document that failed to mine, retried for 3
passes, did the same. Each leg (sync turns, mining, retirement) now
tallies the sources it handled per org and notes one SourcesFailed
("sync failed for most sources in 3 of 4 orgs") only when most of the
orgs it ran for had most of their sources fail.
ops.incidents names sources_unread beside requests_unread when the
restricted set cannot be read. The sources statement filters on the
status expression, not its alias (test_sql_alias_shadow).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…serves A leg divided its failing orgs by the orgs it handled, so a leg that reached one org read as a deployment with one org: one org's removed source whose retirement kept failing, or a pass bound that ended the turns inside one org's failing sources, still built the worker's streak. SourceTally.note now counts against the orgs of every active source the pass read, with those the leg ran for; an org the leg had nothing to do for has not failed. The tally keeps its failures' kinds (an exception's class, a turn's status, SYNC_FAILED for a mirrored source), and the note names the most common one: "sync failed for most sources in 3 of 4 orgs (most often credential_invalid)". The ops.incidents wire text says a failing source never makes status degraded by itself, and the read_scope reason names both org reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The denominator held the org of every active registry row, so orgs whose only rows the pass never syncs (a worker's row, a source in an inactive namespace) diluted an outage of every org it does sync until no leg noted it. It is now the orgs of the usable sources, and the retirement note follows that read. tests/integration/test_ops_incidents.py reads ops.incidents over the transport against the real store: the caller org's two failing sources, latest first, and none of another org's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The gate lets an org admin over * read the org whole once no restricted namespace is hidden from it, but collections are not in the restricted set: an org admin reaches one only through a grant. The sources read named a collection's failing source to an org admin with no grant on it, and its per-org cache served that answer to every caller. The read now applies collection_clause(org), fails closed when the grants cannot be read, and is cached per org and caller. A source's mining counts as failed only when it raised or most of its documents failed: one document that fails to mine is that document's, in the source's extract_error, even for a deployment's only source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…lure A deployment where most orgs held a lapsed credential (dormant accounts) made every pass note SourcesFailed, and ops.incidents answer degraded to the active orgs. A namespace source's credential_invalid turn now counts as handled in the tally; it stays in result.failed, the errors and the source's sync state. A mirrored turn still counts as failed for every cause alike, so the private status row tells no cause. ops.incidents resolves the caller's collection reach before its cache and keys the cache on it, so a subject reading as a platform admin and as an org admin, or two callers of different reach, are never served each other's read. sharing.readable answers an unread tree or grant as no shared collection; the read checks fail_closed.unreadable and answers unread instead of a narrower count. The docs name what the rules do not catch: a model outage while a pass mines few changed documents, and any leg's failure on a deployment with an active mirrored source, whose passes leave the streak as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The mining leg judged a source by all of its live documents, so a source of more documents than a pass tries never counted as failed, even when every document tried failed. Mining now tallies the documents tried per org, counts only the orgs it mined for, and needs at least two tries before an org counts as failing. A source that raised, or whose read or write failed, counts as one failed try at least. The read field's comment of ops.incidents sources names its other unread causes: unread collection grants and a refused tenancy check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The generated Go and Rust wire models are regenerated from the merged operations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Counting the mining leg only against the orgs that mined let one org with changed documents be the majority whenever it alone mined, so its failing documents built the worker's streak for every org. An org with nothing to mine now counts as not failed, as in the sync and retirement legs; the cost, a model outage while fewer than half the orgs mine, is in the docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The note's "most often" kind was counted over every org, so a healthy org's few failures could name the outage of the others; it is now the most common kind among the orgs that failed. A mining read, write or raise fails a source whole, and its org counts however few documents it has, so a store failure on orgs of one source each is noted. ops.incidents cuts the caller's collection reach at the readiness bound and answers the sources unread past it. The integration test calls with an org admin token, and under auth checks that a member reads none and that an org admin's ungranted collection is left out; CI runs it in the auth-on gates. The docs name a pass that fails outright as a worker failure too, and quote the status row's partial_error as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
SourcesFailed is noted under the leg's name (sync, mining, retirement), as other workers name a leg, so the status row's partial_leg says which leg failed. SourceTally.add takes the failed count literally, all of the units only when none is given. failing_sources requires its collection scope, so no caller reads every collection by leaving it out; the analyzer corpus runs the statement under an org admin's collection clause too. The docs and the wire text say what the rule does when one org holds every synced source: its failures still build the streak, as on a deployment with one org. monitoring.md names how the reads are cached, the failing sources per org and collection reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The mining raise path counts a source as failed whole; a test now pins it with two orgs whose only source tried one document and whose record write failed. The docs name the worker status row's error_class and error the note leaves, not the pass event's fields, and drop mirrored turns from the legs that move the streak, since their pass is private. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
With the floor on each org, orgs that each mined one changed document never counted, so a model outage on a quiet deployment never built the streak. The leg is now judged once the pass tried two documents in all; the only document a pass tries failing stays that document's. A source that failed whole no longer needs its own exemption. SourceTally.add names its failure argument kind. ops.incidents builds its unread sources answer one way. The docs drop the provider incident as a signal of a mining outage: the worker's model calls run in the worker child process by default, whose provider health no request reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The two-try floor is for documents: a source whose mining read, write or run fails has failed whole, and the leg is judged however few units it handled, so a store read that fails for a deployment's only source every pass builds the streak as it did. The docs name the denominator in full (the orgs with a synced source and those the leg ran for) and the cost of never counting a refused credential: a refusal every org's credentials share is not counted either. _LEAST_TRIES says why it is not a setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The sources cache key is built from the readable collections only when a collection clause applies, so a renamed parameter raises instead of sharing the platform admin's entry. The docs say the worker streak catches an outage of what most orgs' sources rely on, a provider most of them use included, and that one fewer than half the orgs use is not counted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A refused credential's turn counted as handled, so an org whose every source's credential was refused counted as an org that did not fail and diluted the active orgs' failures: three dormant orgs beside two failing active ones noted nothing. Such a turn is now left out of the tally, and an org with no other turn is not one the leg counts. ops.incidents calls each cached read a read, not a source, now that one of them reads document sources, and its cache comment names the sources key as the org and the collection reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Mining and retirement were judged against every org with a usable source, dormant ones included, so three orgs whose only credential is refused beside two active orgs whose documents all fail to mine read 2 of 5 and noted nothing. run_sync now drops those orgs once the turns are done, and judges retirement there too. ops.incidents names its read cache's TTL for what it bounds (every read). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The tally counted a kind once per source while it counted failures per document, so a mining note could name two sources' failed writes over one source's 40 failed documents. A kind now weighs its failed units; the sync and retirement legs add one unit per source and are unchanged. The orgs whose credential was refused move from the turns tally to PassResult, the one place that reads them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The docs and comments said no leg counts such an org, but mining still counts one whose stored documents it mines, which is right: mining needs no credential. The text now says so, and a test pins both cases. A mirrored source is left out of ops.incidents' sources without the wrong reason that its state is its mirror's, and the HTTP reference names the incidents cache by its reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The generated Go and Rust wire models conflicted; both are regenerated from the merged registry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…reads The comment said a deployment-scoped op reads no namespace's data, with the request counts as its one org-wide read; the failing sources name namespaces and sources too. The knowledge and monitoring paragraphs on source failures are rewrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…rker's failure Every credential_invalid turn was left out of the tally, so dropping the previous root secret before the reseal failed every org's sources and noted nothing. Only a credential the provider refuses is its org's to rotate; one the deployment cannot open now counts. Mining counts each failed document under its own reason, not its source's first, so the note names the reason of most failed documents. ops.incidents caches a sources answer for a minute: a source's state changes once a pass and each read parses every state's detail, its documents' map included. A failed read is still tried again after 5 seconds. The failure-counting rules are one list in the knowledge page, which the monitoring page links to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The test built its own clock; the tests rule sends time through tests/unit/clock_fake.py. It still patches the module's time, so asyncio.timeout keeps the loop's clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
sharing.readable adds each end user's personal collection to the reach, so every org admin had a read of the failing sources of their own. A personal collection holds no source (PERSONAL_NAMESPACE), so it is left out: admins with the same grants share one read, and the answer is the same. The TTL test now also checks that an answered read serves a minute, and the monitoring page says each cache is per process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… org The worker streaks are cached under one key for every org; the module docstring and the cache comment said each read is per org. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`whole` read as the tally being complete; it says a source's mining failed whole, so the leg is judged however few units it handled. The provider-refusal test gave its turn the text of a credential that no longer opens, the next test's case. The knowledge page says a private pass reads SYNC_FAILED only when a leg failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The monitoring page said sources.read answers as requests does; it is also unread when the caller's collection grants are not read within the readiness bound. The reach test's docstring said no caller is served another's read, while its third caller shares the first one's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A failed retirement writes no sync state, so the page names the server's log, the pass's failed count and SOURCE_DELETE_PENDING. A single org's failures note the pass only when most of its sources, or of the documents it tried, fail; the page said every failure did. The test module's docstring names mining's units too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Nothing a tenant does fails a retirement: it deletes Loom's own copies with no credential. Judged against every org the pass serves, the failure only this leg catches, a bug in retiring one org's documents, could never be noted, since a store outage broad enough to reach most orgs already fails the sync leg. The leg now serves only the orgs whose removed sources it retired. SourceTally.fail takes its count before its kind, as handled does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A failing retirement fails the pass when it fails for most of the orgs it retired for; half is not most. The knowledge page and the OpsIncidentSources docstring name it beside the other ways one org's failures fail the pass, and the orgs comment in run_sync names the legs judged against them. The Go models' schema hash follows the docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A pass whose tried documents fail to mine in most orgs fails it too. The knowledge page sets the failing retirement apart from the two ways one org becomes the only org the pass serves. The Go models' schema hash follows the docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… rule A platform admin reads every collection; only an org admin's sources leave out the collections it holds no grant for. _org_reads names its read verdict `whole`, so `reach` means the collection reach alone, and the SourcesFailed docstring reads as one clause. The Go models' schema hash follows the description. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The corpus case copied the org admin fragment by hand; it is a named constant now, and a unit test asserts collection_clause builds it. OpsIncidentSources says a pass that runs a mirrored turn leaves the streak as it was, and the knowledge page says a lost folder ends its turn failed and counts like a provider's error. The Go models' schema hash follows the docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The tally reads only a turn's status, so a folder the account no longer sees counts as a provider's error does; most orgs' folders lost in one pass are more likely Loom's own failure than every org unsharing at once. The knowledge page gives that reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A lost folder fails every turn of its source until it is shared again or the source is removed, so losses that build up one by one count as one at once would. The doc now gives the reason the code has (a wrong stored id gets the same answer) and that cost. The new test drops a line that repeated the fixture's default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
An org whose documents the pass's document bound left waiting counts as not failed, as one with nothing to mine does, so a model outage is noted only while a pass's tries reach most orgs; past twice as many orgs as the bound it never is. The doc states that, and a test pins it: leaving those orgs out would let one org's failing backlog build the streak alone. The lost-folder test moves beside the other note tests and asserts the sync leg's note, the lost-folder threshold is stated per source, and the mining tally's comment gives `error` its own line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The leg notes only when more than half of the orgs the pass serves fail, so an outage at exactly half is not noted either, and the count is of the orgs the pass serves, not the deployment's. The retirement spends the document bound before the sync's fetches do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…heir own The fixture's only connected source was also mirrored, and the mirror's state row had no registry row, so removing `credential_mode = 'shared'` or `not_reserved_sql()` from the statement failed no test. A namespace source on a connected credential and a source row in a mirror's namespace now leave the count at 4 only while both filters stand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
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>
An owner's worker copy whose state write raises is tallied under `SYNC_FAILED`, never its exception's class, and its pass is private. OpsIncidentSources keeps what its fields mean and names the Knowledge page section for when the sync worker is listed, in place of a copy of the rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The caller's collection reach is resolved before the sources' statement starts, each under LOOM_READINESS_CHECK_TIMEOUT_S, so while both are slow an ops.incidents answer can wait for two bounds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
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>
The leg counts only when more than half the orgs it serves fail, so an outage of a provider exactly half the orgs use is not counted either. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
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>
…me count The supervisor retries a pass with a noted failed leg after LOOM_WORKER_PARTIAL_RETRY_S when the worker's interval is longer than that. Since a failing source now counts only as part of an outage of most orgs, on such a deployment a failing source outside one waits the whole interval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`loom knowledge sync` runs a namespace's sources at once, so the paragraph says when the worker tries a failing source again, not when anything does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…d which passes are private `ops.incidents` `sources` lists only the sources every reader of their namespace sees, never a mirrored or a person's connected one. A pass is private only when it runs a mirrored turn, which starts only in the first third of the pass's time, so a pass whose earlier steps take that long counts toward the streak. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The Go and Rust wire models are regenerated from the merged registry. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e pass deadline The mirrored phase is a third of the pass budget, which is 0.75 of `LOOM_KNOWLEDGE_SOURCE_SYNC_MAX_PASS_SECONDS`, so it ends at a quarter of the deadline, as the architecture page and `_sync_mirrored` say. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #2047
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):
One org's failing document sources, such as a folder its account no longer sees or a document that fails to mine, no longer make
ops.incidentsanswerdegradedto every org, unless that org holds every source the deployment syncs, every other org's credentials were refused, or it is the only org retiring a removed source and that retirement fails. A credential the provider refuses (credential_invalid) on a namespace's source, such as a revoked one, never does. Theknowledge_source_syncworker counts its sources' failures toward a failed pass only when most orgs' sources fail, most orgs' tried documents fail to mine, or most of the orgs retiring removed sources could not retire their documents; a pass that fails outright (its source list or registry unread, or past its deadline) still fails.ops.incidentsgains asourcesfield that lists the caller org's failing sources to a caller that reads the org whole.Why
knowledge_source_synccalledpass_context.note_failureonce for each source whose turn failed or raised, mirrored sources included, and once for each source whose mining or retirement failed. The supervisor counts any pass with a noted failure toward the worker's streak. After 3 such passes,ops.incidentslists the worker, and its answer isdegradedfor every org on the deployment. A single tenant'scredential_invalidsource therefore marked Loom degraded for every org, for as long as the credential stayed revoked. So did one document whose mining failed: it is retried for_WAIT_PASSES= 3 passes, as many as the streak needs. The incident detail named no source and no count, so it did not show whether 1 of 5,000 sources had failed or all 5,000.A source's failure is already recorded where its namespace reads it:
_record_turnwritesstatusanderrorinto the source's sync state (loom.code_index_state, keyknowledge_source:<name>), whichknowledge.source.listshows. A document that fails to mine is in its source'sextract_error. A removed source whose documents could not be retired is in the server's log, andknowledge.source.addunder its name answersSOURCE_DELETE_PENDINGwhile its documents are left. One org's failures tell nothing about the worker's health, however many of the deployment's sources are that org's, short of all of them; a failed retirement, which no tenant causes, is the exception (below). A pass in which most orgs have most of their sources fail does, whether because of an outage of what every source relies on or because one org holds every source the pass syncs.Scope and risk
server/knowledge/app/source_sync.py: each leg of the pass keeps a per-org tally (SourceTally, onPassResultasturns,miningandretiring) of the sources it handled and those that failed, in place of a note per source:okor raised.credential_invalidturn is left out of the tally while its stored credential still opens under the deployment's secrets (sources.credential_of). Only its org can rotate a credential the provider refuses, and a deployment where most orgs' credentials lapsed (dormant accounts) would otherwise stay degraded for the active ones.LOOM_JWT_SECRET_PREVIOUSbeforeloom secrets resealhas resealed the stored credentials fails every org's sources and is noted.ops.incidentssourceslists them._items_visible's check; a quota 403 is a rate limit) ends its turnfailed, the status a provider's 5xx also ends with, and the tally reads only the turn's status, so it counts (test_a_lost_folder_counts_toward_the_sync_leg). Loom asking for an item by a wrong id gets the same 404, and the tally cannot tell that from an org unsharing its folder, so leaving these out would hide a fault in Loom's own ids from the streak. The cost: a lost folder fails every turn of its source until it is shared again or the source is removed (a failed turn is not complete, so the next turn is full and checks again), so a deployment where, in most orgs, most sources each lost a folder or shared drive (one failed check fails the source's turn), at once or one by one over months, fails the sync leg every pass. Leaving a failed check out, as a refused credential is, would trade that cost for the hidden fault; this change keeps it counted. The listing's own 403 endscredential_invalid(vendor_failure, unchanged) and is left out as a refusal._Mined.tries, which replaces thetriedflag) and each that failed.extract_error, while one failing document in each of most orgs (a model outage on a quiet deployment) is noted, and so is a failing read of a deployment's only source.LOOM_KNOWLEDGE_SOURCE_SYNC_DOCUMENTS_PER_PASS, 40), even when every document tried failed.LOOM_KNOWLEDGE_SOURCE_SYNC_DOCUMENTS_PER_PASS, 40 by default, which the retirement and the sync's fetches spend first; while the sync turns finish, the leg starts at the same source each pass). So a model outage is not counted toward the streak while the pass tries documents for no more than half the orgs it serves: while no more than half have changed documents, while one org's backlog takes the bound and leaves the others waiting, and always when the pass serves at least twice as many orgs as the bound. Each source'sextract_errorshows it. Theproviderincident does not by default: withLOOM_WORKERS_PROCESS=childthe worker's model calls run in a child process whose provider health no request reads. Counting only the orgs that mined, or leaving the waiting ones out, would catch it, but would let one org whose changed documents fail, in passes where it alone mines or its backlog takes the bound, build the streak for every org._retire_allraised. No tenant causes such a failure: it deletes Loom's own copies and uses no credential. So this leg serves only the orgs whose removed sources it retired, not every org the pass serves: one org's failing retirement fails the pass when it is the only org retiring, and not beside another org whose retirement succeeds. Judged against every org, the failure only this leg catches (a bug in retiring one org's documents) could never be noted, since a store outage broad enough to reach most orgs already fails the sync leg.After each leg,
SourceTally.notenotes oneSourcesFailedunder the leg's name (sync,miningorretirement, as other workers name a leg):failed[org] * 2 > ran[org]for more than half of the orgs). For mining the units are documents (failed for most documents in 1 of 1 orgs)._usable: the sources this build serves and, with auth on, the mirrored ones and owners' worker copies, outside inactive namespaces), with those the leg ran for; for the retirement, only those it ran for (above). An org the leg had nothing to do for, or that the pass bound left for the next pass, has not failed, and an org with no source the pass syncs is not counted. So on a deployment where one org holds every synced source, that org's failures still build the streak for every org, as on a deployment with one org.SYNC_FAILEDfor a mirrored source), never its text, and the note names the one with the most failed units among the orgs that failed. Mining counts each failed document under its own reason (_Mined.reasons, codes such asnot_runorrefused), not under its source's first one.loom.worker_status) readserror_classSourcesFailedanderrorsync: failed for most sources in 3 of 4 orgs (most often failed), the pass event carriespartial_legsync, and anops.incidentsworker incident reads3 failed passes in a row (SourcesFailed). The incident carries the noted exception's class, so the cause is in the status row, not in the incident.LeaseBusy) counts neither way.result.errors, and counts in the tally (a store outage fails every source's write).result.failedandresult.errors, the mirroredSYNC_FAILEDcode, the meet recordingprovider_removedexclusion, and the tally's absence from the pass summary (outcome()).ops.incidents(server/insights/app/incidents.py):sourcesfield is gated likerequests. A caller that does not read the org whole is answerednot_permittedand causes no read.sourcesnever changesstatus.server/knowledge/store/sources.py:loom.code_index_state FINALfororg = {org}, joined to the activeloom.knowledge_sources FINALrows that every reader of their namespace sees (access = 'namespace',credential_mode = 'shared', not a worker row). It leaves out reserved namespaces, the org's inactive namespaces and the statuses'',okandprovider_removed, and returnscount() OVER ()with aLIMIT 5sample, newestlast_synced_atfirst. The registry join is needed because a removed source's state row is never deleted. Mirrored and connected sources are left out by the join: their namespace row sits in an ordinary namespace, so a mirror-name test alone would not exclude it. The statement filters onJSONExtractString(detail, 'status')itself, not on itsstatusalias (test_sql_alias_shadow).loom.code_index_state,loom.knowledge_sources,loom.namespaces), whose sort keys start withorg, but it parses thedetailof every one of the org's source states, which holds the source's map of mined documents (up toLOOM_KNOWLEDGE_SOURCE_MAX_DOCUMENTSentries, 50,000 by default and at most 200,000), and it reads the org's code-index rows in the granules it selects. Astatuscolumn of its own would make the read independent of the map's size; that is a schema change left out of this one. The measurement is under Tests._SOURCES_TTL_S) per org and collection reach in each process, and a failed read as long, so a read slower than the bound is not started again every few seconds._cachedis now generic over what it caches and takes the read's TTL. Each cachedops.incidentsread (the worker streaks, the request counts, the failing sources) now runs understatement_timeout(readiness_check_timeout_s), so ClickHouse stops it at the bound the client waits instead of the read class's 30 s, and a poll after a slow read's cached failure never runs beside it.LOOM_READINESS_CHECK_TIMEOUT_Son the client side only: on a miss, the grant cache's shared load reads it under its own bound, as for every call. Past the bound the sources answerunread. The statement then runs under a bound of its own, so while both are slow an answer waits up to two bounds (docs/operations/monitoring.md). One deadline for both would leave the statement what a slow reach left of it, and_cachedwould keep that failure for the 60 s the sources are cached, after the grant cache is warm again.unreadand is named indegradedasops.incidents: sources_unread, cached as long as an answer. When the restricted set cannot be read, or a platform administrator's tenancy check refuses, bothrequests_unreadandsources_unreadare named.OpsIncidentSourcesandstatusnow say a failing source never makesstatusdegradedby itself, andOpsIncidentSourcesnames the Knowledge page section that says when the sync worker is listed; theops.incidentsreach reason inserver/identity/domain/read_scope.pynames both org reads.Tenant isolation:
read;collection_clause(org): the statement leaves out every collection the caller cannot read (a platform admin reads every one);*), so callers with the same reach share a read and none is served a wider one;sharing.readableadds an end user's own collection to every reach, and such a collection holds no source (PERSONAL_NAMESPACE), so it is left out of the key and the statement: org admins with the same grants share one read;sharing.readableanswers an unread tree or grant as no shared collection (fail_closed.note_unreadable); the read then answersunreadwithsources_unread, not a narrower count, as it does for a backend outage.Read-only change: no table, column or write path, so erasure needs no new step (
loom.code_index_stateis already erased by thecode_index.purgestep, as a step-only table).Out of scope:
code_backport_gaps,code_graph_stats,code_summary,knowledge_gaps);_after_passkeeps the ordinary streak unchanged for it. A leg's note in such a pass therefore reaches only the private status row (SYNC_FAILED), never the worker streak. On a deployment with an active mirrored source that is most passes, not all:_sync_mirroredstarts no turn once its phase of the pass budget (the first third) is spent, and a pass that runs no mirrored turn counts toward the streak;Compatibility, rollout and rollback
ops.incidentsgains the output fieldsources: {failing: int, sample: [{namespace, name, status}], read: "read" | "not_permitted" | "unread"}. It is additive. The server model and the Rust SDK default it to{failing: 0, sample: [], read: "unread"}; the Python (NotRequired), TypeScript (optional) and Go (*OpsIncidentSources,omitempty) SDKs type it optional, so a client reading an earlier server, whose answer omits it, finds it absent. No field is removed or renamed.loom.worker.partial_failures{worker="knowledge_source_sync"}and the worker's streak now count at most one note per leg per pass, in which most of the orgs the leg serves had most of their units fail, not one per failing source. An alert on them fires on an outage, not on one tenant's credential or document. Four outages are not noted:ops.incidentssourceslists its failing sources;sourceslist it;sourceslists its sources ascredential_invalid;extract_error, not insources.LOOM_WORKER_PARTIAL_RETRY_S,next_interval_seconds(partial=bool(ctx.count))) follows the same notes. On a deployment whoseLOOM_KNOWLEDGE_SOURCE_SYNC_INTERVAL_SECONDSis longer than that setting, one org's failing source no longer brings the next pass forward; only a leg's note does. At the defaults (900 s interval, 3600 s retry) nothing changes, since the sooner retry applies only to an interval longer than the retry. The Knowledge page says so; per-source backoff stays out of scope._record_private_status) readsfailed(SYNC_FAILED) when the pass noted a failure, so it now readsfailedonly when a leg fails for most orgs, not whenever any source's turn failed.test_one_mirrored_failure_of_three_notes_no_pass_failurepins a count of zero, which_record_private_statusrecords as an ok row (server/workers/supervisor.py,failed = not success or bool(ctx.count) or ...).ops.incidentswithoutsources.main(last at 3f41868), after Owner-only snapshot and selected-refresh worker sources keep a private copy in the mirror #2165 made an owner's worker copy a mirrored turn (_mirrored): the two turn-tally lines this change adds in_sync_turnuse_mirrored, so a worker copy's failure counts underSYNC_FAILEDlike a mirrored source's (test_a_worker_copys_failure_counts_with_the_one_mirrored_code). The generated SDK models are regenerated over both sides.Tests
Each new test fails on
origin/main.tests/unit/test_knowledge_source_sync_failures.py(new, over the realrun_syncunder a real pass context):failedand for one whose state write raises;SourcesFailed, which the status row shows assync: failed for most sources in 1 of 1 orgs (most often failed);failedturn notes the sync leg (in 1 of 1 orgs, most oftenfailed) and adds no refused org;credential_invalidnote nothing;in 2 of 2 orgs, and so do the same dormant orgs beside two active orgs whose every changed document fails to mine (the mining leg), while dormant orgs with stored documents still to mine are counted (in 5 of 5 orgs);credential_invalid, notein 2 of 2 orgs (most often credential_invalid);in 2 of 2 orgs;in 1 of 1 orgs;SYNC_FAILED;SYNC_FAILED, not its exception's class, and its pass is private;in 1 of 1 orgs;in 2 of 2 orgs, and so does a failed record write after each org's only source tried one document, and one of documents left waiting (mining switched off for both orgs);in 3 of 3 orgs;not_run) notes nothing, and all 3 note one;in 1 of 1 orgsbeside an org with only an active source, and nothing beside an org whose retirement succeeds;failed,ConnectionError,SYNC_FAILED,not_run;rate_limited) names the failing orgs' kind (failed);not_rundocuments over two sources whose record write raisedConnectionError);refuseddocument and fournot_rundocuments across two orgs notenot_run.tests/unit/test_ops_incidents.py:statement_timeout);col_prefix,col_readable);sharing.readableswallows), a backend outage and a reach slower than the readiness bound each answerunreadwith no statement run;sourcesreturns the count and sample for the caller's org only (params["org"] == "acme",limit == 5) withstatusok;read, 0, [];not_permittedand causes no read;unreadplus asources_unreadnote;collection_clausebuilds.The gate tests assert
sources.read(not_permitted,unread) and both unread notes. The existing transport, gate and in-flight tests now also cover the sources read.tests/integration/test_ops_incidents.py(new):ops.incidentsover the transport against the real store, called with an org admin token, with sources and sync states seeded for two orgs, answers the caller org's two failing sources, latest first, and none of the other org's. Against a server that enforces auth, a member readsnot_permittedand an org admin's answer leaves out a failing source of a collection it holds no grant on. CI runs the file in the auth-on isolation gates too (.github/workflows/ci.yml); the auth-on test skips elsewhere. It was not run locally.tests/unit/test_ops_incidents_sql.py: the statement on clickhouse-local over the production DDL. Each of the two filterscredential_mode = 'shared'andnot_reserved_sql()has a row that only it leaves out (a namespace source on a connected credential, and a source row in a mirror's namespace); with either removed, the count is 5. With no collection clause it returns 4 failing sources in order, among them a collection's and a newer failure over an older ok, a recovered source left out, and a mirrored source, a connected source, a source row in a mirror's namespace, a removed source's stale state, a worker source,provider_removed, a never-run source, an inactive namespace, another state key and another org's source all left out.sample=2keeps the count. A collection's failing source is counted with no clause, left out under the clausecollection_clausegives an org admin with no grant on it, and kept with one.Updated pins:
test_knowledge_source_sync_diagnostics.py(a mirrored turn adds only its tally; failures are tallied, not noted),test_knowledge_source_sync.py::test_only_a_retired_meet_turn_is_not_a_pass_failure(the meet exclusion applies to the tally),test_knowledge_source_sync.py::test_a_failed_read_of_a_source_s_documents_is_that_source_s_error(one source's failed read of two notes nothing), and the meet test'scredential_invalidcase (inresult.failedanderrors, left out of the tally, its org inresult.refused_orgs).Measured on clickhouse-local 26.7 on a laptop over generated rows, no deployment's data, with the script below, run from the worktree root as
.venv/bin/python measure_sources.py N DOCS [VERSIONS]: N sources of one org, DOCS entries in each source'sminedmap, VERSIONS unmerged versions of each state (1, merged, by default), beside 50 code-index state rows of 200 KB.20 50000: 62 MB read (19 MB compressed) with an 88 MB memory peak, in 33 to 39 ms;100 50000: 272 MB read (56 MB compressed) with a 153 MB peak, in 120 to 126 ms;400 50000: 1,076 MB read (193 MB compressed) with a 388 MB peak, in 444 to 473 ms;20 50000 3: 234 MB read (41 MB compressed) with a 253 MB peak, in 31 to 53 ms;200 5000: 61 MB read (19 MB compressed) with a 45 MB peak, in 31 to 35 ms.Each time is the wall-clock range of five runs, against the op's 250 ms p99 budget; the read runs beside the worker and request reads, not after them. The cost grows with the org's mined entries, about 23 ms per million at 400 sources. At the default cap of 50,000 entries a source, an org past about 200 sources (10 million entries) passes the 250 ms budget on the call that misses the cache, once a minute per org and reach in each process, and one past about 1,700 would pass the 2 s bound and read
sources: unreadon every answer; at the 200,000 maximum the two figures are about 50 and 430 sources. The 2 s figures are extrapolated, not measured. Astatuscolumn of its own is the fix, as above.Moving the sort-key filters to PREWHERE put a PREWHERE in the plan but read the same bytes under
FINAL, so it is left out. The statement is new, so no deployment'ssystem.query_logholds it yet; running it by hand against a production deployment was left out of this change.measure_sources.py
Commands, on Python 3.12 with
LOOM_ENV_FILE=:CI at f02d225 (run 47462191362, one commit past the merge with
mainat 3efe16d) passed everycijob, both storage integration jobs included. At fa62bea (run 47467977917, the merge withmainat 5daf4aa) everycijob passed butpytest integration (Postgres 16, storage), which failed only the cell test below. At 8204980 (run 47473680144, the merge withmainat 80dcd65) everycijob passed butpytest integration isolation gates, which failed only thememory.for_filepositive control below. Three test failures came from outside this change.tests/integration/test_cell_prepared_bot_native.py::test_normal_prepared_later_cell_proves_both_bootstrap_keysfailed on c5a64ad, 7d152db and fa62bea (a cell fixture command exited 1); it fails onmaintoo, in ci runs 47447740618 (b43e417, both storage jobs), 47436514278 (027f2db), 47425800151 (f691e30), 47413434538 (7d963b1) and 47388725676 (ec3d632), and this change does not touch cell control.tests/unit/test_code_diff_sides.py::test_a_parse_at_the_parent_that_could_not_run_is_a_failed_readfailed once inpytest unit part 5on 130e7c6; this change does not touch the code index, the file passes locally with CI's seed (474401994441) and order, and the job passed at f80dd9d, 7d152db and f02d225.tests/integration/test_cross_principal_leakage.py::test_positive_control_the_owner_reads_their_row_of_another_namespace_for_its_filefailed once inpytest integration isolation gateson 8204980 (1 failed, 264 passed): one of the owner'smemory.for_filelookups served nothing after the fixture had seen all of them served. This change does not touchmemory.for_fileor the default read scope, itstest_ops_incidents.pyin that job writes only its own orgs' source rows and reads them back throughops.incidents, and the job passed onmainat 80dcd65 (run 47472524504).dependency review, a workflow of its own, fails at f02d225, fa62bea and 8204980, as on every earlier head, with "Dependency snapshots are incomplete and snapshot inputs changed": the Rust dependency graph workflow submits a snapshot only onmain, and the review refuses a pull request that changes a file undersdk/rust/without one. This change touchessdk/rust/only through the generatedwire_models.rsandregistry_contracts.rs, and #2144 merged with the same failure.6 of the 17 tests in
tests/unit/test_knowledge_source_revisions_sql.pyfail locally on a cleanmain(5daf4aa) too: the local clickhouse-local does not know the settingenable_quantized_codec. This change does not touch it.Regenerated:
sdk_py_gen,sdk_ts_gen,sdk_rust_gen(it numbers itsdefault_Nhelpers in order, so the four new defaults renumber the later ones),sdk_go_gen,docs_reference(docs/reference/operations/ops.md) and the analyzer corpus (tests/analyzer/shapes.txt: two new shapes, the sources statement unscoped and under an org admin's collection clause).sdk_py_client_gen,sdk_rb_gen,sdk_rust_gen --fixturesandop_reach_censusare unchanged. The analyzer'sEXPLAIN QUERY TREEcheck and the full unit and integration suites are left to 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. The new tests were run against the unchanged code first, and each failed for the expected reason; the statement was run on clickhouse-local over the production DDL.
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.frontend/unchanged) The frontend builds (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
Changes when the deployment is considered degraded and adds a heavy ClickHouse read on
ops.incidentspolls; logic is heavily tested but wrong aggregation could miss real outages or hide tenant-specific failures from the worker streak.Overview
ops.incidentsnow returns asourcesblock for callers who read the org whole: a failing count, up to five latest failures (namespace,name,status), and areadflag likerequests. Failing document sources are informational—they do not setstatustodegradedon their own (revoked credentials stay the tenant’s problem).The handler loads failing shared namespace sources from ClickHouse (excluding mirrors, connected sources, inactive namespaces, etc.), respects collection grants when scoping the query, caches results for 60s per org and reach (worker streaks and request counts stay at 5s), and applies
statement_timeouton incident reads.knowledge_source_syncno longer treats every failed source turn as a pass-level failure. Each pass leg (sync, mining, retirement) tallies per-org failures and notesSourcesFailedonly when most orgs served by that leg had most of their units fail—so one org’s bad credentials or lost folder no longer marks Loom degraded for everyone, while broad outages still trip the worker after three passes.SDK wire types, ops API models, monitoring docs, and CI (
test_ops_incidents) are updated for the new field and semantics.Reviewed by Cursor Bugbot for commit d93f0d8. Bugbot is set up for automated code reviews on this repo. Configure here.