Repository navigation
Commit a7f7f3f
fix(lint)!: knowledge-source review follow-ups: absent platform objects refused at publish, ai_context accepts id, search refusal names list (#38038)
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Fixes #38019
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #37310
## 维护者速读
- 用户能看到什么变化:写知识源的作者在保存被拒时,看到的原因和修法改为「开放 list、不要关掉
searchable」;发布一个指向平台不存在的系统对象的知识源会直接被拒;AI 上下文里写 `id`
不再被提示字段不存在;升级指南只对用到知识源的应用列出相关条目。
- 为什么做:知识库检索这条线(PR 37971 知识源校验)评审留下的四个收尾问题。
- 出错会怎样:最坏是某个发布被多拒或提示文字不准,作者按提示改对象名即可;本改动可直接回退。
- 要你做什么:无。
**Was stacked on PR #37971**, which merged as 3550665. `main`
(f72f335) is merged here (2634eef, no rebase); the diff against
`main` is now this card's 11 files, +150/−24. The add/add conflicts the
squash left were resolved to this branch's side for
`validate-knowledge-source.ts`, its test and the step-19 entry (main's
blob equals the stack base 8301509 for each), and
`rule-explanations.ts` merged three-way clean against that base.
## What changes
1. **N4, the save-door wording** (`service-knowledge`). The
`object-api-not-served` refusal of `admitAuthoredSource` now uses the
wording PR #37971 settled for its S2 fix: the cause is
`enable.apiEnabled` false, an `enable.apiMethods` list that does not
grant `list` (from which search derives), or `list` beside
`enable.searchable: false`; the fix is to keep `apiEnabled` true and
include `list` with `searchable` not false, or index another object. It
no longer tells the author to grant `search`, a retired list value the
parse strips. The admission module's gate-2 header says the same.
2. **`ai_context` and `id`** (`validate-ai-context.ts`). Field existence
(`fields`, a related list's `fields`, `where`, `orderBy`, `body.field`)
is now asked through `injectedColumnsFor`, as `system-fields.ts`
prescribes for an existence check, beside the effective field map. `id`
(driver-provisioned, absent from `injectedColumnDefsFor` by contract) is
no longer `ai-context-field-unknown`; a `body.field` of `id` is reported
as not long text. The type questions (body type, sortability, links)
still read the definition map.
3. **N3, a platform name at the door** (`validate-knowledge-source.ts`).
Against the whole collection the host serves (no package scope at
publish), an absent platform-prefixed name and an absent known platform
name (`sys_user`) are now `knowledge-source-object-unknown` errors, as
an unprefixed name already was. The CLI arms stay: a prefixed name no
known package registers warns, a known platform name the stack does not
carry is not judged. Under a stated closure nothing changes. The `os
explain` entry and the upgrade entry's `surface` say which arm is the
CLI's.
4. **N6, `relevantWhen`** (spec).
`knowledge-source-publish-refuses-missing-references-and-gated-objects`
carries `relevantWhen: { kind: 'stack-declares', keys:
['knowledgeSources'] }`; `semantic-relevance.test.ts`'s reviewed table
gains the row (30 entries, 3 of protocol 19: `main` had meanwhile added
`19:action-locations-page-parts-retired`, so the merge corrected the
counts). The four sibling `19.knowledge-source-*` entries are
deliberately left without one: each names a surface outside the stack (a
source registered in code through `KnowledgeServicePlugin({ sources })`
/ `registerSource`, or host calls to `indexDocument`), and
`SemanticMigration.relevantWhen`'s contract says to omit the question
unless the surface lives ONLY under the keys it names, so a stack with
no `knowledgeSources` is not proven clear of them.
Declaration: item 3 narrows the publish accept set (a source over an
absent platform object was published with a warning or unjudged, and is
now refused 422), hence `no (narrowing)` and `Metadata-protocol:
narrowed` (a value refused). Item 2 widens no published accept set.
Under `--strict`, where a warning fails the run, a pack naming `id` is
now accepted; the refusal it removes is one the published contract
already denies, since `id` exists on every object:
`packages/spec/src/data/injected-system-columns.ts` names it the primary
key the driver provisions on every physical table (`PRIMARY_KEY_COLUMN =
'id'`, around lines 74-79), and `packages/lint/src/system-fields.ts`
reports it from `injectedColumnsFor`, the existence helper (its note
near line 100 says `injectedColumnDefsFor` leaves it out by design).
Removing a refusal the contract already denies, with that text cited,
reads as `no`; so the PR stays `Clause-②: no (narrowing)`, the narrowing
being item 3 alone. The claim carried `Metadata-protocol: none`; the
dispatch left the kind to the diff, and AGENTS.md's definition ("a value
refused ... is `narrowed`") fits item 3.
## Tests
-
`packages/services/service-knowledge/src/__tests__/knowledge-source-admission.test.ts`:
a `list` + `searchable: false` row in the refusal table; a pin that the
not-served refusal names `does not grant \`list\`` and `include \`list\`
with \`enable.searchable\` not false`, and never prescribes a `search`
grant, for all three not-served shapes.
- `packages/lint/src/validate-ai-context.test.ts`: `id` in `fields`,
related `fields`, `where` and `orderBy` is clean, through the rule and
through `runAuthoringRules('validate', …)`; a control misspelling is
still reported; `body.field: 'id'` is not long text, never unknown.
- `packages/lint/src/validate-knowledge-source.test.ts`: at the door
with no scope, `sys_kb_article` (prefixed, unregistered) and `sys_user`
(known platform) absent from the served collection are refused as
errors; the CLI arms stay (warning, not judged); a control with the
platform object served publishes clean.
- `packages/spec/src/migrations/semantic-relevance.test.ts`: the
enumeration table and its counts.
Local runs at head `4cdbceedc2`, each under
`scripts/pm/os-verify-lock.sh` (verdict `command-exit 0`):
- `@objectstack/lint`: 244 test files, 9859 tests passed.
- `@objectstack/service-knowledge`: 19 files, 648 tests passed.
- `@objectstack/spec` `src/migrations`: 5 files, 207 tests passed.
- Typecheck of lint, service-knowledge and spec: clean.
- Ablation (at 80a26df, the same blobs): with the four fixed files
restored from 8301509, lint 3 failed (the two `id` pins and the
whole-collection platform pin), service-knowledge 1 failed (the wording
pin), spec 2 failed (the enumeration table and CHAIN `absentTodos`);
restored, all green.
- Dogfood battery (the `(narrowing)` arm): 490 files passed, 3 skipped;
4144 tests passed, 68 skipped; no failures.
<details><summary>Gates at head 4cdbcee</summary>
- `dispatch-gates --commands`: 98 commands derived over the 11 paths,
all 98 run, each exit 0 (two first answered "not built yet" inside the
lock job, `migrate-meta-engine-guidance` vitest and
`check:dual-build-cjs-loads`, and exit 0 once the dogfood closure build
had built their packages).
- `node scripts/check-adr-0087-registration.mjs --base origin/main`:
exit 0, reading the marker as `not-required (already-registered)`.
- `node scripts/pm/overlap-check.mjs`: VERDICT clean exit 0 against
origin/main 5b8ca36, #38107 and #38060.
</details>
## Acceptance notes
- The ADR-0087 marker is now `not-required (already-registered
knowledge-source-publish-refuses-missing-references-and-gated-objects)`:
#37971 registered the entry and this PR only edits it (commit
4cdbcee).
- Full dogfood ran on the final head `4cdbceedc2` and is green (above).
- Follow-up #38041 carries N1 (a known platform name absent under a
stated closure, including the question of `cloud_` and `ai_` names), N2
(the rule header and explain text on which platform arm applies where)
and N6 (the stack/manifest wording at a write that names no package).
## Verification
Read first: `packages/lint/src/validate-knowledge-source.ts` (the
`whole` condition on the two platform rungs, the one behavioural
narrowing), `packages/lint/src/validate-ai-context.ts` (`fieldExists`
and the `body.field` branch),
`packages/services/service-knowledge/src/knowledge-service.ts` (the
`object-api-not-served` text).
Two minutes: `pnpm --filter @objectstack/lint exec vitest run
--maxWorkers=2 src/validate-knowledge-source.test.ts
src/validate-ai-context.test.ts` after building lint's closure: all
green, including "against the whole collection, an absent platform name,
prefixed or known, is refused as an unprefixed one is".
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6ce1975 commit a7f7f3f
11 files changed
Lines changed: 150 additions & 24 deletions
File tree
- .changeset
- packages
- lint/src
- services/service-knowledge/src
- __tests__
- spec/src/migrations
- entries/semantic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6236 | 6236 | | |
6237 | 6237 | | |
6238 | 6238 | | |
6239 | | - | |
6240 | | - | |
6241 | | - | |
| 6239 | + | |
| 6240 | + | |
| 6241 | + | |
| 6242 | + | |
| 6243 | + | |
6242 | 6244 | | |
6243 | 6245 | | |
6244 | 6246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
189 | 216 | | |
190 | 217 | | |
191 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
106 | 113 | | |
107 | 114 | | |
108 | 115 | | |
| |||
139 | 146 | | |
140 | 147 | | |
141 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
142 | 161 | | |
143 | 162 | | |
144 | 163 | | |
| |||
196 | 215 | | |
197 | 216 | | |
198 | 217 | | |
199 | | - | |
| 218 | + | |
200 | 219 | | |
201 | 220 | | |
202 | 221 | | |
| |||
220 | 239 | | |
221 | 240 | | |
222 | 241 | | |
223 | | - | |
| 242 | + | |
224 | 243 | | |
225 | 244 | | |
226 | 245 | | |
| |||
229 | 248 | | |
230 | 249 | | |
231 | 250 | | |
232 | | - | |
| 251 | + | |
233 | 252 | | |
234 | 253 | | |
235 | 254 | | |
236 | 255 | | |
237 | 256 | | |
238 | 257 | | |
239 | | - | |
| 258 | + | |
240 | 259 | | |
241 | 260 | | |
242 | 261 | | |
| |||
275 | 294 | | |
276 | 295 | | |
277 | 296 | | |
278 | | - | |
| 297 | + | |
279 | 298 | | |
280 | 299 | | |
281 | 300 | | |
| |||
284 | 303 | | |
285 | 304 | | |
286 | 305 | | |
287 | | - | |
| 306 | + | |
288 | 307 | | |
289 | 308 | | |
290 | 309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
256 | 278 | | |
257 | 279 | | |
258 | 280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
193 | 196 | | |
194 | 197 | | |
195 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
196 | 203 | | |
197 | 204 | | |
198 | 205 | | |
| |||
208 | 215 | | |
209 | 216 | | |
210 | 217 | | |
211 | | - | |
| 218 | + | |
| 219 | + | |
212 | 220 | | |
213 | 221 | | |
214 | 222 | | |
| |||
222 | 230 | | |
223 | 231 | | |
224 | 232 | | |
225 | | - | |
| 233 | + | |
226 | 234 | | |
227 | 235 | | |
228 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
891 | 891 | | |
892 | 892 | | |
893 | 893 | | |
| 894 | + | |
894 | 895 | | |
895 | 896 | | |
896 | 897 | | |
| |||
971 | 972 | | |
972 | 973 | | |
973 | 974 | | |
974 | | - | |
| 975 | + | |
| 976 | + | |
975 | 977 | | |
976 | 978 | | |
977 | 979 | | |
| |||
983 | 985 | | |
984 | 986 | | |
985 | 987 | | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
986 | 1002 | | |
987 | 1003 | | |
988 | 1004 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3191 | 3191 | | |
3192 | 3192 | | |
3193 | 3193 | | |
3194 | | - | |
3195 | | - | |
3196 | | - | |
| 3194 | + | |
| 3195 | + | |
| 3196 | + | |
| 3197 | + | |
| 3198 | + | |
3197 | 3199 | | |
3198 | 3200 | | |
3199 | 3201 | | |
| |||
0 commit comments