Repository navigation
Knowledge reads draw from their own rate bucket, and the extractor-less ingest tests configure no extractor - #291
Merged
Merged
Conversation
zlareb1
force-pushed
the
fix/main-red-integration
branch
6 times, most recently
from
November 6, 2026 19:27
4f4e1f5 to
d6c7e87
Compare
…ss ingest tests configure no extractor Every knowledge op without an override drew on the write-shaped knowledge.add bucket (10 burst, 2 per second), so a run of reads was refused: the cross-principal leakage test's knowledge.source.list and inspect at @me were its 14th and 15th calls in a row. The ten read-only knowledge ops now draw on knowledge.read (sized like default); a unit test walks the registry so a new read cannot land in the add bucket. The reference extractor now reads Parquet, so the inspect and tune tests' Parquet jobs reached it and failed format_mismatch. They run those jobs with no extractor configured, and the tune test expects the message for whatever the server's own extractor declares. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…et is registered, and say why the inspect test's Parquet job fails Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ne test's docstring says both messages Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…oarded tenant's raised caps cover knowledge.read Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ed classes, and the bucket tables read the same in every page Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…me words on every page Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…cket table Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…y bucket table Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… whole-namespace report Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
….add rows name it Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… split Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/main-red-integration
branch
from
November 6, 2026 20:11
d6c7e87 to
d5dfc4e
Compare
… discards Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
This was referenced Nov 6, 2026
Merged
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.
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):
Most read-only knowledge ops (
knowledge.get,list,ingest_status,formats,source.list, ...) draw from their ownknowledge.readrate bucket (50 burst, 10 per second), so a page of reads or an agent polling an ingest no longer spends the budgetknowledge.addneeds, and is no longer refused after ten calls.Why
The integration job on
mainfails three tests.test_cross_principal_leakage::test_every_read_op_against_a_collection_leaks_nothing: 429 on knowledge ops at@me.op_class_forfiles everyknowledge.*op without an override underknowledge.add, a write-shaped bucket of 10 with 2 per second. The test sends every read op to each namespace. At@me, the caller's own namespace, authorization passes and the limiter is reached. There, 15 of 17 consecutive calls are knowledge ops in that bucket. The calls past its burst are refused whenever those calls take under about 1.5 seconds, as they do on the CI runner. Which calls those are depends on pace: CI has refusedsource.listwithsource.inspect, anddataset_approvewithsource.list. A slower machine refills the bucket in time: onmain's limiter the test passed locally. The recent knowledge ops (formats,dataset_get,dataset_approve,synthesize) pushed the count past the burst. The tests are not the only callers hit by this: intest_namespace_tune_documents's log, aknowledge.ingest_statuspoll is refused right after uploads. The fix is aknowledge.readclass for nine read-only knowledge ops, sized likedefaultbecause none of them embeds.knowledge.inspectis read-only too but stays inknowledge.add. It builds a report over the whole namespace (documents, chunks, ingestions, extraction, decisions and memory findings, with a p99 budget of 4 s), so the tight bucket bounds it, as it does onmain. After the fix, 6 knowledge calls at@mein the leakage loop draw onknowledge.add, within its burst of 10.knowledge.searchandknowledge.querykeep their own buckets, and every other knowledge op stays inknowledge.add,knowledge.synthesize(audited) andknowledge.dedup_list(admin role) included, as they are notread_only. The set is named, as_EXACT_KEY_READSis. A unit test walks the registry, so a new read-only knowledge op that the set leaves out fails there instead of drawing on the write bucket.test_namespace_tune_documents::test_tune_cuts_the_documents_again_and_writes_nothingandtest_knowledge_inspect_ingest::test_backlog_a_missing_extractor_and_missing_access_are_kept_apart:format_mismatchwhereformat_unavailablewas expected. Both tests use a Parquet upload to stand for a format no extractor serves. The reference extractor now reads Parquet, and the integration job runs it. So the job reached the extractor, which refused the bytes as not Parquet. The tests now run those jobs in their own process with no extractor configured. That is how the inspect test already models a stopped extractor, and it givesformat_unavailableon any deployment. Tune judges a failed source against the server's own extractors. Its test therefore readsknowledge.formatsand expects the message for that case: "the service they go to declares it now: upload each original again" when the server's extractor declares Parquet, else "no configured extractor declares parquet". The unit tests intests/unit/test_namespace_tune_documents.pykeep covering the no-extractor branch.Scope and risk
server/core/ratelimit.py: one new class,knowledge.read, and a named set of nine ops.docs/operations/monitoring.md,docs/architecture/failure-and-recovery.md,docs/architecture/security.mdanddocs/reference/http-api.md: each bucket table now names the new class. The tables that lacked them also gain the existingmemory.importandknowledge.queryrows.dev/onboard_tenant.pyraisesknowledge.readwith the other anchor classes. Without that, an onboarded tenant's knowledge reads would lose the raised cap they had underknowledge.add.knowledge.querystays out of that list, as it already was onmain. It is a scan of up to four datasets with its own bucket (20 / 3 per second), and raising its cap is a sizing decision outside this fix.No write op changes bucket, and memory, code and the other classes are untouched. The limit on the reads is looser than before: a burst of 50 instead of 10. That is the same as
default, and none of these reads calls the embedder, which is what the add bucket's size protects.Compatibility, rollout and rollback
X-RateLimit-*headers on those nine ops now report theknowledge.readbucket.knowledge.addoverride no longer applies to the nine reads, at either tier. This holds whether it was set throughadmin/ratelimit.setor bydev/onboard_tenant.py, and whether it sits above or below the default. Those reads take theknowledge.readlimits: 50 / 10 per namespace and 150 / 30 per org, unless an override exists onknowledge.read. To keep a tenant's reads at the limit itsknowledge.addoverride gave them, set the same override onknowledge.read(POST /v1/admin/ratelimit.setwithop_class: knowledge.read, namespace or org). Runningdev/onboard_tenant.pyagain sets the namespace one, as it now raisesknowledge.read. A tenant with no override needs nothing.knowledge.addand leaves nothing behind. A storedknowledge.readoverride then binds nothing.Tests
Run against a server started through
scripts/serve.shwith 3 workers and its own ClickHouse, with the reference extractor and the end-user issuer set up as CI sets them:tests/integration/test_knowledge_inspect_ingest.py,test_namespace_tune_documents.py,test_cross_principal_leakage.pyandtest_ratelimit_org.py: 51 passed and 3 skipped. The 3 skips need a code repository (LOOM_CODE_ORG), as they do outside CI.tests/integration/test_onboard_tenant.py, which pins the anchor classesdev/onboard_tenant.pyraises: 4 passed.tests/unit/test_ratelimit_read_bucket.pygains two tests: the registry walk, and a burst of 20 knowledge reads that leavesknowledge.add's 10 intact.test_cross_principal_leakage.pyagain with auth on. At earlier heads with the same changes, the unit job sometimes failedtest_document_extraction.py::test_one_line_sql_with_a_comment_after_every_semicolon_splits_in_bounded_timenear its 10 s bound, asmain's own unit job did at 515e34f. This diff touches no extractor code.make format lint typecheckis clean. Before the later rebases, the full unit suite run locally gave 27,510 passed and 4 failed. The 4 failures are the four parametrize cases oftest_document_extraction_tables.py::test_the_delimiter_is_sniffed_in_bounded_time. They take about 10 s against their 5 s bound on the local Python 3.12.13, whether run alone or in the suite. This diff does not touch that test, and CI's unit job passes it.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. It reproduced each failure from the CI log and counted the leakage loop's calls per bucket.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass (see Tests for the one local timing test); the integration suite passes if server behaviour changed.main; no merged migration is edited (none).frontend/changed (unchanged).docs/describe the system as it now is.git commit -s).🤖 Generated with Claude Code