Skip to content

A deployment can turn off self-service document sources - #1685

Merged
zlareb1 merged 9 commits into
ClickHouse:mainfrom
VanshajPoonia:issues/869-knowledge-source-self-service
Nov 30, 2026
Merged

zlareb1 merged 9 commits into
ClickHouse:mainfrom
VanshajPoonia:issues/869-knowledge-source-self-service

Conversation

@VanshajPoonia

@VanshajPoonia VanshajPoonia commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #869

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED=false refuses knowledge.source.add and knowledge.source.rotate with SELF_SERVICE_OFF before any probe or write. The other document source operations keep working, and the dashboard offers neither add nor rotate. Connected-account OAuth is outside the switch: it runs for each provider whose client id is set (LOOM_CONNECT_<PROVIDER>_CLIENT_ID).

Why

Repositories and tracker sources each have a self-service switch (LOOM_CODE_SELF_SERVICE_ENABLED, LOOM_TRACKER_SELF_SERVICE_ENABLED). Document sources had none. A shared deployment could keep the sync worker off, but add and rotate still took, probed and stored the credential.

Scope and risk

  • knowledge_source_self_service_enabled in the settings catalog, default true, so no deployment changes. It is a live setting because both handlers read it at call time, so admin/settings.set turns it off without a restart.
  • _require_self_service() runs first in handle_knowledge_source_add and handle_knowledge_source_rotate, before name checks, probes and writes. It also covers a connected add, because that registers a member's credential on the pods too. It raises SELF_SERVICE_OFF, the code the repository and tracker switches use.
  • knowledge.source.update has no credential input (it probes with the stored one), so it stays open. So do list, inspect, parse_links, check, sync_now, remove and the push ops.
  • The dashboard's lead-in for SELF_SERVICE_OFF said repositories, though tracker and document sources share the code. It is now "The operator turned this off:" and the server's message names the refused action.
  • knowledge.source.list reports the switch as self_service. The Sources list hides "Add a source" and "Rotate credential" when it is false and says "Adding document sources is turned off on this deployment." Check, Sync now, Push notifications and Retire stay. An empty Library section hides, as it does for a place that takes no source.
  • Every source today comes from these self-service ops, so there is no operator-configured path to exempt.

Compatibility, rollout and rollback

  • Wire: knowledge.source.list gains self_service (bool, default true). knowledge.source.add and knowledge.source.rotate can answer SELF_SERVICE_OFF. No default changes.
  • Operator steps: none. To use it, set LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED=false, or set knowledge_source_self_service_enabled to false with admin/settings.set.
  • Rollback: revert. LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED stores nothing. A value set with admin/settings.set is kept in loom.runtime_overrides and outlives the revert. Build N-1 ignores it, and it applies again if the setting comes back. loom settings reset knowledge_source_self_service_enabled clears it on either build. A build N-1 server omits self_service, and the dashboard reads a missing field as on.

Tests

  • pytest tests/unit/test_knowledge_sources.py: 4 new cases. Add is refused in shared and connected mode with no probe and no row. Rotate is refused and the stored credential stays the same. With the switch off, list (sources still listed, self_service false, accepts_sources true), inspect and parse_links still answer. All 4 fail with the handler change reverted.
  • vitest run src/views/Documents.sources.test.tsx: 26 pass. The new case checks the note, that there is no Add button and that the menu is Check, Sync now, Push notifications, Retire. It fails with the SourcesList change reverted.
  • 150 unit files covering settings, docs, the SDKs, the registry and document sources (-n 2): 1847 passed. 6 failed locally and none touch these files: 4 worker registry cases need numpy, which this environment lacks, and 2 in test_code_workspace_registry.py. RepositoryCard.test.tsx has one failing branch-table case here with or without this change.
  • tests/integration/test_knowledge_sources.py: 2 new cases. The list reports self_service: true by default. With the switch off on a server of its own, started with LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED=false, add and rotate answer 422 SELF_SERVICE_OFF, the list reports self_service: false and still lists the source, and inspect answers. The case writes no runtime override, so the shared server's other tests never see the switch off. These need a running server and ClickHouse, so CI is their first run.
  • vitest run src/flows/KnowledgeSourceDialog.test.tsx: 2 new cases, a refused add and a refused rotation. Each checks the alert reads "The operator turned this off" with the server's words and never mentions repositories. Both fail with the old lead-in.
  • test_settings_defaults.py and test_live_settings.py snapshots updated with LOOM_UPDATE_SNAPSHOT=1.
  • Every codegen --check in make lint, ruff, the function-length gate, Biome on the changed files, npm --prefix frontend run build, npm --prefix frontend run budget and Prettier 3.9.9 on the Markdown and YAML pass.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code wrote the diff and ran the checks above.

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

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

