Skip to content

Commit f47ca1b

Browse files
committed
docs(skills): an objectstack-data eval asks for a hook's refusals catalogue instead of a thrown English sentence
One eval case in hooks-security-seeds-datasources.json: a save refused over the account's credit limit in an app serving English and Chinese users — expected `refusals: { CREDIT_LIMIT: { message } }` on the hook, a `language: 'js'` body throwing `{ code: 'CREDIT_LIMIT' }`, and the zh-CN sentence under the bundle's `hooks: { HOOK: { refusals } }`; refused: a sentence on the throw (`new Error('`) and a `handler:`. Paid down first: five sentences in cases 1-5 that restated their own `must_not_contain` assertions (453 bytes = 114 units); the case adds 1129 bytes = 283 units; the file is 5616 -> 6292 bytes, 1404 -> 1573 tokens. The ratchet row moves 1404 -> 1573, pinned at the measurement under the standing ruling quoted beside it. Patch changeset for `@objectstack/skills`, whose build copies skills/** into its published dist. Claude-Session: https://claude.ai/code/session_01QSeKYmhU5KEj1nukYhp1Tg Co-authored-by: Claude <noreply@anthropic.com>
1 parent f708cf2 commit f47ca1b

3 files changed

Lines changed: 46 additions & 6 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): an objectstack-data eval asks for a hook's `refusals` catalogue instead of a sentence thrown from the body
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- **Before.** `references/data-hooks.md` teaches a hook's declared `refusals` catalogue (the body throws `{ code }`, the message is translated under `hooks.HOOK.refusals.CODE.message`), but no eval in `evals/hooks-security-seeds-datasources.json` exercised it: an agent asked for a refusal in a multi-language app could still write an English sentence into `throw new Error(...)`, which reaches zh-CN users untranslated, and nothing scored that wrong.
11+
- **Now.** Eval 7 asks for an `order` save refused over the account's credit limit in an app serving English and Chinese users, and expects `refusals: { CREDIT_LIMIT: { message } }` on the hook, a `language: 'js'` body that throws `{ code: 'CREDIT_LIMIT' }`, and the zh-CN sentence under the bundle's `hooks: { HOOK: { refusals: { CREDIT_LIMIT: { message } } } }`; it refuses a sentence on the throw (`new Error('`) and a `handler:` (a catalogue without a `js` body is refused at save). Five sentences in evals 1–5 that restated their own `must_not_contain` assertions are gone; every fact and assertion stays.
12+
- No schema, key or behaviour changes.

‎scripts/check-skills-token-ratchet.mjs‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,25 @@ export const CEILINGS = new Map([
930930
// `applyOn: 'create'`. +309 tokens at headroom 0, ceiling +309; nothing
931931
// duplicated in the file to cut first. Maintainer ruling 2026-10-27 on the decision card 「skills 修复卡的教学和 eval 都撞 token 天
932932
// 花板,怎么付?」, tap A, verbatim and untranslated: 「A:先削重复,余额按实测提高」.
933-
['skills/objectstack-data/evals/hooks-security-seeds-datasources.json', 1404],
933+
// 1404 -> 1573 (card #26834, the eval owed by the spec PR that added a
934+
// hook's `refusals` catalogue): one case for a save refused over the
935+
// account's credit limit in an app serving English and Chinese users —
936+
// expected `refusals: { CREDIT_LIMIT: { message } }` on the hook, a
937+
// `language: 'js'` body throwing `{ code: 'CREDIT_LIMIT' }`, the zh-CN
938+
// sentence under the bundle's `hooks: { HOOK: { refusals } }`; NO sentence
939+
// on the throw (`new Error('`), NO `handler:`. Triage 6450886908 (room
940+
// inside the package first, no raise) read together with the standing
941+
// ruling, strictest first — maintainer ruling 2026-10-27 on the decision
942+
// card 「skills 修复卡的教学和 eval 都撞 token 天花板,怎么付?」, tap A, verbatim
943+
// and untranslated: 「A:先削重复,余额按实测提高」. PAID DOWN FIRST: five
944+
// sentences in cases 1–5 that restated their own `must_not_contain`
945+
// assertions (case 4 keeps its one non-asserted clause), 453 bytes = 114
946+
// units; the case adds 1129 bytes = 283 units. On `origin/main` the file
947+
// was 5616 bytes (1404 tokens, headroom 0); the LANDED file is 6292 bytes
948+
// -> 1573 tokens, ceiling +169, pinned AT the measurement, zero headroom.
949+
// The raising PR's body carries the same arithmetic.
950+
// ceil($(wc -c < skills/objectstack-data/evals/hooks-security-seeds-datasources.json) / 4) == ceil(6292 / 4)
951+
['skills/objectstack-data/evals/hooks-security-seeds-datasources.json', 1573],
934952
// 946 -> 1050 (#26297): the invoice-line case gains the owner opt-in
935953
// (`ownerMayEdit` on the controlled_by_parent line) and pins `added_by` as
936954
// `type: 'user'`, never a lookup to a `user` object. +104 tokens at

‎skills/objectstack-data/evals/hooks-security-seeds-datasources.json‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"id": 1,
66
"prompt": "Support agents want to search tasks by the name of the project they belong to.",
7-
"expected_output": "Applies the one prescription: a stored `text` mirror field `project_name` on `task`, listed in `searchableFields: ['name', 'project_name']`, maintained by a `beforeInsert` / `beforeUpdate` hook on `task` (stamp the parent's name for the incoming `project_id`) and an `afterUpdate` hook on `project` (re-stamp on rename), plus a one-off backfill for rows written outside hooks. Never a dotted path (`project_id.name` is refused, `400 INVALID_FIELD`) and never a `formula` mirror (virtual, nothing to scan).",
7+
"expected_output": "Applies the one prescription: a stored `text` mirror field `project_name` on `task`, listed in `searchableFields: ['name', 'project_name']`, maintained by a `beforeInsert` / `beforeUpdate` hook on `task` (stamp the parent's name for the incoming `project_id`) and an `afterUpdate` hook on `project` (re-stamp on rename), plus a one-off backfill for rows written outside hooks.",
88
"files": [],
99
"assertions": {
1010
"must_contain": ["searchableFields", "project_name", "beforeInsert", "afterUpdate"],
@@ -14,7 +14,7 @@
1414
{
1515
"id": 2,
1616
"prompt": "Sales reps may only see their own leads, sales managers see their unit and everything below it, and every signed-in user can read the `product` catalog.",
17-
"expected_output": "Access is authored in permission sets, not on the object (an object-level `permissions` key is rejected). `lead` gets `sharingModel: 'private'`; the rep set's grant on `lead` carries `readScope: 'own'`, the manager set's `readScope: 'unit_and_below'` — an ADR-0057 scope that needs the enterprise `@objectstack/security-enterprise` plugin and `requires: ['hierarchy-security']`, failing closed to `own` without it. `product` is `sharingModel: 'public_read'`.",
17+
"expected_output": "Access is authored in permission sets, not on the object. `lead` gets `sharingModel: 'private'`; the rep set's grant on `lead` carries `readScope: 'own'`, the manager set's `readScope: 'unit_and_below'` — an ADR-0057 scope that needs the enterprise `@objectstack/security-enterprise` plugin and `requires: ['hierarchy-security']`, failing closed to `own` without it. `product` is `sharingModel: 'public_read'`.",
1818
"files": [],
1919
"assertions": {
2020
"must_contain": ["sharingModel: 'private'", "readScope", "unit_and_below", "public_read", "hierarchy-security"],
@@ -24,7 +24,7 @@
2424
{
2525
"id": 3,
2626
"prompt": "Expose the existing `customers` table from our Postgres reporting database as a read-only `legacy_customer` object.",
27-
"expected_output": "Declares a `defineDatasource` entry (credentials by `credentialsRef`, never inline) and points the object at it with `datasource: '<id>'`, mapping the physical table via `remoteName` and column names via `columnMap` — there is no `field.columnName` on an external object. Sets the datasource's `schemaMode` so the platform never alters the remote schema, and keeps the external write gate closed.",
27+
"expected_output": "Declares a `defineDatasource` entry (credentials by `credentialsRef`, never inline) and points the object at it with `datasource: '<id>'`, mapping the physical table via `remoteName` and column names via `columnMap`. Sets the datasource's `schemaMode` so the platform never alters the remote schema, and keeps the external write gate closed.",
2828
"files": [],
2929
"assertions": {
3030
"must_contain": ["defineDatasource", "datasource", "remoteName", "columnMap", "schemaMode"],
@@ -34,7 +34,7 @@
3434
{
3535
"id": 4,
3636
"prompt": "Seed the `country` reference table for every environment, and add demo `opportunity` rows (dev/test only) that close 45 days after install and are owned by whoever installs the package. A nightly job advances each opportunity's `stage`; replaying the seed must not reset it.",
37-
"expected_output": "Uses `defineSeed(Country, { externalId: 'code', mode: 'upsert', records })` for reference data and `defineSeed(Opportunity, { env: ['dev', 'test'], ... })` for demo rows, with lookups referenced by natural key and dynamic values as CEL: `close_date: cel`daysFromNow(45)``, `owner_id: cel`os.user.id``. Never `externalId: 'id'`, never `new Date()` / `Date.now()` (breaks build determinism), never `defineDataset` (the analytics layer), parents before children in the exported array. The job-owned column is declared `columns: { stage: { applyOn: 'create' } }`, so an `upsert` replay leaves it as the row holds it.",
37+
"expected_output": "Uses `defineSeed(Country, { externalId: 'code', mode: 'upsert', records })` for reference data and `defineSeed(Opportunity, { env: ['dev', 'test'], ... })` for demo rows, with lookups referenced by natural key and dynamic values as CEL: `close_date: cel`daysFromNow(45)``, `owner_id: cel`os.user.id``. Parents before children in the exported array. The job-owned column is declared `columns: { stage: { applyOn: 'create' } }`, so an `upsert` replay leaves it as the row holds it.",
3838
"files": [],
3939
"assertions": {
4040
"must_contain": ["defineSeed", "externalId", "upsert", "env:", "daysFromNow", "applyOn: 'create'"],
@@ -44,7 +44,7 @@
4444
{
4545
"id": 5,
4646
"prompt": "Finance may edit a contract's legal terms (`governing_law`, `liability_cap`) while it is a draft, but not once it is approved, signing or active. Legal still edits them.",
47-
"expected_output": "Field permission entries with a row condition on the finance set: `'clm_contract.governing_law': { readable: true, editable: false, when: \"status in ['approved', 'signing', 'active']\" }` and the same for `liability_cap`; the legal set keeps its edit grant. No validation rule and no `readonlyWhen`, which would lock the fields for every user.",
47+
"expected_output": "Field permission entries with a row condition on the finance set: `'clm_contract.governing_law': { readable: true, editable: false, when: \"status in ['approved', 'signing', 'active']\" }` and the same for `liability_cap`; the legal set keeps its edit grant.",
4848
"files": [],
4949
"assertions": {
5050
"must_contain": ["when:", "editable: false", "readable: true", "clm_contract.governing_law"],
@@ -60,6 +60,16 @@
6060
"must_contain": ["membershipKeys", "current_user.portal_account_ids", "userField", "valueField", "permissionSets", "external"],
6161
"must_not_contain": ["permissions: {"]
6262
}
63+
},
64+
{
65+
"id": 7,
66+
"prompt": "Our app serves English and Chinese users. An `order` whose `amount` exceeds its account's `credit_limit` must not be saved; API clients branch on the code `CREDIT_LIMIT`, and a zh-CN rep reads `超出账户信用额度`.",
67+
"expected_output": "A `beforeInsert` / `beforeUpdate` hook on `order` declares the refusal once, `refusals: { CREDIT_LIMIT: { message: 'Over the account credit limit.' } }`, and its sandboxed `body: { language: 'js', source }` reads the account through `ctx.api` and refuses by code only: `throw Object.assign(new Error(), { code: 'CREDIT_LIMIT' })` — the body's own text is never shown. The zh-CN bundle carries `hooks: { <hook>: { refusals: { CREDIT_LIMIT: { message: '超出账户信用额度' } } } }`, served whole in the caller's locale; a catalogue on a hook without a `js` body is refused at save.",
68+
"files": [],
69+
"assertions": {
70+
"must_contain": ["refusals:", "CREDIT_LIMIT: {", "code: 'CREDIT_LIMIT'", "language: 'js'", "hooks: {", "超出账户信用额度"],
71+
"must_not_contain": ["new Error('", "handler:"]
72+
}
6373
}
6474
]
6575
}

0 commit comments

Comments
 (0)