Repository navigation
Commit b8456eb
docs(skills): a line-add action sets the price; a self-tied create gets a current_user default (#34019)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9Ty2ru1KHBywrksCX6GQE13)_
Fixes #33978
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:两条搭建教学。① 界面技能
actions.md:「给父记录加明细行」的动作必须设置单价(从产品读价,或在角色可定价时设为必填参数),附一个可类型检查的示例;② 数据技能
security.md:插入策略的 `check` 绑定当前用户的字段时,给该字段设 `defaultValue:
'current_user'`,用户只说「加一个任务」也能建成。各配一条评测用例。
- 为什么改:评测里聊天写数据失败,6 次明细行金额写成空(加行动作没有价格),14 次建任务
403(策略要求用户没说的负责人)。维护者原话「聊天里改数据 出问题的关键还是我们的skills需要优化吧?」。
- 风险与回滚:仅技能文档、评测与 token 天花板,不改运行时;回滚即 revert。actions.md 天花板
2453→2808、security.md 3959→4041、objectstack-ui SKILL.md
3814→3833(先删重复,余额按实测提高)。
- 先看:`skills/objectstack-ui/rules/actions.md`(新段落与示例)→
`skills/objectstack-data/rules/security.md`(`own_tasks` 策略与四行说明)→
`scripts/check-skills-token-ratchet.mjs`(两行天花板与算式)。
- 两分钟验证:`node scripts/check-skills-token-ratchet.mjs`,预期 actions.md 显示
2808 / 2808、security.md 4041 / 4041,全部通过。
- 需要你做的:批准本 PR
## What changes
- `skills/objectstack-ui/rules/actions.md` § Action Parameter Patterns:
**An action that adds a child line sets its price.** `lookupAutofill`
fills only the form and the grid, and a stored `expression` reads only
its own row, so a body inserting `invoice`, `product` and `quantity`
alone stores no `amount`. Read the price from the source the build
declares, or take it as a `required` param where the persona sets
prices. One `os:check` example (`crm_add_invoice_line`, `type:
'script'`, params `product` and `quantity` borrowed with
`objectOverride: 'invoice_line'`, a body with `api.read` + `api.write`
that reads `product.list_price`, throws when the product is not found,
and inserts the line; `refreshAfter: true`, since the invoice's roll-up
total moves). Lines also written past the action (API, an agent, an
import — one with automations off skips hooks) get the price from a
`beforeInsert` hook on the line, `runAs: 'system'` when the writer
cannot read it.
- `skills/objectstack-ui/SKILL.md` § line-item grid behaviors: one
clause scoping its "never add an 'Add line' button" to the grid,
pointing a record-header action that inserts a priced line to
rules/actions.md, so the two do not read as contradicting each other.
- `skills/objectstack-data/rules/security.md` § Row-Level Security: the
example's second policy becomes the insert-only `own_tasks` (`check:
'assignee == current_user.id'`, field `task.assignee: { type: 'user',
defaultValue: 'current_user' }`), followed by four lines: a `check` over
a field the request never names refuses a plain create; `defaultValue:
'current_user'` fills an omitted `user` field before `check` is judged.
- Homes, chosen by where a builder reads it: rule 1 where the add-line
action and its params are written; rule 2 directly under the policy
example, beside `check`. `relationships.md` and `field-types.md`
untouched.
- Paid down first (standing ruling 「A:先削重复,余额按实测提高」, record 6513306068),
each cut keeping a home:
- actions.md, 85 bytes: "`locations` is an array of surfaces:" (the H2
names `locations`, the table header says Surface); the `opensInNewTab`
H3 tail "— async / computed redirect" (its paragraph opens "A redirect
URL computed after a fetch"); ", holes in either" on the `helpText`
bullet (the bullet above lists `description` and a param's `helpText`
among the `{{ }}` copy holes).
- security.md, 137 bytes: the `org_isolation` example policy. A
select-only `using` policy is still shown twice in § Membership keys;
`current_user.organization_id` keeps its placeholder-table row; the
tenant predicate is the Layer 0 wall in § Platform-global objects.
- Evals: `skills/objectstack-ui/evals/views-apps-actions-pages.json`
case 18 (the add-line action);
`skills/objectstack-data/evals/hooks-security-seeds-datasources.json`
case 21 (the self-tied create; it follows case 20, which #33954 landed,
byte-identical after the merge of main). Every `must_contain` appears
verbatim in its `expected_output`; both `must_not_contain` lists are
empty.
- `scripts/check-skills-token-ratchet.mjs`: three rows moved to the
measurement (actions.md, security.md, objectstack-ui SKILL.md),
arithmetic in the row comments. The review-round additions (35 + 24
tokens) had no true duplicate to cut, so they rest on the ruling's
second half.
- `.changeset/33978-line-price-and-self-tied-create.md`:
`'@objectstack/skills': patch`.
- No forced test edits.
## Tests
Measured on `origin/main` before writing (b8ac0e2):
- `defaultValue: 'current_user'` is a runtime token on a `user` field
(`packages/spec/src/data/field.zod.ts`, the `defaultValue` describe),
resolved per request in
`packages/objectql/src/engine-defaults-and-autonumbers.ts`.
- On insert the engine applies field defaults, then `beforeInsert`
hooks, and the RLS `check` judges that post-hook row
(`postHookWriteImageCheck`; pinned by
`packages/plugins/plugin-security/src/insert-check-post-image.test.ts`).
- A CEL `defaultValue` envelope and a stored `expression` read only the
row being written, so neither can read the product's price;
`lookupAutofill` is client-side only.
- Action bodies run elevated
(`packages/runtime/src/action-execution.ts`, `isSystem: true`); hooks
run as the operator unless `runAs: 'system'`
(`packages/objectql/src/hook-run-as.ts`).
<details><summary>Scratch proof (uncommitted vitest file on the
insert-check-post-image harness, deleted after) — 5/5 passed</summary>
```text
assignee: { type: 'user', defaultValue: 'current_user' } + insert check 'assignee == current_user.id'
create naming no assignee -> admitted, stored assignee = the caller
control: same field, no default -> PERMISSION_DENIED 403 "the insert would violate a row-level CHECK"
with the default, naming another user -> still 403
the taught field parses through ObjectSchema.create
invoice_line amount = record.quantity * record.unit_price
quantity 3, no unit_price -> amount null (not 0)
quantity 3, unit_price 20 -> amount 60
Lock VERDICT command-exit 0 · Test Files 1 passed · Tests 5 passed
```
</details>
## Acceptance notes
- Not taught: the card's alternative for rule 2, "say in the field
description that an agent sets it". On main the agent's object
description (`describeServedObject`,
`packages/runtime/src/domains/mcp.ts`) serves name, type, label,
required, readonly, system, options and `defaultValue` per field, and no
`description`, so that route has no measured agent consumer. It does
serve `defaultValue` and tells the agent to omit the field to get it,
which is the taught path.
- The rule 1 example computes the price and takes no price param: the
body runs elevated, so an optional override param would let a persona
write a price their field grant denies. The param route stays prose ("a
`required` param where the persona sets prices").
- NOT MEASURED: the example action run through the action runtime (it is
type-checked; its mechanics follow the file's existing script example);
a hook stamping `unit_price` for a persona whose field grant denies
editing it (the text makes no claim about it).
- `field-types.md`'s `lookupAutofill` paragraph still ends at
"Client-side only" with no pointer to the new rule; left out to keep to
two rule files.
- Review round (seat at-tier review PASS at 31a2d6d, record
6897741755): N2, N3, N4 applied in one commit; N1 and N5 left as they
are.
- Authoring arrangement: this thread is served below the card's mandated
tier, so the `skills/**` text was authored and committed by an at-tier
(`CONTRACT_REVIEW_TIER`) subagent in the same worktree and branch; push,
gates, relay writes and the report stay with the thread.
## Verification
Token counts, `ceil(utf8 bytes / 4)`:
| Scope | Before | After |
|---|---|---|
| `rules/actions.md` | 185 lines · 9807 B · 2452 tok (ceiling 2453) |
224 lines · 11231 B · 2808 tok (ceiling 2808, headroom 0) |
| `rules/security.md` | 329 lines · 15834 B · 3959 tok (ceiling 3959) |
334 lines · 16164 B · 4041 tok (ceiling 4041, headroom 0) |
| `objectstack-ui/SKILL.md` (priced bytes, stamp line excluded) | 15233
B · 3809 tok (ceiling 3814) | 15329 B · 3833 tok (ceiling 3833, headroom
0) |
| all `skills/*/SKILL.md` (240e9ab vs head) | 4596 lines · 237075 B |
4597 lines · 237171 B (+1 line, +96 B) |
| whole shipped `skills/` bundle (ratchet, 240e9ab vs head) | 246388
tok (authored 187806, eval 46787) | 247470 tok (authored 188268, eval
47407): +462 authored, +620 eval fixture |
Local gate union at head `0d221b0` (`origin/main` 240e9ab merged in;
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`, every listed command run, exit captured
before any pipe):
- 65 derived · 64 exit 0 · 1 NOT MEASURED: `pnpm
check:dual-build-cjs-loads` exit 3, PREREQUISITE NOT MET (reads every
package's `dist/`; this worktree built only the spec, client,
client-react and plugin-security closures). Declared narrowing; CI
carries it.
- `--ran` reconciliation: "65 derived famil(ies) accounted for — 64 run,
1 NOT-MEASURED (1 DERIVED from a recorded exit 3)". The union at the
previous heads read the same (63 derived, 62 run, 1 NOT MEASURED at both
`18e323b` and `31a2d6d`).
- Acceptance gates at `0d221b0`, each exit 0: `pnpm --filter
@objectstack/spec check:skill-docs` ("Skill docs in sync"),
`check:skill-refs` ("9 generated files in sync with packages/spec"),
`check:skill-examples` ("347 prose examples type-check across 3
surface(s)", after a spec rebuild), `node
scripts/check-skills-token-ratchet.mjs` ("57 authored bundle file(s)
within their ceilings") and `--self-test` ("104 cases pass"), `pnpm
check:nul-bytes`, `git diff --check`.
- Not run locally: `test:repo` (CI's `Test Core`); the diff touches no
test.
<!-- signed: domain:skills#2 · os-steve ·
session_01ADHkmQ2cXsNaBaNbjBDxsA -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 60fca0f commit b8456eb
7 files changed
Lines changed: 132 additions & 16 deletions
File tree
- .changeset
- scripts
- skills
- objectstack-data
- evals
- rules
- objectstack-ui
- evals
- 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 | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
818 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
819 | 827 | | |
820 | 828 | | |
821 | 829 | | |
| |||
1057 | 1065 | | |
1058 | 1066 | | |
1059 | 1067 | | |
1060 | | - | |
1061 | | - | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
1062 | 1083 | | |
1063 | 1084 | | |
1064 | 1085 | | |
| |||
1142 | 1163 | | |
1143 | 1164 | | |
1144 | 1165 | | |
1145 | | - | |
1146 | | - | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
1147 | 1188 | | |
1148 | 1189 | | |
1149 | 1190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
203 | 213 | | |
204 | 214 | | |
205 | 215 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
173 | 183 | | |
174 | 184 | | |
175 | 185 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | 5 | | |
8 | 6 | | |
9 | 7 | | |
| |||
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
27 | | - | |
| 25 | + | |
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
| |||
142 | 140 | | |
143 | 141 | | |
144 | 142 | | |
145 | | - | |
| 143 | + | |
146 | 144 | | |
147 | 145 | | |
148 | 146 | | |
| |||
182 | 180 | | |
183 | 181 | | |
184 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
185 | 224 | | |
0 commit comments