Repository navigation
Commit 144cdc2
docs(skills): teach the lookupFilters { $record } reference and orEmpty (#34528)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB5crsrYoZ5Eg3aoQQucQsHv)_
Fixes #34201
Clause-②: no
Metadata-protocol: none
Skills-docs: updated here
## 维护者速读
- 改了什么:`objectstack-data` 技能的 `rules/field-types.md`
和两页数据建模文档(`relationships.mdx`、`fields.mdx`)开始教 lookup 筛选里的 `{ $record }`
引用和 `orEmpty`:引用怎么写、引用值为空时这条筛选被略过、`orEmpty` 及它能搭配的六个运算符、它和 `dependsOn`
的区别。
- 为什么改:这两个写法的读取方(表单里的记录选择器)已随 PR #34253
落地,规范里的「PLANNED」标记已摘掉,但技能和文档一个字都没提,AI 和作者不知道可以这样按当前记录筛选候选项。
- 风险与回滚:只改文档和技能文字,不动产品代码;技能文件原本零余量,先删了同文件 5 处重复(179 字节),再把该文件的 token
上限按实测从 3349 提到 3553(+204)。回滚即 revert 本 PR。
- 先看:`skills/objectstack-data/rules/field-types.md` 第 210–234 行(新教学)和第
42、132、254、264 行(删掉的重复);`scripts/check-skills-token-ratchet.mjs` 里
`field-types.md`
那一行上限及其注释;`content/docs/data-modeling/relationships.mdx` 第 44–83 行。
- 两分钟验证:`node scripts/check-skills-token-ratchet.mjs | grep
field-types`,预期看到 `3553 / 3553 (+0)`,末行 ✓。
- 需要你做的:审阅并合并(改了 `skills/**`,属于需要你亲手合并的受管面)。
## Liveness readings (the premise, measured at `9e6fee19`)
The card says to teach only once the reader lands. Both shapes are read
today, so both are taught:
- `packages/spec/liveness/field.json`, row `lookupFilters`: `status:
live`, `verifiedAt: 2026-11-16`. Its note names the readers:
`ui/packages/fields/src/widgets/lookupRecordReference.ts#resolveLookupFilters`
puts the value of the record being edited in place of each `{ $record }`
reference, only on a field a record form stamped through
`withRecordBeingEdited`, and leaves out an entry whose value is empty or
cannot be read;
`ui/packages/fields/src/widgets/RecordPickerDialog.tsx#lookupFiltersToRecord`
sends `orEmpty: true` as an `$or` with a `$null` match on the same
column.
- Both files exist at `9e6fee19` and carry those functions (`git log`
names the landing commit `2c296cf2`, PR #34253).
`RecordPickerDialog.tsx` line 267 builds `{ $or: [{ [f.field]: condition
}, { [f.field]: { $null: true } }] }`.
- `[PLANNED — not enforced]` markers: `grep -c PLANNED
packages/spec/src/data/field.zod.ts` answers 0; the `value`, `orEmpty`
and `lookupFilters` describes say what the picker does. No spec marker
is left to flip.
- Before this PR: `grep -c -E '\$record|orEmpty'` answers 0 in each of
the three target files (control: 36 hits in
`packages/spec/src/data/field.zod.ts`).
- The six operators are copied from `LOOKUP_FILTER_SCALAR_COMPARISONS`
in `field.zod.ts`: `eq`, `ne`, `gt`, `lt`, `gte`, `lte`.
- The path check the docs page mentions (`os validate` refuses a path
that names no field) is `object-field-ref-unknown` in
`packages/lint/src/validate-object-field-refs.ts`, severity `error`.
## What changes
**`skills/objectstack-data/rules/field-types.md`** (§ Lookup). The
section's one example becomes a quote's `price_book` lookup with a
literal entry, a `{ $record: 'quote_date' }` entry and a one-hop `{
$record: 'account.market' }` entry, both with `orEmpty: true`. One
paragraph under it carries the four points: the reference is the whole
`value` and pairs, like `orEmpty`, only with the six operators; only a
record form resolves it and every other picker host leaves the entry
out; an empty or unreadable value drops the entry; `orEmpty: true` also
matches a null column; a `$record` field is not also listed in
`dependsOn`, which would add an equality filter. It ends with the limit
the spec states: the picker only narrows the choice.
**`content/docs/data-modeling/relationships.mdx`** gains `#### Filter by
the record being edited` under Filtered Lookups: the shape, one example
(the same price-book case, with both date bounds), and five short
bullets (the reference, where it resolves, an empty value, `orEmpty`,
`dependsOn` or `$record`).
**`content/docs/data-modeling/fields.mdx`**: one more lookup in the
relationship example, the `lookupFilters` row of the property table
names `orEmpty` and the reference, a `dependsOn` row is added, and a
short `#### Lookup filters that read the record being edited` section
states the four points and links to the relationships page.
**`scripts/check-skills-token-ratchet.mjs`**: the `field-types.md` row
moves 3349 → 3553, with its row comment (next section).
### The ceiling raise: cuts first, then the measured remainder
`field-types.md` sat at zero headroom (3349 / 3349), so any teaching
reds the ratchet. The standing ruling, verbatim and untranslated:
「A:先削重复,余额按实测提高」 (maintainer, 2026-10-27), the gate-recognised path per
ruling record 6513306068 (letter B). The skills seat accepted the row
edit as an in-scope widening for this card.
Five same-file restatements are cut, 179 bytes. Each fact is still
carried by the sentence named:
| Cut | Bytes | Still carried by |
|:---|---:|:---|
| `secret` row: "**The recommended type for credentials**" | 41 | the
`password` row, line 41: "Prefer `secret` for credentials" |
| `autonumber` row: "({0000} counter + optional date / {field} tokens,
resets per scope)", now "(→ Autonumber)" | 51 | § Autonumber: the token
table (lines 254–256) and line 258, the paragraph that opens "The
counter resets per" |
| `autonumber` row: the second `format` example, `"AD{YYYYMMDD}{0000}"`
| 24 | the token table, line 255: `AD{YYYYMMDD}{0000}` →
`AD202606170001` |
| Autonumber rule 3: "Size it for readability, not as a ceiling." | 43 |
the same rule's heading, line 264: "Pad width is a MINIMUM, not a cap" |
| token table, `{0000}` row: "(**minimum** width)" | 20 | rule 3, line
264 |
The teaching adds 994 bytes; net +815 bytes. `wc -c` = 14210 →
`ceil(14210 / 4)` = 3553 tokens. The row is pinned at the measurement,
zero headroom, +204, and no other row moves.
### Published-skill size readings
| | Before | After |
|:---|---:|---:|
| `rules/field-types.md`, lines | 252 | 265 (+13; the order's budget is
+20) |
| `rules/field-types.md`, bytes | 13395 | 14210 |
| `rules/field-types.md`, tokens (the ratchet's count) | 3349 | 3553 |
| all `skills/*/SKILL.md`, lines | 4594 | 4594 |
| ratcheted authored files, tokens | 188607 | 188811 |
| whole shipped bundle, tokens | 249100 | 249304 |
## Why
The `{ $record }` reference and `orEmpty` were declared ahead of their
reader and marked PLANNED; the docs half waited on the picker. The
picker landed in PR #34253, so an author can now filter a lookup's
candidates by the record being edited, and nothing an AI builder reads
said so.
## Tests
None owed: prose in two docs pages and one published skill file, and one
data row in a gate script's map. No tested behaviour changes, so no
ablation. The gate script's own suite is its `--self-test` (104 cases
pass); no `*.test.*` file names it (`git grep -l
check-skills-token-ratchet -- '*.test.ts' '*.test.mjs'` is empty).
## Acceptance notes
- **No eval case.**
`skills/objectstack-data/evals/objects-fields-relationships.json` has 20
cases and none covers lookup filters (`grep -c lookupFilters` answers
0), so by the order none is added here.
- **File surface.** The claim lists the two docs pages, the skill file
and the optional eval file. `scripts/check-skills-token-ratchet.mjs` is
one more file, accepted by the seat before the push; the changeset is
the fifth path.
- **Attribution thread link.** The order prints the seat thread's link;
this body carries this card thread's link, the one the session's
attribution rule names. Same project, same requester.
- **Not touched, noted only.**
`content/docs/data-modeling/field-types.mdx` also describes
`lookupFilters` and dependent lookups and does not mention `{ $record
}`. It is outside the card's three files. carrier: none.
- **Changeset:** `@objectstack/skills` patch
(`.changeset/34201-skills-lookup-filter-record-reference.md`), both
declaration lines in it.
- Out-of-scope findings: none. Security findings: none.
## Verification
Head `09f66fe6` on `origin/main` `9e6fee19`. Main has since moved to
`ec6b5fd3`; none of the four edited files changed there (`git diff
--stat 9e6fee1 ec6b5fd` over them is empty), so the branch was not
re-merged.
**Derived set:** `node scripts/pm/dispatch-gates.mjs --commands` on the
committed change set → 88 commands. Each ran in this worktree at
`09f66fe6`, exit codes captured before any pipe; `--ran`: "88 derived
famil(ies) accounted for — 87 run, 1 NOT-MEASURED (1 DERIVED from a
recorded exit 3)".
- `node scripts/check-skills-token-ratchet.mjs` → exit 0: "57 authored
bundle file(s) within their ceilings"; `field-types.md` 3553 / 3553.
- `node scripts/check-skills-token-ratchet.mjs --self-test` → exit 0,
104 cases pass.
- `pnpm --filter @objectstack/spec run check:skill-examples` → exit 0,
347 prose examples type-check (after the `@objectstack/client-react...`
and `@objectstack/lint...` closure build under the verify lock, VERDICT
command-exit 0, 310 s).
- `pnpm check:doc-anchors` → exit 0, 1042 internal fragment links
resolve (the new `relationships#filter-by-the-record-being-edited` link
among them).
- `pnpm check:doc-authoring`, `pnpm check:skill-links`, `pnpm
check:skill-identifier-liveness`, `pnpm check:ratchet-remedy-authority`,
`pnpm check:pm-governed-merges`, `node scripts/check-empty-changeset.mjs
--base origin/main`, `node scripts/check-changeset-no-major.mjs --base
origin/main` → exit 0 each.
- NOT MEASURED: `pnpm check:dual-build-cjs-loads`, exit 3, "PREREQUISITE
NOT MET — this gate reads built output, and some package has no dist/".
It needs a full `pnpm build`, which this diff does not otherwise owe (no
package source moved); CI's build lanes carry it.
Not run locally, CI's own: `pnpm lint` (repo-wide), the type-check
lanes, `Test Core`, `Build Core`. No package test is owed: no package
source moved.
`node scripts/pm/check-governed-merges.mjs --branch HEAD`: governed, 1
of 5 paths (`skills/**`), landing tier H; 127 changed lines.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind. (no names
added)
- [ ] 3. No formatter ran; `pnpm lint` passes. (no formatter ran; the
repo-wide `pnpm lint` scan is CI's own run, so it is not claimed here:
read the `Lint & Repo Gates` check-run)
- [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: its generated artifacts are
regenerated and committed. (not touched)
- [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 (the maintainer's
ruling is quoted verbatim, untranslated).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzhek783Lg4DsyfFDxo)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8d827da commit 144cdc2
5 files changed
Lines changed: 118 additions & 9 deletions
File tree
- .changeset
- content/docs/data-modeling
- scripts
- skills/objectstack-data/rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
215 | 223 | | |
216 | 224 | | |
217 | 225 | | |
| |||
238 | 246 | | |
239 | 247 | | |
240 | 248 | | |
241 | | - | |
| 249 | + | |
| 250 | + | |
242 | 251 | | |
243 | 252 | | |
244 | 253 | | |
245 | 254 | | |
246 | 255 | | |
247 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
248 | 276 | | |
249 | 277 | | |
250 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
44 | 85 | | |
45 | 86 | | |
46 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
912 | | - | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
913 | 928 | | |
914 | 929 | | |
915 | 930 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
215 | | - | |
| 214 | + | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
222 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
223 | 236 | | |
224 | 237 | | |
225 | 238 | | |
| |||
238 | 251 | | |
239 | 252 | | |
240 | 253 | | |
241 | | - | |
| 254 | + | |
242 | 255 | | |
243 | 256 | | |
244 | 257 | | |
| |||
248 | 261 | | |
249 | 262 | | |
250 | 263 | | |
251 | | - | |
| 264 | + | |
252 | 265 | | |
0 commit comments