Note

Low Risk
Operator-gated feature, default on; only blocks add/rotate and UI affordances, with tests and no auth/data-path changes.

Overview
Deployments can now disable member-driven document source registration via LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED (default true, live). When off, knowledge.source.add and knowledge.source.rotate fail early with SELF_SERVICE_OFF—before probes or credential writes—while list, inspect, check, sync, and connected-account OAuth stay available.

knowledge.source.list exposes self_service so the dashboard hides Add / Rotate credential, shows an operator-off notice, and trims row actions. SELF_SERVICE_OFF UI copy is generalized (“The operator turned this off”) so document sources aren’t mislabeled as repositories.

Docs, settings schema, SDK typings, and unit/integration tests cover the switch.

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

@vercel

vercel Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 30, 2026 6:23am UTC
loom-telemetry Ready Ready Preview Nov 30, 2026 6:23am UTC

Request Review

@cla-assistant

cla-assistant Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@zlareb1 zlareb1 self-assigned this Nov 28, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The server rejects add and rotate before probing or storing credentials, and the list preserves the other source actions. Please cover the new contract in the existing HTTP integration suite, including the SELF_SERVICE_OFF response and the list’s self_service field.

Comment thread server/knowledge/app/sources.py Resolved
zlareb1
zlareb1 previously approved these changes Nov 28, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The add and rotate dialogs now use the shared refusal label and keep the server’s explanation. The new HTTP cases cover both refusals, the false capability in the list, and a source that stays readable with the setting off. The platform-admin override uses the existing live-settings path.

Please update the rollback note before merging. A value set through admin/settings.set persists in the runtime override store and applies if the setting is introduced again.

@zlareb1

zlareb1 commented Nov 28, 2026

Copy link
Copy Markdown
Member

@VanshajPoonia please sign CLA

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The rename integration test fails at the same assertion on clean main. The fixture’s two values differ only by backticks, so the write path folds them into one memory. The assertion passes locally when the prose fixture uses a distinct claim. PR job · Base job

@zlareb1

zlareb1 commented Nov 28, 2026

Copy link
Copy Markdown
Member

The rename integration test fails at the same assertion on clean main. The existing fixture repair makes the two memory claims distinct, and the integration test step passes with that change. PR failure · Main failure · Fixture repair · Passing test step

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GitHub reports a merge conflict with main. Please resolve it so CI can run against the merged tree.

zlareb1
zlareb1 previously approved these changes Nov 28, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The upstream merge preserves the request guards, source list behavior, and HTTP coverage. The regenerated Rust model also keeps the default on for older server responses.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The format job reports the same adoption page assignment as clean main. The pinned formatter passes with the tracked repair. PR job · Repair #1706

@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Thank you for the review. df7dc02 makes the switch a live setting, since both handlers read it at call time. 496593c adds two cases to tests/integration/test_knowledge_sources.py. The list reports self_service: true by default. With the switch off through admin/settings.set, add and rotate answer 422 SELF_SERVICE_OFF, the list reports self_service: false and still lists the source, and inspect still answers. The override is cleared after the case. The integration suite hasn't run locally, so CI is its first run. I also merged main in d26d79e to clear the conflict. Only the generated Rust SDK file conflicted, and it is regenerated.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GitHub reports a merge conflict with main in sdk/rust/src/wire_models.rs. Please resolve the conflict and regenerate the Rust wire models so CI can validate the combined tree.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The source handlers refuse add and rotate when self-service is off. The operator guidance needs to describe where that control applies. The refreshed head also resolves the Rust wire model conflict.

