Skip to content

Commit 7971d24

Browse files
docs(skills): objectstack-ai names the save refusal of a knowledge_source whose adapter is not mounted (#38224)
Fixes #38158 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:给 AI 编程助手看的知识源技能文档里,「存储」那一行多了一句:保存时指定了本部署没挂载的存储会被当场拒绝,以及两种修法;升级说明里「不写存储」那句补上了限定条件。运行行为不变。 - 为什么做:属于「知识检索」这条线的收尾,替写知识源的作者和 AI 助手解决「照文档写却被拒绝」的问题。 - 出错会怎样:只是文档措辞和测试,最坏是这句话写得不准;可以直接撤回,不影响任何已保存的数据。 - 要你做的:这个改动碰了对外发布的技能文档,需要按规定的审核流程放行落地。 ## What changes 1. `skills/objectstack-ai/SKILL.md` § Knowledge Sources, the `adapter` row. It named the refusal of an omitted adapter only. It now also says that 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, with the two remedies that always hold: name a mounted one, or mount the store and save again. Worded from `unmountedAdapterSaveText` in `packages/services/service-knowledge/src/knowledge-service.ts`. 2. Pins, no behaviour change: - `knowledge-source-admission.test.ts`: the "leave `adapter` out" remedy is offered with one adapter mounted and with the deployment's adapter mounted; it is withheld with two mounted and none marked, with a deployment adapter that is not itself mounted, and with none mounted. A control asserts what the clause promises: the omitted adapter is admitted where the remedy is offered and refused where it is withheld. - `packages-knowledge-source-gate.test.ts`: the package-duplicate door answers this refusal `400` with `error.code` `VALIDATION_ERROR` and the save's own sentence, and copies nothing. 3. Migration entry `knowledge-source-unmounted-adapter-refused-at-save`: its `replacement` now qualifies "no `adapter` at all": 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. 4. `scripts/check-skills-token-ratchet.mjs`: the `skills/objectstack-ai/SKILL.md` row moves 7148 to 7200, pinned at the measurement taken on this head, which carries `main` 333e6f3 (with PR #38292, which moved the same row 6906 to 7148). 5. Changeset: `@objectstack/skills` patch and `@objectstack/spec` patch (the entry's text ships in the upgrade guide). The two test files publish nothing, so `@objectstack/service-knowledge` and `@objectstack/runtime` take none. ### Skill size readings Raise path: the standing ruling 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). Paid down first, in the same file: the row's "Optional" (its "Omitted:" clause already says the key may be left out). | Reading | Before (`main` 333e6f3) | After (head e3e2fab) | |:---|---:|---:| | `skills/objectstack-ai/SKILL.md`, lines | 505 | 505 | | `skills/objectstack-ai/SKILL.md`, bytes | 28617 | 28827 | | `skills/objectstack-ai/SKILL.md`, tokens (priced bytes, stamp line excluded: 28590 to 28800) | 7148 | 7200 | | All `skills/*/SKILL.md`, lines | 4956 | 4956 | | Ratcheted bundle, tokens | 200068 | 200120 | The row moves +52, the measured remainder only: `ceil(28800 / 4) = 7200`. The merge of `main` 333e6f3 conflicted on this row only; it was resolved by keeping `main`'s 7148 note and adding this PR's note above the re-measured row. ## Why PR #38060 added the save refusal and the migration entry. Its contract review left three follow-ups: the published skill did not teach the refusal, the remedy branches of the refusal text and the duplicate door's answer had no pin, and the entry's `replacement` offered a remedy that is itself refused on one kind of host. ## Tests Read first, by risk: 1. `skills/objectstack-ai/SKILL.md`, the `adapter` row: published text; check it against `unmountedAdapterSaveText`. 2. `packages/spec/src/migrations/entries/semantic/19.knowledge-source-unmounted-adapter-refused-at-save.ts`, `replacement`: shipped upgrade-guide text. 3. `scripts/check-skills-token-ratchet.mjs`, the new note above the row: the arithmetic. Two-minute check: `pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/knowledge-source-admission.test.ts -t 'offers leaving'` prints 1 passed. The two edited test files, `check-skills-token-ratchet` (gate and self-test) and `check:skill-docs` were re-run on head `92cc3cd391` (the first head, the row re-pin, and merges of `main` up to bd5407e). Heads `f75d35a017` and `f2f00af325` add clean merges of `main` (98bd8de, which lowers the `objectstack-ui` row, then f19350b), and head `e3e2fab53f` merges `main` 333e6f3 with the one ratchet-row conflict resolved as above. The second carries #38208 (898b056), which edits `packages/runtime/src/domains/packages-knowledge-source-gate.test.ts` (also edited here, in other hunks; git merged them without a hand) and `packages/runtime/src/domains/packages.ts` and `packages/metadata-core/src/knowledge-source-save-admission.ts`, which this PR's duplicate-door pin exercises. On `f2f00af325` and `e3e2fab53f` only the ratchet gate and its self-test were re-run locally (exit 0); the edited tests on the merged tree are read from this head's `Test Core`. The ablation, the 121-family gate list and the package-wide runs below were read on the first head `d9c88726c4`, before those merges. <details><summary>Edited test files</summary> ``` pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2 src/__tests__/knowledge-source-admission.test.ts Test Files 1 passed (1) Tests 89 passed (89) pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/packages-knowledge-source-gate.test.ts Test Files 1 passed (1) Tests 75 passed (75) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Ablation: the pins go red when the branch or the mapping is reverted</summary> Each mutation was applied with `scripts/ablation-replace.mjs` (anchor hit once, restore verified as blob equal to HEAD and an empty `git diff HEAD`). Both subjects are imported from `src`, so no `dist` leg applies. | Mutation | Result | |:---|:---| | `placeable = true` (always offer the remedy) | 1 failed: expected the message not to contain "leave `adapter` out" | | `placeable = false` (never offer it) | 1 failed: expected the message to contain "leave `adapter` out" | | `placeable = deployment !== undefined OR mounted.length === 1` (drop the "deployment's adapter is mounted" test) | 1 failed: expected the message not to contain "leave `adapter` out" | | `packages.ts`: the duplicate door answers a fixed `403` in place of `refused.status` | 1 failed: expected 403 to be 400 | </details> ## Acceptance notes - The skill row omits the third remedy the runtime may print ("leave `adapter` out"): it is conditional, and the row's own "Omitted:" clause already states where an omitted adapter is placed and where it is refused. - The duplicate door passes the refusal's status and sentence; the `VALIDATION_ERROR` code on its answer is derived from the `400`, not copied from the refusal's own `code`. The two agree for every refusal the predicate answers today. Noted, not filed. ## Verification - Derived gate list (`node scripts/pm/dispatch-gates.mjs --commands`, 121 families) run on `d9c88726c4`: 119 exit 0. Among them `check-skills-token-ratchet` ("61 authored bundle file(s) within their ceilings"), `check:skill-docs`, `check:skill-refs`, `check:skill-links`, `check:skill-identifier-liveness`, `check:spec-changes`, `check:upgrade-guide`, `check:doc-authoring`, `check:nul-bytes`, `check:cross-package-test-inputs`. - NOT MEASURED locally, both a missing prerequisite and not a red: `check:dual-build-cjs-loads` (exit 3, "PREREQUISITE NOT MET", it needs every package built) and the CLI file `test/migrate-meta-engine-guidance.test.ts` (its global setup could not load the unbuilt CLI closure). CI reads both. - Under the verify lock on `d9c88726c4`, `VERDICT command-exit 0`: `pnpm --filter @objectstack/service-knowledge test` (Test Files 19 passed, Tests 683 passed), `typecheck` of `@objectstack/service-knowledge`, `@objectstack/runtime` and `@objectstack/spec`, and the spec migration suites (`vitest run src/migrations`: Test Files 5 passed, Tests 207 passed). - Declared narrowing: the runtime and spec packages ran the files this diff touches or feeds, not their whole suites; `test:repo` was not run. CI's `Test Core` carries those. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` is CI's reading. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: `check:generated` families ran green; nothing to regenerate. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_ <!-- signed: repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e9002d6 commit 7971d24

6 files changed

Lines changed: 97 additions & 3 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/skills': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
docs(skills): `objectstack-ai` names the save refusal of a `knowledge_source` whose `adapter` is not mounted
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
`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.
12+
13+
`@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.

‎packages/runtime/src/domains/packages-knowledge-source-gate.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,26 @@ describe('/packages — duplicate admits each knowledge source it copies for the
253253
expect(s.admitAuthoredSource).toHaveBeenCalledWith(SOURCE_ITEM, caller.executionContext);
254254
});
255255

