Repository navigation
Document sources live on any shared namespace or collection, and the Library shows the sources of the place in view - #541
Merged
Conversation
zlareb1
force-pushed
the
feat/sources-any-namespace
branch
2 times, most recently
from
November 12, 2026 04:37
059801f to
594d039
Compare
…Library shows the sources of the place in view Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/sources-any-namespace
branch
from
November 12, 2026 12:47
e457f52 to
716ddd9
Compare
…s deadline, and the design page names ERASURE_RUNNING and no longer describes trunk-only sources as current Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ing names every lease wait, a test shows it failing at its deadline while the retirement lease is held, and the design page's sentence is rewrapped Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…a fresh lease wait; drop a comment the docstring repeats; refill the docstring and the design page's intro and Any namespace paragraph Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e code's history Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…and the source error table lists it Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ace, in its docstring, message and docs, rewrapped Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
This was referenced Nov 12, 2026
A document source reads up to 300 items given as links or ids, and update adds and removes them
#562
Merged
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.
Related: #539 (the document-sources design page; this is its step A)
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
A document source can be registered on any shared namespace or collection, not only a repository's trunk code namespace, the Library shows the sources of the place in view, and a source is retired when its namespace is deleted or erased. The source ops no longer answer
NOT_A_CODE_NAMESPACE;knowledge.source.add,rotateandsync_nowanswerNAMESPACE_INACTIVEfor an inactive namespace andPERSONAL_NAMESPACEfor a person's own collection or namespace.Why
Sources lived only on a repository's trunk (
is_trunk_namespace), so meeting notes and team documents, which have no repository, had no place to go. This implements the "Any namespace" section ofdocs/architecture/document-sources.md(#539), whose code names and intro this PR brings in line with what ships.What changed
server/knowledge/app/sources.py:is_trunk_namespace,_require_trunk_namespace,_source_in_repository) is deleted.addrefuses an inactive namespace, or a collection the collections tree no longer holds, withNAMESPACE_INACTIVE. It checks before the probe and again under the source lease, the second time with sequential reads.addrefuses a person's own place withPERSONAL_NAMESPACE: acol-me-…collection, apersonal-…namespace, a namespace claimed at sign-up, a person's or an agent's (its directory row's owner is the namespace itself), or theu-…namespace single sign-on gives a person (personal_namespace.is_own_namespacechecks the three name forms; one read ofknowledge.store.sources.directory_rowthen covers both the sign-up claim and an inactive row). A user erasure erases what the person wrote, but a source's documents are the sync worker's (user_id-), so they would stay after it.code.repo.removeis gone.code.repo.removedeletes the namespace, and that delete now retires, under the lease, any source an add landed meanwhile.knowledge.source.addis refused withERASURE_RUNNING(409, retryable) while a namespace or namespace-list erasure that will still run may cover the namespace (ledger.open_namespace_erasures), checked before the probe and again under the source lease. The erasure step waits until no add holds any erased namespace's source lease before it reads the sources, so an add either lands before that read or sees the erasure. Upgrade step 13's second query also lists a source an older build added during a newer build's erasure, after its retirement, since the older build'sadddoes not read the ledger (rule 44). The query drops itssteps_completedfilter for that, and the step says its list is a worklist acted on once, since a source removed in the cleanup stays listed.code.repo.removetakes them.namespace.deleteandcollection.delete, throughdelete_namespace, even when there is no directory row.knowledge_sources.retire(retire_sources_of), its first step, ahead ofpg_memory.delete, so no mining turn writes a decision into what that step erased. It waits until no live holder keeps any erased namespace's source lease, reads their sources once, sequentially (sources_in: namespace and name, active or not), and takes the source lease only of namespaces that hold a source, to retire them. It then waits until no live holder keeps each source's sync turn lease (knowledge-source-sync:<org>/<ns>/<name>, read only, inactive names included, so a retried step waits too), waiting up to 30 seconds in all, the retirement's own lease wait included, so a turn that passed its last registry check before the retirement finishes before the later steps erase. A turn still running past that fails the step withOVERLOADED, and the saga's retries (erasure_recovery) wait it out; the short wait keeps the step inside a request behind the proxy and inside the recovery worker's pass.OverloadedErrorjoins the erasure saga's failures of the moment, renamed_TRANSIENT_FAILURES. A busy lease in any step is retried like any failure of the moment, and its log line has no traceback.server/knowledge/app/source_sync.py:RegistryUnreadafter its retirements while the registry has never been read._repo_tagtagsrepo:<id>only on a repository's trunk namespace (docs_namespaces).docs/features/knowledge.md,docs/features/dashboard.mdand the CLI help say "namespace".RepoSourcesList(RepoSources.tsx) becomesSourcesList(SourcesList.tsx), takingnamespaceandplace: {label, noun}.canCall("knowledge.source.add", …)on the header namespace's role.knowledge.source.listanswersaccepts_sources, false whereveraddwould refuse the namespace (PERSONAL_NAMESPACEorNAMESPACE_INACTIVE, one predicate for both). On such a place the Library offers no Add, and shows the section only while the place still holds a source (one N-1 left active on a deleted namespace), whose menu then offers only Check and Retire; a viewer sees no section on a place with no source; a person's own namespace shows no Sources section. The dashboard keeps no copy of the server's name forms.Scope and risk
knowledge.source.removewithdelete_documents=truealso accepts a source a namespace delete already retired, so its documents can still be retired. Withoutdelete_documentssuch a source answersSOURCE_NOT_FOUND, as before.adminfor add, check, rotate, remove and sync_now, andviewerfor list and inspect.repo:tag._repo_tagreads the configured repositories once per document written and passes that list todocs_namespaces. It is not cached across documents: next to a ClickHouse write per document, one parse of the list is small.PERSONAL_NAMESPACEgoes by the name's form forpersonal-…,u-…andcol-me-…, so a shared namespace registered under such a name is refused too; a self-signup namespace is told by its directory row.Kept as is, with the reason
identity.app.collections.in_treeis a one-line wrapper because the package contract allows no cross-plane store import fromknowledge.app; the directory row is read by knowledge's own store, asinactive_namespacesalready did.code.repo.removestill retires the namespace's sources itself, before the registry row, although its namespace delete retires them again: a call that fails between the two then leaves the repository registered to retry with its sources already stopped, and five of its tests pin that order. Itssources_deactivatedis the union of both.SourcesListis lazy-loaded with the same line in two views: the views use named exports only, and each lazy declaration is that view's own split point.Compatibility, rollout and rollback
NOT_A_CODE_NAMESPACEis no longer returned byknowledge.source.*;sync_nowanswersNAMESPACE_INACTIVEorPERSONAL_NAMESPACEasrotatedoes.namespace.delete's output gainssources_retired, the sources it retired (also whendeletedis false);collection.delete's sources are retired by its erasure's first step.NAMESPACE_INACTIVE,PERSONAL_NAMESPACEandERASURE_RUNNINGare new.namespace.restorebrings a deleted namespace back without its sources, which the delete retired with their credentials; an admin removes each withdelete_documents=trueand adds it again (docs/features/knowledge.md). Before this change a deleted namespace's source stayed active and synced nothing, since the sync skips an inactive namespace.add,check,rotateandsync_nowon a non-trunk namespace, and its worker skips such sources.loom erasure-re-verifyruns no step.knowledge_sources.retireis new insteps_completed.docs/operations/upgrades.md). It lists, with their queries, the active sources on namespaces an older build deleted and the sources registered before a namespace erasure an older build completed that were still active then (active, or retired after it). An erasure an older build started and the newer one finished needs no step: its final census reopens the steps for what the source wrote back. Remove those sources, or delete or erase those namespaces again.Tests
tests/unit/test_knowledge_sources.py:personal-…, the suffixed form,u-…,col-me-…), and so is a collection the tree no longer holds.directory_row, run on clickhouse-local against a shared namespace, an agent's, an inactive one and one with no row).sync_nowrefuses a source of an inactive namespace; the erasure step waits for a source an older build added between its read and its lease;addanswersERASURE_RUNNINGwhile an erasure of the namespace runs, and not for an abandoned or replay-pending one.knowledge.source.listanswersaccepts_sourcesfalse on a sign-up namespace, a personal name, acol-me-…collection and an inactive namespace, true on a shared one.delete_namespaceleaves the source inactive with its credential cleared. It takes the lease, then the claim.ManualClock).test_the_erasure_step_waits_less_than_the_recovery_workers_pass: the step's wait stays under half theerasure_recoverypass deadline. The 30 s is_SOURCE_RETIRE_WAIT_S, markednot a settingwith its reason.test_pg_authority.py: under the Postgres authority a namespace erasure runsknowledge_sources.retire, thenpg_memory.delete.test_erasure_step_order.py).test_a_busy_sources_lease_is_one_warning_line(test_erasure_backend_failure_logs_one_line.py)._repo_tagtags trunk only, and a pass stops onRegistryUnreadafter its retirements (test_knowledge_source_sync.py,test_repo_snapshot_contract.py).sources_inand the two step-13 queries on clickhouse-local (test_knowledge_sources_sql.py), anamespace_listerasure stored as a plain array included.Documents.sources.test.tsx:test_namespace_delete.py:namespace.deleteand a namespaceerasure.requesteach leave the namespace's source inactive with its credential cleared, and the erasure's steps includeknowledge_sources.retire.test_knowledge_sharing.py:collection.deletedoes the same for a collection's source.test_knowledge_sources.py: a source on a namespace that is no repository's trunk servescheckandsync_now, andaddon a plain namespace reaches the probe.make lintandmake typecheckpass.tsc -b, build, budget and full vitest suite pass.test_deeply_nested_hidden_html_parses_in_bounded_timedeselected, a timing test that also fails on main on this host.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.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lintandmake typecheckpass, and the full unit suite passes on c116557 (the pushes after it change only docstrings, a message and docs, and the sources, error and docs tests pass on 17ef42b) withtest_deeply_nested_hidden_html_parses_in_bounded_timedeselected, a timing test that also fails on main on this host. The integration tests listed run in CI and were not run locally.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code