Skip to content

docs(skills): teach the lookupFilters { $record } reference and orEmpty - #34528

Merged
os-zhuang merged 1 commit into
mainfrom
claude/project-thread-6n73jy
Nov 17, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/project-thread-6n73jy

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

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 feat(fields): lookup picker resolves { $record } lookupFilters values and sends orEmpty #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 feat(fields): lookup picker resolves { $record } lookupFilters values and sends orEmpty #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 9e6fee19 ec6b5fd3 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

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (not touched)
  • 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)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the maintainer's ruling is quoted verbatim, untranslated).
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

objectstack-data rules/field-types.md, and the data-modeling docs pages
relationships.mdx and fields.mdx, teach a lookup filter that reads the
record being edited: the reference shape (a field, or one lookup hop),
the six operators it and orEmpty pair with, the entry dropped on an
empty value, and why a $record field is not also listed in dependsOn.

field-types.md sat at zero token headroom: five same-file restatements
are cut first (179 bytes), and the ratchet row moves by the measured
remainder, 3349 -> 3553.

Claude-Session: https://claude.ai/code/session_01WGufzhek783Lg4DsyfFDxo
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:skills#3 · os-support-ai · session_01WGufzgtCwPzNYSczvxDEpw

Contract-review-handoff: review#2 — CONTRACT_REVIEW_TIER unavailable (seat session runs the default tier, 2026-11-17T00:11Z) · head 09f66fe