Comment thread server/settings/catalog.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ClickHouse expires the adoption directory test’s fixed snapshot rows before the view reads them. Clean main reproduces the failure. The test passes with UTC-relative fixture dates. Failed unit job · Repair #1740

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The operator guidance now covers the OAuth scope. The new integration fixture can leave a deployment-wide override in place and affect other tests.

@zlareb1

zlareb1 commented Nov 29, 2026

Copy link
Copy Markdown
Member

The tunable-constant check reports the same duplicate coverage row limit on this head and on clean main. The coverage repair keeps the store's existing bounds and removes the duplicate. PR unit job · Main unit job · Repair #1722

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 02bcf61. Configure here.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fixture leaves deployment-wide settings alone. The spawned-server auth finding still affects local runs: the fixture only overrides self-service, the child inherits pytest's environment, and its requests carry no token. CI exports auth-off to pytest. A local pytest process without that setting starts the child with auth required. Set auth mode explicitly for the child or authenticate the requests.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The sender census reports the same stale plugin client fingerprints on this CI merge and on clean main. The test passes locally with both fingerprint repairs. PR job · Main job · Plugin repair #1773 · SDK repair #1706

The extraction classification test also fails on main because changed_files has no content classification. PR job · Repair #1747

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The isolated test server sets its own auth mode, so the unauthenticated requests reach the self-service guard regardless of the parent environment. All 234 focused unit tests pass. The new integration case still needs a hosted run.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The integration fixture is fixed. The rollback note finding still applies, and this supersedes my approval. I verified that a stored false override survives while the build ignores the missing setting and takes effect when the field returns. Update the rollback note to say the override persists and can be cleared.

@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Thank you for checking the stored override. The rollback note now says a value set with admin/settings.set outlives the revert and applies again if the setting comes back. loom settings reset knowledge_source_self_service_enabled clears it on either build. I also merged main again in e731e61. Only the generated Rust wire models conflicted, and I regenerated them.

zlareb1
zlareb1 previously approved these changes Nov 29, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The rollback note now explains that a stored override survives a revert and how to clear it on either build. The add and rotate guards still run before credential probes or writes, and the dashboard and Rust SDK preserve the older response default.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The conflict resolver test expects an unattested successor to retire an attested row. The same assertion fails on this CI merge and on clean main with ClickHouse 26.11.5.8. The repair keeps the original ordering assertion at equal standing and checks the lower-standing conflict separately. Both cases pass locally. PR job · Main job · Repair #1781

@zlareb1

zlareb1 commented Nov 30, 2026

Copy link
Copy Markdown
Member

@VanshajPoonia Please rebase

LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED (default true) is the switch
the code and tracker self-service paths already have. When it is off,
knowledge.source.add (shared and connected) and knowledge.source.rotate
answer SELF_SERVICE_OFF before any probe or write, so no member's
credential reaches the pods. List, inspect, parse_links, check, update,
sync and remove keep answering. knowledge.source.list reports the switch
as self_service.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
With self_service false the Sources list hides Add a source and the
Rotate credential item and says adding is turned off. Check, Sync now,
push notifications and Retire stay.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Both handlers read knowledge_source_self_service_enabled at call time,
so it is a live setting: an admin turns it off with admin/settings.set
and no restart.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
knowledge.source.list reports self_service true by default. With the
switch off through a runtime override, add and rotate answer 422
SELF_SERVICE_OFF, the list reports false and still lists the source,
and inspect still answers. The override is cleared after the case.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
The dashboard's lead-in for the code said repositories, so a refused
document source add or rotation read as "Adding repositories is turned
off". The lead-in is now neutral and the server's message names the
action. The add and rotate dialogs each cover a refusal.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
… are governed by their provider's client id

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…eployment-wide override

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…d requests need

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Rebased onto main 1e3d412, so the branch is now 9 commits with no merge commits. Main's sdk_go_gen.py --check fails on sdk/go/wire/models.gen.go, and this PR adds a field there. So the regenerated file also carries pick_confidence, proposals and count_only next to self_service.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The rebased head preserves the add and rotate guards, the older-server default, and the rollback instructions for stored overrides. The 234 focused unit tests passed and the generated Go contracts are current.

@zlareb1
zlareb1 merged commit 7571934 into ClickHouse:main Nov 30, 2026
77 of 82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A setting that refuses self-service document sources, as for repositories and tracker sources

2 participants