Skip to content

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

Open
VanshajPoonia wants to merge 7 commits into
ClickHouse:mainfrom
VanshajPoonia:issues/869-knowledge-source-self-service
Open

VanshajPoonia wants to merge 7 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, so an operator can keep members' credentials off a shared deployment. The other document source operations keep working, and the dashboard offers neither add nor rotate.

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. Nothing is stored. 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 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 answers. The override is cleared after the case. 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
Behavior is opt-in via a new setting defaulting to on; changes are gated refusals and dashboard visibility, not auth or stored credential handling.

Overview
Adds LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED (default on, live) so operators can block members from submitting credentials via knowledge.source.add and knowledge.source.rotate, which now fail early with SELF_SERVICE_OFF—aligned with existing repository/tracker self-service switches. Other source ops (list, inspect, check, sync, retire, etc.) stay available.

knowledge.source.list exposes self_service; the dashboard hides Add a source and Rotate credential, shows a deployment notice, and leaves check/sync/push/retire. SELF_SERVICE_OFF copy is generic (“The operator turned this off:”) while the server message names document-source add/rotate. SDK types, docs, schema, and unit/integration tests cover the flag and UI.

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

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>
@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 28, 2026 12:52pm UTC
loom-telemetry Ready Ready Preview Nov 28, 2026 12:52pm 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
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>
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.

…e-source-self-service

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

# Conflicts:
#	sdk/rust/src/wire_models.rs

@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.

This branch has not been deployed

No deployments
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