You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a7e60c7
Browse filesBrowse the repository at this point in the historyBrowse 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>
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.
0 commit comments