256+
// The save refusal of a source whose `adapter` the deployment does not
257+
// mount is a `400`, where the gates' own are `403`: the door answers the
258+
// predicate's status and sentence, never one of its own.
259+
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 () => {
260+
const UNMOUNTED = {
261+
admitted: false, status: 400, code: 'VALIDATION_ERROR',
262+
message: "The knowledge source \"faq\" was not saved: it names adapter 'ragflow', which this deployment does not mount (mounted: memory).",
263+
};
264+
const held = { ...SOURCE_ITEM, adapter: 'ragflow' };
265+
const s = withKnowledge({ items: [held] }, () => UNMOUNTED);
266+
const caller = authed(BOTH);
267+
const r = await call(s, DUPLICATE, caller);
268+
expect(r.response?.status).toBe(400);
269+
expect(r.response?.body?.error?.code).toBe('VALIDATION_ERROR');
270+
expect(r.response?.body?.error?.message).toContain('nothing was copied');
271+
expect(r.response?.body?.error?.message).toContain(UNMOUNTED.message);
272+
expect(s.protocol.duplicatePackage).not.toHaveBeenCalled();
273+
expect(s.admitAuthoredSource).toHaveBeenCalledWith(held, caller.executionContext);
274+
});
275+
256276
it('every source is asked about: the second one refused refuses the duplicate', async () => {
257277
const second = { ...SOURCE_ITEM, name: 'handbook' };
258278
const s = withKnowledge({ items: [SOURCE_ITEM, second] }, (item: any) => (item.name === 'handbook' ? REFUSAL : { admitted: true }));

‎packages/services/service-knowledge/src/__tests__/knowledge-source-admission.test.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,53 @@ describe('admitAuthoredSource — source admission at save, as the authoring pri
10631063
});
10641064
});
10651065

