Skip to content
Open
13 changes: 13 additions & 0 deletions .changeset/38158-skill-knowledge-source-unmounted-adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@objectstack/skills': patch
'@objectstack/spec': patch
---

docs(skills): `objectstack-ai` names the save refusal of a `knowledge_source` whose `adapter` is not mounted

Clause-②: no
Metadata-protocol: none

`skills/objectstack-ai` § Knowledge Sources (RAG), the `adapter` row: a run-time save naming an adapter the deployment does not mount is refused (`400 VALIDATION_ERROR`, nothing written), naming the source, the adapter and the mounted ones. Fix: name a mounted adapter, or mount the store and save again.

`@objectstack/spec`: migration entry `knowledge-source-unmounted-adapter-refused-at-save` qualifies its `replacement`. Leaving `adapter` out places the source on the deployment's store, except on a host that mounts several adapters and marks none the deployment's, where a source with no `adapter` is itself refused: name a mounted adapter there. No behaviour changes.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,26 @@ describe('/packages — duplicate admits each knowledge source it copies for the
expect(s.admitAuthoredSource).toHaveBeenCalledWith(SOURCE_ITEM, caller.executionContext);
});

// The save refusal of a source whose `adapter` the deployment does not
// mount is a `400`, where the gates' own are `403`: the door answers the
// predicate's status and sentence, never one of its own.
it('a source naming an adapter the deployment does not mount refuses the duplicate 400 VALIDATION_ERROR with the save\'s sentence, and nothing is copied', async () => {
const UNMOUNTED = {
admitted: false, status: 400, code: 'VALIDATION_ERROR',
message: "The knowledge source \"faq\" was not saved: it names adapter 'ragflow', which this deployment does not mount (mounted: memory).",
};
const held = { ...SOURCE_ITEM, adapter: 'ragflow' };
const s = withKnowledge({ items: [held] }, () => UNMOUNTED);
const caller = authed(BOTH);
const r = await call(s, DUPLICATE, caller);
expect(r.response?.status).toBe(400);
expect(r.response?.body?.error?.code).toBe('VALIDATION_ERROR');
expect(r.response?.body?.error?.message).toContain('nothing was copied');
expect(r.response?.body?.error?.message).toContain(UNMOUNTED.message);
expect(s.protocol.duplicatePackage).not.toHaveBeenCalled();
expect(s.admitAuthoredSource).toHaveBeenCalledWith(held, caller.executionContext);
});

