Skip to content
Merged
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
9 changes: 9 additions & 0 deletions .changeset/38369-held-status-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@objectstack/cli': patch
'@objectstack/service-settings': patch
---

Clause-②: no
Metadata-protocol: none

`os knowledge status` prints the knowledge service's state first when the server's `index_status` answer carries an `enablement` (the boot read the service as not enabled, so every source is held): the not-enabled line, the number of held sources, and the reason with its remedy. An answer without it prints exactly as before. The Settings → AI embedder section's help text now says that once a provider is saved and the server restarted, the content fields each knowledge source lists are sent to that provider for every row the source matches, and the provider bills for them (all shipped locales).
2 changes: 1 addition & 1 deletion content/docs/ai/knowledge-rag.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ os knowledge status # each source: built, never built or due
os knowledge rebuild support_articles # start a complete build and follow its progress
```

`os knowledge rebuild` starts the build on the server and prints its progress — rows read, documents written, unchanged, purged, and those that cannot be indexed — until it ends; `--no-wait` returns once it has started. Both commands call the `knowledge` settings actions `rebuild` and `index_status` (`POST /api/settings/knowledge/rebuild` with `{ "source": "ID" }`). The server logs each build's start, its progress every ten seconds, and its result. The progress the commands read is the source's sync state (below), so behind a load balancer any node answers it. On the `memory` adapter the index itself lives in each server process: a rebuild fills the index of the node that ran it only, and the command says so when it ends.
`os knowledge rebuild` starts the build on the server and prints its progress — rows read, documents written, unchanged, purged, and those that cannot be indexed — until it ends; `--no-wait` returns once it has started. Both commands call the `knowledge` settings actions `rebuild` and `index_status` (`POST /api/settings/knowledge/rebuild` with `{ "source": "ID" }`). The server logs each build's start, its progress every ten seconds, and its result. The progress the commands read is the source's sync state (below), so behind a load balancer any node answers it. On the `memory` adapter the index itself lives in each server process: a rebuild fills the index of the node that ran it only, and the command says so when it ends. Where the service is held ([Mounted is not enabled](#turning-it-on-requires-knowledge)), `os knowledge rebuild` starts nothing and exits 1 with the server's sentence, which names what is missing and the fix; `os knowledge status` prints the service's state first — not enabled, how many sources are held, and why — whenever the `index_status` answer carries it (its `enablement`).

### Each source's sync state

Expand Down
51 changes: 51 additions & 0 deletions packages/cli/src/commands/knowledge/knowledge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ describe('os knowledge rebuild', () => {
}
});

it('a held knowledge service: exits 1 at once with the server\'s sentence, which names the remedy', async () => {
// What the rebuild action answers while the boot read the service as not
// enabled: no build started, and the service's refusal of the build.
const message =
"Rebuild of source 'kb' was not started: [knowledge] the knowledge service is not enabled on this deployment: " +
'no embedder is configured (ai.embedder_provider is not saved). Its sources are held: none is built, synced or ' +
'searched. To enable it, save an embedder provider, then restart.';
for (const answer of [ok({ ok: true, message, details: { source: 'kb', build: null } }), refused(message)]) {
const run = await drive(KnowledgeRebuild, ['kb', ...target], [answer]);
expect(run.failure).toMatchObject({ message, exit: 1 });
expect(run.requests).toHaveLength(1);
}
});

it('keeps following a poll whose record does not name this build yet, and does not exit 1 for it', async () => {
const older = { ...done, startedAt: '2026-11-25T00:00:00.000Z' };
const run = await drive(KnowledgeRebuild, ['kb', ...target], [
Expand Down Expand Up @@ -278,6 +292,43 @@ describe('os knowledge status', () => {
expect(text).toContain('record syncs waiting on queue knowledge-record-sync: 7');
// No per-node caveat on the build: the record is the same on every node.
expect(text).not.toContain('node that answered');
// No `enablement` in the answer: no line about the service's state.
expect(text).not.toContain('knowledge service:');
});

/** One source and its queue, the answer of a service that serves. */
const serving = {
sources: [{ id: 'kb', label: 'KB', adapter: 'pgvector', index: CURRENT, build: done, failures: { count: 0 } }],
queue: { queue: 'knowledge-record-sync', pending: 0 },
};

it('a held service (the answer carries enablement): the not-enabled line and the reason come first, the sources after', async () => {
const reason =
'[knowledge] the knowledge service is not enabled on this deployment: no embedder is configured ' +
'(ai.embedder_provider is not saved). Its sources are held: none is built, synced or searched. ' +
'To enable it, save an embedder provider, then restart.';
const run = await drive(KnowledgeStatus, target, [
ok({ ok: true, details: { ...serving, enablement: { state: 'not-enabled', reason, embedder: 'ai.embedder_provider is not saved', heldSources: 1 } } }),
], false);
expect(run.failure).toBeUndefined();
expect(run.logs.slice(0, 3)).toEqual([
'knowledge service: not enabled — 1 source(s) held, none built, synced or searched',
` ${reason}`,
'kb (KB; adapter pgvector)',
]);
});

it('an answer without enablement prints exactly as before', async () => {
const run = await drive(KnowledgeStatus, target, [ok({ ok: true, details: serving })], false);
expect(run.failure).toBeUndefined();
expect(run.logs).toEqual([
'kb (KB; adapter pgvector)',
' index: current — current.',
' last build: done (operator, ended 2026-11-26T05:01:00.000Z): 250 row(s) read, 240 written, 10 unchanged, 2 purged, 0 cannot be indexed',
' Every row was read and the index recorded the build.',
' failed syncs: none',
"record syncs waiting on queue knowledge-record-sync: 0 (every source's together)",
]);
});

it('exits 1 with the server refusal text', async () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/src/commands/knowledge/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ import {
* the build's bound) or `interrupted` (its node stopped), which
* `os knowledge status` then shows.
*
* Where the server's boot read the knowledge service as not enabled (no
* embedder, or the deployment's store not mounted), the server starts no
* build and answers why, naming what is missing and the remedy (save an
* embedder provider, or mount the store, then restart); the command exits 1
* with that sentence.
*
* The progress it reads is the source's sync state: one durable record per
* source, the same whichever node answers a read, so behind a load balancer
* every poll reads this build. A poll is matched to this build by its start
Expand Down
14 changes: 14 additions & 0 deletions packages/cli/src/commands/knowledge/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import { Args, Command, Flags } from '@oclif/core';
import {
describeBuild,
describeEnablement,
describeFailures,
resolveKnowledgeTarget,
runKnowledgeAction,
type KnowledgeEnablementView,
type KnowledgeQueueView,
type KnowledgeSourceView,
} from '../../utils/knowledge-actions.js';
Expand All @@ -22,6 +24,13 @@ import {
* node answers and kept across restarts. The index state is the store's own:
* the same on every node when the adapter's store is shared, and per node on
* the `memory` adapter, whose index lives in each process.
*
* Where the answer carries `enablement` — the server's boot read the
* knowledge service as not enabled (no embedder, or the deployment's store
* not mounted), so every source is held: listed, never built, synced or
* searched — the command prints it first: the state, the number of held
* sources, and the reason with its remedy. An answer without it prints as it
* always did.
*/
export default class KnowledgeStatus extends Command {
static override description =
Expand Down Expand Up @@ -49,6 +58,11 @@ export default class KnowledgeStatus extends Command {
this.error(answer.message, { exit: 1 });
return;
}
const enablement = answer.details.enablement as KnowledgeEnablementView | undefined;
if (enablement && typeof enablement === 'object') {
this.log(describeEnablement(enablement));
if (enablement.reason) this.log(` ${enablement.reason}`);
}
const sources = Array.isArray(answer.details.sources) ? (answer.details.sources as KnowledgeSourceView[]) : [];
if (sources.length === 0) {
this.log('No knowledge source is registered on this server.');
Expand Down
25 changes: 25 additions & 0 deletions packages/cli/src/utils/knowledge-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,31 @@ export interface KnowledgeSourceView {
syncStateError?: string;
}

/**
* The knowledge service's state in an `index_status` answer: present only
* while the server's boot read the service as not enabled, so that every
* source is held (listed, never built, synced or searched). Absent on a
* server whose service serves, as on a server that predates it.
*/
export interface KnowledgeEnablementView {
/** `not-enabled` today; another value is printed as the server sent it. */
state?: string;
/** Why, naming each missing half and the remedy. */
reason?: string;
/** Set when no embedder is available: the settings that are missing. */
embedder?: string;
/** Set when the deployment's store is not mounted: its adapter id. */
store?: string;
/** How many sources the service holds. */
heldSources?: number;
}

/** One line of the knowledge service's state, from an `index_status` answer's `enablement`. */
export function describeEnablement(enablement: KnowledgeEnablementView): string {
const held = enablement.heldSources === undefined ? '' : ` — ${enablement.heldSources} source(s) held, none built, synced or searched`;
return `knowledge service: ${enablement.state === 'not-enabled' ? 'not enabled' : (enablement.state ?? 'unknown')}${held}`;
}

/** The record-sync queue of an `index_status` answer. */
export interface KnowledgeQueueView {
queue?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
resolveAiModelConfiguration,
type AiProviderId,
} from './ai-models.js';
import { settingsBuiltinTranslations } from '../translations/index.js';

/**
* #8026 — the write-door cases below save a complete `openai` provider config,
Expand Down Expand Up @@ -832,3 +833,45 @@ class RouteHttp implements IHttpServer {
}

const platformAdmin = () => ({ enforced: true, permissions: ['manage_platform_settings'], userId: 'usr_admin' });

/**
* [ADR-0161 K8, the dated note on item 12] The embedder section's help text
* says what saving a provider sets off: after a restart, every knowledge
* source's listed content fields go to that provider, which bills for them.
*/
describe('the embedder section says what saving a provider sets off', () => {
const SENTENCE =
'Once a provider is saved and the server restarted, the content fields each knowledge source lists are sent ' +
'to this provider for every row the source matches, and the provider bills for them.';
type Bundle = { settings: { ai: { groups: { embedder: { description: string } } } } };

it('the section declaration and its English copy carry the sentence', () => {
const group = aiEmbedderSettingsSpecifiers.find((s) => s.type === 'group' && (s as { id?: string }).id === 'embedder') as
| { description?: string }
| undefined;
expect(group?.description).toContain(SENTENCE);
expect((settingsBuiltinTranslations.en as Bundle).settings.ai.groups.embedder.description).toContain(SENTENCE);
});

it('every shipped locale says it: its copy names the restart and the bill', () => {
// Two words per locale, from its own sentence: the restart and the provider's bill.
const markers: Record<string, string[]> = {
'zh-CN': ['重启服务器', '计费'],
'zh-Hant': ['重新啟動伺服器', '計費'],
'ja-JP': ['再起動', '課金'],
'es-ES': ['reiniciado el servidor', 'factura'],
ar: ['إعادة تشغيل الخادم', 'رسومها'],
fr: ['serveur redémarré', 'facture'],
'pt-BR': ['reiniciar o servidor', 'cobra'],
ru: ['перезапуска сервера', 'счёт'],
de: ['neu gestartet', 'abrechnet'],
ko: ['다시 시작하면', '요금을 청구'],
};
const bundle = settingsBuiltinTranslations as Record<string, Bundle>;
expect(Object.keys(bundle).filter((l) => l !== 'en').sort()).toEqual(Object.keys(markers).sort());
for (const [locale, words] of Object.entries(markers)) {
const text = bundle[locale]!.settings.ai.groups.embedder.description;
for (const word of words) expect(text, locale).toContain(word);
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ export const aiEmbedderSettingsSpecifiers: SettingsManifest['specifiers'] = [
description:
'Text → vector provider used by knowledge sources and RAG. ' +
'Independent from the chat provider above — mix providers freely ' +
'(e.g. OpenAI for chat + 阿里通义 for embeddings).' },
'(e.g. OpenAI for chat + 阿里通义 for embeddings). ' +
// [ADR-0161 K8, the dated note on item 12] What saving a provider sets off.
'Once a provider is saved and the server restarted, the content fields each knowledge source lists are sent ' +
'to this provider for every row the source matches, and the provider bills for them.' },
{ type: 'select', key: 'embedder_provider', label: 'Provider',
required: false, default: 'none',
// Read once, when the knowledge service boots (#37094): no hot replacement.
Expand Down
4 changes: 3 additions & 1 deletion packages/services/service-settings/src/translations/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ export const ar: PlatformTranslationData = {
observability: { title: 'قابلية المراقبة' },
embedder: {
title: 'Embedder',
description: 'مزوّد تحويل النص → متجه الذي تستخدمه مصادر المعرفة وRAG. مستقل عن مزوّد الدردشة أعلاه.',
description:
'مزوّد تحويل النص → متجه الذي تستخدمه مصادر المعرفة وRAG. مستقل عن مزوّد الدردشة أعلاه. ' +
'بعد حفظ مزوّد وإعادة تشغيل الخادم، تُرسَل حقول المحتوى التي يسردها كل مصدر معرفة إلى هذا المزوّد لكل صف يطابقه المصدر، ويحتسب المزوّد رسومها.',
},
},
keys: {
Expand Down
5 changes: 4 additions & 1 deletion packages/services/service-settings/src/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,10 @@ export const de: PlatformTranslationData = {
observability: { title: 'Beobachtbarkeit' },
embedder: {
title: 'Embedder',
description: 'Text→Vektor-Anbieter für Wissensquellen und RAG. Unabhängig vom Chat-Anbieter oben.',
description:
'Text→Vektor-Anbieter für Wissensquellen und RAG. Unabhängig vom Chat-Anbieter oben. ' +
'Sobald ein Anbieter gespeichert und der Server neu gestartet ist, werden die Inhaltsfelder, die jede Wissensquelle ' +
'aufführt, für jede passende Zeile an diesen Anbieter gesendet, der sie abrechnet.',
},
},
keys: {
Expand Down
4 changes: 3 additions & 1 deletion packages/services/service-settings/src/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ export const en: PlatformTranslationData = {
embedder: { title: 'Embedder',
description:
'Text → vector provider used by knowledge sources and RAG. ' +
'Independent from the chat provider above.' },
'Independent from the chat provider above. ' +
'Once a provider is saved and the server restarted, the content fields each knowledge source lists are sent ' +
'to this provider for every row the source matches, and the provider bills for them.' },
},
keys: {
provider: {
Expand Down
4 changes: 3 additions & 1 deletion packages/services/service-settings/src/translations/es-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,9 @@ export const esES: PlatformTranslationData = {
embedder: { title: 'Embedder',
description:
'Proveedor de texto → vector usado por las fuentes de conocimiento y RAG. ' +
'Independiente del proveedor de chat anterior.' },
'Independiente del proveedor de chat anterior. ' +
'Una vez guardado un proveedor y reiniciado el servidor, los campos de contenido que enumera cada fuente de ' +
'conocimiento se envían a este proveedor por cada fila que la fuente abarca, y el proveedor los factura.' },
},
keys: {
provider: {
Expand Down
5 changes: 4 additions & 1 deletion packages/services/service-settings/src/translations/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,10 @@ export const fr: PlatformTranslationData = {
observability: { title: 'Observabilité' },
embedder: {
title: 'Embedder',
description: 'Fournisseur texte → vecteur utilisé par les sources de connaissances et le RAG. Indépendant du fournisseur de chat ci-dessus.',
description:
'Fournisseur texte → vecteur utilisé par les sources de connaissances et le RAG. Indépendant du fournisseur de chat ci-dessus. ' +
'Une fois un fournisseur enregistré et le serveur redémarré, les champs de contenu listés par chaque source de connaissances ' +
'sont envoyés à ce fournisseur pour chaque ligne retenue par la source, et le fournisseur les facture.',
},
},
keys: {
Expand Down
4 changes: 3 additions & 1 deletion packages/services/service-settings/src/translations/ja-JP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ export const jaJP: PlatformTranslationData = {
embedder: { title: 'Embedder',
description:
'ナレッジソースと RAG が使用するテキスト → ベクトルプロバイダー。' +
'上記のチャットプロバイダーとは独立しています。' },
'上記のチャットプロバイダーとは独立しています。' +
'プロバイダーを保存してサーバーを再起動すると、各ナレッジソースが列挙するコンテンツフィールドが、' +
'ソースに一致するすべての行についてこのプロバイダーに送信され、プロバイダーから課金されます。' },
},
keys: {
provider: {
Expand Down
2 changes: 1 addition & 1 deletion packages/services/service-settings/src/translations/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export const ko: PlatformTranslationData = {
titles: { title: '대화 제목', description: '새 대화에 짧은 요약 제목을 자동으로 만듭니다.' },
defaults: { title: '생성 기본값', description: '에이전트나 채팅 요청이 자체 값을 지정하지 않을 때 적용됩니다.' },
observability: { title: '관측성' },
embedder: { title: 'Embedder', description: '지식 소스와 RAG에 쓰는 텍스트→벡터 공급자입니다. 위의 채팅 공급자와는 별개입니다.' },
embedder: { title: 'Embedder', description: '지식 소스와 RAG에 쓰는 텍스트→벡터 공급자입니다. 위의 채팅 공급자와는 별개입니다. 공급자를 저장하고 서버를 다시 시작하면 각 지식 소스가 나열한 콘텐츠 필드가 해당 소스에 맞는 모든 행에 대해 이 공급자로 전송되며, 공급자가 이에 대해 요금을 청구합니다.' },
},
keys: {
provider: {
Expand Down
5 changes: 4 additions & 1 deletion packages/services/service-settings/src/translations/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,10 @@ export const ptBR: PlatformTranslationData = {
observability: { title: 'Observabilidade' },
embedder: {
title: 'Embedder',
description: 'Provedor de texto → vetor usado pelas fontes de conhecimento e pelo RAG. Independente do provedor de chat acima.',
description:
'Provedor de texto → vetor usado pelas fontes de conhecimento e pelo RAG. Independente do provedor de chat acima. ' +
'Depois de salvar um provedor e reiniciar o servidor, os campos de conteúdo listados por cada fonte de conhecimento ' +
'são enviados a este provedor para cada linha que a fonte abrange, e o provedor cobra por eles.',
},
},
keys: {
Expand Down
Loading
Loading