Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/features/knowledge.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ and databases are shared with, whose credential is the integration's token; and
([recordings](#a-recording-source)). The `knowledge_source_sync` worker pulls each
source's files into the namespace's documents ([syncing](#syncing-a-source)); `list`
says whether this deployment runs it (`enabled`, `LOOM_KNOWLEDGE_SOURCE_SYNC_ENABLED`,
off by default). The design of connected accounts and access that follows the store's
permissions is in [document sources](../architecture/document-sources.md).
off by default). An operator who keeps members' credentials off the deployment sets
`LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED=false`: `add` and `rotate` then answer
`SELF_SERVICE_OFF` before any probe or write, the other source operations still answer,
`list` says so (`self_service`), and the dashboard offers neither. The design of
connected accounts and access that follows the store's permissions is in
[document sources](../architecture/document-sources.md).

Open **Settings → Connected accounts** to connect your Google Drive, Notion or Linear
account. Choose **Connect**, complete the provider's consent screen, and return to the
Expand Down
1 change: 1 addition & 0 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ Knowledge documents and conversations: chunking, search floor, thread titles.
| `LOOM_KNOWLEDGE_CONNECTED_SOURCES_MAX_PER_PERSON` | `int` | `8` | live | Active connected sources one canonical person may register in one namespace. |
| `LOOM_KNOWLEDGE_SOURCE_PROBE_TIMEOUT_S` | `float` | `20.0` | live | Seconds a document source's probe (add, update, check, rotate) or tracker short-id lookup may take in all; past it add, update and rotate answer SOURCE_UNREACHABLE and check answers reachable: false. |
| `LOOM_KNOWLEDGE_SOURCE_SYNC_ENABLED` | `bool` | `False` | | The knowledge_source_sync worker: pulls each registered document source's changed files into its namespace's documents. Off by default: it needs each source's credential, spends embedding calls on every changed document and model calls mining it for decisions. |
| `LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED` | `bool` | `True` | live | Off refuses knowledge.source.add and knowledge.source.rotate (SELF_SERVICE_OFF), so no member's credential reaches the pods; the other source operations still answer. |
| `LOOM_KNOWLEDGE_MIRRORED_SOURCES_ENABLED` | `bool` | `False` | | Require protected automatic session capture and persist deployment privacy state. Off does not lift protection while the deployment latch remains set. |
| `LOOM_KNOWLEDGE_SOURCE_ACL_STALE_SECONDS` | `int` | `3600` | | Mirrored reads require a complete listing and group observation within this many seconds; missing or older evidence admits nobody. |
| `LOOM_KNOWLEDGE_SOURCE_ACL_MAX_ENTRIES` | `int` | `10000` | | Maximum team and member rows read for one project's complete permission list. A larger list refuses publication rather than granting from a partial page. |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ Raised in `server/memory/app/profile.py`.

#### `SELF_SERVICE_OFF`

Raised in `server/code/app/repo_admin.py`, `server/tracker/app/sources.py`.
Raised in `server/code/app/repo_admin.py`, `server/knowledge/app/sources.py`, `server/tracker/app/sources.py`.

#### `SELF_SIGNUP_DISABLED`

Expand Down
1 change: 1 addition & 0 deletions docs/reference/operations/knowledge.md
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ The document sources registered on a namespace, with each one's sync state.
| `sources` | `list[KnowledgeSourceEntry]` | The namespace's active sources, by name. |
| `enabled` | `bool` | Whether this deployment runs the sync worker (LOOM_KNOWLEDGE_SOURCE_SYNC_ENABLED); false: sources are stored and probed, but nothing pulls from them. |
| `accepts_sources` | `bool` | False where add would refuse the namespace (PERSONAL_NAMESPACE, NAMESPACE_INACTIVE). |
| `self_service` | `bool` | Whether knowledge.source.add and rotate answer on this deployment (LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED); the page offers neither when false. |

## `knowledge.source.parse_links`

Expand Down
34 changes: 34 additions & 0 deletions frontend/src/flows/KnowledgeSourceDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ afterEach(() => {

const refused = () =>
new ApiError({ status: 400, code: "CREDENTIAL_REFUSED", message: "the source refused the credential: http_401" });
const selfServiceOff = () =>
new ApiError({
status: 422,
code: "SELF_SERVICE_OFF",
message:
"adding a document source or rotating its credential is off on this deployment " +
"(LOOM_KNOWLEDGE_SOURCE_SELF_SERVICE_ENABLED); ask the operator",
});

/** Nothing the page shows — its text, a field's value outside the password input, a
* toast — carries the key. */
Expand Down Expand Up @@ -141,6 +149,18 @@ describe("AddSourceDialog", () => {
expectKeyNowhere();
});

it("words a self-service refusal by the document source it refused, not repositories", async () => {
vi.mocked(addKnowledgeSource).mockRejectedValue(selfServiceOff());
renderAdd();
await fill();
fireEvent.click(screen.getByRole("button", { name: "Check" }));
const alert = await screen.findByRole("alert");
expect(alert).toHaveTextContent("The operator turned this off");
expect(alert).toHaveTextContent("adding a document source");
expect(alert).not.toHaveTextContent(/repositor/i);
expectKeyNowhere();
});

it("a refused add keeps the passed check, so Add can be tried again", async () => {
vi.mocked(addKnowledgeSource).mockImplementation(async (_id, _f, dryRun) => {
if (dryRun) return addResult(true);
Expand Down Expand Up @@ -394,6 +414,20 @@ describe("RotateSourceDialog", () => {
expect(await screen.findByRole("alert")).toHaveTextContent("refused the credential");
expectKeyNowhere();
});

it("words a self-service refusal of a rotation without naming repositories", async () => {
vi.mocked(rotateKnowledgeSource).mockRejectedValue(selfServiceOff());
render(
<RotateSourceDialog open onOpenChange={() => {}} {...NS} name="design-docs" kind="gdrive" onRotated={() => {}} />,
);
fireEvent.change(screen.getByLabelText(/^Service account key/), { target: { value: KEY } });
fireEvent.click(screen.getByRole("button", { name: "Rotate" }));
const alert = await screen.findByRole("alert");
expect(alert).toHaveTextContent("The operator turned this off");
expect(alert).toHaveTextContent("rotating its credential");
expect(alert).not.toHaveTextContent(/repositor/i);
expectKeyNowhere();
});
});

describe("CheckSourceDialog", () => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/errorWords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export const ERROR_CODE_PREFIXES: Record<string, string> = {
MODEL_CALLS_DISABLED:
"Model calls are off for this org; an org admin can turn them on in Admin › Guardrails unless a platform admin locked them:",
SANDBOX_UNAVAILABLE: "Adding repositories is turned off on this deployment:",
SELF_SERVICE_OFF: "Adding repositories is turned off on this deployment:",
// Shared by repositories, tracker sources and document sources: the server's words name the action.
SELF_SERVICE_OFF: "The operator turned this off:",
REPO_EXISTS: "This repository is already indexed:",
REPO_QUOTA: "The repository limit is reached:",
};
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/knowledgeSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export interface KnowledgeSourceList {
enabled: boolean;
/** False where add would refuse the namespace; absent from an older server. */
accepts_sources?: boolean;
/** False where the operator turned add and rotate off; absent from an older server. */
self_service?: boolean;
}

export interface KnowledgeSourceProbe {
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/views/Documents.sources.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,23 @@ describe("Library sources", () => {
).toEqual(["Check", "Retire"]);
});

it("offers no Add and no Rotate where the deployment turned self-service off", async () => {
sources.listKnowledgeSources.mockResolvedValue({ ...LISTED, self_service: false });
show("admin");
await openSources();
expect(await screen.findByText("team-notes")).toBeInTheDocument();
expect(screen.getByText("Adding document sources is turned off on this deployment.")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Add a source" })).toBeNull();
const user = userEvent.setup();
await user.click(screen.getByRole("button", { name: "Actions for team-notes" }));
const menu = await screen.findByRole("menu", { name: "Actions for team-notes" });
expect(
within(menu)
.getAllByRole("menuitem")
.map((m) => m.textContent),
).toEqual(["Check", "Sync now", "Push notifications", "Retire"]);
});

it("keeps the list closed, counted on its button, until it is pressed, and closes again", async () => {
show("viewer");
const user = userEvent.setup();
Expand Down
23 changes: 17 additions & 6 deletions frontend/src/views/SourcesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const TONE_STATE: Record<SyncTone, BadgeState> = { ok: "success", warn: "warning

type State =
| { kind: "loading" }
| { kind: "ready"; sources: KnowledgeSource[]; enabled: boolean; accepts: boolean }
| { kind: "ready"; sources: KnowledgeSource[]; enabled: boolean; accepts: boolean; selfService: boolean }
| { kind: "absent" }
| { kind: "refused" }
| { kind: "error"; error: unknown };
Expand Down Expand Up @@ -162,7 +162,13 @@ export function SourcesList({
try {
const r = await listKnowledgeSources(id, { signal });
if (!live()) return;
setState({ kind: "ready", sources: r.sources, enabled: r.enabled, accepts: r.accepts_sources !== false });
setState({
kind: "ready",
sources: r.sources,
enabled: r.enabled,
accepts: r.accepts_sources !== false,
selfService: r.self_service !== false,
});
} catch (e) {
if (!live()) return;
if (isOpAbsent(e)) setState({ kind: "absent" });
Expand All @@ -182,7 +188,9 @@ export function SourcesList({
const retire: RowMenuItem = { label: "Retire", icon: "trash", danger: true, onSelect: act("retire") };
// A place that takes no new source refuses a sync and a rotation: Check and Retire remain.
const closed = state.kind === "ready" && !state.accepts;
const items = closed ? [check, retire] : [check, sync, rotate, retire];
// With self-service off the deployment refuses a rotation too; a sync still runs.
const rotates = state.kind === "ready" && state.selfService;
const items = closed ? [check, retire] : rotates ? [check, sync, rotate, retire] : [check, sync, retire];
if (!closed && ["gdrive", "notion", "linear"].includes(s.kind)) {
items.splice(2, 0, { label: "Push notifications", icon: "refresh", onSelect: act("push") });
}
Expand All @@ -195,7 +203,7 @@ export function SourcesList({
// The Library's section hides while its list loads, on an empty place that takes
// no source or that this caller cannot add to, and from a non-admin when the list failed.
const empty = state.kind === "ready" && state.sources.length === 0;
const closedAndEmpty = empty && !state.accepts;
const closedAndEmpty = empty && (!state.accepts || !state.selfService);
const nothingForReader = empty && !manageable;
const loading = state.kind === "loading";
const failedForReader = state.kind !== "ready" && !loading && !manageable;
Expand Down Expand Up @@ -223,7 +231,10 @@ export function SourcesList({
{manageable && state.sources.length > 0 ? "; retire these when they are no longer needed." : "."}
</p>
)}
{state.kind === "ready" && state.accepts && state.sources.length === 0 && (
{state.kind === "ready" && state.accepts && !state.selfService && (
<p className="text-xs text-text-muted">Adding document sources is turned off on this deployment.</p>
)}
{state.kind === "ready" && state.accepts && state.selfService && state.sources.length === 0 && (
<p className="text-xs text-text-muted">
No document sources.{" "}
{manageable
Expand All @@ -238,7 +249,7 @@ export function SourcesList({
))}
</ul>
)}
{manageable && state.kind === "ready" && state.accepts && (
{manageable && state.kind === "ready" && state.accepts && state.selfService && (
<Button type="empty" htmlType="button" iconLeft="plus" disabled={busy} onClick={() => setAdding(true)}>
Add a source
</Button>
Expand Down
5 changes: 5 additions & 0 deletions loom.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,11 @@ settings:
# it for decisions. [restart]
# knowledge_source_sync_enabled: false

# Off refuses knowledge.source.add and knowledge.source.rotate (SELF_SERVICE_OFF), so
# no member's credential reaches the pods; the other source operations still answer.
# [live]
# knowledge_source_self_service_enabled: true

# Require protected automatic session capture and persist deployment privacy state.
# Off does not lift protection while the deployment latch remains set. [restart]
# knowledge_mirrored_sources_enabled: false
Expand Down
5 changes: 5 additions & 0 deletions schemas/loom-settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3617,6 +3617,11 @@
"type": "integer",
"description": "Documents of stopped mirrored sources retired per cleanup pass, independently of the content-sync budget. Cleanup continues while syncing is switched off."
},
"knowledge_source_self_service_enabled": {
"default": true,
"type": "boolean",
"description": "Off refuses knowledge.source.add and knowledge.source.rotate (SELF_SERVICE_OFF), so no member's credential reaches the pods; the other source operations still answer."
},
"knowledge_source_sync_cap_share": {
"default": 0.25,
"exclusiveMinimum": 0.0,
Expand Down
1 change: 1 addition & 0 deletions sdk/python/loom/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -12081,6 +12081,7 @@ class KnowledgeSourceListOutput(TypedDict, total=False):
sources: NotRequired[list["KnowledgeSourceEntry"]]
enabled: NotRequired[bool]
accepts_sources: NotRequired[bool]
self_service: NotRequired[bool]


class KnowledgeSourceEntry(TypedDict, total=False):
Expand Down
Loading
Loading