Repository navigation
Commit 09df571
docs(skills): type-check 14 more objectstack-data examples and fix the Field import path (#31618)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9Ubb2wtMdjxrW3hze65M5q3BXN)_
Refs #31112 (slice 2 of a per-skill split: item 4, objectstack-data; the
card stays open)
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:objectstack-data 技能包里又有 14 段 TypeScript 示例接入了示例编译检查(95 段中由 11 段变为
25 段),并修正一处会让照抄者编译失败的示例:`Field` 原写成从 `@objectstack/spec`
根入口导入,根入口并不导出它,改为 `@objectstack/spec/data`。
- 为什么改:AI 编写元数据时最先照抄这些示例;没接入检查的示例在规范改名后会悄悄失效,这次就查出一处已经失效的导入。
- 风险与回滚:只改发布技能包的文档文字,不动任何运行时代码;每个文件的 token 上限都未抬高,新增字节靠同文件删减重复句支付。回滚即
revert 本 PR。
-
先看:`skills/objectstack-data/rules/field-types.md`(唯一的示例修正)、`skills/objectstack-data/rules/indexing.md`(8
段新接入、改动最多)、`skills/objectstack-data/rules/validation.md`(删去两句重复说明以支付额度)。
- 两分钟验证:`pnpm --filter @objectstack/spec check:skill-examples`,预期最后一行为
322 段示例全部通过类型检查。
- 需要你做的:作为受管面审批人审阅并批准本 PR(skills/** 属 Tier H)。
## What changes
`skills/objectstack-data` had 11 of its 95 fenced `ts`/`typescript`
blocks under `check:skill-examples` (measured on `main` 158cc2a, all
`*.md` outside `evals/`, `_index.md` excluded). It now has 25. Every new
mark is the os:check marker on the line above the fence; wrappers are an
import plus a typed `const`, never more than three lines.
| File | marked before → after / blocks | tokens before → after /
ceiling | lines before → after |
|:--|:--|:--|:--|
| `rules/indexing.md` | 0 → 8 / 10 | 2284 → 2495 / 3241 | 236 → 260 |
| `references/data-hooks.md` | 1 → 5 / 24 | 9905 → 9987 / 10011 | 942 →
953 |
| `rules/lifecycle.md` | 0 → 1 / 2 | 1588 → 1590 / 1590 | 164 → 165 |
| `rules/field-types.md` | 0 → 1 / 8 | 3199 → 3199 / 3199 | 252 → 253 |
| `rules/validation.md` | 2 → 2 / 15 | 2761 → 2754 / 2761 | 329 → 331 |
| `references/examples-objects.md` | 4 → 4 / 5 | 1710 → 1723 / 1728 |
189 → 191 |
| untouched: `SKILL.md`, `seeds.md`, `datasources.md`,
`relationships.md`, `security.md` | 2/4, 0/4, 0/1, 0/13, 2/9 | headroom
9, 0, 3, 0, 0 | unchanged |
Skills bundle reading: no `SKILL.md` changed, so the sum of every
published `SKILL.md` stays 4592 lines.
- **`rules/indexing.md`**: eight index examples become `const indexes:
ObjectIndex[] = [ … ];` (or `const index: ObjectIndex`) with `import
type { ObjectIndex } from '@objectstack/spec/data'`. A retired `type` /
`partial` key or an unscoped `unique: true` now fails the gate. The two
blocks holding ❌ keys stay unmarked; the opening "Guide for …" line,
which carried no rule, now says so.
- **`references/data-hooks.md`**: the full `defineHook` definition is
marked as written; patterns 1 to 3 gain their `defineHook` import.
Pattern 4 stays unmarked (its `record: any` parameter is a bare `any`,
which the gate refuses), as do the context shapes and fragments; the
intro says so once.
- **`rules/lifecycle.md`**: the `ObjectSchema.create` syntax block is
marked as written, paid by "Guide for declaring" becoming "Declaring".
The ❌ block sits under the heading "Validation Rules (rejected at parse
time)".
- **`rules/field-types.md`**: the `Field.*` factory block is marked as
`const fields = { … };`.
- **`references/examples-objects.md`**: the `protection` type excerpt
gets one line saying it is an excerpt and unchecked.
### Example fixes
- `rules/field-types.md:19` (was line 18): `import { Field } from
'@objectstack/spec'` does not compile. The spec root exports no `Field`:
namespace exports were removed from the root for tree-shaking
(`packages/spec/src/index.ts`, "NAMESPACE EXPORTS — REMOVED"), and every
example app imports it from `@objectstack/spec/data`. Now `import {
Field } from '@objectstack/spec/data'`. The prose at line 12 named the
same wrong path, "(`@objectstack/spec`)"; that parenthetical is removed,
because the import line right below it now carries the path and the gate
checks it.
- `rules/validation.md:325`: the ✅ "Correct — Validation Scoped to
Events" example had no `name`, which every validation rule requires
(`BaseValidationRuleShape`). It gains `name: 'no_draft_publish'`. The
block stays unmarked because it is an object-literal fragment.
### Trims that paid the marks (each cut rule and where it survives)
- `rules/validation.md`, Uniqueness section: "There is **no `unique`
validation type**." This survives at "Available Rule Types": "**No
`unique` type** — enforce uniqueness with a **unique index**".
- `rules/validation.md`, Cross-Field section: "Same inverted semantics
as `script` — the predicate is the **failure** condition." This survives
at "Expression Syntax" ("For `script` **and** `cross_field`, the
predicate expresses the **failure** condition") and in the block's own
`// ❌ TRUE = invalid` comment.
- `rules/field-types.md:11`: "overwhelmingly" became "mostly", and the
wrong import parenthetical went (see above).
- `rules/indexing.md:3` and `rules/lifecycle.md:3`: intro wording that
carried no rule.
## Tests
<details><summary>check:skill-examples, before and after</summary>
- Before (`main` 158cc2a): `✅ 308 prose examples type-check across 3
surface(s)`.
- After (head c4e232f, the same skills tree as the merged head): `pnpm
--filter @objectstack/spec check:skill-examples` exited 0 with `✅ 322
prose examples type-check across 3 surface(s) — every marked block
parsed, so tsc ran the SEMANTIC pass on all of them` (skills + docs
surface 274 → 288).
- Reverse check, run after the commit: planted a retired index `type`
(`rules/indexing.md:142`), an unknown hook key `runAsUser`
(`references/data-hooks.md:747`) and the old root `Field` import
(`rules/field-types.md:19`). The checker exited 1 with TS2353, TS2353
and TS2305 at exactly those lines. Restored with `git checkout HEAD --
skills/objectstack-data`; `git status --porcelain` was empty after.
</details>
## Acceptance notes
- `check:skill-examples` is not in the derived gate list for a
`skills/**` diff, so it was run by hand.
- Blocks left unmarked because the file has no headroom to pay for a
wrapper: `rules/relationships.md` (headroom 0; six `ObjectSchema.create`
blocks, which each need an import, and three of them hold two `export
default`s), `rules/security.md` (0; the two `rowLevelSecurity` lists),
`references/seeds.md` (0; each block names an object defined elsewhere,
so it needs a `declare const` line), `rules/datasources.md` (3; the
federated-object block needs an import of about 18 tokens), `SKILL.md`
(9; the `searchableFields` object and the `indexes` list; the same
`indexes` list is checked in `rules/indexing.md`), and the `validations:
[ … ]` lists in `rules/validation.md` (about 27 tokens each). The probe
that sorted the 95 blocks wrapped each of these with its real type, and
every one compiled except the deliberate ❌ examples. So no other example
is wrong today; they are just not gated.
- The fragment note is unpaid in those five untouched files, which have
0 to 9 tokens of headroom and no sentence that could go without losing a
fact. This is reported as a deviation.
- No ceiling was raised or lowered, and the ratchet printed no
instruction to lower one.
## Verification
<details><summary>Derived gates (dispatch-gates --commands, 45 families)
on head c4e232f</summary>
44 exited 0. `pnpm check:dual-build-cjs-loads` exited 3 (PREREQUISITE
NOT MET: it needs every package's `dist`; CI runs it). `dispatch-gates
--ran` exited 0: 45 derived, 44 run, 1 NOT-MEASURED. After merging
`main` (head 1d424c0, which touches no `packages/spec` or `skills/`
path), the token ratchet, `check:cross-package-test-inputs` (whose
script `main` changed), `check:skill-links` and
`check-changeset-no-major` were re-run, all exit 0.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jRhbPVtqq8gkr4md2P)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent fc4c307 commit 09df571
7 files changed
Lines changed: 77 additions & 26 deletions
File tree
- .changeset
- skills/objectstack-data
- references
- rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| |||
736 | 738 | | |
737 | 739 | | |
738 | 740 | | |
| 741 | + | |
739 | 742 | | |
| 743 | + | |
| 744 | + | |
740 | 745 | | |
741 | 746 | | |
742 | 747 | | |
| |||
760 | 765 | | |
761 | 766 | | |
762 | 767 | | |
| 768 | + | |
763 | 769 | | |
| 770 | + | |
| 771 | + | |
764 | 772 | | |
765 | 773 | | |
766 | 774 | | |
| |||
784 | 792 | | |
785 | 793 | | |
786 | 794 | | |
| 795 | + | |
787 | 796 | | |
| 797 | + | |
| 798 | + | |
788 | 799 | | |
789 | 800 | | |
790 | 801 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | | - | |
| 19 | + | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | | - | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
| 89 | + | |
86 | 90 | | |
87 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
95 | | - | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
| 106 | + | |
100 | 107 | | |
101 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
102 | 111 | | |
103 | 112 | | |
104 | 113 | | |
| |||
108 | 117 | | |
109 | 118 | | |
110 | 119 | | |
111 | | - | |
| 120 | + | |
112 | 121 | | |
113 | 122 | | |
114 | 123 | | |
| |||
125 | 134 | | |
126 | 135 | | |
127 | 136 | | |
| 137 | + | |
128 | 138 | | |
129 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
130 | 142 | | |
131 | 143 | | |
132 | 144 | | |
133 | | - | |
| 145 | + | |
134 | 146 | | |
135 | 147 | | |
136 | 148 | | |
| |||
184 | 196 | | |
185 | 197 | | |
186 | 198 | | |
| 199 | + | |
187 | 200 | | |
188 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
189 | 204 | | |
190 | 205 | | |
191 | | - | |
| 206 | + | |
192 | 207 | | |
193 | 208 | | |
194 | 209 | | |
| |||
197 | 212 | | |
198 | 213 | | |
199 | 214 | | |
| 215 | + | |
200 | 216 | | |
| 217 | + | |
| 218 | + | |
201 | 219 | | |
202 | | - | |
| 220 | + | |
203 | 221 | | |
204 | | - | |
| 222 | + | |
205 | 223 | | |
206 | 224 | | |
207 | 225 | | |
| |||
212 | 230 | | |
213 | 231 | | |
214 | 232 | | |
| 233 | + | |
215 | 234 | | |
| 235 | + | |
| 236 | + | |
216 | 237 | | |
217 | | - | |
| 238 | + | |
218 | 239 | | |
219 | | - | |
| 240 | + | |
220 | 241 | | |
221 | 242 | | |
222 | 243 | | |
| |||
226 | 247 | | |
227 | 248 | | |
228 | 249 | | |
| 250 | + | |
229 | 251 | | |
| 252 | + | |
| 253 | + | |
230 | 254 | | |
231 | | - | |
| 255 | + | |
232 | 256 | | |
233 | 257 | | |
234 | 258 | | |
235 | | - | |
| 259 | + | |
236 | 260 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
88 | | - | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
152 | | - | |
153 | | - | |
| 154 | + | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| |||
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
| 325 | + | |
324 | 326 | | |
325 | 327 | | |
326 | 328 | | |
| |||
0 commit comments