1066+
// The refusal offers "leave `adapter` out" only where an omitted adapter
1067+
// would be placed (`adapterIdFor`): one adapter mounted, or the deployment's
1068+
// own adapter mounted. Elsewhere that remedy is itself refused at the save.
1069+
it('the refusal offers leaving `adapter` out only where an omitted adapter would be placed', async () => {
1070+
const LEAVE_OUT = 'leave `adapter` out';
1071+
const refusedFor = async (svc: KnowledgeService, adapter: string): Promise<string> => {
1072+
const verdict = await svc.admitAuthoredSource({ ...item('ticket', ['body']), adapter }, MANAGER);
1073+
expect(verdict, adapter).toMatchObject({ admitted: false, code: 'VALIDATION_ERROR', status: 400 });
1074+
return (verdict as { message: string }).message;
1075+
};
1076+
const mounting = (ids: string[], deploymentAdapter?: string): KnowledgeService => {
1077+
const svc = new KnowledgeService({ dataEngine: makeEngine([TICKET]), ...(deploymentAdapter ? { deploymentAdapter } : {}) });
1078+
for (const id of ids) svc.registerAdapter(id, makeAdapter());
1079+
return svc;
1080+
};
1081+
1082+
// One adapter mounted: an omitted adapter lands on it.
1083+
const one = await refusedFor(mounting(['memory']), 'ragflow');
1084+
expect(one).toContain(LEAVE_OUT);
1085+
expect(one).toContain("mount the 'ragflow' store");
1086+
// Two mounted, one of them the deployment's: an omitted adapter lands on that one.
1087+
const marked = await refusedFor(mounting(['memory', 'turso'], 'turso'), 'ragflow');
1088+
expect(marked).toContain(LEAVE_OUT);
1089+
expect(marked).toContain("'memory', 'turso'");
1090+
1091+
// Two mounted and none the deployment's: an omitted adapter is refused, so it is not offered.
1092+
const unmarked = await refusedFor(mounting(['memory', 'turso']), 'ragflow');
1093+
expect(unmarked).not.toContain(LEAVE_OUT);
1094+
expect(unmarked).toContain("'memory', 'turso'");
1095+
expect(unmarked).toContain("mount the 'ragflow' store");
1096+
// The deployment's adapter is named and not itself mounted: the same.
1097+
expect(await refusedFor(mounting(['memory', 'turso'], 'pgvector'), 'ragflow')).not.toContain(LEAVE_OUT);
1098+
// None mounted: nothing holds an omitted adapter, and no mounted id is offered either.
1099+
const none = await refusedFor(mounting([]), 'ragflow');
1100+
expect(none).not.toContain(LEAVE_OUT);
1101+
expect(none).not.toContain('name one of');
1102+
expect(none).toContain("Mount the 'ragflow' store");
1103+
1104+
// CONTROL: what the clause promises holds. Where it is offered the omitted
1105+
// adapter is admitted; where it is withheld (several, none marked) it is refused.
1106+
const { adapter: _named, ...omitted } = item('ticket', ['body']);
1107+
expect(await mounting(['memory']).admitAuthoredSource(omitted, MANAGER)).toEqual({ admitted: true });
1108+
expect(await mounting(['memory', 'turso'], 'turso').admitAuthoredSource(omitted, MANAGER)).toEqual({ admitted: true });
1109+
expect(await mounting(['memory', 'turso']).admitAuthoredSource(omitted, MANAGER))
1110+
.toMatchObject({ admitted: false, code: 'VALIDATION_ERROR', status: 400 });
1111+
});
1112+
10661113
it('CONTROL: a source naming a mounted adapter, and one that leaves `adapter` out, are admitted', async () => {
10671114
const { svc } = setup({ sources: [] });
10681115
svc.registerAdapter('turso', makeAdapter());

‎packages/spec/src/migrations/entries/semantic/19.knowledge-source-unmounted-adapter-refused-at-save.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export const entry: SemanticMigration = {
1717
+ 'deployment does not mount: a retired store such as `ragflow`, or a mistyped id',
1818
replacement:
1919
'An adapter id the deployment mounts (the refusal lists them), or no `adapter` at all, so the '
20-
+ 'deployment\'s store holds the source; or mount the named store before saving the source.',
20+
+ 'deployment\'s store holds the source (on a host that mounts several adapters and marks none the '
21+
+ 'deployment\'s, a source with no `adapter` is itself refused, so name one there); or mount the named '
22+
+ 'store before saving the source.',
2123
reason:
2224
'Such a source was stored, and then every index and search of it answered SERVICE_UNAVAILABLE (503) and '
2325
+ 'the boot logged it at error. The save now refuses it, VALIDATION_ERROR (400), naming the source, the '

‎scripts/check-skills-token-ratchet.mjs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,19 @@ export const CEILINGS = new Map([
532532
// ceil(28590 / 4) = 7148; the row moves +242, the measured remainder only.
533533
// Pinned AT the measurement.
534534
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(28590 / 4)
535-
['skills/objectstack-ai/SKILL.md', 7148],
535+
// 7148 -> 7200 (2026-11-28, the unmounted-adapter save refusal): the
536+
// `adapter` row named the refusal of an omitted adapter only; a run-time save
537+
// naming an adapter the deployment does not mount is refused too
538+
// (`400 VALIDATION_ERROR`, nothing written), and the row now says so with
539+
// what the refusal names and the two remedies. Raise path the standing ruling
540+
// 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). PAID DOWN
541+
// FIRST: the row's "Optional" (its "Omitted:" clause says it). Arithmetic in
542+
// priced bytes (stamp line excluded), against `main`'s 28590 (the row's 7148,
543+
// headroom 0): the file is 28617 -> 28827 bytes, so the LANDED priced text is
544+
// 28800 -> ceil(28800 / 4) = 7200; the row moves +52, the measured remainder
545+
// only. Pinned AT the measurement.
546+
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(28800 / 4)
547+
['skills/objectstack-ai/SKILL.md', 7200],
536548
// -12 (was 6331): the `http.server` decision-table row dropped a trailing
537549
// clause that taught `contributes.routes` as a key that "parses but serves
538550
// nothing". The key is retired — an authored entry is now REFUSED, carrying

‎skills/objectstack-ai/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ object or field, when you may not search that object or query a field it reads.
255255
|:----|:--------|
256256
| `name` | Snake_case source name |
257257
| `label` / `description` | Display metadata |
258-
| `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 |
258+
| `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 |
259259
| `source.kind` | `'object'`, the one kind |
260260
| `source.object` | The object whose records are indexed |
261261
| `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 |

0 commit comments

Comments
 (0)