Skip to content

Commit a7e60c7

Browse files
fix(lint)!: refuse an absent sys_ knowledge source object under a stated closure (#38310)
Fixes #38041 Clause-②: no (narrowing) — under a stated package closure, a knowledge source naming a `sys_` object the host does not serve (known, like `sys_user`, or not) is now refused with `knowledge-source-object-unknown`; it used to be skipped (known) or refused with a dependency remedy that cannot help (unknown) Metadata-protocol: narrowed Skills-docs: none — the published skill already teaches that a `source.object` naming no object is refused, and names no platform-name arm this change moves ## 维护者速读 - 用户能看到什么变化:应用作者按包发布知识源时,若指向一个平台里根本不存在的系统对象,现在发布当场被拒;租户管理员在组织内直接写知识源被拒时,报错改成"换一个本组织已有的对象,或先安装提供它的包",不再提他们没有的应用和清单文件。 - 为什么做:属于知识检索收口工作,补上上一轮只覆盖了"整个集合"一条路径、按包发布这条常见路径仍放行的缺口。 - 出错会怎样:最坏是某个本该通过的按包知识源被误拒,作者会看到明确的规则名和改法;撤回本改动即可恢复原行为。 - 要你做什么:无。 ## What changes - `packages/lint/src/validate-knowledge-source.ts`: under a stated closure (`packageScope`), an absent name that `isSystemObject({ name })` accepts is an `error` with no dependency remedy. Limb 1 of `narrowObjectsToPackageClosure` in `packages/lint/src/runtime-gate.ts` keeps every object `isSystemObject` accepts; by name alone that is every `sys_` name, so the closure keeps every `sys_` object the host serves and an absent `sys_` name exists nowhere the host serves. - **`cloud_` / `ai_` are NOT on this arm**, and the decision is limb 1's reading: `isSystemObject` accepts a `cloud_` / `ai_` object only when its definition carries `isSystem: true`, which the name alone does not tell. Their absence under a closure may be the closure's own drop, so a known one stays not-judged and any other keeps the closure verdict with the declare-a-dependency remedy. Pinned both ways (dropped without `isSystem`, clean with `isSystem: true`). - A write that names no package (the whole-collection arm) is worded for its author: "not an object of this organization ... install the package that provides it", naming neither a stack nor a manifest. The CLI keeps its stack-and-manifest wording. - Rule header and `os explain knowledge-source-object-unknown` (`rule-explanations.ts`) now state which platform-name arm holds on the command line, under a closure, and against the whole collection (N2). - `packages/lint/src/validate-ai-context.ts` (amendment, N4): `body.field: 'id'` reads "the record id every object carries" instead of "a untyped field"; a typed field takes the right article. - Changeset: `@objectstack/lint` minor, BREAKING section with FROM/TO; ADR-0087 disposition `not-required (already-registered ...)` in the changeset. ## Tests - `pnpm --filter @objectstack/lint test`: Test Files 246 passed (246), Tests 9936 passed (9936); `pnpm --filter @objectstack/lint typecheck` exit 0 (lock VERDICT command-exit 0), on a merge of origin/main f19350b. - New pins in `validate-knowledge-source.test.ts`: closure refusal for `sys_user` and `sys_kb_article`; CONTROL `sys_help_topic` served from a package outside the closure passes; `cloud_` / `ai_` reading both ways; no-package refusal words exclude `stack`, `manifest`, `dependencies` with the CLI control. `validate-ai-context.test.ts` pins the `id` text and the typed control. <details><summary>Ablation (closure arm)</summary> `node scripts/ablation-replace.mjs` replaced `const absentSystemObject = !!closure && isSystemObject({ name: objectName });` with `const absentSystemObject = false;` (anchor 1 -> 0, blob e64700f -> 7346b04732d3). The suite imports `src/` directly, so no build was involved. `validate-knowledge-source.test.ts`: 1 failed | 48 passed, the failure being `under a stated closure, an absent sys_ name > is refused, known or not, with no dependency remedy`. The control and the `cloud_` / `ai_` pins stayed green. Restored: blob == HEAD, `git diff HEAD` empty. </details> ## Acceptance notes - The claim lists `Metadata-protocol: none`. This PR declares `narrowed`: `check-changeset-no-major.mjs` defines `narrowed` as "a value refused", and a `none` beside the `(narrowing)` arm and a `minor` contradicts ruling A. The seat should confirm the claim line. - This narrowing owes a contract-review-tier record before landing (the seat's step). ## Verification Files to read first: (1) `packages/lint/src/validate-knowledge-source.ts`, the `absentSystemObject` hunk and the new `else if (whole)` arm; (2) `packages/lint/src/validate-knowledge-source.test.ts`, the `under a stated closure` block; (3) `.changeset/38041-knowledge-source-closure-system-object.md`. Two-minute check: `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/validate-knowledge-source.test.ts` shows 49 passed. <details><summary>Local gates and dogfood battery</summary> All at head e517826 (a merge of origin/main f19350b), commands from `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`, exit codes captured before any pipe. - Derived families: 68. `--ran` reconciliation: "68 derived famil(ies) accounted for — 66 run, 2 NOT-MEASURED". 63 exit 0. `check:query-options-erasure` exit 0 on a second run; the first hit my local 300s cap. - NOT MEASURED: `check:dual-build-cjs-loads` (exit 3, PREREQUISITE NOT MET, no dist for 42 packages this card never builds); `check:type-check-debt` (exit 3, PREREQUISITE NOT MET, its closure build got no turn on the verify lock); `check:dts-closure` (exit 1, 9 packages missing the declaration files their package.json promises, all outside the lint closure, e.g. `@objectstack/driver-mongodb`; they are unbuilt in this tree, not a verdict on this diff). CI runs all three on a full build. - Dogfood battery (owed by the `(narrowing)` arm), `pnpm --workspace-concurrency=2 --filter '@objectstack/dogfood^...' build && pnpm --filter @objectstack/dogfood test` under the verify lock at e517826: VERDICT command-exit 1, held 48m12s. Test Files 1 failed, 490 passed, 3 skipped (494). Tests 2 failed, 4146 passed, 68 skipped (4216). Both failures are `Test timed out in 5000ms` in `test/external-import-walled-catalog-refusal.dogfood.test.ts`, the two `control:` import cases. That file reads no knowledge source and no lint rule. Rerun alone under the lock: VERDICT command-exit 0, Test Files 1 passed (1), Tests 9 passed (9). Read as load timeouts on a shared box, not caused by this change. - CI families: see this PR's check-runs. Nothing CI runs was re-run locally beyond the derived subset. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 81f2ff8 commit a7e60c7

6 files changed

Lines changed: 168 additions & 16 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/lint': minor
3+
---
4+
5+
fix(lint)!: under a stated package closure, a knowledge source naming a `sys_` object the host does not serve is refused at publish; the no-package refusal is worded for its author
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: narrowed
9+
Skills-docs: none — the published skill already teaches that a `source.object` naming no object is refused, and names no platform-name arm this change moves
10+
11+
<!-- adr-0087: not-required (already-registered knowledge-source-publish-refuses-missing-references-and-gated-objects) the entry that registered this rule's publish refusal landed with the rule itself; this change extends the same refusal to an absent `sys_` name judged under a stated package closure, which keeps every system object the host serves. No id is added and no key is added, removed or re-shaped. -->
12+
13+
ADR-0161 K4, row 4.
14+
15+
**BREAKING** for the publish of a packaged knowledge source whose `source.object` is a `sys_` name the host does not serve: when the publish gate states the package's closure, such a name, known (`sys_user`) or not, is now a `knowledge-source-object-unknown` error (422). Before, a known one was not judged, and an unknown one was refused with a dependency remedy that cannot help, because the closure already keeps every system object the host serves. FROM a source over such an object TO a source over an object the host serves: name the system object by its full name, or install the package that registers it where this package is installed. A `cloud_` or `ai_` name is not on this arm: the closure keeps such an object only when its definition marks it `isSystem: true`, so its verdict is unchanged. On the command line nothing changes.
16+
17+
- A knowledge source write that names no package, refused for an object the host does not serve, now tells its author to name an object the organization has or install the package that provides it, instead of a stack and a manifest that author does not have.
18+
- `ai_context`: a `body.field` of `id` is reported as the record id every object carries, not as "a untyped field"; a declared field's type now takes the right article.
19+
- `os explain knowledge-source-object-unknown` and the rule's header state which platform-name arm holds on the command line, under a closure, and against the whole collection.

‎packages/lint/src/rule-explanations.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6321,7 +6321,8 @@ const AI_CONTEXT_SORT_FIELD_UNSORTABLE_EXPLANATION: RuleExplanation = {
63216321

63226322
const KNOWLEDGE_SOURCE_DOORS =
63236323
'Judged by `os validate`, `os build` and `os lint`, and at the runtime publish gate for a ' +
6324-
'`knowledge_source` write (Studio, the metadata API, MCP), with the same rule id and message. An error ' +
6324+
'`knowledge_source` write (Studio, the metadata API, MCP), with the same rule id and message, except that an ' +
6325+
'object verdict at the gate names the remedy its author has. An error ' +
63256326
'refuses the publish (ADR-0161 K4): a source over a missing object has nothing to index, a missing field ' +
63266327
'indexes no text for that member, and a gated object is never searched for a caller the service judges.';
63276328

@@ -6337,10 +6338,14 @@ const KNOWLEDGE_SOURCE_OBJECT_UNKNOWN_EXPLANATION: RuleExplanation = {
63376338
'registers (`sys_user`) is not judged when the stack does not carry its definition, and a name with a ' +
63386339
'platform prefix that no known package registers is a warning, because a third-party package may still ' +
63396340
'provide it. At the publish gate with no package stated, the source is judged against every object the ' +
6340-
'host serves, so either one is an error there when the host does not serve it. When the publish ' +
6341-
'gate states the package\'s closure (the package, the packages its manifest declares in ' +
6342-
'`dependencies`, and platform objects), an object outside it is reported with the remedy to declare the ' +
6343-
'dependency.',
6341+
'host serves, so either one is an error there when the host does not serve it, worded for the ' +
6342+
'organization\'s author: name an object the organization has, or install the package that provides it. ' +
6343+
'When the publish gate states the package\'s closure (the package, the packages its manifest declares ' +
6344+
'in `dependencies`, and platform objects), the closure keeps every `sys_` object the host serves, so a ' +
6345+
'`sys_` name the host does not serve, known or not, is an error with no dependency to declare. A known ' +
6346+
'platform object of another prefix (`cloud_`, `ai_`) is not judged there, because the closure keeps such ' +
6347+
'an object only when its definition marks it a system object; any other object outside the closure is ' +
6348+
'reported with the remedy to declare the dependency.',
63446349
'On the command line a package the manifest declares in `dependencies` but the artifact does not carry ' +
63456350
'is out of sight: its objects cannot be read there. So while the manifest declares such a dependency, ' +
63466351
'an object the stack does not define is a warning, which clears when that dependency defines it (the ' +

‎packages/lint/src/validate-ai-context.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ describe('validateAiContext — ADR-0160 D1 author defects', () => {
211211
expect(rulesOf({ objects, aiContexts: [pack({ body: { field: 'id' } })] })).toEqual([
212212
[AI_CONTEXT_BODY_NOT_LONG_TEXT, 'aiContexts[0].body.field'],
213213
]);
214+
// The text names `id` as the record id, not as a typeless field.
215+
const [finding] = validateAiContext({ objects, aiContexts: [pack({ body: { field: 'id' } })] });
216+
expect(finding!.message).toBe(
217+
"`body.field` names 'id', the record id every object carries; a body is a long-text field "
218+
+ '(textarea, markdown, html, richtext), so the pack carries no body',
219+
);
220+
// CONTROL: a declared field keeps its type in the text, with the article it takes.
221+
const [typed] = validateAiContext({ objects, aiContexts: [pack({ body: { field: 'created_at' } })] });
222+
expect(typed!.message).toMatch(/^`body\.field` names 'created_at', a datetime field; /);
214223
});
215224

216225
it('a column the platform does not inject on the object is still unknown: owner_id under ownership org', () => {

‎packages/lint/src/validate-ai-context.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,19 @@ export function validateAiContext(
249249
hint: `Name a long-text field of '${root}' (check the spelling)`,
250250
});
251251
} else if (!(AI_CONTEXT_BODY_FIELD_TYPES as readonly string[]).includes(str(def?.type))) {
252+
// No definition means a column addressable without one: `id`, which
253+
// the driver provisions on every object, is the only such name.
254+
const type = str(def?.type);
255+
const what = !def
256+
? bodyField === 'id' ? 'the record id every object carries' : 'a column with no declared type'
257+
: type ? `${/^[aeiou]/i.test(type) ? 'an' : 'a'} ${type} field` : 'a field with no declared type';
252258
out.push({
253259
severity: 'warning',
254260
rule: AI_CONTEXT_BODY_NOT_LONG_TEXT,
255261
where: `${at} · body`,
256262
path: `aiContexts[${i}].body.field`,
257263
message:
258-
`\`body.field\` names '${bodyField}', a ${str(def?.type) || 'untyped'} field; a body is a long-text ` +
264+
`\`body.field\` names '${bodyField}', ${what}; a body is a long-text ` +
259265
`field (${AI_CONTEXT_BODY_FIELD_TYPES.join(', ')}), so the pack carries no body`,
260266
hint: `Name a long-text field of '${root}' as the body, or list '${bodyField}' in \`fields\` instead`,
261267
});

‎packages/lint/src/validate-knowledge-source.test.ts‎

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ describe('validateKnowledgeSource on the runtime publish door', () => {
187187
const advised = verdict.advisories.filter((f) => KS_RULE.test(f.rule));
188188
expect((severity === 'error' ? refused : advised).map((f) => f.rule)).toEqual([rule]);
189189
expect((severity === 'error' ? advised : refused)).toEqual([]);
190-
expect([...refused, ...advised].map(face)).toEqual(atValidate(source).map(face));
190+
// A write that names no package is worded for its author, who has no
191+
// stack and no manifest; every other verdict prints the CLI's words.
192+
const sameWords = rule !== KNOWLEDGE_SOURCE_OBJECT_UNKNOWN;
193+
const at = (f: ReturnType<typeof face>) => (sameWords ? f : { rule: f.rule, severity: f.severity, where: f.where });
194+
expect([...refused, ...advised].map(face).map(at)).toEqual(atValidate(source).map(face).map(at));
191195
});
192196
}
193197

@@ -259,7 +263,7 @@ describe('validateKnowledgeSource on the runtime publish door', () => {
259263
const verdict = runRuntimeAuthoringRules({ type: 'knowledge_source', item, context: { objects } });
260264
expect(verdict.errors.map((f) => [f.rule, f.severity, f.path]), object)
261265
.toEqual([[KNOWLEDGE_SOURCE_OBJECT_UNKNOWN, 'error', 'knowledgeSources[0].source.object']]);
262-
expect(verdict.errors[0]!.message, object).toContain(`'${object}', which this stack does not define`);
266+
expect(verdict.errors[0]!.message, object).toContain(`'${object}', which is not an object of this organization`);
263267
expect(verdict.advisories.filter((f) => KS_RULE.test(f.rule)), object).toEqual([]);
264268
}
265269
// The CLI arms stay: a prefixed name no known package registers warns, a known platform name is not judged.
@@ -275,6 +279,70 @@ describe('validateKnowledgeSource on the runtime publish door', () => {
275279
}).errors).toEqual([]);
276280
});
277281

282+
it('a write that names no package is refused in words that name neither a stack nor a manifest', () => {
283+
const verdict = runRuntimeAuthoringRules({ type: 'knowledge_source', item: kbSource({ object: 'kb_artcle' }), context: { objects } });
284+
expect(verdict.errors.map((f) => [f.rule, f.severity])).toEqual([[KNOWLEDGE_SOURCE_OBJECT_UNKNOWN, 'error']]);
285+
const [finding] = verdict.errors;
286+
for (const word of [/\bstack\b/i, /manifest/i, /dependencies/]) {
287+
expect(finding!.message).not.toMatch(word);
288+
expect(finding!.hint).not.toMatch(word);
289+
}
290+
expect(finding!.message).toContain('organization');
291+
expect(finding!.hint).toMatch(/install the package/);
292+
// CONTROL: the CLI keeps its stack-and-manifest remedy, which its author can follow.
293+
expect(atValidate(kbSource({ object: 'kb_artcle' }))[0]!.hint).toMatch(/manifest's `dependencies`/);
294+
});
295+
296+
/**
297+
* Limb 1 of the closure (`narrowObjectsToPackageClosure`) keeps every object
298+
* `isSystemObject` accepts, and by name alone that is every `sys_` object:
299+
* under a stated closure an absent `sys_` name is absent from the host.
300+
*/
301+
describe('under a stated closure, an absent sys_ name', () => {
302+
const scope = { packageId: 'app.kb', dependencies: [] as string[] };
303+
const served = [
304+
...objects.map((o) => ({ ...o, _packageId: 'app.kb' })),
305+
{ name: 'sys_help_topic', _packageId: 'com.platform.help', enable: { aiReadable: true }, fields: { body: { type: 'text' } } },
306+
];
307+
const atScoped = (object: string, context = served) => runRuntimeAuthoringRules({
308+
type: 'knowledge_source',
309+
item: kbSource({ object, content: ['body'], metadataFields: [] }),
310+
context: { objects: context },
311+
packageScope: scope,
312+
});
313+
314+
it('is refused, known or not, with no dependency remedy', () => {
315+
for (const object of ['sys_user', 'sys_kb_article']) {
316+
const verdict = atScoped(object);
317+
expect(verdict.errors.map((f) => [f.rule, f.severity, f.path]), object)
318+
.toEqual([[KNOWLEDGE_SOURCE_OBJECT_UNKNOWN, 'error', 'knowledgeSources[0].source.object']]);
319+
expect(verdict.errors[0]!.message, object).toContain(`'${object}', a system object the host does not serve`);
320+
expect(verdict.errors[0]!.hint, object).not.toMatch(/dependenc/);
321+
expect(verdict.advisories.filter((f) => KS_RULE.test(f.rule)), object).toEqual([]);
322+
}
323+
});
324+
325+
it('CONTROL: a sys_ object the host serves, from a package outside the closure, passes', () => {
326+
expect(atScoped('sys_help_topic').errors).toEqual([]);
327+
});
328+
329+
it('cloud_ and ai_ names are not on that arm: limb 1 keeps them only on their definition\'s isSystem', () => {
330+
const foreign = (extra: Record<string, unknown>) => [
331+
...served,
332+
...['cloud_usage_note', 'ai_memory_note'].map((name) => ({ name, _packageId: 'com.cloud', ...extra, fields: { body: { type: 'text' } } })),
333+
];
334+
for (const object of ['cloud_usage_note', 'ai_memory_note']) {
335+
// Not isSystem: the closure drops it, so the verdict is the closure's, with the dependency remedy.
336+
const dropped = atScoped(object, foreign({}));
337+
expect(dropped.errors.map((f) => f.rule), object).toEqual([KNOWLEDGE_SOURCE_OBJECT_UNKNOWN]);
338+
expect(dropped.errors[0]!.message, object).toContain('outside the closure of package "app.kb"');
339+
expect(dropped.errors[0]!.hint, object).toMatch(/^Declare a dependency on the package that defines/);
340+
// isSystem: true: limb 1 keeps it, and the source is clean.
341+
expect(atScoped(object, foreign({ isSystem: true })).errors, object).toEqual([]);
342+
}
343+
});
344+
});
345+
278346
it('an empty whole collection at the door is no universe, and judges no object', () => {
279347
const stack = { objects: [], knowledgeSources: [kbSource({ object: 'faq_entry' })] };
280348
expect(validateKnowledgeSource(stack, { wholeCollection: true })).toEqual([]);

‎packages/lint/src/validate-knowledge-source.ts‎

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,25 @@
3030
* A `warning` with the hedge on the CLI when the manifest declares such a
3131
* dependency: the build cannot see that package's objects, and the publish
3232
* door judges the source against its closure, which holds them (the
33-
* `flow-trigger-unknown-object` split). The ladder
33+
* `flow-trigger-unknown-object` split). On the CLI the ladder
3434
* `validateObjectReferences` resolves object names by also applies: a
3535
* platform object a known package registers is not judged when the stack
3636
* does not carry it (its declaration is not in hand), and a
37-
* platform-prefixed name no known package registers is a `warning`; both
38-
* on the CLI and under a closure. Against the whole collection at the door
39-
* either one is absent from every package the host serves, so it is an
40-
* `error` as an unprefixed name is. An empty whole collection at the door
41-
* is no universe, and judges nothing.
37+
* platform-prefixed name no known package registers is a `warning`. Under
38+
* a closure only the first holds, and only for a name the closure may
39+
* drop. The closure keeps every system object the host serves
40+
* (`narrowObjectsToPackageClosure` in `runtime-gate.ts`, limb 1, which asks
41+
* `isSystemObject`), and by name alone that reading keeps every `sys_`
42+
* object, so an absent `sys_` name, known or not, exists nowhere the host
43+
* serves: an `error`, with no dependency remedy. A `cloud_` or `ai_` name
44+
* is not on that arm: limb 1 keeps such an object only when its definition
45+
* says `isSystem: true`, which the name does not tell, so its absence may
46+
* be the closure's own; a known one is not judged, and any other is
47+
* outside the closure. Against the whole collection at the door every
48+
* absent name, platform or not, is absent from every package the host
49+
* serves, so it is an `error`, worded for an author with no stack and no
50+
* manifest (the organization's objects, or a package to install). An
51+
* empty whole collection at the door is no universe, and judges nothing.
4252
* - `knowledge-source-field-unknown` (`error`): a `source.content` or
4353
* `source.metadataFields` member names no field of the object: neither one
4454
* it declares (its own stack's extensions folded in, `objectsAsServed`) nor
@@ -82,6 +92,7 @@ import { hasPlatformObjectPrefix, isPlatformProvidedObjectName } from '@objectst
8292
import { collectionEntries } from './collection-entries.js';
8393
import { closureDependencyRemedy, objectsAsServed, packagesOf, recordsOf, suggestName } from './object-graph.js';
8494
import { injectedColumnsFor } from './system-fields.js';
95+
import { isSystemObject } from './validate-security-posture.js';
8596

8697
export type KnowledgeSourceSeverity = 'error' | 'warning';
8798

@@ -213,11 +224,30 @@ export function validateKnowledgeSource(
213224

214225
if (!def) {
215226
if (noUniverse) continue;
227+
// Limb 1 of the closure keeps every system object the host serves, and
228+
// asked by name alone (`isSystemObject`) it keeps every `sys_` one: an
229+
// absent `sys_` name is as final under a closure as against the whole
230+
// collection. A `cloud_` / `ai_` name is kept only on its definition's
231+
// `isSystem: true`, which the name does not tell, so it is not here.
232+
const absentSystemObject = !!closure && isSystemObject({ name: objectName });
216233
// A platform object a known package registers: its declaration is not
217234
// in this stack, so neither its fields nor its gates can be read here.
218235
// Against the whole collection it is in hand, and its absence is final.
219-
if (!whole && isPlatformProvidedObjectName(objectName)) continue;
220-
if (closure) {
236+
if (!whole && !absentSystemObject && isPlatformProvidedObjectName(objectName)) continue;
237+
if (absentSystemObject) {
238+
out.push({
239+
severity: 'error',
240+
rule: KNOWLEDGE_SOURCE_OBJECT_UNKNOWN,
241+
where,
242+
path: objectPath,
243+
message:
244+
`\`source.object\` names '${objectName}', a system object the host does not serve. The closure of ` +
245+
`package "${closure.packageId}" holds every system object the host serves, so no dependency brings it ` +
246+
'in, and the source indexes nothing.' +
247+
suggestName(objectName, objects.keys()),
248+
hint: 'Name a system object the host serves (check the spelling), or another object inside that closure',
249+
});
250+
} else if (closure) {
221251
out.push({
222252
severity: 'error',
223253
rule: KNOWLEDGE_SOURCE_OBJECT_UNKNOWN,
@@ -257,6 +287,21 @@ export function validateKnowledgeSource(
257287
'Ignore this if a declared dependency defines the object (the publish checks it against the package\'s ' +
258288
'closure); otherwise name an object the stack defines (check the spelling)',
259289
});
290+
} else if (whole) {
291+
// A write that names no package: its author has no stack and no
292+
// manifest, only the organization's objects and the packages it installs.
293+
out.push({
294+
severity: 'error',
295+
rule: KNOWLEDGE_SOURCE_OBJECT_UNKNOWN,
296+
where,
297+
path: objectPath,
298+
message:
299+
`\`source.object\` names '${objectName}', which is not an object of this organization (neither one it ` +
300+
'authored nor one an installed package registers), so the source indexes nothing and no search ever ' +
301+
'returns a hit from it.' +
302+
suggestName(objectName, objects.keys()),
303+
hint: `Name an object the organization has (check the spelling), or install the package that provides '${objectName}' first`,
304+
});
260305
} else {
261306
out.push({
262307
severity: 'error',

0 commit comments

Comments
 (0)