Skip to content

Commit 3d744f1

Browse files
docs(skills): give the requiredWhen alias rule and the flow runAs rule one home each (#32326)
<!-- claude-projects-attribution: {"github_login":"huangyiirene"} --> _Requested by **Irene** · [project thread](https://claude.ai/code/project/chan_01TJXtQ1tVD26ecLDZxFS67x?thread=cmsg_01TJXtQ1tVD26ecLDZxFS67xA5AFaCmiVemTNyDjX44Zt6)_ Part of #31112 Slice 11 of the card: item 1, the first two of its five duplicated-rule groups (`conditionalRequired` → `requiredWhen`, and `runAs` for flows that write `readonly` fields). ## 维护者速读 **需要你做的:** 本 PR 为 **Tier H**(`skills/**`,`check-governed-merges.mjs --test` 实测 GOVERNED、H(人合)),保持 draft;当前 head 还欠契约审查(contract review),由 skills 席位按 `CONTRACT_REVIEW_TIER` 做记录审查,通过后席位再请你批准。 改了什么:两条在多个技能里重复书写的规则,各留一个归属方,其他位置缩成一句带真实锚点的链接。 `conditionalRequired` 已移除这一条:归 `objectstack-data` § Conditional Field Rules;`objectstack-formula`、`objectstack-ui` 的复述删掉,改为链接。 「维护 `readonly` 字段的 flow 用 `runAs: 'system'`、`runAs: 'user'` 写它构建期报错」这一条:归 `objectstack-automation` § Failure routing & `runAs`;`objectstack-data` 的 readonly 条目删掉复述,改为链接,只保留 data 独有的事实(REST/UI 也被剥离、系统 hook/seed/import/migration 豁免、字段保持 `readonly`)。 不改任何规则的教学内容;三个 token 行都缩小(data 6654 → 6606,formula 5973 → 5971,ui 3814 → 3800),automation 未动;`check:skill-links` 验证了两个新锚点。 ## Measurement on `main` `351c22c94`: rule statements vs mentions Only a sentence that states the rule is a duplicate. Every other hit uses the key inside another rule or an example and stays. **`conditionalRequired` → `requiredWhen`** (`grep -c conditionalRequired`: data 1, formula 1, ui 1) | File:line | Kind | Verdict | |:--|:--|:--| | data L225–227 (§ Conditional Field Rules) | states the rule | **owner**, unchanged | | formula L277–278 (§ 3. Predicate) | states the rule | **duplicate, cut** | | ui L120–121 (§ Field Conditional Rules in Forms) | states the rule | **duplicate, cut** | | data L10, L202, L231, L265, L464; formula L5, L75, L97, L428; ui L115 | `requiredWhen` named in a description, an example, or another rule | mention, stays | **`runAs`** (`grep -c runAs`: automation 12, data 4) | File:line | Kind | Verdict | |:--|:--|:--| | automation L143–197 (§ Failure routing & `runAs`), 12 lines | the readonly-write rule, elevate-the-write, identity assignment, org pinning, hook `runAs` | **owner**, unchanged | | data L216 "`runAs:'user'` flow — the default" | names who is stripped (data's `readonly` rule); "— the default" restates automation | clause cut, rest stays | | data L219 "`runAs:'system'` flows, system hooks, seeds, …" | names who is exempt (data's `readonly` rule) | stays | | data L220–224 | restates the flow-side rule and its build error | **duplicate, cut** | ## Cut list (砍点逐条核幸存) | # | Cut text (main `351c22c94`) | Surviving home | |:--|:--|:--| | 1 | formula L277–278: "Never emit `conditionalRequired` (use `requiredWhen`) — it was REMOVED in protocol 17 and is a parse error." | data SKILL.md L225–227, § Conditional Field Rules: "The `conditionalRequired` alias was REMOVED in protocol 17 — emitting it is a parse error." Replaced by a one-line link to that section. | | 2 | ui L120–121: "Use `requiredWhen` — the `conditionalRequired` alias was REMOVED in protocol 17 and is now a parse error." | Same data section. The paragraph above already pointed there in plain text ("**objectstack-data → Conditional Field Rules**"); that pointer is now a real link. | | 3 | data L216: the clause "— the default" (a flow's `runAs` defaults to `'user'`) | automation SKILL.md L158–159: "Under the default `runAs: 'user'` the engine **strips** it". | | 4 | data L220–223: "So the pattern … is expressed by declaring the field `readonly` **and** running the maintaining flow `runAs:'system'` (see **objectstack-automation**), not by removing `readonly`." | Flow side: automation L158–161 ("a flow maintaining one … runs `runAs: 'system'`"). The data-side half, keep the field `readonly`, stays in data as the new sentence "Keep the field `readonly` when automation maintains it". | | 5 | data L223–224: "Writing a `readonly` field from a `runAs:'user'` `update_record` node is a build-time **error** (`os validate` / `os build`)." | automation L162–163: "`os validate` / `os build` fail a `runAs:'user'` `update_record` writing one (`readonlyWhen`: a warning)". | The automation owner already states everything the data duplicate said about flows, so no fact moved into an owner. Facts only data held stay in data: REST/UI writes are stripped too; system hooks, seeds, imports and migrations are exempt. ## Diffs ```diff --- a/skills/objectstack-data/SKILL.md +++ b/skills/objectstack-data/SKILL.md - **`readonly: true` governs the end-user surface, not trusted system writers.** - A non-system write (REST/UI, and any `runAs:'user'` flow — the default) has + A non-system write (REST/UI, and any `runAs:'user'` flow) has the field **stripped**; the write reports success but the value never lands. System-context writes — `runAs:'system'` flows, system hooks, seeds, imports, migrations — are exempt - and DO write it. So the pattern "users can't edit this, but automation - maintains it" is expressed by declaring the field `readonly` **and** running - the maintaining flow `runAs:'system'` (see **objectstack-automation**), not by - removing `readonly`. Writing a `readonly` field from a `runAs:'user'` - `update_record` node is a build-time **error** (`os validate` / `os build`). + and DO write it. Keep the field `readonly` when automation maintains it; the + flow side: [objectstack-automation → Failure routing & `runAs`](../objectstack-automation/SKILL.md#failure-routing--runas). ``` ```diff --- a/skills/objectstack-formula/SKILL.md +++ b/skills/objectstack-formula/SKILL.md -Never emit `conditionalRequired` (use `requiredWhen`) — it was REMOVED in -protocol 17 and is a parse error. +Conditional requiredness: [objectstack-data](../objectstack-data/SKILL.md#conditional-field-rules). ``` ```diff --- a/skills/objectstack-ui/SKILL.md +++ b/skills/objectstack-ui/SKILL.md ObjectUI forms consume them. Their semantics and server behaviour: -**objectstack-data → Conditional Field Rules**. +[objectstack-data → Conditional Field Rules](../objectstack-data/SKILL.md#conditional-field-rules). UI-side: inline master-detail grids evaluate these rules **row-by-row** against -each child row. Use `requiredWhen` — the `conditionalRequired` alias was REMOVED -in protocol 17 and is now a parse error. +each child row. ``` Plus `.changeset/31112-skills-requiredwhen-runas-one-home.md` (`'@objectstack/skills': patch`). ## Token ratchet (`scripts/check-skills-token-ratchet.mjs`) | File | main | this PR | ceiling | |:--|--:|--:|--:| | `skills/objectstack-data/SKILL.md` | 6654 | 6606 (−48) | 6665 | | `skills/objectstack-formula/SKILL.md` | 5973 | 5971 (−2) | 5997 | | `skills/objectstack-ui/SKILL.md` | 3814 | 3800 (−14) | 3814 | | `skills/objectstack-automation/SKILL.md` | 6687 | 6687 (0, untouched) | 6687 | Every row shrinks or holds. The ceilings are shrink-only and are not lowered here: that edit is in `scripts/`, outside this slice's file surface. ## Evals and pins An eval tests what a reader of the whole package can answer, and every cut rule still lives in its owner, so no eval changes. Per hit: - `objectstack-data/evals/objects-fields-relationships.json` case 4 ("never the removed `conditionalRequired` alias", `must_not_contain: "conditionalRequired:"`): the owner text is untouched, so it stays true. - `objectstack-formula/evals/cel-predicates-formulas.json` case 5 and `objectstack-ui/evals/views-apps-actions-pages.json` case 1 (`must_not_contain: "conditionalRequired:"`): guards against emitting the key, not quotes of the cut sentence. The rule is one link away in data. They stay true. - `objectstack-automation/evals/flows-triggers-approvals.json` cases at L7, L193, L320, L339 and `integrations-declared.json` L17 (`runAs: 'system'` / `'user'`): automation's text is untouched. They stay true. - No data eval asserts the `readonly` strip or the `runAs` build error. Pins: no `packages/*/src/**/*.test.ts` or `scripts/**` gate quotes any changed line. Grepped for each cut phrase; the only hits are code comments (`packages/lint/src/validate-readonly-flow-writes.ts` L37, `packages/spec/src/kernel/metadata-plugin.test.ts` L317) that do not read the skill. `check-skill-identifier-liveness` registers no section touched here. ## Contract review `dispatch-gates --tier` mandates `CONTRACT_REVIEW_TIER` for `skills/**` (clause ①). The maintainer's standing order for card threads (2026-11-03) waives that tier for the build; the skills seat runs the contract review of record at `CONTRACT_REVIEW_TIER`. ## Gates Head `1a45d0f7` (the commit `7050a425` plus one merge of `origin/main` `121640b9`, which touches no `skills/` path). `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derives **46** commands; all 46 exit 0, and so does `pnpm check:changeset-fixed` (its roster sits under `.changeset/`, which dispatch-gates flags). Run after `pnpm install --frozen-lockfile --ignore-scripts` and a full `pnpm build` at this head, under `NODE_OPTIONS=--max-old-space-size=8192`. Record: `/mnt/project-files/card-31112/s11-gates-1a45d0f7.txt` (`<cmd> :: exit N` per line). Not measured locally, as dispatch-gates states: the CI-only jobs and type-check lanes it lists as NOT MEASURED (no TypeScript is touched here). Clause-②: no Metadata-protocol: none 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01J8VVAmL6NoXgETdPLMU3VH Co-authored-by: Claude <noreply@anthropic.com>
1 parent da13003 commit 3d744f1

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the `conditionalRequired` → `requiredWhen` rule and the flow `runAs` rule for `readonly` fields each keep one home
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The removed `conditionalRequired` alias was stated in three skills. `objectstack-data` § Conditional Field Rules keeps it. `objectstack-formula` § 3 Predicate drops its copy for a one-line link to that section, and `objectstack-ui` § Field Conditional Rules in Forms drops its copy and turns its existing plain-text pointer to the same section into a real link. The rule that a flow maintaining a `readonly` field runs `runAs: 'system'`, and that `os validate` / `os build` fail a `runAs: 'user'` `update_record` writing one, was stated in `objectstack-data` and `objectstack-automation`. `objectstack-automation` § Failure routing & `runAs` keeps it, and the `readonly` bullet in `objectstack-data` now links there. The data bullet keeps what only it says: REST/UI writes are stripped too, system hooks, seeds, imports and migrations are exempt, and the field stays `readonly` when automation maintains it. No rule's teaching changes.

‎skills/objectstack-data/SKILL.md‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,12 @@ export const Invoice = ObjectSchema.create({
213213
incoming changes when the predicate is `TRUE` (for everyone; per permission
214214
set → field permission `when`, rules/security.md).
215215
- **`readonly: true` governs the end-user surface, not trusted system writers.**
216-
A non-system write (REST/UI, and any `runAs:'user'` flow — the default) has
216+
A non-system write (REST/UI, and any `runAs:'user'` flow) has
217217
the field **stripped**; the write reports
218218
success but the value never lands. System-context writes —
219219
`runAs:'system'` flows, system hooks, seeds, imports, migrations — are exempt
220-
and DO write it. So the pattern "users can't edit this, but automation
221-
maintains it" is expressed by declaring the field `readonly` **and** running
222-
the maintaining flow `runAs:'system'` (see **objectstack-automation**), not by
223-
removing `readonly`. Writing a `readonly` field from a `runAs:'user'`
224-
`update_record` node is a build-time **error** (`os validate` / `os build`).
220+
and DO write it. Keep the field `readonly` when automation maintains it; the
221+
flow side: [objectstack-automation → Failure routing & `runAs`](../objectstack-automation/SKILL.md#failure-routing--runas).
225222
- Use `requiredWhen` for conditional requiredness; the ObjectQL validator
226223
enforces it on submit. The `conditionalRequired` alias was REMOVED in
227224
protocol 17 — emitting it is a parse error.

‎skills/objectstack-formula/SKILL.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ P`record.amount != null && record.amount > 10000 && record.region in ['us', 'eu'
274274
P`!isBlank(record.po_number)`;
275275
```
276276

277-
Never emit `conditionalRequired` (use `requiredWhen`) — it was REMOVED in
278-
protocol 17 and is a parse error.
277+
Conditional requiredness: [objectstack-data](../objectstack-data/SKILL.md#conditional-field-rules).
279278

280279
❌ Salesforce-flavor — **fails CEL compile**: `os build` errors with a
281280
located message, and the flow engine throws if it ever reaches runtime:

‎skills/objectstack-ui/SKILL.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,10 @@ parent's record page by default; the flags, slots and open mode: [Record Page](.
114114
Conditions that belong to a field's lifecycle — `visibleWhen`, `readonlyWhen`,
115115
`requiredWhen` — are declared on the **DATA MODEL field**, not in the form view;
116116
ObjectUI forms consume them. Their semantics and server behaviour:
117-
**objectstack-data → Conditional Field Rules**.
117+
[objectstack-data → Conditional Field Rules](../objectstack-data/SKILL.md#conditional-field-rules).
118118

119119
UI-side: inline master-detail grids evaluate these rules **row-by-row** against
120-
each child row. Use `requiredWhen` — the `conditionalRequired` alias was REMOVED
121-
in protocol 17 and is now a parse error.
120+
each child row.
122121

123122
---
124123

0 commit comments

Comments
 (0)