it('every source is asked about: the second one refused refuses the duplicate', async () => {
const second = { ...SOURCE_ITEM, name: 'handbook' };
const s = withKnowledge({ items: [SOURCE_ITEM, second] }, (item: any) => (item.name === 'handbook' ? REFUSAL : { admitted: true }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,53 @@ describe('admitAuthoredSource — source admission at save, as the authoring pri
});
});

// The refusal offers "leave `adapter` out" only where an omitted adapter
// would be placed (`adapterIdFor`): one adapter mounted, or the deployment's
// own adapter mounted. Elsewhere that remedy is itself refused at the save.
it('the refusal offers leaving `adapter` out only where an omitted adapter would be placed', async () => {
const LEAVE_OUT = 'leave `adapter` out';
const refusedFor = async (svc: KnowledgeService, adapter: string): Promise<string> => {
const verdict = await svc.admitAuthoredSource({ ...item('ticket', ['body']), adapter }, MANAGER);
expect(verdict, adapter).toMatchObject({ admitted: false, code: 'VALIDATION_ERROR', status: 400 });
return (verdict as { message: string }).message;
};
const mounting = (ids: string[], deploymentAdapter?: string): KnowledgeService => {
const svc = new KnowledgeService({ dataEngine: makeEngine([TICKET]), ...(deploymentAdapter ? { deploymentAdapter } : {}) });
for (const id of ids) svc.registerAdapter(id, makeAdapter());
return svc;
};

// One adapter mounted: an omitted adapter lands on it.
const one = await refusedFor(mounting(['memory']), 'ragflow');
expect(one).toContain(LEAVE_OUT);
expect(one).toContain("mount the 'ragflow' store");
// Two mounted, one of them the deployment's: an omitted adapter lands on that one.
const marked = await refusedFor(mounting(['memory', 'turso'], 'turso'), 'ragflow');
expect(marked).toContain(LEAVE_OUT);
expect(marked).toContain("'memory', 'turso'");

// Two mounted and none the deployment's: an omitted adapter is refused, so it is not offered.
const unmarked = await refusedFor(mounting(['memory', 'turso']), 'ragflow');
expect(unmarked).not.toContain(LEAVE_OUT);
expect(unmarked).toContain("'memory', 'turso'");
expect(unmarked).toContain("mount the 'ragflow' store");
// The deployment's adapter is named and not itself mounted: the same.
expect(await refusedFor(mounting(['memory', 'turso'], 'pgvector'), 'ragflow')).not.toContain(LEAVE_OUT);
// None mounted: nothing holds an omitted adapter, and no mounted id is offered either.
const none = await refusedFor(mounting([]), 'ragflow');
expect(none).not.toContain(LEAVE_OUT);
expect(none).not.toContain('name one of');
expect(none).toContain("Mount the 'ragflow' store");

// CONTROL: what the clause promises holds. Where it is offered the omitted
// adapter is admitted; where it is withheld (several, none marked) it is refused.
const { adapter: _named, ...omitted } = item('ticket', ['body']);
expect(await mounting(['memory']).admitAuthoredSource(omitted, MANAGER)).toEqual({ admitted: true });
expect(await mounting(['memory', 'turso'], 'turso').admitAuthoredSource(omitted, MANAGER)).toEqual({ admitted: true });
expect(await mounting(['memory', 'turso']).admitAuthoredSource(omitted, MANAGER))
.toMatchObject({ admitted: false, code: 'VALIDATION_ERROR', status: 400 });
});

it('CONTROL: a source naming a mounted adapter, and one that leaves `adapter` out, are admitted', async () => {
const { svc } = setup({ sources: [] });
svc.registerAdapter('turso', makeAdapter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const entry: SemanticMigration = {
+ 'deployment does not mount: a retired store such as `ragflow`, or a mistyped id',
replacement:
'An adapter id the deployment mounts (the refusal lists them), or no `adapter` at all, so the '
+ 'deployment\'s store holds the source; or mount the named store before saving the source.',
+ 'deployment\'s store holds the source (on a host that mounts several adapters and marks none the '
+ 'deployment\'s, a source with no `adapter` is itself refused, so name one there); or mount the named '
+ 'store before saving the source.',
reason:
'Such a source was stored, and then every index and search of it answered SERVICE_UNAVAILABLE (503) and '
+ 'the boot logged it at error. The save now refuses it, VALIDATION_ERROR (400), naming the source, the '
Expand Down
14 changes: 13 additions & 1 deletion scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,19 @@ export const CEILINGS = new Map([
// ceil(28590 / 4) = 7148; the row moves +242, the measured remainder only.
// Pinned AT the measurement.
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(28590 / 4)
['skills/objectstack-ai/SKILL.md', 7148],
// 7148 -> 7200 (2026-11-28, the unmounted-adapter save refusal): the
// `adapter` row named the refusal of an omitted adapter only; a run-time save
// naming an adapter the deployment does not mount is refused too
// (`400 VALIDATION_ERROR`, nothing written), and the row now says so with
// what the refusal names and the two remedies. Raise path the standing ruling
// 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). PAID DOWN
// FIRST: the row's "Optional" (its "Omitted:" clause says it). Arithmetic in
// priced bytes (stamp line excluded), against `main`'s 28590 (the row's 7148,
// headroom 0): the file is 28617 -> 28827 bytes, so the LANDED priced text is
// 28800 -> ceil(28800 / 4) = 7200; the row moves +52, the measured remainder
// only. Pinned AT the measurement.
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(28800 / 4)
['skills/objectstack-ai/SKILL.md', 7200],
// -12 (was 6331): the `http.server` decision-table row dropped a trailing
// clause that taught `contributes.routes` as a key that "parses but serves
// nothing". The key is retired — an authored entry is now REFUSED, carrying
Expand Down
2 changes: 1 addition & 1 deletion skills/objectstack-ai/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ object or field, when you may not search that object or query a field it reads.
|:----|:--------|
| `name` | Snake_case source name |
| `label` / `description` | Display metadata |
| `adapter` | Optional store id (`pgvector`, `turso`, `memory`). Omitted: the deployment's store (`pgvector` on PostgreSQL, `turso` otherwise), else the only one registered; several and none the deployment's is refused, naming them |
| `adapter` | Store id (`pgvector`, `turso`, `memory`). Omitted: the deployment's store (`pgvector` on PostgreSQL, `turso` otherwise), else the only one registered; several and none the deployment's is refused, naming them. A run-time save naming one the deployment does not mount is refused (`400 VALIDATION_ERROR`, nothing written), naming the source, the adapter and the mounted ones: name a mounted one, or mount the store and save again |
| `source.kind` | `'object'`, the one kind |
| `source.object` | The object whose records are indexed |
| `source.content` | Non-empty list of the fields whose text is indexed, in order. `'*'` is refused: it would also send fields added later. Never ids or system fields |
Expand Down
Loading