Skip to content

Commit f7252bc

Browse files
feat(service-knowledge): index_status and rebuild say when the knowledge service is held (#38796)
Part of #38369 (PR 3b, the server half of the card's part 3. PR 3a, #38786, shipped the CLI reading and the embedder help text. Item 6, the skill, is its own governed PR.) Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:没启用知识服务(缺嵌入模型或知识存储没挂上)的私有部署上,管理员查看知识库状态时,第一行写明未启用、几个知识源被挂起、原因和怎么补,每个知识源显示「挂起」,不再误报「需要重建」;手动重建会被直接拒绝并给出补救办法。没有知识服务的部署,启动日志里的补救说明也补上了「保存嵌入模型后再重启一次」这一步。 - 为什么做:知识服务「挂载不等于启用」那张卡的最后一块代码,让管理员看得见服务为什么没生效;同时修正了上一张 PR 审核时留下的三处小问题。 - 出错会怎样:只影响状态查询和手动重建的回答,以及一行启动日志;已启用的部署和宿主自己挂载知识服务的部署回答不变。撤回这次合并即可恢复。 - 要你做什么:无。 ## What changes - **`index_status`, while the service is held** (`knowledge-build-actions.ts`): each source's index reads the new state `held` (`heldIndexReading` in `knowledge-build.ts`: not due, with one sentence), and the store is **not** asked what it holds. On `main` a held read called the store adapter's `indexStatus` once per source, through `KnowledgeService.readIndexState`, and could answer "it is built anew" for a build that nothing would run. The answer gains `enablement` (`state: 'not-enabled'`, the `reason` naming each missing half and its remedy, `embedder` / `store`, `heldSources`), and its message leads with the reason and the held count. A service a host mounts itself, and an enabled one, answer exactly as before. - **`rebuild`, while held**: the service's own refusal of the build (`heldSourcesError` in `rebuildSource`) is now answered as a refusal (`ok: false`, which the settings door answers 400): `Rebuild of source 'X' is refused: [knowledge] the knowledge service is not enabled on this deployment: ... To enable it, save an embedder provider, then restart.` Before, it was answered `ok` as "was not started". No second refusal path is added: the action reads `heldReading()` only after `rebuildSource` threw. - `KnowledgeBuildActionsService` gains `heldReading` as an **optional** member, so a caller's own service double still fits. - **Carry-overs from the PR 2 contract review** (record 7257422588, routed here by L1 record 7257956376): - N1: `knowledge-settings-contribution.test.ts`. The "no identity" assertion now passes `null`, because `undefined` hit the helper's default parameter and repeated the author's case. It asserts the held `503 SERVICE_UNAVAILABLE`, which pins that the held refusal comes ahead of the identity check. - N2: the `admitAuthoredSource` jsdoc in `knowledge-service.ts` now says that `door` also decides whether the held refusal applies. - N6: `packages/objectql/src/knowledge-source-unserved.ts`. The boot line of a deployment that holds `knowledge_source` items and runs no knowledge service now names the embedder step its save refusal already names: `Declare requires: ['knowledge'] in the stack and restart, then save an embedder provider and restart again`. This makes `knowledge-rag.mdx`'s "and the same fix" true again. - **Docs**: `content/docs/protocol/knowledge.mdx` gets the sentence that PR 3a dropped (it conflicted with #38730, which has since merged), now saying what both actions answer while held. ## Tests - New `packages/services/service-knowledge/src/__tests__/held-status-38369.test.ts`. Both actions run through the settings service's action door on a kernel running the plugin as the runtime composes it: - the not-enabled `enablement` with its reason, the embedder half and the held count; - both halves at once; - a host-mounted service and an enabled one answer no `enablement` and the old message; - a held rebuild is refused with the remedy and no store call; - an enabled rebuild is not refused. - On a service with a data engine bound and a counting store, while held: the index reads `held`, not due, with no "built anew", and **0 `indexStatus` calls**. Control, enabled: the same store is asked once (`new-fingerprint`). - `knowledge-source-unserved.test.ts` pins the embedder step in the boot line. ## Acceptance notes - N2's other stale lines are in `packages/metadata-core/src/knowledge-source-save-admission.ts`: `noKnowledgeServiceRefusal`'s "the token, a restart, then the save" at :185, and the door docs at :84 and :115. That file is outside this claim's surface, so they are left for a follow-up. - The `new-fingerprint` detail "it is built anew" stays as it is for an enabled service, where it is true. While held, that reading is no longer produced. ## Verification <details><summary>Local runs at 142f3f6 (base c8b1dbb)</summary> - `pnpm --filter @objectstack/service-knowledge test`: 29 files, 879 passed. `typecheck` exit 0 (it includes `check:test-typecheck`). - `pnpm --filter @objectstack/objectql exec vitest run src/knowledge-source-unserved.test.ts`: 7 passed. `pnpm --filter @objectstack/objectql typecheck`: exit 0. - Ablation 1: with `index_status` reading the store while held (the fix reverted), "held, the store mounted: ... the store is never called" fails (1 failed / 6 passed). - Ablation 2: with the held branch disabled (`heldOf` answering `undefined`), the four held pins fail (4 failed / 3 passed). Both restored; tree clean. - `dispatch-gates --ran`: 105 derived, 102 exit 0, 3 NOT MEASURED: - `check:skill-examples`: no client-react dist; - `check:dual-build-cjs-loads`: no scenarios/studio dist; - `check:type-check-debt`: its `--re-measure` starts a whole-workspace build beyond the 10-minute cap; stopped, and CI runs it. - eslint over the changed `.ts` files: exit 0. `overlap-check` against `origin/main` 6cc2024 (with #38786 merged): clean; #38791 merges cleanly. </details> Two-minute check: `pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/held-status-38369.test.ts` should report 7 passed. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6cc2024 commit f7252bc

9 files changed

Lines changed: 393 additions & 28 deletions

File tree

‎.changeset/38369-held-status.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/service-knowledge': patch
3+
'@objectstack/objectql': patch
4+
---
5+
6+
feat(service-knowledge): index_status and rebuild say when the knowledge service is held
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
While the boot read a knowledge service the runtime composed as not enabled (no embedder, or the deployment's store not mounted), the `knowledge` settings actions say so. `index_status` answers each source's index as the new state `held` (not due) without asking its store, adds `enablement` — `state: 'not-enabled'`, the `reason` naming each missing half and its remedy, `embedder` / `store` for the missing halves, and `heldSources` — and its message leads with the reason and the held count. `rebuild` is refused (`ok: false`, which the settings door answers 400) with the service's own sentence: "Rebuild of source 'X' is refused: … To enable it, save an embedder provider, then restart." `os knowledge rebuild` exits 1 with that sentence. A service a host mounts itself, and an enabled one, answer exactly as before.
12+
13+
The boot line of a deployment that holds `knowledge_source` items and runs no knowledge service now names the embedder step its save refusal already names: declare `requires: ['knowledge']`, restart, then save an embedder provider and restart again.

‎content/docs/protocol/knowledge.mdx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ no `search_knowledge` definition is handed out; `search`, `rebuildSource` and
225225
`reindexSource` answer `503 SERVICE_UNAVAILABLE` naming the missing half; a
226226
removed source keeps its index, and no store is called. The boot logs one line,
227227
`info` when only a shipped source mounted the service and nothing was saved,
228-
`warn` otherwise, and never refuses to start. A change takes effect at the next
228+
`warn` otherwise, and never refuses to start. The settings `index_status`
229+
action answers each held source's index as `held`, without reading its store,
230+
and adds `enablement`: not enabled, the reason with its remedy, and how many
231+
sources are held. The `rebuild` action refuses the build with the same remedy,
232+
and `os knowledge rebuild` exits 1 with it. A change takes effect at the next
229233
restart. A host-mounted service is not read this way and serves from the start.
230234

231235
#### How a source is loaded

‎packages/objectql/src/knowledge-source-unserved.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ describe('describeUnservedKnowledgeSources — items with no knowledge service (
2323
expect(line).toContain('or remove the item.');
2424
// The remedy an author's save on such a deployment is refused with: the token, then a restart.
2525
expect(line).toContain("Declare requires: ['knowledge'] in the stack and restart");
26+
// [ADR-0161 K8, the dated note on item 12] ...and, as the save's remedy does, the embedder step: the
27+
// service the token mounts is held until a provider is saved and the server restarted once more.
28+
expect(line).toContain("in the stack and restart, then save an embedder provider and restart again");
2629
});
2730

2831
it(`names at most ${UNSERVED_KNOWLEDGE_SOURCES_NAMED} items, counts the rest, and says a name two packages hold once`, () => {

‎packages/objectql/src/knowledge-source-unserved.ts‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
* The remedy it names is the one an author's save is refused with on such a
2121
* deployment (`authoredKnowledgeSourceRefusal`, `@objectstack/metadata-core`):
2222
* `requires: ['knowledge']` in the stack, then a restart, since the service is
23-
* composed at boot and never while the process runs. The items this line
23+
* composed at boot and never while the process runs; then an embedder
24+
* provider saved and one more restart, since a service the stack requires is
25+
* enabled only with an embedder, and its embedder settings exist only once
26+
* the service is mounted (ADR-0161 K8, the dated note on item 12). The items this line
2427
* finds are ones the stack does not ship, since a `knowledgeSources` entry
2528
* mounts the service by itself: they arrived by the engine's own write,
2629
* which is never refused (a package
@@ -56,14 +59,16 @@ export function describeUnservedKnowledgeSources(names: readonly string[], servi
5659
}
5760

5861
/**
59-
* What mounts the service for an item on a deployment that runs none: the
60-
* token (or the plugin, for a host that composes its own kernel), then a
61-
* restart. The same remedy an author's save there is refused with.
62+
* What mounts the service for an item on a deployment that runs none and
63+
* serves the item: the token (or the plugin, for a host that composes its own
64+
* kernel), a restart, then an embedder provider and one more restart. The
65+
* same remedy an author's save there is refused with.
6266
*/
6367
const UNSERVED_REMEDY =
64-
"Declare requires: ['knowledge'] in the stack and restart — the service and the deployment's store are mounted " +
65-
'at boot, never while the process runs — or, on a host that composes its own kernel, add KnowledgeServicePlugin ' +
66-
'(@objectstack/service-knowledge) and a knowledge store;';
68+
"Declare requires: ['knowledge'] in the stack and restart, then save an embedder provider and restart again — " +
69+
"the service and the deployment's store are mounted at boot, never while the process runs, and the service the " +
70+
'stack requires serves only once an embedder is configured — or, on a host that composes its own kernel, add ' +
71+
'KnowledgeServicePlugin (@objectstack/service-knowledge) and a knowledge store;';
6772

6873
/** What {@link announceUnservedKnowledgeSources} reads of its host. */
6974
export interface UnservedKnowledgeSourcesHost {
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* [ADR-0161 K8, the dated note on item 12] The administrator's two knowledge
5+
* actions say when the service is held. While the boot read a service the
6+
* runtime composed as not enabled (no embedder, or the deployment's store not
7+
* mounted):
8+
*
9+
* - `index_status` answers what it answers otherwise, plus `enablement` — the
10+
* state, the reason with its remedy, the missing halves and how many
11+
* sources are held — and its message leads with the state;
12+
* - `rebuild` is refused (`ok: false`, which the settings door answers 400)
13+
* with the service's own refusal of the build, naming the remedy, and no
14+
* store is called.
15+
*
16+
* A service a host mounts itself, and an enabled one, answer as they always
17+
* did: no `enablement`, the same message. The actions are run the way the
18+
* settings page and `os knowledge status` / `os knowledge rebuild` reach
19+
* them: through the settings service's action door.
20+
*
21+
* While held, `index_status` answers each source's index as `held` without
22+
* asking its store: a held service calls no store, and a reading of the
23+
* store would say a build is due that nothing will run.
24+
*/
25+
26+
import { createHash } from 'node:crypto';
27+
import { describe, it, expect } from 'vitest';
28+
import { LiteKernel } from '@objectstack/core';
29+
import type { Plugin, PluginContext } from '@objectstack/core';
30+
import { EMBEDDER_SERVICE, KNOWLEDGE_SERVICE } from '@objectstack/spec/contracts';
31+
import type { KnowledgeSource } from '@objectstack/spec/ai';
32+
import type { IEmbedder, IKnowledgeAdapter } from '@objectstack/spec/contracts';
33+
import { SettingsServicePlugin, type CryptoAdapter, type SettingsService } from '@objectstack/service-settings';
34+
import { KnowledgeServicePlugin } from '../knowledge-service-plugin.js';
35+
import { KnowledgeService } from '../knowledge-service.js';
36+
import { knowledgeIndexStatusActionHandler, type KnowledgeIndexStatusEnablement } from '../knowledge-build-actions.js';
37+
38+
/** The settings service stores the embedder key only through an adapter that declares confidentiality. */
39+
class ConfidentialTestAdapter implements CryptoAdapter {
40+
readonly confidential = true;
41+
async encrypt(plaintext: string): Promise<string> {
42+
return 'kms:' + Buffer.from(plaintext, 'utf8').toString('base64');
43+
}
44+
async decrypt(ciphertext: string): Promise<string> {
45+
return Buffer.from(ciphertext.replace(/^kms:/, ''), 'base64').toString('utf8');
46+
}
47+
digest(plaintext: string): string {
48+
return createHash('sha256').update(plaintext).digest('hex');
49+
}
50+
}
51+
52+
/** The deployment's store (`id`), counting every call made to it. */
53+
class CountingStorePlugin implements Plugin {
54+
name = 'test.knowledge.counting-store';
55+
version = '1.0.0';
56+
type = 'standard' as const;
57+
dependencies = ['com.objectstack.service.knowledge'];
58+
constructor(private readonly storeId: string, private readonly calls: string[]) {}
59+
async init(): Promise<void> {}
60+
async start(ctx: PluginContext): Promise<void> {
61+
const calls = this.calls;
62+
const adapter: IKnowledgeAdapter = {
63+
id: this.storeId,
64+
async upsert() {
65+
calls.push('upsert');
66+
},
67+
async search() {
68+
calls.push('search');
69+
return [];
70+
},
71+
async delete() {
72+
calls.push('delete');
73+
},
74+
async dropSource() {
75+
calls.push('dropSource');
76+
},
77+
};
78+
ctx.getService<KnowledgeService>(KNOWLEDGE_SERVICE).registerAdapter(this.storeId, adapter);
79+
}
80+
}
81+
82+
/** A host's own embedder, registered at `init`. */
83+
class HostEmbedderPlugin implements Plugin {
84+
name = 'test.host-embedder';
85+
version = '1.0.0';
86+
type = 'standard' as const;
87+
async init(ctx: PluginContext): Promise<void> {
88+
const embedder: IEmbedder = { id: 'host-own', dimensions: 2, embed: async (t) => t.map(() => [0.6, 0.8]) };
89+
ctx.registerService(EMBEDDER_SERVICE, embedder);
90+
}
91+
}
92+
93+
const SOURCES: KnowledgeSource[] = [
94+
{ name: 'docs', label: 'Docs', source: { kind: 'object', object: 'doc', content: ['body'] } },
95+
{ name: 'faq', label: 'FAQ', source: { kind: 'object', object: 'faq', content: ['answer'] } },
96+
];
97+
98+
async function boot(opts: {
99+
/** Set ⇒ the runtime composed the service (`resolveCapabilityArgument`). */
100+
runtimeComposed?: { declared: boolean };
101+
/** Whether the deployment's store registers its adapter. @default true */
102+
storeMounted?: boolean;
103+
/** Whether a host plugin registers an embedder. @default false */
104+
hostEmbedder?: boolean;
105+
}) {
106+
const calls: string[] = [];
107+
const kernel = new LiteKernel();
108+
if (opts.hostEmbedder) kernel.use(new HostEmbedderPlugin());
109+
kernel.use(new KnowledgeServicePlugin({
110+
enableEventSync: false,
111+
buildAtBoot: false,
112+
reconcile: false,
113+
deploymentAdapter: 'vec',
114+
...(opts.runtimeComposed ? { runtimeComposed: opts.runtimeComposed } : {}),
115+
sources: SOURCES,
116+
}));
117+
kernel.use(new SettingsServicePlugin({ env: {}, registerRoutes: false, crypto: new ConfidentialTestAdapter() }));
118+
if (opts.storeMounted !== false) kernel.use(new CountingStorePlugin('vec', calls));
119+
await kernel.bootstrap();
120+
const knowledge = kernel.getService<KnowledgeService>(KNOWLEDGE_SERVICE);
121+
const settings = kernel.getService<SettingsService>('settings');
122+
const run = (action: 'index_status' | 'rebuild', payload: unknown) => settings.runAction('knowledge', action, payload);
123+
return { kernel, knowledge, calls, run };
124+
}
125+
126+
const enablementOf = (details: unknown): KnowledgeIndexStatusEnablement | undefined =>
127+
(details as { enablement?: KnowledgeIndexStatusEnablement }).enablement;
128+
129+
describe('[ADR-0161 K8, note on item 12] index_status states a held service: not enabled, why, how many sources', () => {
130+
it('no embedder: the state, the reason naming the remedy, the embedder half and every held source', async () => {
131+
const { knowledge, run, calls } = await boot({ runtimeComposed: { declared: false } });
132+
expect(knowledge.heldReading()).toBeDefined();
133+
134+
const answer = await run('index_status', {});
135+
expect(answer.ok).toBe(true);
136+
const enablement = enablementOf(answer.details);
137+
expect(enablement).toEqual({
138+
state: 'not-enabled',
139+
reason: expect.stringMatching(/^\[knowledge\] the knowledge service is not enabled on this deployment: no embedder is configured/),
140+
embedder: expect.stringContaining('ai.embedder_provider'),
141+
heldSources: 2,
142+
});
143+
expect(enablement?.reason).toContain('To enable it, save an embedder provider, then restart.');
144+
expect(enablement?.reason).not.toContain('knowledge store');
145+
// The message leads with the state and counts the held sources.
146+
expect(answer.message).toBe(`${enablement?.reason} 2 source(s) held.`);
147+
// Every source is still listed, as on an enabled service.
148+
expect((answer.details as { sources: Array<{ id: string }> }).sources.map((s) => s.id)).toEqual(['docs', 'faq']);
149+
150+
// One source named: its entry alone, and the service's held count all the same.
151+
const one = await run('index_status', { source: 'docs' });
152+
expect((one.details as { sources: Array<{ id: string }> }).sources.map((s) => s.id)).toEqual(['docs']);
153+
expect(enablementOf(one.details)?.heldSources).toBe(2);
154+
expect(calls).toEqual([]);
155+
});
156+
157+
it("the store not mounted as well: both halves, and the reason names the store's remedy", async () => {
158+
const { run } = await boot({ runtimeComposed: { declared: false }, storeMounted: false });
159+
const enablement = enablementOf((await run('index_status', {})).details);
160+
expect(enablement).toMatchObject({ state: 'not-enabled', store: 'vec', embedder: expect.any(String), heldSources: 2 });
161+
expect(enablement?.reason).toContain("the deployment's knowledge store 'vec' is not mounted");
162+
expect(enablement?.reason).toContain("save an embedder provider and mount the deployment's knowledge store, then restart.");
163+
});
164+
165+
it('a host-mounted service with no embedder, and an enabled runtime-composed one, answer no enablement and the same message', async () => {
166+
for (const opts of [{}, { runtimeComposed: { declared: false }, hostEmbedder: true }]) {
167+
const { knowledge, run } = await boot(opts);
168+
expect(knowledge.heldReading(), JSON.stringify(opts)).toBeUndefined();
169+
const answer = await run('index_status', {});
170+
expect(answer.ok).toBe(true);
171+
expect(Object.keys(answer.details as object), JSON.stringify(opts)).not.toContain('enablement');
172+
expect(answer.message, JSON.stringify(opts)).toMatch(/^2 source\(s\): \d+ need a build, 0 building, 0 with failed syncs\.$/);
173+
}
174+
});
175+
});
176+
177+
describe('[ADR-0161 K8, note on item 12] rebuild is refused on a held service, with the remedy', () => {
178+
it("refused (ok: false), the service's own sentence naming the remedy, and no store is called", async () => {
179+
const { run, calls } = await boot({ runtimeComposed: { declared: false } });
180+
const answer = await run('rebuild', { source: 'docs' });
181+
expect(answer).toMatchObject({ ok: false, severity: 'error', details: { source: 'docs', build: null } });
182+
expect(answer.message).toMatch(
183+
/^Rebuild of source 'docs' is refused: \[knowledge\] the knowledge service is not enabled on this deployment: no embedder is configured/,
184+
);
185+
expect(answer.message).toContain('To enable it, save an embedder provider, then restart.');
186+
expect(calls).toEqual([]);
187+
});
188+
189+
it('an enabled runtime-composed service is not refused', async () => {
190+
const { run } = await boot({ runtimeComposed: { declared: false }, hostEmbedder: true });
191+
const answer = await run('rebuild', { source: 'docs' });
192+
expect(answer.message ?? '').not.toContain('is refused');
193+
expect(answer.message ?? '').not.toContain('not enabled');
194+
});
195+
});
196+
197+
describe('[ADR-0161 K8, note on item 12] a held index_status asks no store what it holds', () => {
198+
/** A service with a data engine bound, so its index reading reaches the store; the store counts every call. */
199+
function service(held: boolean) {
200+
const calls: string[] = [];
201+
const dataEngine = { find: async () => [], findOne: async () => null, count: async () => 0 } as never;
202+
const knowledge = new KnowledgeService({ dataEngine, deploymentAdapter: 'vec', enabledByConfiguration: true });
203+
const adapter: IKnowledgeAdapter = {
204+
id: 'vec',
205+
async upsert() { calls.push('upsert'); },
206+
async search() { calls.push('search'); return []; },
207+
async delete() { calls.push('delete'); },
208+
async indexStatus() {
209+
calls.push('indexStatus');
210+
return { fingerprint: 'built-under-another-model', recipeHash: 'r' };
211+
},
212+
};
213+
knowledge.registerAdapter('vec', adapter);
214+
knowledge.registerSource(SOURCES[0]!);
215+
knowledge.settleEnablement(held ? { embedder: 'ai.embedder_provider is not saved' } : undefined);
216+
const status = knowledgeIndexStatusActionHandler(knowledge);
217+
const read = () => status({ namespace: 'knowledge', actionId: 'index_status', values: {}, payload: {}, ctx: {} } as never);
218+
return { calls, read };
219+
}
220+
221+
it('held, the store mounted: the index reads held, not due, and the store is never called', async () => {
222+
const { calls, read } = service(true);
223+
const answer = await read();
224+
const [entry] = (answer.details as { sources: Array<{ index: { state: string; due: boolean; detail: string } }> }).sources;
225+
expect(entry?.index).toMatchObject({ state: 'held', due: false });
226+
expect(entry?.index.detail).toMatch(/^held: the knowledge service is not enabled on this deployment/);
227+
expect(entry?.index.detail).not.toContain('built anew');
228+
expect(calls).toEqual([]);
229+
});
230+
231+
it('control: enabled, the same store is asked once per source, as it always was', async () => {
232+
const { calls, read } = service(false);
233+
const answer = await read();
234+
const [entry] = (answer.details as { sources: Array<{ index: { state: string } }> }).sources;
235+
expect(entry?.index.state).toBe('new-fingerprint');
236+
expect(calls).toEqual(['indexStatus']);
237+
});
238+
});

‎packages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,9 @@ describe('[ADR-0161 K8, note on item 12] a runtime-composed knowledge service is
10121012
// The engine's own write (a package install, a seed) is admitted, and nothing calls the store.
10131013
expect(await admit(knowledge, SYSTEM)).toEqual({ admitted: true });
10141014
// A save with no identity is refused for the held state first: it names the deployment, not the caller.
1015-
expect((await admit(knowledge, undefined)).message).toContain(HELD);
1015+
// `null`, not `undefined`: `admit`'s default parameter would read `undefined` as the author's identity.
1016+
expect(await admit(knowledge, null)).toMatchObject({ admitted: false, status: 503, code: 'SERVICE_UNAVAILABLE' });
1017+
expect((await admit(knowledge, null)).message).toContain(HELD);
10161018
expect(calls).toEqual([]);
10171019
});
10181020

0 commit comments

Comments
 (0)