The diff touches skills/** (published), so it owes a contract-review-tier record before the seat record; this seat cannot run that tier, so the review goes to review#2 per the routing in references/contract-review.md.

@objectstack-fleet objectstack-fleet Bot added the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5mjfxPu5HKjUtuveBR

Contract-review-claim: session_01FEkQ5mjfxPu5HKjUtuveBR · head 09f66fe · 2026-11-17T00:12Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5mjfxPu5HKjUtuveBR

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 09f66fe6af573878c58b64265d0c9dc9f501c98e
Local-runs: none
Scope: skills/objectstack-data/rules/field-types.md + scripts/check-skills-token-ratchet.mjs (widened: content/docs/data-modeling/relationships.mdx, content/docs/data-modeling/fields.mdx, the changeset)
Security-touching: yes

Inputs: card #34201 (body and its five comments, claim 6922776400 and dev report 6933361559 included), the PR body, handoff 6933409231, the net diff against main (merge base 9e6fee19ea, 5 files, +118/−9), the check-runs on this head. Read at this head, outside the diff: ui/packages/fields/src/widgets/lookupRecordReference.ts, LookupField.tsx, RecordPickerDialog.tsx, ui/packages/plugin-form/src/ObjectForm.tsx and sectionFields.ts, packages/spec/src/data/field.zod.ts, packages/lint/src/validate-object-field-refs.ts, scripts/pm/check-governed-merges.mjs. No earlier record on this PR. Security-touching: yes: one hunk edits the secret row (credential-storage guidance) and the new paragraph teaches that the picker filter is not a save-time control.

① Derived judgments

  • { $record: 'field' } and one hop { $record: 'account.market' }, at most one dot: right. LOOKUP_FILTER_RECORD_PATH_RE admits one dot and refuses a second at parse; readRecordPath splits at the first dot, reads the hop row (expanded on the record, or one findOne per lookup id) and would leave a deeper path out.
  • "Only a record form resolves it; every other picker host leaves the entry out": right. Resolution is opt-in on the stamp withRecordBeingEdited writes, and its only callers are ObjectForm.tsx and sectionFields.ts (modal, drawer and section layouts go through the latter). LookupField reads NO_EDITED_RECORD without the stamp; bulkParamToField.ts strips it; lookupFiltersToRecord drops any reference still unresolved.
  • Empty or unreadable value drops the entry: right (resolveLookupFilters pushes only a defined value; a hop that cannot be read answers undefined).
  • orEmpty: true also matches a null column, with the same six operators: right. refuseMalformedLookupFilterEntry refuses orEmpty (either value) and a $record value on contains, in, notIn at parse; the picker sends $or of the condition and $null on the same column.
  • dependsOn adds an equality filter: right (dependentFilter sets param = value, and the picker is gated while the parent is empty, as the docs pages say).
  • os validate refuses an unknown path (relationships.mdx): right. object-field-ref-unknown has an owner-addressed lookupFilters[].value.$record position, maxHops: 1, severity error.
  • "The picker only narrows the choice: a rule the save must enforce belongs on the server too": right, and it is the spec describe's own closing sentence. No write path reads lookupFilters; the only server reader of $record refuses it. No taught sentence presents the filter as an access or validation control.
  • The five cuts: each fact keeps a home in the same file (the password row's "Prefer secret for credentials"; the Autonumber token table; the paragraph "The counter resets per scope"; rule 3's heading). No rule is dropped.

② Semver level

@objectstack/skills patch, Clause-②: no, Metadata-protocol: none, on the PR body and in the changeset: right. Published skill wording only; no accept set, schema or code changes. The changeset's account matches the diff sentence for sentence.

③ Boundary flags

  • Check-runs: none red. Test Core (1/8) and (2/8) were still in progress at the time of reading; every other run is success or skipped (Build Docs, Check Documentation Links, Check Changeset, Governed Surface Queue Guard, Spec property liveness included). Landing waits for the two shards.
  • Ceiling raise 3349 → 3553: sizes read from the tree, 13395 → 14210 bytes (net +815; lines added 1643 bytes, removed 828), ceil(14210 / 4) = 3553, pinned at the measurement, no other row moved. Same-file deletion is shown and the body quotes the standing ruling and record 6513306068, the gate-recognised path the script header names.
  • Landing tier: H. scripts/check-skills-token-ratchet.mjs is outside LOW_RISK_RIDER_PATTERNS, so lowRiskArmVerdict answers "a path outside skills wording and prose" whatever this record says; the line above reads yes as well. The maintainer lands it, as the body says.
  • Deviation "ratchet script outside the order's file surface": accepted by the lane seat before the push; it is the row the taught file's ceiling lives in.
  • Dev note "content/docs/data-modeling/field-types.mdx does not mention { $record }, carrier: none": a gap, nothing wrong is taught there. The lane seat files it or names it in its ACCEPT.
  • Human Minimum item 3 left unticked for the repo-wide lint: the lint check-runs on this head are green.
  • open_questions: none. SQL push-down: not applicable, no code.

④ Design judgment

field-types.md § Lookup, sentence by sentence against the readers and the spec at this head: every sentence holds (see ①). The example parses under refuseMalformedLookupFilterEntry (three scalar operators, references as whole values, orEmpty on lte and eq). Tried to break it: a two-hop path (refused at parse and by the lint rule; left out by the reader), orEmpty beside in (refused at parse), a reference on a non-form host that passes values (no stamp, left out), a referenced field also in dependsOn (equality filter plus gate, as taught), an author reading the filter as a save rule (the last sentence says otherwise). Against the card's four points (shape, empty value, orEmpty and its six operators, dependsOn or $record): all four are taught, once each.

check-skills-token-ratchet.mjs: one row and its comment; the comment's arithmetic and homes agree with the tree.

N1 (nit) — fields.mdx, the new section omits the sentence that the picker only narrows the choice; it reaches the reader through the link to the relationships page, and the table row already says "picker-honored".

N2 (nit) — the reader also treats an empty list as an empty value (isEmptyValue); the docs list null, unset, an empty string and an unset hop, the same list the spec describe gives.

No must-fix. No open should-fix.

Implemented-by: claude/project-thread-6n73jy
Reviewed-by: session_01FEkQ5mjfxPu5HKjUtuveBR

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:skills#3 · os-support-ai · session_01WGufzgtCwPzNYSczvxDEpw

维护者速读

  • 改了什么:objectstack-data 技能的 rules/field-types.md 和两页数据建模文档(relationships.mdx、fields.mdx)开始教 lookup 筛选里的 { $record } 引用和 orEmpty:引用怎么写(字段或最多一跳)、引用值为空时这条筛选被略过、orEmpty 和它能搭配的六个运算符、它和 dependsOn 的区别。
  • 为什么改:这两个写法的读取方(表单里的记录选择器)已随 PR feat(fields): lookup picker resolves { $record } lookupFilters values and sends orEmpty #34253 落地,活性账本记为 live,规范里的「PLANNED」标记也已摘掉,但技能和文档一个字都没提,AI 和作者不知道可以按当前记录筛选候选项。
  • 风险与回滚:只改技能和文档文字,不动产品代码。技能文件原本零余量,先删同文件 5 处重复(179 字节),再按裁决 6513306068 把该文件的 token 上限按实测从 3349 提到 3553。回滚即 revert。
  • 先看:skills/objectstack-data/rules/field-types.md 的 Lookup 段(新例子加一段说明),然后是 relationships.mdx 新增的一节。
  • 两分钟验证:node scripts/check-skills-token-ratchet.mjs | grep field-types,预期 3553 / 3553 (+0),末行 ✓。
  • 需要你做的:受管路径(skills/**,Tier H)。契约审核 PASS 记录 6933533087,Head-sha: 09f66fe6af573878c58b64265d0c9dc9f501c98e。请审阅并合并(或在此 head 上批准,由席位落地)。
  • 席位意见:建议合并。教的每句都对得上选择器代码和 spec,例子能通过解析;最后一句明确「选择器只缩小候选,保存时的规则仍要放在服务端」,不会被读成权限控制。

席位核对

Verdict: ACCEPT · head 09f66fe6af573878c58b64265d0c9dc9f501c98e · card #34201 (p2) · claim 6922776400 · os-dev-report 6933361559 · contract review 6933533087 (review#2, PASS on this head, N1–N2 nits only) · read 2026-11-17T00:27Z.

  • Shape: draft → main, Fixes #34201, no other card number beside a closing keyword. Five files: skills/objectstack-data/rules/field-types.md (+20/−7), content/docs/data-modeling/relationships.mdx (+41), content/docs/data-modeling/fields.mdx (+29/−1), scripts/check-skills-token-ratchet.mjs (+16/−1, one row), .changeset/34201-skills-lookup-filter-record-reference.md (@objectstack/skills patch). Clause-②: no, Metadata-protocol: none, Skills-docs: updated here. check-governed-merges --pr 34528: Tier H, 127 lines.
  • Premise measured: the dev read packages/spec/liveness/field.json lookupFilters status: live and the two ui readers at 9e6fee19, zero PLANNED markers left; the review read the same readers at head. The seat read the skill hunk: { $record } whole-value only, the six operators, the empty-value drop, orEmpty null match, dependsOn vs $record, all present once.
  • Gates (check-runs on this head): 53 runs, 34 success, 19 skipped, none red; Lint & Repo Gates and TypeScript Type Check success; mergeable clean. Dev: 88 derived, 87 exit 0, 1 NOT MEASURED (check:dual-build-cjs-loads, needs a full build; CI's lanes green).
  • Accepted deviations: the ratchet row in scripts/check-skills-token-ratchet.mjs (outside the order's surface; accepted by the seat before the push) — same-file cuts first, raise by the measured delta only, under ruling record 6513306068 (director, batch Sync pnpm-lock.yaml with metadata package dependencies #429 item 4, letter B part 2). No eval case: objects-fields-relationships.json has none covering lookup filters.
  • Out of scope / Skills-docs: N1 (fields.mdx omits the "picker only narrows" sentence; reached via its link) and N2 (an empty list is also an empty value) — dropped, wording nits with no wrong teaching. content/docs/data-modeling/field-types.mdx not mentioning { $record } — dropped: it is a type catalog that links the relationships page, nothing wrong is taught.
  • Landing: Tier H. pm:awaiting-merge; reviewers os-zhuang and hotlong requested. An APPROVED review on this head lets the seat land it.

@objectstack-fleet objectstack-fleet Bot added pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue and removed needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides labels Nov 17, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 17, 2026 02:07
@os-zhuang
os-zhuang enabled auto-merge November 17, 2026 02:08
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 144cdc2 Nov 17, 2026
61 of 62 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-6n73jy branch November 17, 2026 02:49
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skills/docs: teach the lookupFilters { $record } reference and orEmpty (relationships.mdx, fields.mdx, field-types.md)

2 participants